monitorModule.go 683 字节
Newer Older
Y
Your Name 已提交
1 2 3 4 5 6
package dao_version_config

import (
	"fmt"
)

Y
Your Name 已提交
7 8 9
//GetMonitorModules 获取监控模块信息
func (d *VersionConfigDao)GetMonitorModules(status int, isAll bool) (map[string]string, error) {
	db := d.db
Y
Your Name 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
	sql := "SELECT `name`,`config` FROM goku_monitor_module %s;"
	if isAll {
		sql = fmt.Sprintf(sql, "")
	} else {
		sql = fmt.Sprintf(sql, fmt.Sprintf("WHERE moduleStatus = %d", status))
	}
	rows, err := db.Query(sql)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	modules := make(map[string]string)
	for rows.Next() {
		var name, config string
		err = rows.Scan(&name, &config)
		if err != nil {
			return nil, err
		}
		modules[name] = config
	}
	return modules, nil
}