Mollien dot Net is IPv6 Enabled!


   My About.Me page
   View my profile on LinkedIn
   Follow me on Twitter
    View my Facebook profile   View my Hyves profile   View my YouTube favorites and uploads

      01010011
      01100101
      01110010
      01101001
      01101111
      01110101
      01110011
      01000111
      01100101
      01100101
      01101011

IPv6 Certification Badge for Cas Mollien
 


 
Monitoring a DD-WRT wireless router
 
How to output the radio status of a DD-WRT box over SNMP
 
By: Cas Mollien
Last modified on: 10 November 2008, 17:43h




 
My Linksys WRT54G with the brilliant DD-WRT firmware has one of those 'EasyConnect' buttons, that can be remapped to turn the radio on or off. I want to have my Nagios box check if my DD-WRT based router has it's radio turned on or not.

Since my Nagios box monitors almost everything over SNMP and since this router fully supports it, I figured that it would be best to just use this technology instead of re-inventing the wheel.

I came up with the following solution, which should work, but somehow I cannot write anything to JFFS2, so this is untested for now (consider this a 'note-to-self'):

1) Through the web interface (Administration -> Commands), add the following lines and click on 'Save Startup':

echo "exec Radio /usr/sbin/wl radio" >> /var/snmp/snmpd.conf
killall -TERM snmpd
snmpd -c /var/snmp/snmpd.conf


This will add an extra command to the SNMP daemon and restart it, after which it will automatically run the radio check command and pass the output to the custom SNMP MIB.

2) Now, test the functionality, Just SNMP-walk the following MIB: .1.3.6.1.4.1.2021.8.1
The output value you are looking for should be stored in: .1.3.6.1.4.1.2021.8.1.101

SNMPGET the last MIB and you should get a result like '0x0000' or '0x0001'. 0x0000 means 'ON', 0x0001 means 'OFF'.

3) If you are using Nagios, you can use this quick-and-dirty Nagios plugin that parses this output and translates it to Nagios output (performance data is most likely not according to spec, though, if you need to use this).


#!/usr/bin/php -q

$hostname=$argv[1];
$community=$argv[2];

$value = shell_exec("snmpwalk -t 3 -r 0 -v 1 $hostname -c $community 1.3.6.1.4.1.2021.8.1.101");

if ($value==""){
echo "UNKNOWN - No data returned from host...|\n";
exit(3);
}

$arr_value = explode (" ", $value);
$myval=rtrim($arr_value[3]);

if ($myval == "0x0001"){
// Return WARNING
echo "WARNING - Radio is OFF|0\n";
exit(1);
} elseif ($myval == "0x0000") {
//Return OK
echo "OK - Radio is ON|1\n";
exit(0);
} else {
//Return UNKNOWN
echo("Something went wrong..... Check the plugin..\n");
exit(3);
}

?>


Tadaa! :-)
 


Found this article useful? Please consider buying me a beer - or something else useful..
blog comments powered by Disqus
 

 
Terug naar Mollien Dot Net

Terug naar Mollien Dot Net

Terug naar Mollien Dot Net
Total Hits: 1
Unique Visitors: 1
Page Impressions : 1
Remote address: 54.82.56.95