*/
require_once 'Wrt3g.php';
+$options = array();
+foreach (array('host', 'user', 'password') as $variable) {
+ if (isset($_SERVER[$variable])) {
+ $options[$variable] = $_SERVER[$variable];
+ }
+}
+
if (isset($argv[1]) && $argv[1] == 'autoconf') {
$router = new Wrt3g();
- $router->loadConfig();
+ $router->loadConfig($options);
if ($router->config->host === null) {
echo "no (no host configured)\n";
} else {
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
+munin-node plugin to monitor a linksys wrt3g router.
+
+Supports environment variables: host, user, password
+
Commands:
autoconf - Check if the plugin would work
config - Show munin config values
- <nothing> - Print status
+ <nothing> - Print status for munin-node consumption
TXT;
exit();
try {
$router = new Wrt3g();
- $router->loadConfig();
+ $router->loadConfig($options);
$arStatus = $router->getConnectionStatus();