4 * Munin node plugin to monitor the router status.
5 * Part of Linksys WRT3G tools
10 * @package linksys-wrt3g-tools
11 * @author Christian Weiske <cweiske@cweiske.de>
13 * @link http://cweiske.de/linksys-wrt3g-tools.htm
14 * @link http://munin-monitoring.org/wiki/ConcisePlugins
16 require_once 'Wrt3g.php';
19 foreach (array('host', 'user', 'password') as $variable) {
20 if (isset($_SERVER[$variable])) {
21 $options[$variable] = $_SERVER[$variable];
25 if (isset($argv[1]) && $argv[1] == 'autoconf') {
26 $router = new Wrt3g();
27 $router->loadConfig($options);
28 if ($router->config->host === null) {
29 echo "no (no host configured)\n";
35 } else if (isset($argv[1]) && $argv[1] == 'config') {
37 graph_title WRT3G router status
38 graph_args --base 1000 -l 0 --upper-limit 7
39 graph_vlabel Status values
40 graph_category network
41 graph_info This graph shows the status of a WRT3G router
42 conn_connected.label Connected
43 conn_connected.info Router is connected
44 conn_connected.draw LINE2
45 conn_connecting.label Connecting
46 conn_connecting.info Router is connecting
47 conn_connecting.draw LINE2
48 conn_disconnected.label Disconnected
49 conn_disconnected.info Router is disconnected
50 conn_disconnected.draw LINE2
51 notavailable.label Not available
52 notavailable.info Router cannot be reached
53 notavailable.draw LINE2
55 type_gprs.info Connection via GPRS
58 type_umts.info Connection via UMTS
64 } else if (isset($argv[1])
65 && ($argv[1] == 'help' || $argv[1] == '--help' || $argv[1] == '-h')
68 munin-node plugin to monitor a linksys wrt3g router.
70 Supports environment variables: host, user, password
73 autoconf - Check if the plugin would work
74 config - Show munin config values
75 <nothing> - Print status for munin-node consumption
83 $router = new Wrt3g();
84 $router->loadConfig($options);
86 $arStatus = $router->getConnectionStatus();
88 $conn = $arStatus['connection'];
89 if ($conn == 'disconnected') {
90 echo "conn_disconnected.value 1\n";
91 } else if ($conn == 'connecting') {
92 echo "conn_connecting.value 2\n";
93 } else if ($conn == 'connected') {
94 echo "conn_connected.value 3\n";
97 $type = strtolower($arStatus['type']);
98 if ($type == 'gprs') {
99 echo "type_gprs.value 4.5\n";
100 } else if ($type == 'umts') {
101 echo "type_umts.value 5\n";
103 } catch (Exception $e) {
104 echo "notavailable 0.5\n";