add help to munin plugin
authorChristian Weiske <cweiske@cweiske.de>
Tue, 28 Dec 2010 21:53:06 +0000 (22:53 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 28 Dec 2010 21:53:06 +0000 (22:53 +0100)
scripts/munin.php

index 5fc252601cafc832b45799954cc4a19e35a6b55e..4872e90114e5e0dc89a412d2dc53e6241e7a4fbb 100755 (executable)
@@ -1,28 +1,37 @@
 #!/usr/bin/env php
 <?php
 /**
-* munin node output for the router status
-*
-* PHP version 5
-*
-* @category Tools
-* @package  linksys-wrt3g-tools
-* @author   Christian Weiske <cweiske@cweiske.de>
-* @license  AGPL v3
-* @link     http://cweiske.de/linksys-wrt3g-tools.htm
-*/
+ * Munin node plugin to monitor the router status.
+ * Part of Linksys WRT3G tools
+ *
+ * PHP version 5
+ *
+ * @category Tools
+ * @package  linksys-wrt3g-tools
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  AGPL v3
+ * @link     http://cweiske.de/linksys-wrt3g-tools.htm
+ * @link     http://munin-monitoring.org/wiki/ConcisePlugins
+ */
 require_once 'Wrt3g.php';
 
 if (isset($argv[1]) && $argv[1] == 'autoconf') {
-    echo "yes\n";
+    $router = new Wrt3g();
+    $router->loadConfig();
+    if ($router->config->host === null) {
+        echo "no (no host configured)\n";
+    } else {
+        echo "yes\n";
+    }
     exit();
+
 } else if (isset($argv[1]) && $argv[1] == 'config') {
     echo <<<TXT
 graph_title WRT3G router status
 graph_args --base 1000 -l 0 --upper-limit 7
 graph_vlabel Status values
 graph_category network
-graph_info This graph shows the status of WRT3G router
+graph_info This graph shows the status of WRT3G router
 conn_connected.label Connected
 conn_connected.info Router is connected
 conn_connected.draw LINE2
@@ -42,6 +51,18 @@ type_umts.label UMTS
 type_umts.info Connection via UMTS
 type_umts.draw LINE2
 
+TXT;
+    exit();
+} else if (isset($argv[1])
+    && ($argv[1] == 'help' || $argv[1] == '--help' || $argv[1] == '-h')
+) {
+    echo <<<TXT
+munin-node plugin to monitor a linksys wrt3g router
+Commands:
+  autoconf  - Check if the plugin would work
+  config    - Show munin config values
+  <nothing> - Print status
+
 TXT;
     exit();
 }