|
@@ -152,8 +152,20 @@ func WriteAlertBindValue(code, value string) (err error) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取influxdb连接配置
|
|
|
|
|
+// 返回值 user, password, token, db, server_ipport
|
|
|
|
|
+func getSeedConn() (string, string, string, string, string) {
|
|
|
|
|
+ addr := utils.Cfg.MustValue("influxdb", "addr")
|
|
|
|
|
+ dbname := utils.Cfg.MustValue("influxdb", "name")
|
|
|
|
|
+ user := utils.Cfg.MustValue("influxdb", "user")
|
|
|
|
|
+ password := utils.Cfg.MustValue("influxdb", "password")
|
|
|
|
|
+ token := utils.Cfg.MustValue("influxdb", "token")
|
|
|
|
|
+ return user, password, token, dbname, addr
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func GetChannelInfov2(code string, startandend ...int64) (cols []string, arrs [][]interface{}) {
|
|
func GetChannelInfov2(code string, startandend ...int64) (cols []string, arrs [][]interface{}) {
|
|
|
- client := labsop.GetLabSopClient("coldcloud", "cc@1qaz2wsx", "coldcloud", "114.215.27.56:9086")
|
|
|
|
|
|
|
+ // client := labsop.GetLabSopClient("coldcloud", "cc@1qaz2wsx", "coldcloud", "114.215.27.56:9086")
|
|
|
|
|
+ client := labsop.GetLabSopClient(getSeedConn())
|
|
|
sql := fmt.Sprintf("select * from %v ", code)
|
|
sql := fmt.Sprintf("select * from %v ", code)
|
|
|
if len(startandend) == 2 {
|
|
if len(startandend) == 2 {
|
|
|
sql = sql + fmt.Sprintf(" where time>%vs and time<%vs ", startandend[0], startandend[1])
|
|
sql = sql + fmt.Sprintf(" where time>%vs and time<%vs ", startandend[0], startandend[1])
|
|
@@ -169,7 +181,8 @@ func GetChannelInfov2(code string, startandend ...int64) (cols []string, arrs []
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func GetChannelBysql(sql string) (cols []string, arrs [][]interface{}) {
|
|
func GetChannelBysql(sql string) (cols []string, arrs [][]interface{}) {
|
|
|
- client := labsop.GetLabSopClient("coldcloud", "cc@1qaz2wsx", "coldcloud", "47.92.249.239:9086")
|
|
|
|
|
|
|
+ // client := labsop.GetLabSopClient("coldcloud", "cc@1qaz2wsx", "coldcloud", "47.92.249.239:9086")
|
|
|
|
|
+ client := labsop.GetLabSopClient(getSeedConn())
|
|
|
data, err := client.QueryOneResultByCommand(sql)
|
|
data, err := client.QueryOneResultByCommand(sql)
|
|
|
if err == nil && len(data) > 0 && len(data[0].Values) > 0 {
|
|
if err == nil && len(data) > 0 && len(data[0].Values) > 0 {
|
|
|
cols, arrs = data[0].Columns, data[0].Values
|
|
cols, arrs = data[0].Columns, data[0].Values
|