From 795ac204005f642a0dcc3ce9ad1e90e14286828c Mon Sep 17 00:00:00 2001 From: netniV Date: Tue, 19 Dec 2017 11:02:43 +0000 Subject: [PATCH] v0.2.4b --- ...ph_template_cisco_-_sfp_statistics_dbm.xml | 311 ++++++++++++++++ cisco_sfp.xml | 80 ++-- ss_65xx_sfp.php | 352 ++++++++++-------- 3 files changed, 548 insertions(+), 195 deletions(-) create mode 100644 cacti_graph_template_cisco_-_sfp_statistics_dbm.xml diff --git a/cacti_graph_template_cisco_-_sfp_statistics_dbm.xml b/cacti_graph_template_cisco_-_sfp_statistics_dbm.xml new file mode 100644 index 0000000..07be3d2 --- /dev/null +++ b/cacti_graph_template_cisco_-_sfp_statistics_dbm.xml @@ -0,0 +1,311 @@ + + + Cisco - SFP statistics (dBm) + + + |host_description| - SFP |query_interface| - |query_descr| + + 1 + + 120 + + 600 + + on + + on + + 1 + + + + + + + + on + + on + + 10 + + -40 + + 1000 + + + + + + dBm + + + + hash_080021b77e19e466d292239d67fa5fd8f1b3f4 + 002A97 + FF + 4 + 4 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + OpticalTxPower + + 1 + + + hash_080021b77e19e466d292239d67fa5fd8f1b3f4 + 0 + FF + 9 + 4 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + Current: + + 2 + + + hash_080021b77e19e466d292239d67fa5fd8f1b3f4 + 0 + FF + 9 + 1 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + Average: + + 3 + + + hash_080021b77e19e466d292239d67fa5fd8f1b3f4 + 0 + FF + 9 + 3 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + Maximum: + on + 4 + + + hash_080021c02d990615e0e8544cbba54721826809 + 00CF00 + FF + 4 + 4 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + OpticalRxPower + + 5 + + + hash_080021c02d990615e0e8544cbba54721826809 + 0 + FF + 9 + 4 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + Current: + + 6 + + + hash_080021c02d990615e0e8544cbba54721826809 + 0 + FF + 9 + 1 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + Average: + + 7 + + + hash_080021c02d990615e0e8544cbba54721826809 + 0 + FF + 9 + 3 + 0 + + hash_0600216bf08fdd497f43bb9ba34743ad1bcc94 + Maximum: + on + 8 + + + + + Data Source [sfp_tx] + + task_item_id + hash_0000217007836117f60c437b1f5cb67cddbe05|hash_000021ddc646681bbcd109379c1a64bc2e7623|hash_000021b9c7b578859f5c9bca54bd20c56742a0|hash_0000218c02b28b31623e526186de01e63a3aee + + + Data Source [sfp_rx] + + task_item_id + hash_0000213356ab3f7c36a77cb085aa5e0557eff1|hash_0000213090191545315934ac6ff62ba2230f72|hash_0000217e6cbeecb942772d1f08ed674df58959|hash_000021e78def52d478d9e25295c13ce6b185b3 + + + + + Cisco 65xx - SFP statistics + + + |host_description| - SFP Statistics - |query_interface| + hash_030021332111d8b54ac8ce939af87a7eac0c06 + + + 300 + + on + hash_150021c21df5178e5c955013591239eb0afd46|hash_1500210d9c0af8b8acdc7807943937b3208e29|hash_1500216fc2d038fb42950138b0ce3e9874cc60|hash_150021e36f3adb9f152adfa5dc50fd2b23337e|hash_150021283ea2bf1634d92ce081ec82a634f513 + + + + + sfp_rx + + -40 + + 10 + + 1 + + 600 + + 0 + + + + sfp_tx + + -40 + + 10 + + 1 + + 600 + + 0 + + + + + hash_07002131112c85ae4ff821d3b288336288818c + + + + + hash_07002130fb5d5bcf3d66bb5abe88596f357c26 + + + + + hash_070021172b4b0eacee4948c6479f587b62e512 + + + + + + + Get Script Server Data (Indexed) + 6 + + + + Index Type + + + + index_type + in + index_type + + + Index Value + + + + index_value + in + index_value + + + Output Type ID + + + + output_type + in + output_type + + + Output Value + on + + + + out + output + + + + + Daily (5 Minute Average) + 0.5 + 1 + 600 + 86400 + 1|2|3|4 + + + Weekly (30 Minute Average) + 0.5 + 6 + 700 + 604800 + 1|2|3|4 + + + Monthly (2 Hour Average) + 0.5 + 24 + 775 + 2678400 + 1|2|3|4 + + + Yearly (1 Day Average) + 0.5 + 288 + 797 + 33053184 + 1|2|3|4 + + + Hourly (1 Minute Average) + 0.5 + 1 + 500 + 14400 + 1|2|3|4 + + + Optical Power + %2.1lf + + \ No newline at end of file diff --git a/cisco_sfp.xml b/cisco_sfp.xml index 2233525..9cf9ccd 100644 --- a/cisco_sfp.xml +++ b/cisco_sfp.xml @@ -1,42 +1,46 @@ - Get Cisco SFP Statistics - |path_cacti|/scripts/ss_65xx_sfp.php - php + Get Cisco SFP Statistics + Get Cisco SFP Statistics + |path_cacti|/scripts/ss_65xx_sfp.php ss_sfp - |host_hostname| |host_id| |host_snmp_version|:|host_snmp_port|:|host_snmp_timeout|:|host_ping_retries|:|host_max_oids|:|host_snmp_community|:|host_snmp_username|:|host_snmp_password|:|host_snmp_auth_protocol|:|host_snmp_priv_passphrase|:|host_snmp_priv_protocol|:|host_snmp_context| - index - query - get - device - alphabetic - |chosen_order_field| - : - - - Interface - input - index - - - Operational status - input - status - - - Interface Description - input - descr - - - SensorTXPower - output - tx - - - SensorRXPower - output - rx - + php + |host_hostname|:|host_id|:|host_snmp_version|:|host_snmp_port|:|host_snmp_timeout|:|host_ping_retries|:|host_max_oids|:|host_snmp_community|:|host_snmp_username|:|host_snmp_password|:|host_snmp_context|:|host_snmp_auth_protocol|:|host_snmp_priv_passphrase|:|host_snmp_priv_protocol| + index + query + get + : + sfpindex - + + + SFP Index + input + sfpindex + + + Operational status + input + status + + + Interface name + input + interface + + + Interface Description + input + descr + + + SensorTXPower + output + tx + + + SensorRXPower + output + rx + + diff --git a/ss_65xx_sfp.php b/ss_65xx_sfp.php index 7ea9914..537ec2c 100644 --- a/ss_65xx_sfp.php +++ b/ss_65xx_sfp.php @@ -14,21 +14,20 @@ | GNU General Public License for more details. | +-------------------------------------------------------------------------+ | name : ss_65xx_sfp.php | - | version : 0.2.2 | - | date : 20080429 | + | version : 0.3 | + | date : 20111103 | +-------------------------------------------------------------------------+ */ $no_http_headers = true; -error_reporting(E_ERROR); +error_reporting(0); +include_once(dirname(__FILE__) . "/../include/config.php"); +include_once(dirname(__FILE__) . "/../include/global.php"); include_once(dirname(__FILE__) . "/../lib/snmp.php"); if (!isset($called_by_script_server)) { - include_once(dirname(__FILE__) . "/../include/config.php"); - include_once(dirname(__FILE__) . "/../include/global.php"); array_shift($_SERVER["argv"]); print call_user_func_array("ss_sfp", $_SERVER["argv"]); - } # PortIndex - 1.3.6.1.2.1.47.1.1.1.1.2 @@ -41,13 +40,15 @@ # /usr/bin/php -q /usr/share/cacti/scripts/ss_65xx_sfp.php 192.168.1.11 public 2 get rx|tx TenGigabitEthernet1/1 # -function ss_sfp($hostname, $host_id, $snmp_auth, $cmd, $direction = "", $interface = "") { +function ss_sfp($snmp_auth, $cmd, $arg1 = "", $arg2 = "") { $snmp = explode(":", $snmp_auth); - $snmp_version = $snmp[0]; - $snmp_port = $snmp[1]; - $snmp_timeout = $snmp[2]; - $ping_retries = $snmp[3]; - $max_oids = $snmp[4]; + $hostname = $snmp[0]; + $host_id = $snmp[1]; + $snmp_version = $snmp[2]; + $snmp_port = $snmp[3]; + $snmp_timeout = $snmp[4]; + $ping_retries = $snmp[5]; + $max_oids = $snmp[6]; $snmp_auth_username = ""; $snmp_auth_password = ""; @@ -58,159 +59,196 @@ function ss_sfp($hostname, $host_id, $snmp_auth, $cmd, $direction = "", $interfa $snmp_community = ""; if ($snmp_version == 3) { - $snmp_auth_username = $snmp[6]; - $snmp_auth_password = $snmp[7]; - $snmp_auth_protocol = $snmp[8]; - $snmp_priv_passphrase = $snmp[9]; - $snmp_priv_protocol = $snmp[10]; - $snmp_context = $snmp[11]; + $snmp_auth_username = $snmp[8]; + $snmp_auth_password = $snmp[9]; + $snmp_auth_protocol = $snmp[11]; + $snmp_priv_passphrase = $snmp[12]; + $snmp_priv_protocol = $snmp[13]; + $snmp_context = $snmp[10]; } else { - $snmp_community = $snmp[5]; + $snmp_community = $snmp[7]; } - - - $result = ""; - $oid_name = ""; - $sensor_name = ""; - $sensor_status = ""; - $sensor_string = ""; - $status_string = ""; - $tx_status = 0; - $int = ""; - $snmp_retries = read_config_option("snmp_retries"); - $var = (cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.4.1.9.9.91.1.1.1.1.1", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); - - if ($cmd == "index" || $cmd == "query") { - for ($i=0;$i<(count($var));$i++) { - if ($var[$i]["value"] == "14") { // found a dBm entry - $sensor_name = (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.2.1.47.1.1.1.1.2.\\1', $var[$i]["oid"]), $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); - $sensor_status = (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.4.1.9.9.91.1.1.1.1.5.\\1', $var[$i]["oid"]), $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); - - - // Extract the Slot/Module/Port from "subslot 3/0 transceiver 8 Rx Power Sensor" - - if (preg_match_all("/subslot (\d+\/\d+) transceiver (\d+) .x Power Sensor/" - ,$sensor_name,$matches,PREG_PATTERN_ORDER)) { - - $modSlotPort = $matches[1][0].'/'.$matches[2][0]; - $oid_name[0] = ""; // Reset this to null - - // Test interface exists in the host_snmp_cache table - // Try to match Gig and Ten Gig combinations - - foreach (array('GigabitEthernet','TenGigabitEthernet') as $type) { - - $test_name = $type.$modSlotPort; - - if (db_fetch_cell( - "select snmp_index from host_snmp_cache - where host_id = '$host_id' and - field_value = '$test_name' and - field_name = 'ifDescr'")) { - - $oid_name[0] = $test_name; - } - } - } - else { - - preg_match("/[^\ ]+/", $sensor_name, $oid_name); // don't care about the rest of the string - + $result = ""; + $oid_name = ""; + $sensor_name = ""; + $sensor_status = ""; + $sensor_string = ""; + $tx_status_string = ""; + $rx_status_string = ""; + $tx_status = 0; + $int = ""; + $snmp_retries = read_config_option("snmp_retries"); + $var = cacti_snmp_walk($hostname, $snmp_community, ".1.3.6.1.4.1.9.9.91.1.1.1.1.1", $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, +$snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER); + + switch ($cmd) { + case "index": + // loop through $var + for ($i=0;$i<(count($var));$i++) { + + // find dBm entries + if ($var[$i]["value"] == "14") { + + // get interface name, will duplicate because of TX/RX both having dBm sensors (1st line = TX, 2nd = RX) + $index = preg_match('/.*\.[0-9]+\.[0-9]+\.([0-9]+)$/i', $var[$i]["oid"], $matches); + + // print it, but skip RX because of duplicates + print $matches[1]."\n"; + $i=$i+1; } - - - if ($cmd == "index") { - print $oid_name[0]."\n"; - } elseif ($cmd == "query") { - switch ($direction) { - case "index": - print $oid_name[0].":".$oid_name[0]."\n"; - $i=$i+1; // skip rx - break; - case "status": - if ($tx_status == 0) { - if ($sensor_status == 1) { - $status_string = "Online"; - } else { - $status_string = "Tx failure"; - } - $tx_status = 1; - } else { - if ($sensor_status != 1) { - if ($status_string == "Online") { - $status_string = "Rx failure"; - } else { - $status_string = $status_string . " Rx failure"; - } - } - } - $tx_status = 0; - print $oid_name[0].":".$status_string."\n"; - break; - case "descr": - $host_id = db_fetch_cell("select id from host where hostname = '$hostname'"); - $snmp_index = db_fetch_cell("select snmp_index from host_snmp_cache where host_id = '$host_id' and field_value = '$oid_name[0]' and field_name = 'ifDescr'"); - $alias = db_fetch_cell("select field_value from host_snmp_cache where snmp_index='$snmp_index' and host_id='$host_id' and field_name='ifAlias'"); + } + break; + case "query": + // loop through $var + for ($i=0;$i<(count($var));$i++) { + + // find dBm entries + if ($var[$i]["value"] == "14") { + + switch ($arg1) { + case "status": + $index = preg_match('/.*\.[0-9]+\.[0-9]+\.([0-9]+)$/i', $var[$i]["oid"], $matches); + //get interface status: 1 = ok, 2 = unavailable, 3 = nonoperational + $sensor_status = cacti_snmp_get($hostname, $snmp_community, '.1.3.6.1.4.1.9.9.91.1.1.1.1.5.' . $matches[1], $snmp_version, $snmp_auth_username, $snmp_auth_password, +$snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER); + + if ($tx_status == 0) { + if ($sensor_status == 1) { + $tx_status_string = "TX Online"; + $tx_status = 1; + } else { + $tx_status_string = "TX Failure"; + $tx_status = 1; + } + } else { + if ($sensor_status == 1) { + $rx_status_string = "RX Online"; + } else { + $rx_status_string = "RX Failure"; + } + $tx_status = 0; + } + if ($tx_status_string && $rx_status_string) { + print $matches[1]-1 . ":" . $tx_status_string . " / " . $rx_status_string . "\n"; + $i=$i+1; + $tx_status_string = ""; + $rx_status_string = ""; + } + break; + case "descr": + // get interface name, will duplicate because of TX/RX both having dBm sensors (1st line = TX, 2nd = RX) + $sensor_name = (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.2.1.47.1.1.1.1.2.\\1', $var[$i]["oid"]), $snmp_version, +$snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); + + // Extract the Slot/Module/Port from "subslot 3/0 transceiver 8 Rx Power Sensor" + if (preg_match_all("/subslot (\d+\/\d+) transceiver (\d+) .x Power Sensor/",$sensor_name,$matches,PREG_PATTERN_ORDER)) { + + $modSlotPort = $matches[1][0].'/'.$matches[2][0]; + $oid_name[0] = ""; // Reset this to null + + // Test interface exists in the host_snmp_cache table + // Try to match Gig and Ten Gig combinations + foreach (array('GigabitEthernet','TenGigabitEthernet') as $type) { + $test_name = $type.$modSlotPort; + + if (db_fetch_cell( + "select snmp_index from host_snmp_cache + where host_id = '$host_id' and + field_value = '$test_name' and + field_name = 'ifDescr'")) { + + $oid_name[0] = $test_name; + } + } + } + else { + preg_match("/[^\ ]+/", $sensor_name, $oid_name); // don't care about the rest of the string + } + + // get interface name, will duplicate because of TX/RX both having dBm sensors (1st line = TX, 2nd = RX) + $index = preg_match('/.*\.[0-9]+\.[0-9]+\.([0-9]+)$/i', $var[$i]["oid"], $matches); + + $host_id = db_fetch_cell("select id from host where hostname = '$hostname'"); + $snmp_index = db_fetch_cell("select snmp_index from host_snmp_cache where host_id = '$host_id' and field_value = '$oid_name[0]' and field_name = 'ifDescr'"); + $alias = db_fetch_cell("select field_value from host_snmp_cache where snmp_index='$snmp_index' and host_id='$host_id' and field_name='ifAlias'"); $alias = preg_replace("/:/","-",$alias); // Fix script server exploding args - print $oid_name[0] . ":" . $alias ."\n"; - $i=$i+1; // rx & tx description are the same - break; - } - } - } - } - } elseif ($cmd == "get") { - for ($i=0;$i<(count($var));$i++) { - if ($var[$i]["value"] == "14") { // found a dBm entry - - $sensor_name = (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.2.1.47.1.1.1.1.2.\\1', $var[$i]["oid"]), $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); - + + // print it, but skip RX because descriptions are the same + print $matches[1] . ":" . $alias . "\n"; + $i=$i+1; + break; + case "interface": + // get interface name, will duplicate because of TX/RX both having dBm sensors (1st line = TX, 2nd = RX) + $sensor_name = (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.2.1.47.1.1.1.1.2.\\1', $var[$i]["oid"]), $snmp_version, +$snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)); - // For some reason the TenGigabitEthernet transceivers on the SUP cards return results in 1/10th dB - // ..and the [Ten]GigabitEthernet interfaces on SPAs are rounded down to the nearest whole DB. - // Nice Cisco.. - - - $divisor = 1; // By default we devide by 1 - - // Reverse GigabitEthernetx\y\z into subslot x/y transceiver z Rx Power Sensor - - if (preg_match("/[Ten]?GigabitEthernet(\d+)\/(\d+)\/(\d+)$/", - $interface,$matches)) { - $suffix = $direction == "tx" ? "Tx Power Sensor" : "Rx Power Sensor"; - $int = "subslot ".$matches[1]."/".$matches[2]." transceiver ".$matches[3] ." $suffix"; - - } - elseif (preg_match("/TenGigabitEthernet\d+\/\d+$/",$interface)) { - - $divisor = 10; - - if ($direction == "tx") { - - $int=$interface." Transmit Power Sensor"; - + // Extract the Slot/Module/Port from "subslot 3/0 transceiver 8 Rx Power Sensor" + if (preg_match_all("/subslot (\d+\/\d+) transceiver (\d+) .x Power Sensor/",$sensor_name,$matches,PREG_PATTERN_ORDER)) { + + $modSlotPort = $matches[1][0].'/'.$matches[2][0]; + $oid_name[0] = ""; // Reset this to null + + // Test interface exists in the host_snmp_cache table + // Try to match Gig and Ten Gig combinations + foreach (array('GigabitEthernet','TenGigabitEthernet') as $type) { + $test_name = $type.$modSlotPort; + + if (db_fetch_cell( + "select snmp_index from host_snmp_cache + where host_id = '$host_id' and + field_value = '$test_name' and + field_name = 'ifDescr'")) { + + $oid_name[0] = $test_name; + } + } + } + else { + preg_match("/[^\ ]+/", $sensor_name, $oid_name); // don't care about the rest of the string + } + + // get interface name, will duplicate because of TX/RX both having dBm sensors (1st line = TX, 2nd = RX) + $index = preg_match('/.*\.[0-9]+\.[0-9]+\.([0-9]+)$/i', $var[$i]["oid"], $matches); - } elseif ($direction == "rx") { - $int=$interface." Receive Power Sensor"; - } + $host_id = db_fetch_cell("select id from host where hostname = '$hostname'"); + $snmp_index = db_fetch_cell("select snmp_index from host_snmp_cache where host_id = '$host_id' and field_value = '$oid_name[0]' and field_name = 'ifDescr'"); + $alias = db_fetch_cell("select field_value from host_snmp_cache where snmp_index='$snmp_index' and host_id='$host_id' and field_name='ifDescr'"); + $alias = preg_replace("/:/","-",$alias); // Fix script server exploding args + + // print it, but skip RX because descriptions are the same + print $matches[1] . ":" . $alias . "\n"; + $i=$i+1; + break; + case "sfpindex": + $index = preg_match('/.*\.[0-9]+\.[0-9]+\.([0-9]+)$/i', $var[$i]["oid"], $matches); + // print it, but skip RX + print $matches[1] . ":" . $matches[1] . "\n"; + $i=$i+1; + break; + } } - - preg_match("/[^\ ]+/", $sensor_name, $oid_name); - if (strstr($int, $sensor_name)) { - - - if (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.4.1.9.9.91.1.1.1.1.5.\\1', $var[$i]["oid"]), $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER) == "1") { - $result = (cacti_snmp_get($hostname, $snmp_community, ereg_replace('.*\.[0-9]+\.[0-9]+\.([0-9]+)$', '.1.3.6.1.4.1.9.9.91.1.1.1.1.4.\\1', $var[$i]["oid"]), $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER))/$divisor; - } else { - $result = "-40"; // lights are off - } - } - } - } - } - return trim($result); + } + break; + case "get": + if ($arg1 == "tx") { + $int=$arg2; + } elseif ($arg1 == "rx") { + $int=$arg2 + 1; + } + + if (cacti_snmp_get($hostname, $snmp_community, '.1.3.6.1.4.1.9.9.91.1.1.1.1.5.' . $int, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, $snmp_priv_passphrase, +$snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER) == "1") { + $result = cacti_snmp_get($hostname, $snmp_community, '.1.3.6.1.4.1.9.9.91.1.1.1.1.4.' . $int, $snmp_version, $snmp_auth_username, $snmp_auth_password, $snmp_auth_protocol, +$snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $ping_retries, $max_oids, SNMP_POLLER)/10; + } else { + // if not ok, send -40, symbolic for lights off + $result = "-40"; + } + + return trim($result); + break; + } } - ?>