function Get($ip, $ver, $cm, $oid, $t = 1000000, $r = 2) { global $debug, $comms; if ($ver == 3 and $comms[$cm]['pprot']) { if ($debug) { echo "<div class=\"textpad noti \">snmpget -v3 -c{$cm} " . $comms[$cm]['aprot'] . "/" . $comms[$cm]['pprot'] . " {$ip} {$oid} ({$t} usec * {$r})</div>"; } return snmp3_get($ip, $cm, 'authPriv', $comms[$cm]['aprot'], $comms[$cm]['apass'], $comms[$cm]['pprot'], $comms[$cm]['ppass'], ".{$oid}", $t, $r); } elseif ($ver == 3 and $comms[$cm]['aprot']) { if ($debug) { echo "<div class=\"textpad noti \">snmpget -v3 -c{$cm} " . $comms[$cm]['aprot'] . " {$ip} {$oid} ({$t} usec * {$r})</div>"; } return snmp3_get($ip, $cm, 'authNoPriv', $comms[$cm]['aprot'], $comms[$cm]['apass'], 'DES', '', ".{$oid}", $t, $r); } elseif ($ver == 2) { if ($debug) { echo "<div class=\"textpad noti \">snmpget -v2c -c{$cm} {$ip} {$oid} ({$t} usec * {$r})</div>"; } return snmp2_get($ip, $cm, ".{$oid}", $t, $r); } else { if ($debug) { echo "<div class=\"textpad noti \">snmpget -v1 -c{$cm} {$ip} {$oid} ({$t} usec * {$r})</div>"; } return snmpget($ip, $cm, ".{$oid}", $t, $r); } }
function cacti_snmp_get($hostname, $community, $oid, $version, $username, $password, $port = 161, $timeout = 500, $retries = 0, $environ = SNMP_POLLER) { global $config; /* determine default retries */ if ($retries == 0 || !is_numeric($retries)) { $retries = read_config_option("snmp_retries"); if ($retries == "") { $retries = 3; } } /* do not attempt to poll invalid combinations */ if ($version == 0 || $community == "" && $version != 3) { return "U"; } if (snmp_get_method($version) == SNMP_METHOD_PHP) { /* make sure snmp* is verbose so we can see what types of data we are getting back */ snmp_set_quick_print(0); if ($version == "1") { $snmp_value = @snmpget("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries); } elseif ($version == "2") { $snmp_value = @snmp2_get("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries); } else { $snmp_value = @snmp3_get("{$hostname}:{$port}", $username, "authNoPriv", "MD5", $password, "", "", $oid, $timeout * 1000, $retries); } } else { /* ucd/net snmp want the timeout in seconds */ $timeout = ceil($timeout / 1000); if ($version == "1") { $snmp_auth = read_config_option("snmp_version") == "ucd-snmp" ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ } elseif ($version == "2") { $snmp_auth = read_config_option("snmp_version") == "ucd-snmp" ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ $version = "2c"; /* ucd/net snmp prefers this over '2' */ } elseif ($version == "3") { $snmp_auth = "-u {$username} -l authNoPriv -a MD5 -A {$password}"; /* v3 - username/password */ } /* no valid snmp version has been set, get out */ if (empty($snmp_auth)) { return; } if (read_config_option("snmp_version") == "ucd-snmp") { exec(read_config_option("path_snmpget") . " -O vt -v{$version} -t {$timeout} -r {$retries} {$hostname}:{$port} {$snmp_auth} {$oid}", $snmp_value); } else { exec(read_config_option("path_snmpget") . " -O fntev {$snmp_auth} -v {$version} -t {$timeout} -r {$retries} {$hostname}:{$port} {$oid}", $snmp_value); } } if (isset($snmp_value)) { /* fix for multi-line snmp output */ if (is_array($snmp_value)) { $snmp_value = implode(" ", $snmp_value); } } /* strip out non-snmp data */ $snmp_value = format_snmp_string($snmp_value); return $snmp_value; }
function get($oid) { if ($this->version == "1") { $snmp_result = snmpget($this->ip, $this->community, $oid); } else { if ($this->version == "2c") { $snmp_result = snmp2_get($this->ip, $this->community, $oid); } } $result = $this->clear_snmp_string($snmp_result); return $result; }
function cacti_snmp_get($hostname, $community, $oid, $version, $username, $password, $port = 161, $timeout = 500, $environ = SNMP_POLLER) { global $config; /* determine default retries */ $retries = read_config_option("snmp_retries"); if ($retries == "") $retries = 3; if (snmp_get_method($version) == SNMP_METHOD_PHP) { /* make sure snmp* is verbose so we can see what types of data we are getting back */ snmp_set_quick_print(0); if ($version == "1") { $snmp_value = @snmpget("$hostname:$port", $community, $oid, ($timeout * 1000), $retries); }else { $snmp_value = @snmp2_get("$hostname:$port", $community, $oid, ($timeout * 1000), $retries); } }else { /* ucd/net snmp want the timeout in seconds */ $timeout = ceil($timeout / 1000); if ($version == "1") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ }elseif ($version == "2") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ $version = "2c"; /* ucd/net snmp prefers this over '2' */ }elseif ($version == "3") { $snmp_auth = "-u $username -l authPriv -a MD5 -A $password -x DES -X $password"; /* v3 - username/password */ } /* no valid snmp version has been set, get out */ if (empty($snmp_auth)) { return; } if (read_config_option("snmp_version") == "ucd-snmp") { exec(read_config_option("path_snmpget") . " -O vt -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $oid", $snmp_value); }else { exec(read_config_option("path_snmpget") . " -O fntUev $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid", $snmp_value); } } if (isset($snmp_value)) { /* fix for multi-line snmp output */ if (is_array($snmp_value)) { $snmp_value = implode(" ", $snmp_value); } } /* strip out non-snmp data */ $snmp_value = format_snmp_string($snmp_value); return $snmp_value; }
function rf2_conf2_read() { global $frequency2, $acquisitionBandwidth2, $symbolRate2, $goldCode2, $isi2, $lnbPower2, $signal22KHz2, $compensation2, $profileName2; global $oid, $device_IP; $profileName2 = substr(snmp2_get($device_IP, "public", $oid['profileName4']), 9); $frequency2 = substr(snmp2_get($device_IP, "public", $oid['frequency4']), 9) / 1000; $acquisitionBandwidth2 = substr(snmp2_get($device_IP, "public", $oid['acquisitionBandwidth4']), 9) / 1000; $symbolRate2 = substr(snmp2_get($device_IP, "public", $oid['symbolRate4']), 9) / 1000; $goldCode2 = substr(snmp2_get($device_IP, "public", $oid['goldCode4']), 9); $isi2 = substr(snmp2_get($device_IP, "public", $oid['isi4']), 9); $lnbPower2 = substr(snmp2_get($device_IP, "public", $oid['lnbPower4']), 9); $signal22KHz2 = substr(snmp2_get($device_IP, "public", $oid['signal22KHz4']), 9); $compensation2 = substr(snmp2_get($device_IP, "public", $oid['compensation4']), 9); }
function asi_read() { global $egrAsiEnabled, $egrAsiDstIpAddress, $egrAsiDstEthAddress, $egrAsiDstUdpPort, $egrAsiDscp, $egrAsiSrcIpAddress, $egrAsiSrcEthAddress, $egrAsiSrcUdpPort, $egrAsiTSoIPContainerSize, $egrAsiPcrAwareness, $egrAsiMaxTimeout; global $oid, $device_IP; $egrAsiEnabled = substr(snmp2_get($device_IP, "public", $oid['egrAsiEnabled']), 9); $egrAsiDstIpAddress = substr(snmp2_get($device_IP, "public", $oid['egrAsiDstIpAddress']), 11); $egrAsiDstEthAddress = substr(snmp2_get($device_IP, "public", $oid['egrAsiDstEthAddress']), 11); $egrAsiDstUdpPort = substr(snmp2_get($device_IP, "public", $oid['egrAsiDstUdpPort']), 9); $egrAsiDscp = substr(snmp2_get($device_IP, "public", $oid['egrAsiDscp']), 9); $egrAsiSrcIpAddress = substr(snmp2_get($device_IP, "public", $oid['egrAsiSrcIpAddress']), 11); $egrAsiSrcEthAddress = substr(snmp2_get($device_IP, "public", $oid['egrAsiSrcEthAddress']), 11); $egrAsiSrcUdpPort = substr(snmp2_get($device_IP, "public", $oid['egrAsiSrcUdpPort']), 11); $egrAsiTSoIPContainerSize = substr(snmp2_get($device_IP, "public", $oid['egrAsiTSoIPContainerSize']), 9); $egrAsiPcrAwareness = substr(snmp2_get($device_IP, "public", $oid['egrAsiPcrAwareness']), 9); $egrAsiMaxTimeout = substr(snmp2_get($device_IP, "public", $oid['egrAsiMaxTimeout']), 9); }
static function get($host, $object_id, $cache_ttl = null) { if ($cache_ttl) { $cache_var = str_replace('.', '_', $host->ip . $object_id); $cache = new CacheAPC(); $resultCache = $cache->load($cache_var); if ($resultCache !== null) { return $resultCache; } } snmp_set_oid_output_format(self::$oid_format); $snmp = $host->snmpTemplate; if ($snmp instanceof SnmpTemplate) { switch ($snmp->version) { case "1": $result = @snmpget($host->ip, $snmp->community, $object_id, $snmp->timeout, $snmp->retries); break; case "2": case "2c": $result = @snmp2_get($host->ip, $snmp->community, $object_id, $snmp->timeout, $snmp->retries); break; case "3": $result = @snmp3_get($host->ip, $snmp->security_name, $snmp->security_level, $snmp->auth_protocol, $snmp->auth_passphrase, $snmp->priv_protocol, $snmp->priv_passphrase, $object_id, $snmp->timeout, $snmp->retries); break; default: throw new Exception('SNMP Template not implemented yet'); } } if ($result) { // retira 'STRING: ' do inicio do texto $result = trim(preg_replace('/^[^:]+: ?/', '', $result)); if ($cache_var && $cache_ttl) { $cache->save($cache_var, $result, $cache_ttl); } return $result; } else { //throw new Exception("Sem resposta SNMP"); return null; } }
function cacti_snmp_get($hostname, $community, $oid, $version, $v3username, $v3password, $v3authproto = "", $v3privpassphrase = "", $v3privproto = "", $port = 161, $timeout = 500, $environ = SNMP_POLLER) { /* determine default retries */ $retries = read_config_option("snmp_retries"); if ($retries == "") $retries = 3; /* do not attempt to poll invalid combinations */ if (($version == 0) || (($community == "") && ($version != 3))) { return "U"; } /* get rid of quotes in privacy passphrase */ $v3privpassphrase = str_replace("#space#", " ", $v3privpassphrase); if ($v3privproto == "[None]") { $v3privproto = ""; } if (snmp_get_method($version) == SNMP_METHOD_PHP) { /* make sure snmp* is verbose so we can see what types of data we are getting back */ snmp_set_quick_print(0); if ($version == "1") { $snmp_value = @snmpget("$hostname:$port", $community, trim($oid), ($timeout * 1000), $retries); }elseif ($version == "2") { $snmp_value = @snmp2_get("$hostname:$port", $community, $oid, ($timeout * 1000), $retries); }else{ $snmp_value = @snmp3_get("$hostname:$port", $v3username, snmp_get_v3authpriv($v3privproto), $v3authproto, $v3password, $v3privproto, $v3privpassphrase, trim($oid), ($timeout * 1000), $retries); } }else{ /* ucd/net snmp want the timeout in seconds */ $timeout = ceil($timeout / 1000); if ($version == "1") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ }elseif ($version == "2") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER : "-c " . SNMP_ESCAPE_CHARACTER . $community . SNMP_ESCAPE_CHARACTER; /* v1/v2 - community string */ $version = "2c"; /* ucd/net snmp prefers this over '2' */ }elseif ($version == "3") { $snmp_auth = "-u $v3username -A $v3password -a $v3authproto -X $v3privpassphrase -x $v3privproto -l " . snmp_get_v3authpriv($v3privproto); /* v3 - username/password/etc... */ } /* no valid snmp version has been set, get out */ if (empty($snmp_auth)) { return; } if (read_config_option("snmp_version") == "ucd-snmp") { exec(read_config_option("path_snmpget") . " -O vt -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $oid", $snmp_value); }else { exec(read_config_option("path_snmpget") . " -O fntev $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid", $snmp_value); } } if (isset($snmp_value)) { /* fix for multi-line snmp output */ if (is_array($snmp_value)) { $snmp_value = implode(" ", $snmp_value); } } /* strip out non-snmp data */ $snmp_value = format_snmp_string($snmp_value); return $snmp_value; }
$frequency3 = substr(snmp2_get($device_IP, "public", $oid['frequency3']), 9) / 1000; $esno2 = substr(snmp2_get($device_IP, "public", $oid['esno2']), 9) / 10; $powerLevel2 = substr(snmp2_get($device_IP, "public", $oid['powerLevel2']), 9) / 10; $ber2 = substr(snmp2_get($device_IP, "public", $oid['ber2']), 9); $frequencyOffset2 = substr(snmp2_get($device_IP, "public", $oid['frequencyOffset2']), 9) / 1000; $badPacketCount2 = substr(snmp2_get($device_IP, "public", $oid['badPacketCount2']), 9); $modcodStatus2 = substr(snmp2_get($device_IP, "public", $oid['modcodStatus2']), 9); $rollOffStatus2 = substr(snmp2_get($device_IP, "public", $oid['rollOffStatus2']), 9); $pilotsStatus2 = substr(snmp2_get($device_IP, "public", $oid['pilotsStatus2']), 9); $rx2CfgSet1Status = substr(snmp2_get($device_IP, "public", $oid['rx2CfgSet1Status']), 9); $rx2CfgSet2Status = substr(snmp2_get($device_IP, "public", $oid['rx2CfgSet2Status']), 9); if ($rx2CfgSet1Status == 0) { $rx2ActiveProfile = '"' . substr(snmp2_get($device_IP, "public", $oid['profileName3']), 9); } if ($rx2CfgSet2Status == 0) { $rx2ActiveProfile = '"' . substr(snmp2_get($device_IP, "public", $oid['profileName4']), 9); } } } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>-->
$_SESSION['device_IP_st'] = $device_IP; $_SESSION['read_st'] = "read"; // Board Information $hardwareVersion = substr(snmp2_get($device_IP, "public", $oid['hardwareVersion']), 9); $fpgaVersion = substr(snmp2_get($device_IP, "public", $oid['fpgaVersion']), 9); $softwareVersion = substr(snmp2_get($device_IP, "public", $oid['softwareVersion']), 9); $serialNumber = substr(snmp2_get($device_IP, "public", $oid['serialNumber']), 9); // system info include_once 'info_function.php'; // $txPowerStateStatus = substr(snmp2_get($device_IP, "public", $oid['txPowerStateStatus']), 9); $txFrequencyStatus = substr(snmp2_get($device_IP, "public", $oid['txFrequencyStatus']), 9) / 1000; $modInputBitrateStatus = substr(snmp2_get($device_IP, "public", $oid['modInputBitrateStatus']), 9) / 1000; $modOutputBitrateStatus = substr(snmp2_get($device_IP, "public", $oid['modOutputBitrateStatus']), 9) / 1000; $modModcodStatus = substr(snmp2_get($device_IP, "public", $oid['modModcodStatus']), 9); $modRolloffStatus = substr(snmp2_get($device_IP, "public", $oid['modRolloffStatus']), 9); } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>--> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> <style type="text/css"> body {
function get_snmp($details) { $CI =& get_instance(); if (!isset($details->system_id) or $details->system_id == '') { $details->snmp_community = 'public'; $details->snmp_version = '2c'; $details->snmp_port = '161'; } else { $encrypted_access_details = $CI->m_system->get_access_details($details->system_id); if ($encrypted_access_details == '') { } $decoded_access_details = $CI->encrypt->decode($encrypted_access_details); $decoded_access_details = json_decode($decoded_access_details); $details->snmp_community = @$decoded_access_details->snmp_community; $details->snmp_version = @$decoded_access_details->snmp_version; $details->snmp_port = @$decoded_access_details->snmp_port; $details->man_ip_address = @$decoded_access_details->ip_address; } if (!isset($details->snmp_community) or $details->snmp_community == '') { $details->snmp_community = 'public'; } if (!isset($details->snmp_version) or $details->snmp_version == '') { $details->snmp_version = ''; } if (!isset($details->snmp_port) or $details->snmp_port == '') { $details->snmp_port = '161'; } # we may only have been given a system_id # but if the access_details were completed, that may be enough # if they weren't, we would at least need a hostname ot ip address if (!isset($details->man_ip_address) and !isset($details->hostname)) { return; } $module = new stdclass(); if ((!isset($details->hostname) or $details->hostname == '') and (isset($details->man_ip_address) and $details->man_ip_address != '' and $details->man_ip_address != '000.000.000.000' and $details->man_ip_address != '0.0.0.0')) { $details->hostname = gethostbyaddr(ip_address_from_db($details->man_ip_address)); } if ((!isset($details->man_ip_address) or $details->man_ip_address == '' or $details->man_ip_address == '0.0.0.0' or $details->man_ip_address == '000.000.000.000') and (isset($details->hostname) and $details->hostname != '')) { $details->man_ip_address = gethostbyname($details->hostname); } if (filter_var($details->hostname, FILTER_VALIDATE_IP)) { # we did not get a valid hostname back :-( } else { # we have a name of some sort if (strpos($details->hostname, ".") !== FALSE) { # fqdn - explode it if (!isset($details->fqdn) or $details->fqdn == '') { $details->fqdn = $details->hostname; } $i = explode(".", $details->hostname); $details->hostname = $i[0]; if (!isset($details->domain) or $details->domain == '') { unset($i[0]); $details->domain = implode(".", $i); } } else { # it's just a name } } $timeout = '300000'; $retries = '2'; if (!extension_loaded('snmp')) { return $details; } # test for SNMP version # to do - test for v3 if ($details->snmp_version == '') { if ($test_v1 = @snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.5.0", $timeout)) { # ok, we have v1 $details->snmp_version = '1'; } if ($test_v2 = @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.5.0", $timeout)) { # ok, we have v2 $details->snmp_version = '2c'; } } if ($details->snmp_version == '2c') { snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC); // test for connectivity $test_connect = @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.5.0", $timeout, $retries); if ($test_connect) { // printer duplex $details->printer_duplex = ''; $i = @snmp2_walk($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.43.13.4.1.10.1"); if (count($i) > 0) { $details->printer_duplex = 'False'; for ($k = 0; $k < count($i); $k++) { if (mb_strpos($i[$k], "Duplex") !== FALSE) { $details->printer_duplex = 'True'; } } } // sysObjectID #$i = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.1.0" )); $details->snmp_oid = str_replace("OID: .", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.2.0")); if (strtolower($details->snmp_oid) == 'no such object available on this agent at this oid') { $details->snmp_oid = ''; } if ($details->snmp_oid > '') { $oid = get_oid($details->snmp_oid); $details->manufacturer = $oid->manufacturer; $details->man_manufacturer = $oid->manufacturer; $details->model = $oid->model; $details->man_model = $oid->model; $details->type = $oid->type; $details->device_type = $oid->type; $details->man_type = $oid->type; $details->os_group = $oid->os_group; $details->man_os_group = $oid->os_group; } if ($details->snmp_oid == '1.3.6.1.4.1.8072.3.2.255') { # a generic OID - take some guesses... $i = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.1.0")); if (strpos($i, "Darwin Kernel Version 12") !== FALSE) { # looks like an OSX device $details->manufacturer = "Apple Inc"; } } if ($details->snmp_oid == '1.3.6.1.4.1.6876.4.1') { # grab some specific details for VMware ESX $model = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.6876.1.1.0")); $version = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.6876.1.2.0")); $details->model = $model . " (" . $version . ")"; $details->model = str_replace("\"", "", $details->model); $details->man_model = $details->model; $details->os_group = "VMware"; $details->man_os_group = "VMware"; $details->os_family = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.6876.1.1.0")); $details->os_family = str_replace("\"", "", $details->os_family); $details->man_os_family = $details->os_family; $details->os_name = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.1.0")); $details->os_name = str_replace("\"", "", $details->os_name); $details->man_os_name = $details->os_name; $details->type = 'computer'; $details->man_type = 'computer'; $details->device_type = 'computer'; $details->man_class = 'hypervisor'; } if (substr($details->snmp_oid, 0, 13) == '1.3.6.1.4.1.9') { # grab some Cisco specific details $i = explode("\$", @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.9.9.25.1.1.1.2.5")); $details->os_version = trim($i[1]); $i = @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.9.9.25.1.1.1.2.7"); if (strpos($i, "IOS") !== FALSE) { $details->os_group = 'Cisco'; $details->man_os_group = 'Cisco'; $details->os_family = 'Cisco IOS'; $details->man_os_family = 'Cisco IOS'; $details->os_name = "Cisco IOS version " . $details->os_version; $details->man_os_name = "Cisco IOS version " . $details->os_version; } if (strpos($i, "Catalyst Operating") !== FALSE) { $details->os_group = 'Cisco'; $details->man_os_group = 'Cisco'; $details->os_family = 'Cisco Catalyst OS'; $details->man_os_family = 'Cisco Catalyst OS'; $detail->os_name = "Cisco Catalyst OS version " . $details->os_version; $detail->man_os_name = "Cisco Catalyst OS version " . $details->os_version; } } // manufacturer if (!isset($details->manufacturer) or $details->manufacturer == '') { $hex = @snmp2_walk($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.43.8.2.1.14.1"); if (count($hex) > 0) { if (isset($hex[1])) { if (mb_strpos($hex[1], "Hex-STRING: ") !== FALSE) { $hex[1] = str_replace("Hex-STRING: ", "", $hex[1]); for ($i = 0; $i < strlen($hex[1]); $i++) { $details->manufacturer .= chr(hexdec(substr($hex[1], $i, 2))); } } else { $details->manufacturer = str_replace("STRING: ", "", $hex[1]); $details->manufacturer = str_replace('"', '', $details->manufacturer); } } } if ($details->manufacturer == '' or $details->manufacturer == 'No Such Object available on this agent at this OID') { $details->manufacturer = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.47.1.1.1.1.12.1"))); } } if ($details->manufacturer == 'No Such Instance currently exists at this OID') { $details->manufacturer = ''; } if ($details->manufacturer == 'No Such Object available on this agent at this OID') { $details->manufacturer = ''; } // serial if (!isset($details->serial) or $details->serial == '') { # generic snmp $details->serial = str_replace('"', '', str_replace("STRING: ", "", @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.43.5.1.1.17.1"))); if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Object available on this agent at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } # Generic Cisco if ($details->serial == '') { $details->serial = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.47.1.1.1.1.11.1"))); if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Object available on this agent at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } } # Cisco 37xx stack if ($details->serial == '') { $details->serial = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.9.5.1.2.19.0"))); if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Object available on this agent at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } } # remove false if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Object available on this agent at this OID') { $details->serial = ''; } if ($details->serial == 'No Such Instance currently exists at this OID') { $details->serial = ''; } } $details->man_serial = $details->serial; // mac address if (!isset($details->mac_address) or $details->mac_address == '') { $interface_number = @str_replace("INTEGER: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.20.1.2." . $details->man_ip_address)); $details->mac_address = @str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.2.2.1.6." . $interface_number)); $details->mac_address = @trim(str_replace("Hex-", "", $details->mac_address)); $details->mac_address = @str_replace(" ", ":", $details->mac_address); # need to split and join because of the dropped 0's $i = explode(":", $details->mac_address); for ($k = 0; $k < count($i); $k++) { if (strlen($i[$k]) == 1) { $i[$k] = '0' . $i[$k]; } if (strlen($i[$k]) == 0) { $i[$k] = '00'; } } $details->mac_address = strtoupper(implode(":", $i)); if ($details->mac_address == '00') { $details->mac_address = ''; } } // type if (!isset($details->type) or $details->type == '') { $h = str_replace("OID: HOST-RESOURCES-TYPES::hrDevice", "", str_replace("STRING: ", "", @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.25.3.2.1.2.1"))); if (strtolower($h) == 'no such object available on this agent at this oid' or $h == '') { # If the device is a Switch, the OID 1.3.6.1.2.1.17.1.2.0 and OID 1.3.6.1.2.1.4.1.0 should have a value of 2 $i = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.17.1.2.0")); $j = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.1.0")); if ($i == '2' and $j == '2') { $details->type = 'switch'; } # If the device is a Router, the OID 1.3.6.1.2.1.4.1.0 should have a value of 1 if (!isset($details->type) or $details->type == '') { $i = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.1.0")); if ($i == '1') { $device->type = 'router'; } } # If the device is a Printer, the OID 1.3.6.1.2.1.43.5.1.1.1.1 should have a value if (!isset($details->type) or $details->type == '') { $i = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.43.5.1.1.1.1")); if ($i == '1') { $device->type = 'printer'; } } } } if (isset($details->type) and $details->type != '' and (!isset($details->man_type) or $details->man_type == '')) { $details->man_type = $details->type; } // model if (!isset($details->model) or $details->model == '') { $details->model = str_replace("STRING: ", "", @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.25.3.2.1.3.1")); if ($details->model == '' or $details->model == 'No Such Object available on this agent at this OID') { if (strpos(strtolower($details->manufacturer), 'cisco') !== FALSE) { $details->model = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.47.1.1.1.1.13.1"))); } } } if (strtolower($details->model) == 'no such object available on this agent at this oid') { $details->model = ''; } // name if (!isset($details->sysname) or $details->sysname == '') { $details->sysname = strtolower(str_replace("\"", "", str_replace("STRING: ", "", @snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.5.0")))); } if (strtolower($details->sysname) == 'no such object available on this agent at this oid') { $details->sysname = ''; } // description if (!isset($details->description) or $details->description == '') { $details->description = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.1.0"))); $details->description = str_replace("\r\n", " ", $details->description); } if (strtolower($details->description) == 'no such object available on this agent at this oid') { $details->description = ''; } // uptime if (!isset($details->uptime) or $details->uptime == '') { $i = str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.3.0")); if ($i > '' and strpos($i, ")") !== FALSE) { $j = explode(")", $i); $details->uptime = trim($j[1]); } else { $details->uptime = ''; } } // location if (!isset($details->location) or $details->location == '') { $details->location = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.6.0"))); } if ($details->location == 'Unknown (edit /etc/snmp/snmpd.conf)') { $details->location = ''; } if ($details->location == 'not set') { $details->location = ''; } if ($details->location == 'No Such Object available on this agent at this OID') { $details->location = ''; } if ($details->location > '') { $details->description = "Location: " . $details->location . ". " . $details->description; } // contact if (!isset($details->contact) or $details->contact == '') { $details->contact = str_replace("\"", "", str_replace("STRING: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.4.0"))); } if ($details->contact == 'Root (configure /etc/snmp/snmpd.conf)') { $details->contact = ''; } if ($details->contact == 'not set') { $details->contact = ''; } if ($details->contact > '') { $details->description = "Contact: " . $details->contact . ". " . $details->description; } // subnet if (!isset($details->subnet) or $details->subnet == '') { $details->subnet = @str_replace("IpAddress: ", "", snmp2_get($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.20.1.3." . $details->man_ip_address)); } if ($details->subnet == 'No Such Instance currently exists at this OID') { $details->subnet = ''; } if ($details->subnet == 'No Such Object available on this agent at this OID') { $details->subnet = ''; } /* // installed modules with serial numbers $i = @snmp2_walk($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.47.1.1.1.1.11"); if (count($i) > 0) { if (($i[0] == 'No more variables left in this MIB View (It is past the end of the MIB tree)') or ($i[0] == '')){unset($i); $i = array();} if (count($i) > 0) { $count = 0; for ($j=0; $j<count($i); $j++) { if ((mb_strpos($i[$j], $details->serial) === FALSE) and ($i[$j] != "") and ($i[$j] != "\"\"")){ $k = $j + 1; $k = "1.3.6.1.2.1.47.1.1.1.1.3." . $k; $oid = snmp2_get($details->man_ip_address, $details->snmp_community, $k); $oid = str_replace("OID: .", "", $oid); $module->$count = get_oid($oid); $module->$count->serial = str_replace("STRING: ", "", $i[$j]); $module->$count->serial = str_replace('"', '', $module->$count->serial); $count++; } } $details->modules = $module; } } */ } } if ($details->snmp_version == '1') { $details->snmp_oid = ''; $details->snmp_oid = str_replace("OID: .", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.2.0")); if (strtolower($details->snmp_oid) == 'no such object available on this agent at this oid') { $details->snmp_oid = ''; } if ($details->snmp_oid > '') { $oid = get_oid($details->snmp_oid); $details->manufacturer = $oid->manufacturer; $details->man_manufacturer = $oid->manufacturer; $details->model = $oid->model; $details->man_model = $oid->model; $details->type = $oid->type; $details->device_type = $oid->type; $details->man_type = $oid->type; $details->os_group = $oid->os_group; $details->man_os_group = $oid->os_group; } if ($details->oid == '1.3.6.1.4.1.714.1.2.6') { # We have a Wyse thin client - some specifics. $details->serial = str_replace("String: .", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.4.1.714.1.2.6.2.1.0")); $details->sysname = str_replace("String: .", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.5.0")); $details->description = str_replace("String: .", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.1.0")); $details->contact = str_replace("String: .", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.4.0")); if ($details->contact > '') { $details->description = "Contact: " . $details->contact . ". " . $details->description; } $details->location = str_replace("String: .", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.6.0")); if ($details->location > '') { $details->description = "Location: " . $details->location . ". " . $details->description; } } $interface_number = str_replace("INTEGER: ", "", @snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.20.1.2." . $details->man_ip_address)); $i = "1.3.6.1.2.1.2.2.1.6." . $interface_number; $details->mac_address = snmpget($details->man_ip_address, $details->snmp_community, $i); $details->mac_address = trim(str_replace("Hex-STRING: ", "", $details->mac_address)); $details->mac_address = str_replace(" ", ":", $details->mac_address); $details->subnet = str_replace("IpAddress: ", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.20.1.3." . $details->man_ip_address)); $details->hostname = trim(str_replace("\"", "", str_replace("STRING: ", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.1.5.0")))); $details->next_hop = str_replace("IpAddress: ", "", snmpget($details->man_ip_address, $details->snmp_community, "1.3.6.1.2.1.4.21.1.7.0.0.0.0")); } // update the system #if ($details->snmp_version > '') { #$CI2->m_system->process_snmp($details); return $details; #} }
$rxChannelOpMode = substr(snmp2_get($device_IP, "public", $oid['rxChannelOpMode']), 9); $rxSwitchMode = substr(snmp2_get($device_IP, "public", $oid['rxSwitchMode']), 9); $rxSwitchPeriod = substr(snmp2_get($device_IP, "public", $oid['rxSwitchPeriod']), 9); $rxActive = substr(snmp2_get($device_IP, "public", $oid['rxActive']), 9); } // Write if (isset($_POST['write']) and $read == "read") { snmp2_set($device_IP, "private", $oid['rxChannelOpMode'], $type['rxChannelOpMode'], $_POST['rxChannelOpMode']); snmp2_set($device_IP, "private", $oid['rxSwitchMode'], $type['rxSwitchMode'], $_POST['rxSwitchMode']); snmp2_set($device_IP, "private", $oid['rxSwitchPeriod'], $type['rxSwitchPeriod'], $_POST['rxSwitchPeriod']); snmp2_set($device_IP, "private", $oid['rxActive'], $type['rxActive'], $_POST['rxActive']); // read $rxChannelOpMode = substr(snmp2_get($device_IP, "public", $oid['rxChannelOpMode']), 9); $rxSwitchMode = substr(snmp2_get($device_IP, "public", $oid['rxSwitchMode']), 9); $rxSwitchPeriod = substr(snmp2_get($device_IP, "public", $oid['rxSwitchPeriod']), 9); $rxActive = substr(snmp2_get($device_IP, "public", $oid['rxActive']), 9); } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>--> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> <style type="text/css"> body {
function snmpget($oid) { return snmp2_get($this->hostname, $this->snmpsetup['community'], $oid); }
$total_procs = 0; $total_mem = 0; $total_vms = 0; for (reset($a); $i = key($a); next($a)) { // echo "$i: $a[$i]<br />\n"; echo "<tr>\n"; $chave = substr($i, strrpos($i, '.') + 1); $vm_nome_tmp = snmp2_get($server, $snmp_community, '.1.3.6.1.4.1.6876.2.1.1.2.' . $chave); $vm_nome = str_replace("\"", "", substr($vm_nome_tmp, strrpos($vm_nome_tmp, ':') + 1)); $vm_kernel_version_tmp = snmp2_get($server, $snmp_community, '.1.3.6.1.4.1.6876.2.1.1.4.' . $chave); $vm_kernel_version = str_replace("\"", "", substr($vm_kernel_version_tmp, strrpos($vm_kernel_version_tmp, ':') + 1)); $vm_memory_total_tmp = snmp2_get($server, $snmp_community, '.1.3.6.1.4.1.6876.2.1.1.5.' . $chave); $vm_memory_total = str_replace("\"", "", substr($vm_memory_total_tmp, strrpos($vm_memory_total_tmp, ':') + 1)); $vm_power_status_tmp = snmp2_get($server, $snmp_community, '.1.3.6.1.4.1.6876.2.1.1.6.' . $chave); $vm_power_status = str_replace("\"", "", substr($vm_power_status_tmp, strrpos($vm_power_status_tmp, ':') + 1)); $vm_proc_total_tmp = snmp2_get($server, $snmp_community, '.1.3.6.1.4.1.6876.2.1.1.9.' . $chave); $vm_proc_total = str_replace("\"", "", substr($vm_proc_total_tmp, strrpos($vm_proc_total_tmp, ':') + 1)); echo " <td>{$vm_nome}</td>\n <td>{$vm_kernel_version}</td>\n <td align=\"center\">{$vm_proc_total}</td>\n <td align=\"center\">{$vm_memory_total}</td>\n <td align=\"center\">"; if ($vm_power_status == " powered off") { echo "<font color=\"red\">{$vm_power_status}</font>"; } else { echo "<font color=\"green\">{$vm_power_status}</font>"; } echo "</td>\n"; echo "</tr>\n"; $total_procs = $total_procs + $vm_proc_total; $total_mem = $total_mem + $vm_memory_total; $total_vms = $total_vms + 1; } echo "<tr><td align=\"center\"><b>{$total_vms} VMs Instalada(s)</b></td><td></td><td align=\"center\"><b>{$total_procs}</b></td><td align=\"center\"><b>{$total_mem}</b></td><td></td></tr>"; echo "</table>\n";
snmp2_set($device_IP, "private", $fwRow2['fpgaVersionActive'], "i", "1"); } //UpgradeInfo snmp2_set($device_IP, "private", $oid['tftpServerIp'], $type['tftpServerIp'], $_POST['tftpServerIp']); snmp2_set($device_IP, "private", $oid['softwareImageFilename'], $type['softwareImageFilename'], $_POST['softwareImageFilename']); snmp2_set($device_IP, "private", $oid['fpgaImageFilename'], $type['fpgaImageFilename'], $_POST['fpgaImageFilename']); snmp2_set($device_IP, "private", $oid['bootloaderImageFilename'], $type['bootloaderImageFilename'], $_POST['bootloaderImageFilename']); // read $softwareVersionActive2 = substr(snmp2_get($device_IP, "public", $swRow2['softwareVersionActive']), 9); $softwareVersionActive1 = substr(snmp2_get($device_IP, "public", $swRow1['softwareVersionActive']), 9); $fpgaVersionActive2 = substr(snmp2_get($device_IP, "public", $fwRow2['fpgaVersionActive']), 9); $fpgaVersionActive1 = substr(snmp2_get($device_IP, "public", $fwRow1['fpgaVersionActive']), 9); $tftpServerIp = substr(snmp2_get($device_IP, "public", $oid['tftpServerIp']), 11); $softwareImageFilename = substr(snmp2_get($device_IP, "public", $oid['softwareImageFilename']), 9); $fpgaImageFilename = substr(snmp2_get($device_IP, "public", $oid['fpgaImageFilename']), 9); $bootloaderImageFilename = substr(snmp2_get($device_IP, "public", $oid['bootloaderImageFilename']), 9); } if (isset($_POST['startSoftwareUpgrade'])) { snmp2_set($device_IP, "private", $oid['tftpServerIp'], $type['tftpServerIp'], $_POST['tftpServerIp']); snmp2_set($device_IP, "private", $oid['softwareImageFilename'], $type['softwareImageFilename'], $_POST['softwareImageFilename']); snmp2_set($device_IP, "private", $oid['startSoftwareUpgrade'], $type['startSoftwareUpgrade'], '1'); echo '<script type="text/javascript">alert("Please wait 1 minute and read from device again.")</script>'; } if (isset($_POST['startFpgaUpgrade'])) { snmp2_set($device_IP, "private", $oid['tftpServerIp'], $type['tftpServerIp'], $_POST['tftpServerIp']); snmp2_set($device_IP, "private", $oid['fpgaImageFilename'], $type['fpgaImageFilename'], $_POST['fpgaImageFilename']); snmp2_set($device_IP, "private", $oid['startFpgaUpgrade'], $type['startFpgaUpgrade'], '1'); echo '<script type="text/javascript">alert("Please wait 1 minute and read from device again.")</script>'; } if (isset($_POST['startBootloaderDownload'])) { snmp2_set($device_IP, "private", $oid['tftpServerIp'], $type['tftpServerIp'], $_POST['tftpServerIp']);
snmp2_set($device_IP, "private", $oid['snmpReadCommunity'], $type['snmpReadCommunity'], $_POST['snmpReadCommunity']); snmp2_set($device_IP, "private", $oid['ntpServerIpAddress'], $type['ntpServerIpAddress'], $_POST['ntpServerIpAddress']); snmp2_set($device_IP, "private", $oid['snmpTrapServerIpAddress'], $type['snmpTrapServerIpAddress'], $_POST['snmpTrapServerIpAddress']); snmp2_set($device_IP, "private", $oid['username'], $type['username'], $_POST['username']); snmp2_set($device_IP, "private", $oid['telnetTimeout'], $type['telnetTimeout'], $_POST['telnetTimeout']); if ($_POST['password'] != "") { snmp2_set($device_IP, "private", $oid['password'], $type['password'], $_POST['password']); } //read $snmpWriteCommunity = substr(snmp2_get($device_IP, "public", $oid['snmpWriteCommunity']), 9); $snmpReadCommunity = substr(snmp2_get($device_IP, "public", $oid['snmpReadCommunity']), 9); $ntpServerIpAddress = substr(snmp2_get($device_IP, "public", $oid['ntpServerIpAddress']), 11); $snmpTrapServerIpAddress = substr(snmp2_get($device_IP, "public", $oid['snmpTrapServerIpAddress']), 11); //telnet $username = substr(snmp2_get($device_IP, "public", $oid['username']), 9); $telnetTimeout = substr(snmp2_get($device_IP, "public", $oid['telnetTimeout']), 9); } //Reset if (isset($_POST['coldReset'])) { echo '<script type="text/javascript">alert("Please wait 1 minute and read from device again.")</script>'; snmp2_set($device_IP, "private", $oid['coldReset'], $type['coldReset'], "1"); } if (isset($_POST['warmReset'])) { echo '<script type="text/javascript">alert("Please wait 1 minute and read from device again.")</script>'; snmp2_set($device_IP, "private", $oid['warmReset'], $type['warmReset'], '1'); } ?> <!doctype html> <html>
$hardwareVersion = substr(snmp2_get($device_IP, "public", $oid['hardwareVersion']), 9); $fpgaVersion = substr(snmp2_get($device_IP, "public", $oid['fpgaVersion']), 9); $softwareVersion = substr(snmp2_get($device_IP, "public", $oid['softwareVersion']), 9); $serialNumber = substr(snmp2_get($device_IP, "public", $oid['serialNumber']), 9); //system info include_once 'info_function.php'; // Choose Read Table if (isset($_POST['selectTableSubmit'])) { // Choose table $selectTable = $_POST['selectTable']; for ($i = 1; $i <= 8; $i++) { // row number ($i) for ($c = 1; $c <= 10; $c++) { // column number ($c) $oid = "1.3.6.1.4.1.27928.101.1." . $selectTable . ".4.3.1." . $c . ".{$i}"; $get[$i][$c] = substr(snmp2_get($device_IP, "public", $oid), 9); // clean the mac address result if ($c == 3) { $get[$i][$c] = substr($get[$i][$c], 2); } } } // loop closed } } /******************************** * Write! * ******************************** */ if (isset($_POST['write']) and $read == "read") { for ($i = 1; $i <= 8; $i++) {
<?php $sysUpTime = substr(snmp2_get($device_IP, "public", "1.3.6.1.2.1.1.3"), 22); $sysContact = substr(snmp2_get($device_IP, "public", "1.3.6.1.2.1.1.4"), 0); $sysDescr = substr(snmp2_get($device_IP, "public", "1.3.6.1.2.1.1.1"), 9); $sysName = substr(snmp2_get($device_IP, "public", "1.3.6.1.2.1.1.5"), 0); $sysLocation = substr(snmp2_get($device_IP, "public", "1.3.6.1"), 0); $sysObjectID = substr(snmp2_get($device_IP, "public", "1.3.6.1.2.1.1.2"), 9); $sysServices = substr(snmp2_get($device_IP, "public", "1.3.6.1.2.1.1.7"), 9);
snmp2_set($device_IP, "private", $oid['lanSubnetMask'], $type['lanSubnetMask'], $_POST['lanSubnetMask']); snmp2_set($device_IP, "private", $oid['routerIpAddress'], $type['routerIpAddress'], $_POST['routerIpAddress']); if ($_POST['lanMulticastMode'] == "0") { //selected snmp2_set($device_IP, "private", $oid['lanMulticastMode'], $type['lanMulticastMode'], '0'); } else { //not selected snmp2_set($device_IP, "private", $oid['lanMulticastMode'], $type['lanMulticastMode'], '1'); } //read $lanIpAddress = substr(snmp2_get($device_IP, "public", $oid['lanIpAddress']), 11); $lanSubnetMask = substr(snmp2_get($device_IP, "public", $oid['lanSubnetMask']), 11); $lanMacAddress = substr(snmp2_get($device_IP, "public", $oid['lanMacAddress']), 11); $lanMulticastMode = substr(snmp2_get($device_IP, "public", $oid['lanMulticastMode']), 9); $routerIpAddress = substr(snmp2_get($device_IP, "public", $oid['routerIpAddress']), 11); $lanDhcpClient = substr(snmp2_get($device_IP, "public", $oid['lanDhcpClient']), 9); } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>--> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> <style type="text/css">
snmp2_set($device_IP, "private", $oid['txPowerLevel'], $type['txPowerLevel'], $_POST['txPowerLevel'] * 10); if ($_POST['txPowerState'] == "1") { snmp2_set($device_IP, "private", $oid['txPowerState'], $type['txPowerState'], "1"); } else { snmp2_set($device_IP, "private", $oid['txPowerState'], $type['txPowerState'], "0"); } if ($_POST['txPowerStateInitial'] == "1") { snmp2_set($device_IP, "private", $oid['txPowerStateInitial'], $type['txPowerStateInitial'], "1"); } else { snmp2_set($device_IP, "private", $oid['txPowerStateInitial'], $type['txPowerStateInitial'], "0"); } //read $txFrequency = substr(snmp2_get($device_IP, "public", $oid['txFrequency']), 9) / 1000; $txPowerLevel = substr(snmp2_get($device_IP, "public", $oid['txPowerLevel']), 9) / 10; $txPowerState = substr(snmp2_get($device_IP, "public", $oid['txPowerState']), 9); $txPowerStateInitial = substr(snmp2_get($device_IP, "public", $oid['txPowerStateInitial']), 9); } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>--> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> <style type="text/css"> body {
require_once 'sql.php'; sql_connect(); require_once 'array.php'; oidarray(); require_once 'rf_functions.php'; if (isset($_POST['read']) or $read == "read") { if (isset($_POST['read'])) { $device_IP = $_POST['device_IP']; } $_SESSION['device_IP_tc'] = $device_IP; $_SESSION['read_tc'] = "read"; // Board Information $hardwareVersion = substr(snmp2_get($device_IP, "public", $oid['hardwareVersion']), 9); $fpgaVersion = substr(snmp2_get($device_IP, "public", $oid['fpgaVersion']), 9); $softwareVersion = substr(snmp2_get($device_IP, "public", $oid['softwareVersion']), 9); $serialNumber = substr(snmp2_get($device_IP, "public", $oid['serialNumber']), 9); // System info include_once 'info_function.php'; // RF1 if ($_GET['rf'] == "1") { rf1_conf1_read(); rf1_conf2_read(); } // RF2 if ($_GET['rf'] == "2") { rf2_conf1_read(); rf2_conf2_read(); } } // Write if (isset($_POST['write']) and $read == "read") {
function cacti_snmp_get($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $environ = SNMP_POLLER) { global $config; /* determine default retries */ if ($retries == 0 || !is_numeric($retries)) { $retries = read_config_option("snmp_retries"); if ($retries == "") { $retries = 3; } } /* do not attempt to poll invalid combinations */ if ($version == 0 || !is_numeric($version) || !is_numeric($port) || !is_numeric($retries) || !is_numeric($timeout) || $community == "" && $version != 3) { return "U"; } if (snmp_get_method($version) == SNMP_METHOD_PHP && (!strlen($context) || $version != 3)) { /* make sure snmp* is verbose so we can see what types of data we are getting back */ snmp_set_quick_print(0); if ($version == "1") { $snmp_value = @snmpget("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries); } elseif ($version == "2") { $snmp_value = @snmp2_get("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries); } else { if ($priv_proto == "[None]" || $priv_pass == '') { $proto = "authNoPriv"; $priv_proto = ""; } else { $proto = "authPriv"; } $snmp_value = @snmp3_get("{$hostname}:{$port}", "{$username}", $proto, $auth_proto, "{$password}", $priv_proto, "{$priv_pass}", "{$oid}", $timeout * 1000, $retries); } if ($snmp_value === false) { cacti_log("WARNING: SNMP Get Timeout for Host:'{$hostname}', and OID:'{$oid}'", false); } } else { $snmp_value = ''; /* ucd/net snmp want the timeout in seconds */ $timeout = ceil($timeout / 1000); if ($version == "1") { $snmp_auth = read_config_option("snmp_version") == "ucd-snmp" ? snmp_escape_string($community) : "-c " . snmp_escape_string($community); /* v1/v2 - community string */ } elseif ($version == "2") { $snmp_auth = read_config_option("snmp_version") == "ucd-snmp" ? snmp_escape_string($community) : "-c " . snmp_escape_string($community); /* v1/v2 - community string */ $version = "2c"; /* ucd/net snmp prefers this over '2' */ } elseif ($version == "3") { if ($priv_proto == "[None]" || $priv_pass == '') { $proto = "authNoPriv"; $priv_proto = ""; } else { $proto = "authPriv"; } if (strlen($priv_pass)) { $priv_pass = "******" . snmp_escape_string($priv_pass) . " -x " . snmp_escape_string($priv_proto); } else { $priv_pass = ""; } if (strlen($context)) { $context = "-n " . snmp_escape_string($context); } else { $context = ""; } $snmp_auth = trim("-u " . snmp_escape_string($username) . " -l " . snmp_escape_string($proto) . " -a " . snmp_escape_string($auth_proto) . " -A " . snmp_escape_string($password) . " " . $priv_pass . " " . $context); /* v3 - username/password */ } /* no valid snmp version has been set, get out */ if (empty($snmp_auth)) { return; } if (read_config_option("snmp_version") == "ucd-snmp") { /* escape the command to be executed and vulnerable parameters * numeric parameters are not subject to command injection * snmp_auth is treated seperately, see above */ exec(cacti_escapeshellcmd(read_config_option("path_snmpget")) . " -O vt -v{$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} {$snmp_auth} " . cacti_escapeshellarg($oid), $snmp_value); } else { exec(cacti_escapeshellcmd(read_config_option("path_snmpget")) . " -O fntev " . $snmp_auth . " -v {$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid), $snmp_value); } /* fix for multi-line snmp output */ if (is_array($snmp_value)) { $snmp_value = implode(" ", $snmp_value); } } /* fix for multi-line snmp output */ if (isset($snmp_value)) { if (is_array($snmp_value)) { $snmp_value = implode(" ", $snmp_value); } } if (substr_count($snmp_value, "Timeout:")) { cacti_log("WARNING: SNMP Get Timeout for Host:'{$hostname}', and OID:'{$oid}'", false); } /* strip out non-snmp data */ $snmp_value = format_snmp_string($snmp_value, false); return $snmp_value; }
function cacti_snmp_get($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $environ = SNMP_POLLER) { global $config; /* determine default retries */ if (($retries == 0) || (!is_numeric($retries))) { $retries = read_config_option("snmp_retries"); if ($retries == "") $retries = 3; } /* do not attempt to poll invalid combinations */ if (($version == 0) || (($community == "") && ($version != 3))) { return "U"; } if ((snmp_get_method($version) == SNMP_METHOD_PHP) && (!strlen($context) || ($version != 3))) { /* make sure snmp* is verbose so we can see what types of data we are getting back */ snmp_set_quick_print(0); if ($version == "1") { $snmp_value = @snmpget("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries); }elseif ($version == "2") { $snmp_value = @snmp2_get("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries); }else{ if ($priv_proto == "[None]") { $proto = "authNoPriv"; $priv_proto = ""; }else{ $proto = "authPriv"; } $snmp_value = @snmp3_get("$hostname:$port", "$username", $proto, $auth_proto, "$password", $priv_proto, "$priv_pass", "$oid", ($timeout * 1000), $retries); } }else { /* ucd/net snmp want the timeout in seconds */ $timeout = ceil($timeout / 1000); if ($version == "1") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? cacti_escapeshellarg($community): "-c " . cacti_escapeshellarg($community); /* v1/v2 - community string */ }elseif ($version == "2") { $snmp_auth = (read_config_option("snmp_version") == "ucd-snmp") ? cacti_escapeshellarg($community) : "-c " . cacti_escapeshellarg($community); /* v1/v2 - community string */ $version = "2c"; /* ucd/net snmp prefers this over '2' */ }elseif ($version == "3") { if ($priv_proto == "[None]") { $proto = "authNoPriv"; $priv_proto = ""; }else{ $proto = "authPriv"; } if (strlen($priv_pass)) { $priv_pass = "******" . cacti_escapeshellarg($priv_pass) . " -x " . cacti_escapeshellarg($priv_proto); }else{ $priv_pass = ""; } if (strlen($context)) { $context = "-n " . cacti_escapeshellarg($context); }else{ $context = ""; } $snmp_auth = trim("-u " . cacti_escapeshellarg($username) . " -l " . cacti_escapeshellarg($proto) . " -a " . cacti_escapeshellarg($auth_proto) . " -A " . cacti_escapeshellarg($password) . " " . $priv_pass . " " . $context); /* v3 - username/password */ } /* no valid snmp version has been set, get out */ if (empty($snmp_auth)) { return; } if (read_config_option("snmp_version") == "ucd-snmp") { exec(read_config_option("path_snmpget") . " -O vt -v$version -t $timeout -r $retries $hostname:$port $snmp_auth $oid", $snmp_value); }else { exec(read_config_option("path_snmpget") . " -O fntev $snmp_auth -v $version -t $timeout -r $retries $hostname:$port $oid", $snmp_value); } } if (isset($snmp_value)) { /* fix for multi-line snmp output */ if (is_array($snmp_value)) { $snmp_value = implode(" ", $snmp_value); } } /* strip out non-snmp data */ $snmp_value = format_snmp_string($snmp_value, false); return $snmp_value; }
function cacti_snmp_get($hostname, $community, $oid, $version, $username, $password, $auth_proto, $priv_pass, $priv_proto, $context, $port = 161, $timeout = 500, $retries = 0, $max_oids = 10, $method = SNMP_VALUE_LIBRARY, $environ = SNMP_POLLER) { global $config; /* determine default retries */ if ($retries == 0 || !is_numeric($retries)) { $retries = read_config_option('snmp_retries'); if ($retries == '') { $retries = 3; } } /* do not attempt to poll invalid combinations */ if ($version == 0 || !is_numeric($version) || !is_numeric($port) || !is_numeric($retries) || !is_numeric($timeout) || $community == '' && $version != 3) { return 'U'; } if (snmp_get_method($version) == SNMP_METHOD_PHP && (!strlen($context) || $version != 3)) { /* make sure snmp* is verbose so we can see what types of data we are getting back */ snmp_set_quick_print(0); /* set the output format to numeric */ snmp_set_valueretrieval($method); if ($version == '1') { $snmp_value = @snmpget("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries); } elseif ($version == '2') { $snmp_value = @snmp2_get("{$hostname}:{$port}", "{$community}", "{$oid}", $timeout * 1000, $retries); } else { if ($priv_proto == '[None]') { $proto = 'authNoPriv'; $priv_proto = ''; } else { $proto = 'authPriv'; } $snmp_value = @snmp3_get("{$hostname}:{$port}", "{$username}", $proto, $auth_proto, "{$password}", $priv_proto, "{$priv_pass}", "{$oid}", $timeout * 1000, $retries); } if ($snmp_value === false) { cacti_log("WARNING: SNMP Get Timeout for Host:'{$hostname}', and OID:'{$oid}'", false); } } else { /* ucd/net snmp want the timeout in seconds */ $timeout = ceil($timeout / 1000); if ($version == '1') { $snmp_auth = '-c ' . snmp_escape_string($community); /* v1/v2 - community string */ } elseif ($version == '2') { $snmp_auth = '-c ' . snmp_escape_string($community); /* v1/v2 - community string */ $version = '2c'; /* ucd/net snmp prefers this over '2' */ } elseif ($version == '3') { if ($priv_proto == '[None]') { $proto = 'authNoPriv'; $priv_proto = ''; } else { $proto = 'authPriv'; } if (strlen($priv_pass)) { $priv_pass = '******' . snmp_escape_string($priv_pass) . ' -x ' . snmp_escape_string($priv_proto); } else { $priv_pass = ''; } if (strlen($context)) { $context = '-n ' . snmp_escape_string($context); } else { $context = ''; } $snmp_auth = trim('-u ' . snmp_escape_string($username) . ' -l ' . snmp_escape_string($proto) . ' -a ' . snmp_escape_string($auth_proto) . ' -A ' . snmp_escape_string($password) . ' ' . $priv_pass . ' ' . $context); /* v3 - username/password */ } /* no valid snmp version has been set, get out */ if (empty($snmp_auth)) { return; } exec(cacti_escapeshellcmd(read_config_option('path_snmpget')) . ' -O fntev ' . $snmp_auth . " -v {$version} -t {$timeout} -r {$retries} " . cacti_escapeshellarg($hostname) . ":{$port} " . cacti_escapeshellarg($oid), $snmp_value); /* fix for multi-line snmp output */ if (is_array($snmp_value)) { $snmp_value = implode(' ', $snmp_value); } } /* fix for multi-line snmp output */ if (isset($snmp_value)) { if (is_array($snmp_value)) { $snmp_value = implode(' ', $snmp_value); } } if (substr_count($snmp_value, 'Timeout:')) { cacti_log("WARNING: SNMP Get Timeout for Host:'{$hostname}', and OID:'{$oid}'", false); } /* strip out non-snmp data */ $snmp_value = format_snmp_string($snmp_value, false); return $snmp_value; }
function my_snmp_get($ip, $credentials, $oid) { $timeout = '3000000'; $retries = '0'; if (empty($credentials->credentials->version) or $credentials->credentials->version != 1 or $credentials->credentials->version != 2 or $credentials->credentials->version != 3) { $credentials->credentials->version = 2; } switch ($credentials->credentials->version) { case '1': $string = @snmpget($ip, $credentials->credentials->community, $oid, $timeout, $retries); break; case '2': $string = @snmp2_get($ip, $credentials->credentials->community, $oid, $timeout, $retries); break; case '3': $sec_name = $credentials->credentials->security_name ?: ''; $sec_level = $credentials->credentials->security_level ?: ''; $auth_protocol = $credentials->credentials->authentication_protocol ?: ''; $auth_passphrase = $credentials->credentials->authentication_passphrase ?: ''; $priv_protocol = $credentials->credentials->privacy_protocol ?: ''; $priv_passphrase = $credentials->credentials->privacy_passphrase ?: ''; $string = @snmp3_get($ip, $sec_name, $sec_level, $auth_protocol, $auth_passphrase, $priv_protocol, $priv_passphrase, $oid, $timeout, $retries); break; default: return false; break; } if (empty($string) and $string != '0') { return false; } if ($string == '""') { $string = ''; } $string = trim($string); # if the first character is a '.', remove it. if (strpos($string, '.') === 0) { $string = substr($string, 1); } // remove the first and last characters if they are " if (substr($string, 0, 1) == "\"") { $string = substr($string, 1, strlen($string)); } if (substr($string, -1, 1) == "\"") { $string = substr($string, 0, strlen($string) - 1); } // remove some return strings if (strpos(strtolower($string), '/etc/snmp') !== false or strpos(strtolower($string), 'no such instance') !== false or strpos(strtolower($string), 'no such object') !== false or strpos(strtolower($string), 'not set') !== false or strpos(strtolower($string), 'unknown value type') !== false) { $string = ''; } // remove any quotation marks $string = str_replace('"', ' ', $string); // replace any line breaks with spaces $string = str_replace(array("\r", "\n"), " ", $string); return (string) $string; }
snmp2_set($device_IP, "private", $oid['egrNetOutputEnabled'], $type['egrNetOutputEnabled'], $_POST['egrNetOutputEnabled']); //read $egrDstEthAddress = substr(snmp2_get($device_IP, "public", $oid['egrDstEthAddress']), 11); $egrSrcEthAddress = substr(snmp2_get($device_IP, "public", $oid['egrSrcEthAddress']), 11); $egrVlanSupport = substr(snmp2_get($device_IP, "public", $oid['egrVlanSupport']), 9); $egrVlanPcp = substr(snmp2_get($device_IP, "public", $oid['egrVlanPcp']), 9); $egrVlanVid = substr(snmp2_get($device_IP, "public", $oid['egrVlanVid']), 9); $egrDscp = substr(snmp2_get($device_IP, "public", $oid['egrDscp']), 9); $egrSrcIpAddress = substr(snmp2_get($device_IP, "public", $oid['egrSrcIpAddress']), 11); $egrDstIpAddress = substr(snmp2_get($device_IP, "public", $oid['egrDstIpAddress']), 11); $egrDstUdpPort = substr(snmp2_get($device_IP, "public", $oid['egrDstUdpPort']), 9); $egrTsoipNumber = substr(snmp2_get($device_IP, "public", $oid['egrTsoipNumber']), 9); $egrTsoipTimeoutAwarenessEnable = substr(snmp2_get($device_IP, "public", $oid['egrTsoipTimeoutAwarenessEnable']), 9); $egrTsoipMaxTimeout = substr(snmp2_get($device_IP, "public", $oid['egrTsoipMaxTimeout']), 9); $egrModOutputEnabled = substr(snmp2_get($device_IP, "public", $oid['egrModOutputEnabled']), 9); $egrNetOutputEnabled = substr(snmp2_get($device_IP, "public", $oid['egrNetOutputEnabled']), 9); } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>--> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> <style type="text/css"> body {
private function __snmpget($object_id) { $retval = FALSE; switch ($this->version) { case self::VERSION_1: $retval = snmpget($this->host, $this->community, $object_id); break; case self::VERSION_2C: case self::VERSION_2c: $retval = snmp2_get($this->host, $this->community, $object_id); break; case self::VERSION_3: $retval = snmp3_get($this->host, $this->community, $this->sec_level, $this->auth_protocol, $this->auth_passphrase, $this->priv_protocol, $this->priv_passphrase, $object_id); break; } return $retval; }
//Validacion de IP if ($data->ipWan === '0.0.0.0' || $data->ipWan === '1.1.1.1' || $data->ipWan === '1.0.0.0') { $update_profile = "INSERT INTO `bm_item_profile` \r\n ( `id_item`, `id_host`, `snmp_oid`, `snmp_port`, `snmp_community`, \r\n `nextcheck`, `lastclock`, `lastvalue`, `prevvalue`, `error`, `status`)\r\n VALUES (" . $data->idItem . "," . $data->idHost . ", '" . $data->snmpOid . "', " . $data->snmpPort . ", '" . $data->snmpCommunity . "', '" . $data->nextcheck . "' , UNIX_TIMESTAMP(), 0, 0, 'IP invalid', 'error') \r\n ON DUPLICATE KEY UPDATE `error`='IP invalid' , \r\n `status`='error' ,\r\n `nextcheck` = '" . $data->nextcheck . "' , \r\n `lastclock` = " . $data->utime . " ,\r\n `prevvalue`=`lastvalue`,`lastvalue`=0"; $cmd->conexion->query($update_profile); $insert_query = "/* BSW - Poller NOK */ INSERT INTO {$tableHistory} \r\n (`id_item`,`id_host`,`clock`,`value`,`valid`) \r\n VALUES ( {$data->idItem},{$data->idHost},{$data->utime}, 0 ,0)"; $cmd->conexion->query($insert_query); //Status Host if ((int) $data->idItem === 1) { $set_status_host_sql = "/* BSW */ UPDATE `bm_host` SET `availability` = '0' WHERE `id_host` = '{$data->idHost}';"; $cmd->conexion->query($set_status_host_sql); } liberando($memcache, $idHost, $idItem, $serial, "Ip incorrecta", $cmd); } if (function_exists('snmp2_get') && $continue === true) { $timeStart = microtime(true); $resultSnmp = @snmp2_get($ipDestiny, $data->snmpCommunity, $data->snmpOid, $timeout, $retry); $timeEnd = microtime(true); $time = $timeEnd - $timeStart; if ($resultSnmp) { //Todo OK por el momento $cmd->logs->debug("La consulta snmp al host: [{$data->host}] mediante la ip: [{$ipDestiny}] y el objetid: [{$data->snmpOid}] , tiempo: {$time} , respondio: ", $resultSnmp); //validaciones if (strpos($resultSnmp, 'uci') !== false) { $cmd->logs->error("La consulta snmp -> host: [{$data->host}] ip: [{$ipDestiny}] objetid: [{$data->snmpOid}] respondio con Error: ", $resultSnmp); $valorSnmp = 'UCI : Entry not found'; $tipoValorSnmp = 'STRING'; } elseif (strpos($resultSnmp, 'OID') !== false) { $cmd->logs->error("La consulta snmp -> host: [{$data->host}] ip: [{$ipDestiny}] objetid: [{$data->snmpOid}] respondio con Error: ", $resultSnmp); $valorSnmp = 'No Such Object available on this agent at this OID'; $tipoValorSnmp = 'STRING'; } else {
require_once dirname(__FILE__) . '/snmp_include.inc'; //EXPECTF format is quickprint OFF snmp_set_quick_print(false); snmp_set_valueretrieval(SNMP_VALUE_PLAIN); echo "Checking error handling\n"; var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', '')); var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, '')); echo "Empty OID array\n"; var_dump(snmp2_get($hostname, $community, array(), $timeout, $retries)); echo "Checking working\n"; echo "Single OID\n"; var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); echo "Single OID in array\n"; var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries)); echo "Multiple OID\n"; var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries)); echo "More error handling\n"; echo "Single OID\n"; var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2..1.1.1.0', $timeout, $retries)); echo "Single OID in array\n"; var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1...1.1.0'), $timeout, $retries)); echo "Multiple OID\n"; var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1...1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries)); echo "noSuchName checks\n"; echo "Single OID\n"; var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.110', $timeout, $retries)); echo "Single OID in array\n"; var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.110'), $timeout, $retries)); echo "Multiple OID\n"; var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.220'), $timeout, $retries));
$lanIpAddress = substr(snmp2_get($device_IP, "public", $oid['lanIpAddress']), 11); $lanSubnetMask = substr(snmp2_get($device_IP, "public", $oid['lanSubnetMask']), 11); $lanMacAddress = substr(snmp2_get($device_IP, "public", $oid['lanMacAddress']), 11); $lanMulticastMode = substr(snmp2_get($device_IP, "public", $oid['lanMulticastMode']), 9); $routerIpAddress = substr(snmp2_get($device_IP, "public", $oid['routerIpAddress']), 11); $lanDhcpClient = substr(snmp2_get($device_IP, "public", $oid['lanDhcpClient']), 9); //ARP snmp2_set($device_IP, "private", $oid['routerArpMode'], $type['routerArpMode'], $_POST['routerArpMode']); snmp2_set($device_IP, "private", $oid['routerArpPeriod'], $type['routerArpPeriod'], $_POST['routerArpPeriod'] * 1000); snmp2_set($device_IP, "private", $oid['routerArpTimeout'], $type['routerArpTimeout'], $_POST['routerArpTimeout'] * 1000); snmp2_set($device_IP, "private", $oid['routerMacAddress'], $type['routerMacAddress'], $_POST['routerMacAddress']); //read $routerArpMode = substr(snmp2_get($device_IP, "public", $oid['routerArpMode']), 9); $routerArpPeriod = substr(snmp2_get($device_IP, "public", $oid['routerArpPeriod']), 9) / 1000; $routerArpTimeout = substr(snmp2_get($device_IP, "public", $oid['routerArpTimeout']), 9) / 1000; $routerMacAddress = substr(snmp2_get($device_IP, "public", $oid['routerMacAddress']), 11); } ?> <!doctype html> <html> <head> <title>Ayecka Web Interface</title> <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon" /> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css"> <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>--> <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script> <style type="text/css">