change buildDS param

This commit is contained in:
zoues 2017-03-22 22:34:44 +08:00
parent fc5da49617
commit 18d03d99d3
2 changed files with 7 additions and 3 deletions

View file

@ -18,6 +18,7 @@ package collector
import ( import (
"fmt" "fmt"
"strings"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
@ -42,13 +43,16 @@ type (
} }
) )
func buildNS(namespace, class string) string { func buildNS(system, namespace, class string) string {
if namespace == "" { if namespace == "" {
namespace = "all" namespace = "all"
} }
if class == "" { if class == "" {
class = "all" class = "all"
} }
if strings.Compare(system, namespace) == 1 {
namespace = ""
}
return fmt.Sprintf("%v_%v", namespace, class) return fmt.Sprintf("%v_%v", namespace, class)
} }
@ -61,7 +65,7 @@ func NewNginxStatus(namespace, class string, ngxHealthPort int, ngxVtsPath strin
ngxVtsPath: ngxVtsPath, ngxVtsPath: ngxVtsPath,
} }
ns := buildNS(namespace, class) ns := buildNS(system, namespace, class)
p.data = &nginxStatusData{ p.data = &nginxStatusData{
active: prometheus.NewDesc( active: prometheus.NewDesc(

View file

@ -62,7 +62,7 @@ func NewNGINXVTSCollector(namespace, class string, ngxHealthPort int, ngxVtsPath
ngxVtsPath: ngxVtsPath, ngxVtsPath: ngxVtsPath,
} }
ns := buildNS(namespace, class) ns := buildNS(system, namespace, class)
p.data = &vtsData{ p.data = &vtsData{
bytes: prometheus.NewDesc( bytes: prometheus.NewDesc(