mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
a million fixes. half way to 0.6.0! :D
git-svn-id: http://www.observium.org/svn/observer/trunk@407 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -4,7 +4,7 @@ $query = "SELECT * FROM cpmCPU WHERE device_id = '" . $device['device_id'] . "'"
|
||||
$proc_data = mysql_query($query);
|
||||
while($processor = mysql_fetch_array($proc_data)) {
|
||||
|
||||
$proc_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpmCPUTotal5minRev." . $processor['cpmCPU_oid'];
|
||||
$proc_cmd = "snmpget -m CISCO-PROCESS-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpmCPUTotal5minRev." . $processor['cpmCPU_oid'];
|
||||
$proc = shell_exec($proc_cmd);
|
||||
|
||||
echo("Checking CPU " . $processor['entPhysicalDescr'] . "... ");
|
||||
@@ -27,7 +27,6 @@ while($processor = mysql_fetch_array($proc_data)) {
|
||||
echo($proc . "%\n");
|
||||
|
||||
$updatecmd = $config['rrdtool'] ." update $procrrd N:$proc";
|
||||
echo("$updatecmd");
|
||||
shell_exec($updatecmd);
|
||||
|
||||
mysql_query("UPDATE `cpmCPU` SET `cpmCPUTotal5minRev` = '$proc' WHERE `cpmCPU_id` = '".$processor['cpmCPU_id']."'");
|
||||
|
||||
@@ -107,5 +107,6 @@
|
||||
|
||||
include("includes/polling/bgpPeer.inc.php");
|
||||
include("includes/polling/cisco-processors.inc.php");
|
||||
include("includes/polling/cisco-mempool.inc.php");
|
||||
|
||||
?>
|
||||
|
||||
@@ -14,7 +14,7 @@ if($device[os] != "Snom") {
|
||||
|
||||
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/netinfo.rrd";
|
||||
|
||||
$rrd_create = "rrdtool create $rrdfile ";
|
||||
$rrd_create = $config['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";
|
||||
|
||||
@@ -23,8 +23,10 @@ if($device[os] != "Snom") {
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
if(!file_exists($rrdfile)) { `$rrd_create`; }
|
||||
$snmpdata_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring";
|
||||
if(!file_exists($rrdfile)) {
|
||||
shell_exec($rrd_create);
|
||||
}
|
||||
$snmpdata_cmd = "snmpget -m IP-MIB:SNMPv2-MIB:UDP-MIB:TCP-MIB:IP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring";
|
||||
$snmpdata = trim(`$snmpdata_cmd`);
|
||||
$rrdupdate = "N";
|
||||
foreach(explode("\n", $snmpdata) as $data) {
|
||||
|
||||
@@ -48,7 +48,7 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
$hrStorageAllocationUnits = $dr['hrStorageAllocationUnits'];
|
||||
$hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize'];
|
||||
$hrStorageDescr = $dr['hrStorageDescr'];
|
||||
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageUsed.$hrStorageIndex";
|
||||
$cmd = "snmpget -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageUsed.$hrStorageIndex";
|
||||
$used_units = trim(`$cmd`);
|
||||
$used = $used_units * $hrStorageAllocationUnits;
|
||||
$perc = round($used / $hrStorageSize * 100, 2);
|
||||
@@ -78,14 +78,10 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
if($dr['storage_perc'] < '40' && $perc >= '40') {
|
||||
|
||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||
|
||||
$msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'] . " is " . $perc;
|
||||
$msg .= " at " . date('l dS F Y h:i:s A');
|
||||
|
||||
mail($email, "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'], $msg, $config['email_headers']);
|
||||
|
||||
echo("Alerting for " . $device['hostname'] . " " . $dr['hrStorageDescr'] . "/n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -104,11 +100,11 @@ $oid_ssCpuUser = ".1.3.6.1.4.1.2021.11.9.0";
|
||||
$oid_ssCpuSystem = ".1.3.6.1.4.1.2021.11.10.0";
|
||||
|
||||
|
||||
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cpu_cmd = $config['snmpget'] ." -m UCD-SNMP-MIB:HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses";
|
||||
$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem .1.3.6.1.4.1.2021.1.101.1";
|
||||
$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem";
|
||||
$cpu = `$cpu_cmd`;
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem, $cputemp) = explode("\n", $cpu);
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem) = explode("\n", $cpu);
|
||||
|
||||
$cpuUsage = $UsageUser + $UsageSystem;
|
||||
|
||||
@@ -192,13 +188,14 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
|
||||
RRA:MAX:0.5:288:800");
|
||||
} // end create load rrd
|
||||
|
||||
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
|
||||
$mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get;
|
||||
$mem_raw = `$mem_cmd`;
|
||||
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw);
|
||||
$mem_cmd = $config['snmpget'] . " -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$mem_cmd .= " memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
|
||||
|
||||
$mem_raw = shell_exec($mem_cmd);
|
||||
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", str_replace(" kB", "", $mem_raw));
|
||||
|
||||
$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3";
|
||||
$load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
|
||||
$load_cmd = "snmpget -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
|
||||
$load_raw = `$load_cmd`;
|
||||
list ($load1, $load5, $load10) = explode ("\n", $load_raw);
|
||||
|
||||
@@ -206,16 +203,4 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
|
||||
rrdtool_update($loadrrd, "N:$load1:$load5:$load10");
|
||||
rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
|
||||
|
||||
if($device['courier']) {
|
||||
include("includes/polling/courierstats.inc.php");
|
||||
}
|
||||
|
||||
if($device['postfix']) {
|
||||
include("includes/polling/mailstats.inc.php");
|
||||
}
|
||||
|
||||
if($device['apache']) {
|
||||
include("includes/polling/apachestats.inc.php");
|
||||
}
|
||||
|
||||
} // end Non-m0n0wall
|
||||
|
||||
@@ -18,7 +18,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
|
||||
echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n");
|
||||
|
||||
$snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_cmd = $config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_cmd .= " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ifAlias." . $interface['ifIndex'];
|
||||
|
||||
$snmp_output = trim(`$snmp_cmd`);
|
||||
@@ -93,8 +93,8 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
|
||||
if($ifOperStatus == "up") {
|
||||
|
||||
$snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
# $snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_data_cmd = "snmpget -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_data_cmd .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex'];
|
||||
$snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex'];
|
||||
$snmp_data_cmd .= " ifInNUcastPkts." . $interface['ifIndex'] . " ifOutNUcastPkts." . $interface['ifIndex'];
|
||||
@@ -119,7 +119,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
}
|
||||
}
|
||||
|
||||
$rates = interface_rates ($interface);
|
||||
$rates = interface_rates ($rrdfile);
|
||||
mysql_query("UPDATE `interfaces` SET in_rate = '" . $rates['in'] . "', out_rate = '" . $rates['out'] . "' WHERE interface_id= '" . $interface['interface_id'] . "'");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user