Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help text #3

Merged
merged 1 commit into from
Mar 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions sources/procfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type lustreProcMetric struct {
name string
source string //The node type (OSS, MDS, MGS)
path string //Path to retreive metric from
helpText string
}

func init() {
Expand All @@ -39,22 +40,25 @@ type lustreSource struct {
basePath string
}

func newLustreProcMetric(name string, source string, path string) lustreProcMetric {
func newLustreProcMetric(name string, source string, path string, helpText string) lustreProcMetric {
var m lustreProcMetric
m.name = name
m.source = source
m.path = path
m.helpText = helpText

return m
}

func (s *lustreSource) generateOSSMetricTemplates() error {
metricMap := map[string][]string{
"obdfilter/*": []string{"filestotal"}, //add metrics here for obdfilter
metricMap := map[string]map[string]string{
"obdfilter/*": map[string]string{ //add metrics here for obdfilter
"filestotal": "The maximum number of inodes (objects) the filesystem can hold",
},
}
for path, _ := range metricMap {
for _, metric := range metricMap[path] {
newMetric := newLustreProcMetric(metric, "OSS", path)
for metric, helpText := range metricMap[path] {
newMetric := newLustreProcMetric(metric, "OSS", path, helpText)
s.lustreProcMetrics = append(s.lustreProcMetrics, newMetric)
}
}
Expand All @@ -80,8 +84,8 @@ func (s *lustreSource) Update(ch chan<- prometheus.Metric) (err error) {
}
for _, path := range paths {

err = s.parseFile(metric.source, "single", path, func(nodeType string, nodeName string, name string, value uint64) {
ch <- s.constMetric(nodeType, nodeName, name, value)
err = s.parseFile(metric.source, "single", path, metric.helpText, func(nodeType string, nodeName string, name string, helpText string, value uint64) {
ch <- s.constMetric(nodeType, nodeName, name, helpText, value)
})
if err != nil {
return err
Expand All @@ -91,7 +95,7 @@ func (s *lustreSource) Update(ch chan<- prometheus.Metric) (err error) {
return nil
}

func (s *lustreSource) parseFile(nodeType string, metricType string, path string, handler func(string, string, string, uint64)) (err error) {
func (s *lustreSource) parseFile(nodeType string, metricType string, path string, helpText string, handler func(string, string, string, string, uint64)) (err error) {
pathElements := strings.Split(path, "/")
pathLen := len(pathElements)
if pathLen < 1 {
Expand All @@ -109,16 +113,16 @@ func (s *lustreSource) parseFile(nodeType string, metricType string, path string
if err != nil {
return err
}
handler(nodeType, nodeName, name, convertedValue)
handler(nodeType, nodeName, name, helpText, convertedValue)
}
return nil
}

func (s *lustreSource) constMetric(nodeType string, nodeName string, name string, value uint64) prometheus.Metric {
func (s *lustreSource) constMetric(nodeType string, nodeName string, name string, helpText string, value uint64) prometheus.Metric {
return prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "lustre", name),
string("Help text here"),
helpText,
[]string{nodeType},
nil,
),
Expand Down