I have a network with a number of devices that are frequently turned on or off based on usage (picture lab computers, a television with ethernet, etc). And I'd like to measure how much time they spend turned on. I'm already monitoring network performance using smokeping, and pinging the devices will give enough data so it seemed a natural fit.<div>
<br></div><div>I'm having a hard enough time figuring this out that I was considering building my own tool. I thought I'd ask here if it's reasonable to try to adapt smokeping for this usage or how to go about it.</div>
<div><br></div><div><div><br></div><div>What I want:</div><div> Assume if that if a single ping response during a probe, then the device is up for 5 minutes, otherwise it's down for 5 minutes.</div><div><br></div><div>
Store minutes up per hour for the last week; Viewable for day, week</div><div> Store minutes up per day (with exact day boundaries at midnight) for the last year; Viewable for last month, year.</div><div><br></div><div>
I also intend to extract some of this data to embed current on/off values in a different web page and to help publish weekly usage reports. Below is a bash CGI test script to pull On/Off values directly out of rrdtool. I'll want to do something similar for the weekly reports.</div>
<div><br></div><div><br></div><div><div>#!/bin/bash</div><div><br></div><div>RRDTOOL=/usr/bin/rrdtool</div><div>TAIL=/usr/bin/tail</div><div>CUT=/usr/bin/cut</div><div><br></div><div># This pulls out the number of timeout pings in the last attempt</div>
<div># to ping the TV. We normally see 0 failures when it's on. Could</div><div># also test for 20 failures to show it's off.</div><div>fail_count=`${RRDTOOL} lastupdate /var/lib/smokeping/Local/TV.rrd | \</div><div>
${TAIL} -n 1 | \</div><div> ${CUT} -f 3 -d ' '`</div><div><br></div><div>result=0</div><div><br></div><div>[ "${fail_count}" == "0" ] && result=1</div><div><br>
</div><div>echo Content-type: text/plain</div><div>echo ""</div><div>echo "${result}"</div></div><div><br></div>-- <br>Don<br>
</div><div><br></div>