-
Notifications
You must be signed in to change notification settings - Fork 21
Example use cases
Currently I'm using the script (located on my RaspberryPi which is always connected to my router via ethernet) combined with Workflow (https://itunes.apple.com/de/app/workflow/id915249334?mt=8) on my iPhone/iPad. Workflow offers the possibility to send SSH commands directly to your raspberry or to any other SSH capable device. After creating the workflow itself, I have added them to the Today Widget view for faster access.
Suppose, you want to visualize the overall Download Rate of your FritzBox: The way to go here is to use the Action IGDWAN with parameter STATE. It gives (for example) this output:
NewByteSendRate 265
NewByteReceiveRate 17
NewPacketSendRate 0
NewPacketReceiveRate 0
NewTotalBytesSent 0
NewTotalBytesReceived 0
NewAutoDisconnectTime 0
NewIdleDisconnectTime 0
NewDNSServer1 83.169.186.33
NewDNSServer2 83.169.186.97
NewVoipDNSServer1 83.169.186.33
NewVoipDNSServer2 83.169.186.97
NewUpnpControlEnabled 0
NewRoutedBridgedModeBoth 1
The important line here is the one with NewByteReceiveRate
in it. If we augment the script execution with some pipe magic, we get exactly
the Download Rate value:
BoxUSER=YourUser BoxPW=YourPassword /opt/telegraf/FritzBoxShell/fritzBoxShell.sh IGDWAN STATE|grep NewByteReceiveRate|cut -d ' ' -f 2
Now - how to get this measurement into Telegraf? Well, Telegraf has an exec
input that allows us to inject one measurement with a specific value. It looks like this:
[[inputs.exec]]
commands = ["<some command>"]
name_override = "fritzbox_byte_receive_rate"
data_format = "value"
data_type = "integer"
Now for the ugly truth: we can not use the command shown earlier for where it says some command
- we must instead use some simple bash logic:
[[inputs.exec]]
commands = ["/bin/bash -c \"BoxUSER=YourUser BoxPW=YourPassword /opt/telegraf/FritzBoxShell/fritzBoxShell.sh IGDWAN STATE|grep NewByteReceiveRate|cut -d ' ' -f 2\"" ]
name_override = "fritzbox_byte_receive_rate"
data_format = "value"
data_type = "integer"
Data with huge absolute values probably dont fit into type integer
- in this case, long
is the way to go...