From d2bec6d7d145b977e64fd59587047f6525cdc455 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 12 Apr 2012 23:56:45 +0000 Subject: [PATCH] juniper hardware detection through chassis mib, with fancy rewrite array - makes observium recognize srx650 git-svn-id: http://www.observium.org/svn/observer/trunk@3031 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/polling/os/junos.inc.php | 32 +------------- includes/polling/os/junose.inc.php | 6 --- includes/rewrites.php | 68 ++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 36 deletions(-) diff --git a/includes/polling/os/junos.inc.php b/includes/polling/os/junos.inc.php index 2b45de202b..3066e25af9 100644 --- a/includes/polling/os/junos.inc.php +++ b/includes/polling/os/junos.inc.php @@ -7,41 +7,13 @@ if (strpos($poll_device['sysDescr'], "olive")) $hardware = "Olive"; $serial = ""; } else { - $hardware = snmp_get($device, ".1.3.6.1.4.1.2636.3.1.2.0", "-OQv", "+JUNIPER-MIB", "+".$config['install_dir']."/mibs/junos"); + $hardware = snmp_get($device, "sysObjectID.0", "-Ovqs", "+Juniper-Products-MIB:JUNIPER-CHASSIS-DEFINES-MIB", $config['install_dir']."/mibs/junos"); + $hardware = "Juniper " . rewrite_junos_hardware($hardware); $serial = snmp_get($device, ".1.3.6.1.4.1.2636.3.1.3.0", "-OQv", "+JUNIPER-MIB", "+".$config['install_dir']."/mibs/junos"); - list(,$hardware,) = explode(" ", $hardware); - $hardware = "Juniper " . $hardware; } list($version) = explode("]", $jun_ver); list(,$version) = explode("[", $version); $features = ""; -$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/junos-cpu.rrd"; - -#$cpu_cmd = $config['snmpget'] . " -m JUNIPER-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; -#$cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0"; -#$cpu_usage = trim(shell_exec($cpu_cmd)); - -if (is_numeric($cpu_usage)) -{ - if (!is_file($cpurrd)) - { - rrdtool_create($cpurrd," --step 300 DS:LOAD:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200 RRA:AVERAGE:0.5:1:2000 \ - RRA:AVERAGE:0.5:6:2000 \ - RRA:AVERAGE:0.5:24:2000 \ - RRA:AVERAGE:0.5:288:2000 \ - 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:MIN:0.5:1:2000 \ - RRA:MIN:0.5:6:2000 \ - RRA:MIN:0.5:24:2000 \ - RRA:MIN:0.5:288:2000"); - } - echo("CPU: $cpu_usage%\n"); - rrdtool_update($cpurrd, " N:$cpu_usage"); -} - ?> \ No newline at end of file diff --git a/includes/polling/os/junose.inc.php b/includes/polling/os/junose.inc.php index 196382c216..f434cf02ab 100644 --- a/includes/polling/os/junose.inc.php +++ b/includes/polling/os/junose.inc.php @@ -19,10 +19,4 @@ list(,$version) = explode("(", $version); list($features) = explode("]", $junose_version); list(,$features) = explode("[", $features); -$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/junose-cpu.rrd"; - -#$cpu_cmd = $config['snmpget'] . " -m JUNIPER-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; -#$cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0"; -#$cpu_usage = trim(shell_exec($cpu_cmd)); - ?> \ No newline at end of file diff --git a/includes/rewrites.php b/includes/rewrites.php index 29dadbbcca..ac9014b6ab 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -132,6 +132,65 @@ $rewrite_junose_hardware = array( 'juniSsx1440' => 'SSX-1440', ); +$rewrite_junos_hardware = array( + 'jnxProductNameM40' => 'M40', + 'jnxProductNameM20' => 'M20', + 'jnxProductNameM160' => 'M160', + 'jnxProductNameM10' => 'M10', + 'jnxProductNameM5' => 'M5', + 'jnxProductNameT640' => 'T640', + 'jnxProductNameT320' => 'T320', + 'jnxProductNameM40e' => 'M40e', + 'jnxProductNameM320' => 'M320', + 'jnxProductNameM7i' => 'M7i', + 'jnxProductNameM10i' => 'M10i', + 'jnxProductNameJ2300' => 'J2300', + 'jnxProductNameJ4300' => 'J4300', + 'jnxProductNameJ6300' => 'J6300', + 'jnxProductNameIRM' => 'IRM', + 'jnxProductNameTX' => 'TX', + 'jnxProductNameM120' => 'M120', + 'jnxProductNameJ4350' => 'J4350', + 'jnxProductNameJ6350' => 'J6350', + 'jnxProductNameMX960' => 'MX960', + 'jnxProductNameJ4320' => 'J4320', + 'jnxProductNameJ2320' => 'J2320', + 'jnxProductNameJ2350' => 'J2350', + 'jnxProductNameMX480' => 'MX480', + 'jnxProductNameSRX5800' => 'SRX5800', + 'jnxProductNameT1600' => 'T1600', + 'jnxProductNameSRX5600' => 'SRX5600', + 'jnxProductNameMX240' => 'MX240', + 'jnxProductNameEX3200' => 'EX3200', + 'jnxProductNameEX4200' => 'EX4200', + 'jnxProductNameEX8208' => 'EX8208', + 'jnxProductNameEX8216' => 'EX8216', + 'jnxProductNameSRX3600' => 'SRX3600', + 'jnxProductNameSRX3400' => 'SRX3400', + 'jnxProductNameSRX210' => 'SRX210', + 'jnxProductNameTXP' => 'TXP', + 'jnxProductNameJCS' => 'JCS', + 'jnxProductNameSRX240' => 'SRX240', + 'jnxProductNameSRX650' => 'SRX650', + 'jnxProductNameSRX100' => 'SRX100', + 'jnxProductNameESR1000V' => 'ESR1000V', + 'jnxProductNameEX2200' => 'EX2200', + 'jnxProductNameEX4500' => 'EX4500', + 'jnxProductNameFXSeries' => 'FX Series', + 'jnxProductNameIBM4274M02J02M' => 'IBM4274M02J02M', # ? + 'jnxProductNameIBM4274M06J06M' => 'IBM4274M06J06M', # ? + 'jnxProductNameIBM4274M11J11M' => 'IBM4274M11J11M', # ? + 'jnxProductNameSRX1400' => 'SRX1400', + 'jnxProductNameIBM4274S58J58S' => 'IBM4274S58J58S', # ? + 'jnxProductNameIBM4274S56J56S' => 'IBM4274S56J56S', # ? + 'jnxProductNameIBM4274S36J36S' => 'IBM4274S36J36S', # ? + 'jnxProductNameIBM4274S34J34S' => 'IBM4274S34J34S', # ? + 'jnxProductNameIBM427348EJ48E' => 'IBM427348EJ48E', # ? + 'jnxProductNameIBM4274E08J08E' => 'IBM4274E08J08E', # ? + 'jnxProductNameIBM4274E16J16E' => 'IBM4274E16J16E', # ? + 'jnxProductNameMX80' => 'MX80', +); + $rewrite_cisco_hardware = array( '.1.3.6.1.4.1.9.1.275' => 'C2948G-L3', ); @@ -904,6 +963,15 @@ function rewrite_junose_hardware ($hardware) return ($hardware); } +function rewrite_junos_hardware ($hardware) +{ + global $rewrite_junos_hardware; + + $hardware = array_str_replace($rewrite_junos_hardware, $hardware); + + return ($hardware); +} + function fixiftype ($type) { global $rewrite_iftype;