3 require_once "common.inc.php";
7 // Stolen from a php.net comment
9 // Return back the numeric OIDs, instead of text strings.
10 snmp_set_oid_numeric_print(1);
12 // Get just the values.
13 snmp_set_quick_print(TRUE);
15 // For sequence types, return just the numbers, not the string and numbers.
16 snmp_set_enum_print(TRUE);
18 // Don't let the SNMP library get cute with value interpretation. This makes
19 // MAC addresses return the 6 binary bytes, timeticks to return just the integer
20 // value, and some other things.
21 snmp_set_valueretrieval(SNMP_VALUE_PLAIN
);
29 function server_status($server)
34 $load = snmpget ($server, "public", "UCD-SNMP-MIB::laLoad.1", $snmp_timeout);
36 /* Host is down - timed out */
37 return array ($ret, "", "", "");
41 /* Grab logged in users */
42 $users = snmpget ($server, "public", "HOST-RESOURCES-MIB::hrSystemNumUsers.0", $snmp_timeout);
45 $processes = snmpget ($server, "public", "HOST-RESOURCES-MIB::hrSystemProcesses.0", $snmp_timeout);
47 return array (0, $users, $processes, $load);
57 function node_status($buildnode)
62 $load = snmpget ($buildnode, "public", "UCD-SNMP-MIB::laLoad.1", $snmp_timeout);
64 /* Host is down - timed out */
65 return array ($ret, "", "", "", "", "");
68 /* Grab free disk space */
69 $disk_avail = snmpget ($buildnode, "public", "UCD-SNMP-MIB::dskAvail.1", $snmp_timeout);
70 $disk_total = snmpget ($buildnode, "public", "UCD-SNMP-MIB::dskTotal.1", $snmp_timeout);
71 $disk = sprintf ("%dG/%dG", $disk_avail/1024/1024, $disk_total/1024/1024);
73 /* Grab logged in users */
74 $users = snmpget ($buildnode, "public", "HOST-RESOURCES-MIB::hrSystemNumUsers.0", $snmp_timeout);
77 $processes = snmpget ($buildnode, "public", "HOST-RESOURCES-MIB::hrSystemProcesses.0", $snmp_timeout);
79 /* Check if it's enabled */
80 /* Check if cron is running */
81 if (!file_exists ("/var/run/crond.pid")) {
84 /* Check if the node is really enabled */
86 // Force always enabled, as we can't parse upload.conf anymore :(
89 exec ('/bin/grep -q "^[ ]\+'.$buildnode.'[ ]\+=" /home/mandrake/.upload.conf',
100 return array (0, $enabled, $users, $processes, $load, $disk);
117 // Setup snmp library
121 page_header("status");
125 <h3
>Build system
: servers status
</h3
>
136 $server_status = array();
138 foreach ($servers as $server) {
139 $server_status[$server] = server_status ($server);
143 <table style
='text-align: right;'>
149 <th
>Current load
</th
>
153 foreach ($server_status as $server => $status) {
154 $online = !$status[0] ?
"Yes" : "No";
158 "<td>${status[1]}</td>".
159 "<td>${status[2]}</td>".
160 "<td>${status[3]}</td>".
182 $node_status = array();
184 foreach ($nodes as $node) {
185 $node_status[$node] = node_status ($node);
190 <h3
>Build system
: build nodes status
</h3
>
191 <table style
='text-align: right;'>
198 <th
>Current load
</th
>
203 foreach ($node_status as $node => $status) {
204 $online = !$status[0] ?
"Yes" : "No";
205 $enabled = $status[1] ?
"Yes" : "No";
210 "<td>${status[2]}</td>".
211 "<td>${status[3]}</td>".
212 "<td>${status[4]}</td>".
213 "<td>${status[5]}</td>".