tasmota-charge telegraf
This commit is contained in:
parent
3c09b3a984
commit
7663d3fcce
3 changed files with 48 additions and 1 deletions
18
bundles/tasmota-charge/files/telegraf-plugin
Normal file
18
bundles/tasmota-charge/files/telegraf-plugin
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PLUG_IP=${plug_ip}
|
||||||
|
|
||||||
|
PLUG_IS=$(curl -s "http://$PLUG_IP/cm?cmnd=Power" | jq -r .POWER)
|
||||||
|
|
||||||
|
if [[ $PLUG_IS = ON ]]
|
||||||
|
then
|
||||||
|
STATE=1
|
||||||
|
elif [[ $PLUG_IS = OFF ]]
|
||||||
|
then
|
||||||
|
STATE=0
|
||||||
|
else
|
||||||
|
echo "unknown state: '$PLUG_IS'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tasmota_charge,host=${node.name} state=$STATE $(date --utc +%s%N)"
|
|
@ -11,4 +11,12 @@ files = {
|
||||||
'max': node.metadata.get('tasmota-charge/plug/max'),
|
'max': node.metadata.get('tasmota-charge/plug/max'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'/usr/local/share/icinga/plugins/tasmota_charge': {
|
||||||
|
'content_type': 'mako',
|
||||||
|
'source': 'telegraf-plugin',
|
||||||
|
'mode': '0755',
|
||||||
|
'context': {
|
||||||
|
'plug_ip': node.metadata.get('tasmota-charge/plug/ip'),
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,5 +9,26 @@ defaults = {
|
||||||
'command': f'/usr/bin/sudo -u tasmota-charge /opt/tasmota-charge',
|
'command': f'/usr/bin/sudo -u tasmota-charge /opt/tasmota-charge',
|
||||||
'when': 'minutely',
|
'when': 'minutely',
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@metadata_reactor.provides(
|
||||||
|
'telegraf/config/inpus/exec',
|
||||||
|
)
|
||||||
|
def telegraf(metadata):
|
||||||
|
return {
|
||||||
|
'telegraf': {
|
||||||
|
'config': {
|
||||||
|
'inputs': {
|
||||||
|
'exec': {
|
||||||
|
repo.libs.hashable.hashable({
|
||||||
|
'commands': ["/usr/local/share/icinga/plugins/tasmota_charge"],
|
||||||
|
'name_override': "tasmota_charge",
|
||||||
|
'data_format': "influx",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue