diff --git a/proxy.go b/proxy.go index 8586f02..f4de41a 100644 --- a/proxy.go +++ b/proxy.go @@ -26,6 +26,7 @@ var ( //shellyAuthUser = flagset.String("shellyplug-auth-username", "", "Shellyplug authentication username (also via SHELLYPLUG_AUTH_USERNAME)") //shellyAuthPass = flagset.String("shellyplug-auth-password", "", "Shellyplug authentication username (also via SHELLYPLUG_AUTH_PASSWORD)") exporterPort = flagset.Int("exporter-port", 5000, "Exporter port (also via EXPORTER_PORT)") + exporterName = flagset.String("exporter-name", "shelly_plug", "Exporter name (also via EXPORTER_NAME)") // additional flags _ = flagset.String("config", "", "Path to config file (ini format)") @@ -159,7 +160,8 @@ func (s *ShellyStatus) Fetch() { func GetMetrics(c *gin.Context) { switch ss.Version { case 1: - c.String(http.StatusOK, `# HELP shellyplug_power Current power drawn in watts + c.String(http.StatusOK, `shellyplug_name %s +# HELP shellyplug_power Current power drawn in watts # TYPE shellyplug_power gauge shellyplug_power %.2f # HELP shellyplug_overpower Overpower drawn in watts/minute @@ -174,9 +176,10 @@ shellyplug_temperature %.2f # HELP shellyplug_uptime Plug uptime in seconds # TYPE shellyplug_uptime gauge shellyplug_uptime %d -`, ss.Status1.Meters[0].Counters[0], float32(0), 0, ss.Status1.Temperature, ss.Status1.Uptime) +`, exporterName, ss.Status1.Meters[0].Counters[0], float32(0), 0, ss.Status1.Temperature, ss.Status1.Uptime) case 2: - c.String(http.StatusOK, `# HELP shellyplug_power Current power drawn in watts + c.String(http.StatusOK, `shellyplug_name %s +# HELP shellyplug_power Current power drawn in watts # TYPE shellyplug_power gauge shellyplug_power %.2f # HELP shellyplug_overpower Overpower drawn in watts/minute @@ -191,9 +194,10 @@ shellyplug_temperature %.2f # HELP shellyplug_uptime Plug uptime in seconds # TYPE shellyplug_uptime gauge shellyplug_uptime %d -`, ss.Status2.Switch.Power, float32(0), 0, ss.Status2.Switch.Temperature.Celsius, ss.Status2.Sys.Uptime) +`, exporterName, ss.Status2.Switch.Power, float32(0), 0, ss.Status2.Switch.Temperature.Celsius, ss.Status2.Sys.Uptime) default: - c.String(http.StatusOK, `# HELP shellyplug_power Current power drawn in watts + c.String(http.StatusOK, `shellyplug_name %s +# HELP shellyplug_power Current power drawn in watts # TYPE shellyplug_power gauge shellyplug_power %.2f # HELP shellyplug_overpower Overpower drawn in watts/minute @@ -208,7 +212,7 @@ shellyplug_temperature %.2f # HELP shellyplug_uptime Plug uptime in seconds # TYPE shellyplug_uptime gauge shellyplug_uptime %d -`, float32(0), float32(0), 0, float32(0), 0) +`, exporterName, float32(0), float32(0), 0, float32(0), 0) } }