mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
Moving around polling files...
git-svn-id: http://www.observium.org/svn/observer/trunk@72 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
parent
1b0c67efb5
commit
d01ad04f34
@ -9,7 +9,7 @@
|
||||
$type = strtolower($device['os']);
|
||||
unset($image);
|
||||
|
||||
$image = getImage($device[id]);
|
||||
$image = getImage($device['device_id']);
|
||||
|
||||
echo("
|
||||
<tr bgcolor='$bg'>
|
||||
|
@ -4,31 +4,31 @@ if(!$samehost) {
|
||||
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg = $list_colour_a; }
|
||||
}
|
||||
|
||||
$service_type = strtolower($service[service_type]);
|
||||
$service_type = strtolower($service['service_type']);
|
||||
|
||||
if($service[service_status] == '0') {$status = "<span class=red><b>$service_type</b></span>";
|
||||
} elseif ($service[service_status] == '1') {$status = "<span class=green><b>$service_type</b></span>";
|
||||
} elseif ($service[service_status] == '2') {$status = "<span class=grey><b>$service_type</b></span>";}
|
||||
|
||||
$message = trim($service[service_message]);
|
||||
$message = trim($service['service_message']);
|
||||
$message = str_replace("\n", "<br />", $message);
|
||||
|
||||
$since = time() - $service[service_changed];
|
||||
$since = time() - $service['service_changed'];
|
||||
$since = formatUptime($since);
|
||||
|
||||
if($service[service_checked]) {
|
||||
$checked = time() - $service[service_checked];
|
||||
if($service['service_checked']) {
|
||||
$checked = time() - $service['service_checked'];
|
||||
$checked = formatUptime($checked);
|
||||
} else { $checked = "Never"; }
|
||||
|
||||
|
||||
echo("
|
||||
<tr style=\"background-color: $bg; padding: 5px;\"><td valign=top>$service[service_id].</td>");
|
||||
<tr style=\"background-color: $bg; padding: 5px;\"><td valign=top>" . $service['service_id'] . ".</td>");
|
||||
|
||||
if($device_id) {
|
||||
if(!$samehost) {
|
||||
$device[id] = $device_id;
|
||||
$device[hostname] = $device_hostname;
|
||||
$device['device_id'] = $device_id;
|
||||
$device['hostname'] = $device_hostname;
|
||||
echo("<td valign=top width=200><span style='font-weight:bold;'>" . generatedevicelink($device) . "</span></td>");
|
||||
} else {
|
||||
echo("<td></td>");
|
||||
@ -49,5 +49,4 @@ echo("
|
||||
|
||||
$i++;
|
||||
|
||||
|
||||
?>
|
||||
|
@ -6,12 +6,12 @@ echo("<div style='margin: 5px;'><table cellpadding=7 border=0 cellspacing=0 widt
|
||||
//echo("<tr class=interface-desc bgcolor='#e5e5e5'><td>Device</td><td>Service</td><td>Status</td><td>Changed</td><td>Checked</td><td>Message</td></tr>");
|
||||
|
||||
|
||||
$host_sql = "SELECT D.id, D.hostname FROM devices AS D, services AS S WHERE D.id = S.service_host GROUP BY D.hostname ORDER BY D.hostname";
|
||||
$host_sql = "SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.service_host GROUP BY D.hostname ORDER BY D.hostname";
|
||||
$host_query = mysql_query($host_sql);
|
||||
while($host_data = mysql_fetch_array($host_query)) {
|
||||
$device_id = $host_data[id];
|
||||
$device_hostname = $host_data[hostname];
|
||||
$service_query = mysql_query("SELECT * FROM `services` WHERE `service_host` = '$host_data[id]' $where");
|
||||
$device_id = $host_data['device_id'];
|
||||
$device_hostname = $host_data['hostname'];
|
||||
$service_query = mysql_query("SELECT * FROM `services` WHERE `service_host` = '" . $host_data['device_id'] . "' $where");
|
||||
while($service = mysql_fetch_array($service_query)) {
|
||||
include("includes/print-service.inc");
|
||||
$samehost = 1;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
echo("Polling device network statistics...\n");
|
||||
|
||||
$oids = array ('ipForwDatagrams','ipInDelivers','ipInReceives','ipOutRequests','ipInDiscards','ipOutDiscards','ipOutNoRoutes',
|
||||
'icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
||||
'icmpOutEchoReps','snmpInTotalReqVars','snmpInTotalSetVars','snmpInTraps','snmpOutTraps','snmpInPkts',
|
||||
@ -13,25 +15,33 @@ $rrd_create = "rrdtool create $rrdfile ";
|
||||
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
|
||||
unset($snmpstring);
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
|
||||
foreach($oids as $oid){
|
||||
$rrd_create .= " DS:$oid:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
echo("$snmpstring");
|
||||
|
||||
if(!file_exists($rrdfile)) { `$rrd_create`; }
|
||||
|
||||
$snmpdata_cmd = "snmpbulkget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " $snmpstring";
|
||||
$snmpdata_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " $snmpstring";
|
||||
$snmpdata = trim(`$snmpdata_cmd`);
|
||||
|
||||
#echo($snmpdata_cmd . "\n");
|
||||
|
||||
#echo($snmpdata . "\n");
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach(explode("\n", $snmpdata) as $data) {
|
||||
if(strstr($data, "No")) { $data = ""; }
|
||||
if(strstr($data, "No") || strstr($data, "d") || strstr($data, "s")) { $data = ""; }
|
||||
$rrdupdate .= ":$data";
|
||||
}
|
||||
|
||||
echo("$rrdupdate\n");
|
||||
|
||||
rrd_update($rrdfile, $rrdupdate);
|
||||
|
||||
rrd_error();
|
||||
|
@ -55,10 +55,11 @@ $oid_ssCpuRawIdle = ".1.3.6.1.4.1.2021.11.53.0";
|
||||
$oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.0";
|
||||
$oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0";
|
||||
|
||||
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||
$cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses";
|
||||
$cmd .= " $oid_hrSystemNumUsers .1.3.6.1.4.1.2021.1.101.1";
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $cputemp) = explode("\n", $s);
|
||||
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||
$cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses";
|
||||
$cpu_cmd .= " $oid_hrSystemNumUsers .1.3.6.1.4.1.2021.1.101.1";
|
||||
$cpu = `$cpu_cmd`;
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $cputemp) = explode("\n", $cpu);
|
||||
|
||||
## Create CPU RRD if it doesn't already exist
|
||||
if (!is_file($cpurrd)) {
|
||||
|
@ -2,35 +2,4 @@
|
||||
|
||||
include("procurve-graphing.php");
|
||||
|
||||
function pollDeviceHP() {
|
||||
|
||||
global $device;
|
||||
global $community;
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
$hardware = $device['hardware'];
|
||||
$version = $device['version'];
|
||||
$features = $device['features'];
|
||||
$location = $device['location'];
|
||||
$os = $device['location'];
|
||||
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
||||
$memrrd = "rrd/" . $hostname . "-mem.rrd";
|
||||
$cpu = `snmpget -O qv -v2c -c $community $hostname 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0`;
|
||||
$meminfo = `snmpget -O qv -v2c -c $community $hostname 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.7.1`;
|
||||
echo("$meminfo");
|
||||
list ($memtotal, $memfree, $memused) = explode("\n", $meminfo);
|
||||
echo("$hostname\n");
|
||||
$memused = $memused + 0;
|
||||
$memfree = $memfree + 0;
|
||||
$memtotal = $memtotal + 0;
|
||||
if (!is_file($cpurrd)) {
|
||||
$rrdcreate = `rrdtool create $cpurrd --step 300 DS:LOAD:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200`;
|
||||
}
|
||||
if (!is_file($memrrd)) {
|
||||
$rrdcreate = `rrdtool create $memrrd --step 300 DS:TOTAL:GAUGE:600:0:500000000 DS:FREE:GAUGE:600:-1:500000000 DS:USED:GAUGE:600:0:500000000 RRA:AVERAGE:0.5:1:1200`;
|
||||
}
|
||||
`rrdtool update $cpurrd N:$cpu`;
|
||||
`rrdtool update $memrrd N:$memtotal:$memfree:$memused`;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -125,7 +125,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
echo("$ciscomodel");
|
||||
$newhardware = str_replace("\"", "", $ciscomodel);
|
||||
}
|
||||
pollDeviceHP();
|
||||
include("includes/polling/device-procurve.inc.php");
|
||||
break;
|
||||
case "Snom":
|
||||
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " 1.3.6.1.2.1.7526.2.4";
|
||||
|
Loading…
Reference in New Issue
Block a user