mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
add missing files
git-svn-id: http://www.observium.org/svn/observer/trunk@504 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
34
html/includes/graphs/device_cpu_windows.inc.php
Normal file
34
html/includes/graphs/device_cpu_windows.inc.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
include("common.inc.php");
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . "cpu.rrd";
|
||||
|
||||
$rrd_options .= " DEF:user=$rrd_filename:user:AVERAGE";
|
||||
$rrd_options .= " DEF:nice=$rrd_filename:nice:AVERAGE";
|
||||
$rrd_options .= " DEF:system=$rrd_filename:system:AVERAGE";
|
||||
$rrd_options .= " DEF:idle=$rrd_filename:idle:AVERAGE";
|
||||
$rrd_options .= " CDEF:total=user,nice,system,idle,+,+,+";
|
||||
$rrd_options .= " CDEF:user_perc=user,total,/,100,*";
|
||||
$rrd_options .= " CDEF:nice_perc=nice,total,/,100,*";
|
||||
$rrd_options .= " CDEF:system_perc=system,total,/,100,*";
|
||||
$rrd_options .= " CDEF:idle_perc=idle,total,/,100,*";
|
||||
$rrd_options .= " COMMENT:Usage\ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ Maximum\\\\n";
|
||||
$rrd_options .= " AREA:user_perc#c02020:user";
|
||||
$rrd_options .= " GPRINT:user_perc:LAST:\ \ \ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:user_perc:AVERAGE:\ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:user_perc:MAX:\ \ \ %5.2lf%%\\\\n";
|
||||
$rrd_options .= " AREA:nice_perc#008f00:nice:STACK";
|
||||
$rrd_options .= " GPRINT:nice_perc:LAST:\ \ \ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:nice_perc:AVERAGE:\ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:nice_perc:MAX:\ \ \ %5.2lf%%\\\\n";
|
||||
$rrd_options .= " AREA:system_perc#ea8f00:system:STACK";
|
||||
$rrd_options .= " GPRINT:system_perc:LAST:\ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:system_perc:AVERAGE:\ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:system_perc:MAX:\ \ \ %5.2lf%%\\\\n";
|
||||
$rrd_options .= " AREA:idle_perc#f5f5e5:idle:STACK";
|
||||
$rrd_options .= " GPRINT:idle_perc:LAST:\ \ \ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%";
|
||||
$rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n";
|
||||
|
||||
?>
|
29
html/includes/graphs/device_load_windows.inc.php
Normal file
29
html/includes/graphs/device_load_windows.inc.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
include("common.inc.php");
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/load.rrd";
|
||||
|
||||
$rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE";
|
||||
$rrd_options .= " DEF:5min=$rrd_filename:5min:AVERAGE";
|
||||
$rrd_options .= " DEF:15min=$rrd_filename:15min:AVERAGE";
|
||||
$rrd_options .= " CDEF:a=1min,100,/";
|
||||
$rrd_options .= " CDEF:b=5min,100,/";
|
||||
$rrd_options .= " CDEF:c=15min,100,/";
|
||||
$rrd_options .= " CDEF:cdefd=a,b,c,+,+";
|
||||
$rrd_options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n";
|
||||
$rrd_options .= " AREA:a#ffeeaa:1\ Min:";
|
||||
$rrd_options .= " LINE1:a#c5aa00:";
|
||||
$rrd_options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf";
|
||||
$rrd_options .= " GPRINT:a:AVERAGE:\ \ %7.2lf";
|
||||
$rrd_options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n";
|
||||
$rrd_options .= " LINE1.25:b#ea8f00:5\ Min:";
|
||||
$rrd_options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf";
|
||||
$rrd_options .= " GPRINT:b:AVERAGE:\ \ %7.2lf";
|
||||
$rrd_options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n";
|
||||
$rrd_options .= " LINE1.25:c#cc0000:15\ Min";
|
||||
$rrd_options .= " GPRINT:c:LAST:\ \ \ %7.2lf";
|
||||
$rrd_options .= " GPRINT:c:AVERAGE:\ \ %7.2lf";
|
||||
$rrd_options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n";
|
||||
|
||||
?>
|
64
html/includes/graphs/device_memory_windows.inc.php
Normal file
64
html/includes/graphs/device_memory_windows.inc.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
include("common.inc.php");
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
|
||||
|
||||
$rrd_options .= " -b 1024";
|
||||
|
||||
$rrd_options .= " DEF:atotalswap=$rrd_filename:totalswap:AVERAGE";
|
||||
$rrd_options .= " DEF:aavailswap=$rrd_filename:availswap:AVERAGE";
|
||||
$rrd_options .= " DEF:atotalreal=$rrd_filename:totalreal:AVERAGE";
|
||||
$rrd_options .= " DEF:aavailreal=$rrd_filename:availreal:AVERAGE";
|
||||
$rrd_options .= " DEF:atotalfree=$rrd_filename:totalfree:AVERAGE";
|
||||
$rrd_options .= " DEF:ashared=$rrd_filename:shared:AVERAGE";
|
||||
$rrd_options .= " DEF:abuffered=$rrd_filename:buffered:AVERAGE";
|
||||
$rrd_options .= " DEF:acached=$rrd_filename:cached:AVERAGE";
|
||||
$rrd_options .= " CDEF:totalswap=atotalswap,1024,*";
|
||||
$rrd_options .= " CDEF:availswap=aavailswap,1024,*";
|
||||
$rrd_options .= " CDEF:totalreal=atotalreal,1024,*";
|
||||
$rrd_options .= " CDEF:availreal=aavailreal,1024,*";
|
||||
$rrd_options .= " CDEF:totalfree=atotalfree,1024,*";
|
||||
$rrd_options .= " CDEF:shared=ashared,1024,*";
|
||||
$rrd_options .= " CDEF:buffered=abuffered,1024,*";
|
||||
$rrd_options .= " CDEF:cached=acached,1024,*";
|
||||
$rrd_options .= " CDEF:usedreal=totalreal,availreal,-";
|
||||
$rrd_options .= " CDEF:usedswap=totalswap,availswap,-";
|
||||
$rrd_options .= " CDEF:cusedswap=usedswap,-1,*";
|
||||
$rrd_options .= " CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+";
|
||||
$rrd_options .= " COMMENT:'Bytes Current Average Maximum\\n'";
|
||||
$rrd_options .= " LINE1:usedreal#d0b080:";
|
||||
$rrd_options .= " AREA:usedreal#f0e0a0:used";
|
||||
$rrd_options .= " GPRINT:usedreal:LAST:\ \ \ %7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:usedreal:AVERAGE:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:usedreal:MAX:%7.2lf%sB\\\\n";
|
||||
$rrd_options .= " STACK:availreal#e5e5e5:free";
|
||||
$rrd_options .= " GPRINT:availreal:LAST:\ \ \ %7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:availreal:AVERAGE:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:availreal:MAX:%7.2lf%sB\\\\n";
|
||||
$rrd_options .= " LINE1:usedreal#d0b080:";
|
||||
$rrd_options .= " AREA:shared#afeced::";
|
||||
$rrd_options .= " AREA:buffered#cc0000::STACK";
|
||||
$rrd_options .= " AREA:cached#ffaa66::STACK";
|
||||
$rrd_options .= " LINE1.25:shared#008fea:shared";
|
||||
$rrd_options .= " GPRINT:shared:LAST:\ %7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:shared:AVERAGE:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:shared:MAX:%7.2lf%sB\\\\n";
|
||||
$rrd_options .= " LINE1.25:buffered#ff1a00:buffers:STACK";
|
||||
$rrd_options .= " GPRINT:buffered:LAST:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:buffered:AVERAGE:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:buffered:MAX:%7.2lf%sB\\\\n";
|
||||
$rrd_options .= " LINE1.25:cached#ea8f00:cached:STACK";
|
||||
$rrd_options .= " GPRINT:cached:LAST:\ %7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:cached:AVERAGE:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:cached:MAX:%7.2lf%sB\\\\n";
|
||||
$rrd_options .= " LINE1:totalreal#050505:";
|
||||
$rrd_options .= " AREA:cusedswap#C3D9FF:swap";
|
||||
$rrd_options .= " LINE1.25:cusedswap#356AA0:";
|
||||
$rrd_options .= " GPRINT:usedswap:LAST:\ \ \ %7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:usedswap:AVERAGE:%7.2lf%sB";
|
||||
$rrd_options .= " GPRINT:usedswap:MAX:%7.2lf%sB\\\\n";
|
||||
$rrd_options .= " LINE1:totalreal#050505:total";
|
||||
$rrd_options .= " GPRINT:totalreal:AVERAGE:\ \ %7.2lf%sB";
|
||||
|
||||
?>
|
5
html/php.php
Normal file
5
html/php.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
phpinfo();
|
||||
|
||||
?>
|
8
includes/osdiscovery/discover-windows.php
Normal file
8
includes/osdiscovery/discover-windows.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if(!$os) {
|
||||
if(preg_match("/Windows/", $sysDescr)) { $os = "Windows"; }
|
||||
}
|
||||
|
||||
?>
|
||||
|
36
includes/polling/hr-mib.inc.php
Executable file
36
includes/polling/hr-mib.inc.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/// HOST-RESOURCES-MIB
|
||||
// Generic System Statistics
|
||||
|
||||
$hrSystem_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/hrSystem.rrd";
|
||||
$hrSystem_cmd = $config['snmpget'] ." -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$hrSystem_cmd .= " hrSystemProcesses.0 hrSystemNumUsers.0 hrSystemUptime.0 hrMemorySize.0";
|
||||
$hrSystem = `$hrSystem_cmd`;
|
||||
list ($hrSystemProcesses, $hrSystemNumUsers, $hrSystemUptime, $hrMemorySize) = explode("\n", $hrSystem);
|
||||
|
||||
list($days, $hours, $mins, $secs) = explode(":", $hrSystemUptime);
|
||||
list($secs, $microsecs) = explode(".", $secs);
|
||||
$uptime = $secs + ($mins * 60) + ($hours * 60 * 60) + ($days * 24 * 60 * 60);
|
||||
|
||||
if (!is_file($hrSystem_rrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $hrSystem_rrd \
|
||||
--step 300 \
|
||||
DS:users:GAUGE:600:0:U \
|
||||
DS:procs:GAUGE:600:0:U \
|
||||
DS:uptime: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($hrSystem_rrd, "N:$hrSystemNumUsers:$hrSystemProcesses:$uptime");
|
||||
|
||||
include("hr-mib_storage.inc.php"); // Run HOST-RESOURCES-MIB Storage
|
||||
|
||||
?>
|
43
includes/polling/hr-mib_storage.inc.php
Executable file
43
includes/polling/hr-mib_storage.inc.php
Executable file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/// HOST-RESOURCES-MIB - Storage Objects
|
||||
|
||||
$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 = $config['snmpget'] . " -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageUsed.$hrStorageIndex";
|
||||
$used_units = trim(shell_exec($cmd));
|
||||
$used = $used_units * $hrStorageAllocationUnits;
|
||||
$perc = round($used / $hrStorageSize * 100, 2);
|
||||
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
||||
$old_storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
|
||||
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/hrStorage-" . $hrStorageIndex . ".rrd";
|
||||
if(is_file($old_storage_rrd)) { shell_exec("mv $old_storage_rrd $storage_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");
|
||||
}
|
||||
}
|
97
includes/polling/ucd-mib.inc.php
Executable file
97
includes/polling/ucd-mib.inc.php
Executable file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
$loadrrd = $host_rrd . "/ucd_load.rrd";
|
||||
$cpurrd = $host_rrd . "/ucd_cpu.rrd";
|
||||
$memrrd = $host_rrd . "/ucd_mem.rrd";
|
||||
|
||||
## 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_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 -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, $UsageUser, $UsageSystem) = explode("\n", $cpu);
|
||||
|
||||
$cpuUsage = $UsageUser + $UsageSystem;
|
||||
|
||||
## Create CPU RRD if it doesn't already exist
|
||||
if (!is_file($cpurrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $cpurrd \
|
||||
--step 300 \
|
||||
DS:user:COUNTER:600:0:U \
|
||||
DS:system:COUNTER:600:0:U \
|
||||
DS:nice:COUNTER:600:0:U \
|
||||
DS:idle:COUNTER: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($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($memrrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $memrrd \
|
||||
--step 300 \
|
||||
DS:totalswap:GAUGE:600:0:10000000000 \
|
||||
DS:availswap:GAUGE:600:0:10000000000 \
|
||||
DS:totalreal:GAUGE:600:0:10000000000 \
|
||||
DS:availreal:GAUGE:600:0:10000000000 \
|
||||
DS:totalfree:GAUGE:600:0:10000000000 \
|
||||
DS:shared:GAUGE:600:0:10000000000 \
|
||||
DS:buffered:GAUGE:600:0:10000000000 \
|
||||
DS:cached:GAUGE:600:0:10000000000 \
|
||||
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");
|
||||
} // end create mem rrd
|
||||
|
||||
if(!is_file($loadrrd)) {
|
||||
shell_exec($config['rrdtool'] . " create $loadrrd \
|
||||
--step 300 \
|
||||
DS:1min:GAUGE:600:0:5000 \
|
||||
DS:5min:GAUGE:600:0:5000 \
|
||||
DS:15min:GAUGE:600:0:5000 \
|
||||
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");
|
||||
} // end create load rrd
|
||||
|
||||
$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 -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);
|
||||
|
||||
rrdtool_update($loadrrd, "N:$load1:$load5:$load10");
|
||||
rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
|
||||
|
||||
} // end Non-m0n0wall
|
||||
|
@ -1,155 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
if($argv[1]) { $where = "WHERE `interface_id` = '$argv[1]'"; }
|
||||
|
||||
$interface_query = mysql_query("SELECT * FROM `interfaces` $where ORDER BY interface_id DESC");
|
||||
while ($interface = mysql_fetch_array($interface_query)) {
|
||||
|
||||
unset($this);
|
||||
|
||||
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE device_id = '" . $interface['device_id'] . "'"));
|
||||
if($device['status'] == '1') {
|
||||
|
||||
unset($update);
|
||||
unset($update_query);
|
||||
unset($seperator);
|
||||
|
||||
echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n");
|
||||
|
||||
$snmp_cmd = $config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifName." . $interface['ifIndex'];
|
||||
$snmp_cmd .= " ifDescr." . $interface['ifIndex'] . " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ";
|
||||
$snmp_cmd .= "ifAlias." . $interface['ifIndex'] . " ifSpeed." . $interface['ifIndex'];
|
||||
$snmp_cmd .= " ifType." . $interface['ifIndex'] . " ifMtu." . $interface['ifIndex'] . " ifPhysAddress." . $interface['ifIndex'];
|
||||
|
||||
$snmp_output = trim(`$snmp_cmd`);
|
||||
$snmp_output = str_replace("No Such Object available on this agent at this OID", "", $snmp_output);
|
||||
$snmp_output = str_replace("No Such Instance currently exists at this OID", "", $snmp_output);
|
||||
$snmp_output = str_replace("\"", "", $snmp_output);
|
||||
|
||||
if($device['os'] == "IOS") {
|
||||
|
||||
$snmp_cmdb = $config['snmpget'] . " -m CISCO-SMI:CISCO-VLAN-MEMBERSHIP-MIB:CISCO-VTP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_cmdb .= " .1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex'];
|
||||
$snmp_cmdb .= " .1.3.6.1.4.1.9.9.68.1.2.2.1.2." . $interface['ifIndex'];
|
||||
$snmp_cmdb .= " .1.3.6.1.4.1.9.9.46.1.6.1.1.16." . $interface['ifIndex'];
|
||||
|
||||
$snmp_outputb = trim(`$snmp_cmdb`);
|
||||
$snmp_outputb = str_replace("No Such Object available on this agent at this OID", "", $snmp_outputb);
|
||||
$snmp_outputb = str_replace("No Such Instance currently exists at this OID", "", $snmp_outputb);
|
||||
$snmp_outputb = str_replace("\"", "", $snmp_outputb);
|
||||
|
||||
list($this['ifHardType'], $this['ifVlan'], $this['ifTrunk']) = explode("\n", $snmp_outputb);
|
||||
if($this['ifTrunk'] == "notApplicable" || $this['ifTrunk'] == "6") { unset($this['ifTrunk']); }
|
||||
if($this['ifVlan'] == "") { unset($this['ifVlan']); }
|
||||
|
||||
if ( $interface['ifTrunk'] != $this['ifTrunk'] ) {
|
||||
$update .= $seperator . "`ifTrunk` = '" . $this['ifTrunk'] . "'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'VLAN Trunk -> " . $this['ifTrunk'] . "')");
|
||||
}
|
||||
|
||||
|
||||
if ( $interface['ifVlan'] != $this['ifVlan']) {
|
||||
$update .= $seperator . "`ifVlan` = '" . $this['ifVlan'] . "'";
|
||||
#echo($update);
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'VLAN Vlan -> " . $this['ifVlan'] . "')");
|
||||
}
|
||||
|
||||
if($this['ifTrunk']) { echo("Interface is a " . $this['ifTrunk'] . " trunk\n"); }
|
||||
if($this['ifVlan']) { echo("Interface is a member of vlan " . $this['ifVlan'] . " \n"); }
|
||||
|
||||
}
|
||||
|
||||
list($ifName, $ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifSpeed, $ifType, $ifMtu, $ifPhysAddress) = explode("\n", $snmp_output);
|
||||
$ifDescr = trim(str_replace("\"", "", $ifDescr));
|
||||
if ($ifDuplex == 3) { $ifDuplex = "half"; } elseif ($ifDuplex == 2) { $ifDuplex = "full"; } else { $ifDuplex = "unknown"; }
|
||||
$ifDescr = strtolower($ifDescr);
|
||||
if ($ifAlias == " ") { $ifAlias = str_replace(" ", "", $ifAlias); }
|
||||
$ifAlias = trim(str_replace("\"", "", $ifAlias));
|
||||
$ifAlias = trim($ifAlias);
|
||||
|
||||
#echo("\n$ifName\n");
|
||||
$ifDescr = fixifname($ifDescr);
|
||||
|
||||
$ifPhysAddress = strtolower(str_replace("\"", "", $ifPhysAddress));
|
||||
$ifPhysAddress = str_replace(" ", ":", $ifPhysAddress);
|
||||
|
||||
# if ( $interface['ifDescr'] != $ifDescr && $ifDescr != "" ) {
|
||||
# $update .= $seperator . "`ifDescr` = '$ifDescr'";
|
||||
# $seperator = ", ";
|
||||
# mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Name -> " . $ifDescr . "')");
|
||||
# }
|
||||
# if ( $interface['ifAlias'] != $ifAlias ) {
|
||||
# $update .= $seperator . "`ifAlias` = '$ifAlias'";
|
||||
# $seperator = ", ";
|
||||
# mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Desc -> $ifAlias')");
|
||||
# }
|
||||
|
||||
# if ( $interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) {
|
||||
# $update .= $seperator . "`ifOperStatus` = '$ifOperStatus'";
|
||||
# $seperator = ", ";
|
||||
# mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface went $ifOperStatus')");
|
||||
# }
|
||||
# if ( $interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) {
|
||||
# $update .= $seperator . "`ifAdminStatus` = '$ifAdminStatus'";
|
||||
# $seperator = ", ";
|
||||
# if($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; }
|
||||
# mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface $admin')");
|
||||
# }
|
||||
|
||||
if ( $interface['ifDuplex'] != $ifDuplex && $ifDuplex != "" ) {
|
||||
$update .= $seperator . "`ifDuplex` = '$ifDuplex'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Duplex -> $ifDuplex')");
|
||||
}
|
||||
if ( $interface['ifType'] != $ifType && $ifType != "" ) {
|
||||
$update .= $seperator . "`ifType` = '$ifType'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Type -> $ifType')");
|
||||
}
|
||||
if ( $interface['ifMtu'] != $ifMtu && $ifMtu != "" ) {
|
||||
$update .= $seperator . "`ifMtu` = '$ifMtu'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'MTU -> $ifMtu')");
|
||||
}
|
||||
if ( $interface['ifPhysAddress'] != $ifPhysAddress && $ifPhysAddress != "" ) {
|
||||
$update .= $seperator . "`ifPhysAddress` = '$ifPhysAddress'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'MAC -> $ifPhysAddress')");
|
||||
}
|
||||
|
||||
if ( $interface['ifHardType'] != $this['ifHardType']) {
|
||||
$update .= $seperator . "`ifHardType` = '" . $this['ifHardType'] . "'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" .$interface['interface_id'] . "', NOW(), 'HW Type -> " . $this['ifHardType']. "')");
|
||||
}
|
||||
|
||||
|
||||
if ( $interface['ifSpeed'] != $ifSpeed && $ifSpeed != "" ) {
|
||||
$update .= $seperator . "`ifSpeed` = '$ifSpeed'";
|
||||
$seperator = ", ";
|
||||
$prev = humanspeed($interface['ifSpeed']);
|
||||
$now = humanspeed($ifSpeed);
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Speed -> $now')");
|
||||
}
|
||||
|
||||
if ($update) {
|
||||
$update_query = "UPDATE `interfaces` SET ";
|
||||
$update_query .= $update;
|
||||
$update_query .= " WHERE `interface_id` = '" . $interface['interface_id'] . "'";
|
||||
$update_result = mysql_query($update_query);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mysql_query("UPDATE interfaces set ifPhysAddress = '' WHERE ifPhysAddress = 'No Such Instance currently exists at this OID'");
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user