Update: added extra argument

pull/1/head v1.1.0
Darshil Chanpura 4 years ago
parent 3b4f423055
commit a8ca719e13

@ -7,15 +7,17 @@ import (
)
var (
period poller.PeriodValue
period poller.PeriodValue
argument string
)
func init() {
// Add and parse flags passed to script
flag.Var(&period, "period", "Period to send metric at")
flag.StringVar(&argument, "argument", "STATE_CODE", "Argument Variable name")
flag.Parse()
}
func main() {
poller.StartTicker(period.Duration)
poller.StartTicker(period.Duration, argument)
}

@ -34,7 +34,9 @@ func init() {
}
// StartTicker for starting the ticker
func StartTicker(period time.Duration) {
func StartTicker(period time.Duration, argument string) {
// Argument variable for getting extra parameters
project.argument = os.Getenv(argument)
if period > 0 {
ticker = time.NewTicker(period)
} else {

@ -3,8 +3,9 @@ package poller
import "time"
type projecttype struct {
name string
mode string
name string
argument string
mode string
}
type metrictype struct {

@ -56,6 +56,9 @@ func newMetric(metric string, value float64) *metrictype {
if project.name != "" {
prefixes = append(prefixes, project.name)
}
if project.argument != "" {
prefixes = append(prefixes, project.argument)
}
prefix := strings.Join(prefixes, ".")
return newMetricWithPrefix(prefix, metric, value)

Loading…
Cancel
Save