revert name

This commit is contained in:
shoopea 2023-12-16 16:14:19 +01:00
parent edd8b778f3
commit 48d854c8ca
1 changed files with 6 additions and 10 deletions

View File

@ -26,7 +26,6 @@ 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)")
@ -160,8 +159,7 @@ func (s *ShellyStatus) Fetch() {
func GetMetrics(c *gin.Context) {
switch ss.Version {
case 1:
c.String(http.StatusOK, `shellyplug_name %s
# HELP shellyplug_power Current power drawn in watts
c.String(http.StatusOK, `# HELP shellyplug_power Current power drawn in watts
# TYPE shellyplug_power gauge
shellyplug_power %.2f
# HELP shellyplug_overpower Overpower drawn in watts/minute
@ -176,10 +174,9 @@ shellyplug_temperature %.2f
# HELP shellyplug_uptime Plug uptime in seconds
# TYPE shellyplug_uptime gauge
shellyplug_uptime %d
`, *exporterName, ss.Status1.Meters[0].Counters[0], float32(0), 0, ss.Status1.Temperature, ss.Status1.Uptime)
`, ss.Status1.Meters[0].Counters[0], float32(0), 0, ss.Status1.Temperature, ss.Status1.Uptime)
case 2:
c.String(http.StatusOK, `shellyplug_name %s
# HELP shellyplug_power Current power drawn in watts
c.String(http.StatusOK, `# HELP shellyplug_power Current power drawn in watts
# TYPE shellyplug_power gauge
shellyplug_power %.2f
# HELP shellyplug_overpower Overpower drawn in watts/minute
@ -194,10 +191,9 @@ shellyplug_temperature %.2f
# HELP shellyplug_uptime Plug uptime in seconds
# TYPE shellyplug_uptime gauge
shellyplug_uptime %d
`, *exporterName, ss.Status2.Switch.Power, float32(0), 0, ss.Status2.Switch.Temperature.Celsius, ss.Status2.Sys.Uptime)
`, ss.Status2.Switch.Power, float32(0), 0, ss.Status2.Switch.Temperature.Celsius, ss.Status2.Sys.Uptime)
default:
c.String(http.StatusOK, `shellyplug_name %s
# HELP shellyplug_power Current power drawn in watts
c.String(http.StatusOK, `# HELP shellyplug_power Current power drawn in watts
# TYPE shellyplug_power gauge
shellyplug_power %.2f
# HELP shellyplug_overpower Overpower drawn in watts/minute
@ -212,7 +208,7 @@ shellyplug_temperature %.2f
# HELP shellyplug_uptime Plug uptime in seconds
# TYPE shellyplug_uptime gauge
shellyplug_uptime %d
`, *exporterName, float32(0), float32(0), 0, float32(0), 0)
`, float32(0), float32(0), 0, float32(0), 0)
}
}