blob: 0722035b74379e9359ac092a97f66f1eff3cf1d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/usr/bin/env php
<?php
/**
* 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') {
$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 a WRT3G router
conn_connected.label Connected
conn_connected.info Router is connected
conn_connected.draw LINE2
conn_connecting.label Connecting
conn_connecting.info Router is connecting
conn_connecting.draw LINE2
conn_disconnected.label Disconnected
conn_disconnected.info Router is disconnected
conn_disconnected.draw LINE2
notavailable.label Not available
notavailable.info Router cannot be reached
notavailable.draw LINE2
type_gprs.label GPRS
type_gprs.info Connection via GPRS
type_gprs.draw LINE2
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.
Supports environment variables: host, user, password
Commands:
autoconf - Check if the plugin would work
config - Show munin config values
<nothing> - Print status for munin-node consumption
TXT;
exit();
}
try {
$router = new Wrt3g();
$router->loadConfig();
$arStatus = $router->getConnectionStatus();
$conn = $arStatus['connection'];
if ($conn == 'disconnected') {
echo "conn_disconnected.value 1\n";
} else if ($conn == 'connecting') {
echo "conn_connecting.value 2\n";
} else if ($conn == 'connected') {
echo "conn_connected.value 3\n";
}
$type = strtolower($arStatus['type']);
if ($type == 'gprs') {
echo "type_gprs.value 4.5\n";
} else if ($type == 'umts') {
echo "type_umts.value 5\n";
}
} catch (Exception $e) {
echo "notavailable 0.5\n";
}
?>
|