mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
updates et al
git-svn-id: http://www.observium.org/svn/observer/trunk@503 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
unset( $storage_exists );
|
||||
|
||||
echo("Storage : ");
|
||||
echo("hrStorage : ");
|
||||
|
||||
$oids = shell_exec($config['snmpwalk'] . " -m HOST-RESOURCES-MIB -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageIndex");
|
||||
$oids = trim(str_replace("hrStorageIndex.","",$oids));
|
||||
@@ -17,14 +17,11 @@
|
||||
|
||||
$allow = 1;
|
||||
foreach($config['ignore_mount'] as $bi) {
|
||||
# echo("$descr == $bi\n");
|
||||
if($descr == $bi) {
|
||||
$allow = 0;
|
||||
}
|
||||
}
|
||||
|
||||
# echo("$fstype\n");
|
||||
|
||||
if(strstr($fstype, "FixedDisk") && $size > '0' && $allow) {
|
||||
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"),0) == '0') {
|
||||
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) ";
|
||||
@@ -49,22 +46,17 @@ $sql = "SELECT * FROM storage AS S, devices AS D where S.host_id = D.device_id A
|
||||
$query = mysql_query($sql);
|
||||
|
||||
while ($store = mysql_fetch_array($query)) {
|
||||
|
||||
unset($exists);
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($storage_exists) && !$exists) {
|
||||
$thisstore = $store['host_id'] . " " . $store['hrStorageIndex'];
|
||||
if ($storage_exists[$i] == $thisstore) { $exists = 1; }
|
||||
$i++;
|
||||
}
|
||||
|
||||
if(!$exists) {
|
||||
echo("-");
|
||||
mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
|
||||
+14
-14
@@ -91,9 +91,16 @@ function shorthost($hostname, $len=16) {
|
||||
|
||||
function rrdtool_update($rrdfile, $rrdupdate) {
|
||||
global $config;
|
||||
echo($config['rrdtool'] . " update $rrdfile $rrdupdate \n");
|
||||
return shell_exec($config['rrdtool'] . " update $rrdfile $rrdupdate");
|
||||
}
|
||||
|
||||
function rrdtool($command, $file, $options) {
|
||||
global $config;
|
||||
if($config['debug']) { echo($config['rrdtool'] . " $command $file $options \n"); }
|
||||
return shell_exec($config['rrdtool'] . " $command $file $options");
|
||||
}
|
||||
|
||||
function getHostOS($hostname, $community, $snmpver, $port) {
|
||||
|
||||
global $config;
|
||||
@@ -155,8 +162,7 @@ function devicepermitted($device_id)
|
||||
|
||||
}
|
||||
|
||||
function formatRates($rate)
|
||||
{
|
||||
function formatRates($rate) {
|
||||
$rate = format_si($rate) . "bps";
|
||||
return $rate;
|
||||
}
|
||||
@@ -331,7 +337,6 @@ $data = mysql_fetch_array(mysql_query($sql));
|
||||
$type = strtolower($data['os']);
|
||||
if(file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = "<img src='".$config['base_url']."/images/os/$type.png'>";
|
||||
} elseif(file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = "<img src='".$config['base_url']."/images/os/$type.gif'>"; }
|
||||
if($device['monowall']) {$image = "<img src='".$config['base_url']."images/os/m0n0wall.png'>";}
|
||||
if($type == "linux") {
|
||||
$features = strtolower(trim($data[features]));
|
||||
list($distro) = split(" ", $features);
|
||||
@@ -342,8 +347,7 @@ $type = strtolower($data['os']);
|
||||
}
|
||||
|
||||
|
||||
function renamehost($id, $new)
|
||||
{
|
||||
function renamehost($id, $new) {
|
||||
global $config;
|
||||
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
||||
shell_exec("mv ".$config['rrd_dir']."/$host ".$config['rrd_dir']."/$new");
|
||||
@@ -517,8 +521,7 @@ function isSNMPable($hostname, $community, $snmpver, $port)
|
||||
return $status;
|
||||
}
|
||||
|
||||
function isPingable($hostname)
|
||||
{
|
||||
function isPingable($hostname) {
|
||||
global $config;
|
||||
$status = shell_exec($config['fping'] . " $hostname");
|
||||
if(strstr($status, "alive")) {
|
||||
@@ -529,13 +532,11 @@ function isPingable($hostname)
|
||||
}
|
||||
|
||||
|
||||
function is_odd($number)
|
||||
{
|
||||
return $number & 1; // 0 = even, 1 = odd
|
||||
function is_odd($number) {
|
||||
return $number & 1; // 0 = even, 1 = odd
|
||||
}
|
||||
|
||||
function isValidInterface($if)
|
||||
{
|
||||
function isValidInterface($if) {
|
||||
global $config;
|
||||
$if = strtolower($if);
|
||||
$nullintf = 0;
|
||||
@@ -561,8 +562,7 @@ function ifclass($ifOperStatus, $ifAdminStatus)
|
||||
return $ifclass;
|
||||
}
|
||||
|
||||
function utime()
|
||||
{
|
||||
function utime() {
|
||||
$time = explode( " ", microtime());
|
||||
$usec = (double)$time[0];
|
||||
$sec = (double)$time[1];
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
echo("$hostname\n");
|
||||
|
||||
if (!is_file($cpurrd)) {
|
||||
$rrdcreate = `rrdtool create $cpurrd --step 300 \
|
||||
$rrdcreate = shell_exec($config['rrdtool'] . " create $cpurrd --step 300 \
|
||||
DS:LOAD5S:GAUGE:600:-1:100 \
|
||||
DS:LOAD5M:GAUGE:600:-1:100 \
|
||||
RRA:AVERAGE:0.5:1:2000 \
|
||||
@@ -38,10 +38,10 @@
|
||||
RRA:MAX:0.5:1:2000 \
|
||||
RRA:MAX:0.5:6:2000 \
|
||||
RRA:MAX:0.5:24:2000 \
|
||||
RRA:MAX:0.5:288:2000`;
|
||||
RRA:MAX:0.5:288:2000");
|
||||
}
|
||||
|
||||
`rrdtool update $cpurrd N:$cpu5s:$cpu5m`;
|
||||
shell_exec($config['rrdtool'] . " update $cpurrd N:$cpu5s:$cpu5m");
|
||||
|
||||
include("includes/polling/bgpPeer.inc.php");
|
||||
include("includes/polling/cisco-processors.inc.php");
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
$loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd";
|
||||
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd";
|
||||
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd";
|
||||
$sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd";
|
||||
|
||||
if ($device['os'] == "FreeBSD") {
|
||||
$sysDescr = str_replace(" 0 ", " ", $sysDescr);
|
||||
@@ -41,70 +40,18 @@ $sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd";
|
||||
}
|
||||
|
||||
|
||||
## Check Disks
|
||||
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '" . $device['device_id'] . "'");
|
||||
while ($dr = mysql_fetch_array($dq)) {
|
||||
$hrStorageIndex = $dr['hrStorageIndex'];
|
||||
$hrStorageAllocationUnits = $dr['hrStorageAllocationUnits'];
|
||||
$hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize'];
|
||||
$hrStorageDescr = $dr['hrStorageDescr'];
|
||||
$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);
|
||||
|
||||
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
||||
|
||||
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
|
||||
|
||||
if (!is_file($storage_rrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $storage_rrd \
|
||||
--step 300 \
|
||||
DS:size:GAUGE:600:0:U \
|
||||
DS:used:GAUGE:600:0:U \
|
||||
DS:perc:GAUGE:600:0:U \
|
||||
RRA:AVERAGE:0.5:1:800 \
|
||||
RRA:AVERAGE:0.5:6:800 \
|
||||
RRA:AVERAGE:0.5:24:800 \
|
||||
RRA:AVERAGE:0.5:288:800 \
|
||||
RRA:MAX:0.5:1:800 \
|
||||
RRA:MAX:0.5:6:800 \
|
||||
RRA:MAX:0.5:24:800 \
|
||||
RRA:MAX:0.5:288:800");
|
||||
}
|
||||
rrdtool_update($storage_rrd, "N:$hrStorageSize:$used:$perc");
|
||||
mysql_query("UPDATE `storage` SET `hrStorageUsed` = '$used_units', `storage_perc` = '$perc' WHERE storage_id = '" . $dr['storage_id'] . "'");
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
## Set OIDs
|
||||
$oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0";
|
||||
$oid_ssCpuRawNice = ".1.3.6.1.4.1.2021.11.51.0";
|
||||
$oid_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.52.0";
|
||||
$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";
|
||||
|
||||
$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 = $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";
|
||||
$cpu_cmd = $config['snmpget'] ." -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_ssCpuUser $oid_ssCpuSystem";
|
||||
$cpu = `$cpu_cmd`;
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem) = explode("\n", $cpu);
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $UsageUser, $UsageSystem) = explode("\n", $cpu);
|
||||
|
||||
$cpuUsage = $UsageUser + $UsageSystem;
|
||||
|
||||
@@ -136,21 +83,6 @@ rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
|
||||
|
||||
## If the device isn't monowall or pfsense, monitor all the pretty things
|
||||
if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSense" ) {
|
||||
if (!is_file($sysrrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $sysrrd \
|
||||
--step 300 \
|
||||
DS:users:GAUGE:600:0:U \
|
||||
DS:procs:GAUGE:600:0:U \
|
||||
RRA:AVERAGE:0.5:1:800 \
|
||||
RRA:AVERAGE:0.5:6:800 \
|
||||
RRA:AVERAGE:0.5:24:800 \
|
||||
RRA:AVERAGE:0.5:288:800 \
|
||||
RRA:MAX:0.5:1:800 \
|
||||
RRA:MAX:0.5:6:800 \
|
||||
RRA:MAX:0.5:24:800 \
|
||||
RRA:MAX:0.5:288:800");
|
||||
}
|
||||
|
||||
if (!is_file($memrrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $memrrd \
|
||||
--step 300 \
|
||||
@@ -199,8 +131,8 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
|
||||
$load_raw = `$load_cmd`;
|
||||
list ($load1, $load5, $load10) = explode ("\n", $load_raw);
|
||||
|
||||
rrdtool_update($sysrrd, "N:$users:$procs");
|
||||
rrdtool_update($loadrrd, "N:$load1:$load5:$load10");
|
||||
rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
|
||||
|
||||
} // end Non-m0n0wall
|
||||
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
<?php
|
||||
|
||||
if(strstr($sysDescr, "x86")) { $hardware = "Generic x86"; }
|
||||
if(strstr($sysDescr, "AMD64")) { $hardware = "Generic x64"; }
|
||||
if(strstr($sysDescr, "Windows Version 5.2")) { $version = "2003 Server"; }
|
||||
if(strstr($sysDescr, "Windows Version 6.1")) { $version = "Windows 7"; }
|
||||
if(strstr($sysDescr, "Uniprocessor Free")) { $features = "Uniprocessor"; }
|
||||
if(strstr($sysDescr, "Multiprocessor Free")) { $features = "Multiprocessor"; }
|
||||
|
||||
$hostname = $device['hostname'];
|
||||
$hardware = $device['hardware'];
|
||||
$version = $device['version'];
|
||||
$features = $device['features'];
|
||||
|
||||
$loadrrd = "rrd/" . $hostname . "-load.rrd";
|
||||
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
||||
$memrrd = "rrd/" . $hostname . "-mem.rrd";
|
||||
$sysrrd = "rrd/" . $hostname . "-sys.rrd";
|
||||
$loadrrd = $host_rrd . "/load.rrd";
|
||||
$cpurrd = $host_rrd . "/cpu.rrd";
|
||||
$memrrd = $host_rrd . "/mem.rrd";
|
||||
$sysrrd = $host_rrd . "/sys.rrd";
|
||||
|
||||
$oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0";
|
||||
$oid_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.51.0";
|
||||
@@ -22,9 +19,9 @@
|
||||
$oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.0";
|
||||
$oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0";
|
||||
|
||||
$s_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$s_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$s_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses $oid_hrSystemNumUsers";
|
||||
$s = `$s_cmd`;
|
||||
$s = shell_exec($s_cmd);
|
||||
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s);
|
||||
|
||||
if (!is_file($cpurrd)) {
|
||||
@@ -97,13 +94,13 @@
|
||||
}
|
||||
|
||||
$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`;
|
||||
$mem_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get;
|
||||
$mem_raw = shell_exec($mem_cmd);
|
||||
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $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_raw = `$load_cmd`;
|
||||
$load_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
|
||||
$load_raw = shell_exec($load_cmd);
|
||||
list ($load1, $load5, $load10) = explode ("\n", $load_raw);
|
||||
|
||||
rrdtool_update($sysrrd, "N:$users:$procs");
|
||||
|
||||
@@ -6,7 +6,6 @@ $config['ifdescr']['IOS XE'] = true;
|
||||
$config['ifname']['ASA'] = true;
|
||||
$config['ifname']['CatOS'] = true;
|
||||
|
||||
|
||||
## AFI / SAFI pairs for BGP (and other stuff, perhaps)
|
||||
$config['afi']['ipv4']['unicast'] = "IPv4";
|
||||
$config['afi']['ipv4']['multiicast'] = "IPv4 Multicast";
|
||||
@@ -14,6 +13,17 @@ $config['afi']['ipv4']['vpn'] = "VPNv4";
|
||||
$config['afi']['ipv6']['unicast'] = "IPv6";
|
||||
$config['afi']['ipv6']['multicast'] = "IPv6 Multicast";
|
||||
|
||||
## Set OS Groups
|
||||
|
||||
$os_groups['linux'] = "unix";
|
||||
$os_groups['freebsd'] = "unix";
|
||||
$os_groups['openbsd'] = "unix";
|
||||
$os_groups['netbsd'] = "unix";
|
||||
$os_groups['dragonfly'] = "unix";
|
||||
$os_groups['solaris'] = "unix";
|
||||
|
||||
$os_groups['ios xe'] = "ios";
|
||||
|
||||
if(!$config['graph_colours']['greens']) {
|
||||
$config['graph_colours']['greens'] = array('B6D14B','91B13C','6D912D','48721E','24520F','003300');
|
||||
}
|
||||
@@ -34,7 +44,7 @@ if(!$config['graph_colours']['default']) {
|
||||
# No changes below this line #
|
||||
##############################
|
||||
|
||||
$config['version'] = "0.6.0";
|
||||
$config['version'] = "0.7.0";
|
||||
|
||||
if($config['enable_nagios']) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user