コード例 #1
0
ファイル: assets.inc.php プロジェクト: ghasedak/openDCIM
 static function OSS_SNMP_Lookup($dev, $snmplookup, $oid = null, $walk = false)
 {
     // This is find out the name of the function that called this to make the error logging more descriptive
     $caller = debug_backtrace();
     $caller = $caller[1]['function'];
     $snmpHost = new OSS_SNMP\SNMP($dev->PrimaryIP, $dev->SNMPCommunity, $dev->SNMPVersion, $dev->v3SecurityLevel, $dev->v3AuthProtocol, $dev->v3AuthPassphrase, $dev->v3PrivProtocol, $dev->v3PrivPassphrase);
     $snmpresult = false;
     try {
         $snmpresult = is_null($oid) ? $snmpHost->useSystem()->{$snmplookup}(true) : $walk ? $snmpHost->realWalk($oid) : $snmpHost->get($oid);
     } catch (Exception $e) {
         $dev->IncrementFailures();
         error_log("Device::{$caller}({$dev->DeviceID}) " . $e->getMessage());
     }
     $dev->ResetFailures();
     return $snmpresult;
 }
コード例 #2
0
ファイル: devices.php プロジェクト: spezialist1/openDCIM
    $v3AuthProtocol = $_POST['v3AuthProtocol'] == "" ? $config->ParameterArray["v3AuthProtocol"] : $_POST['v3AuthProtocol'];
    $v3AuthPassphrase = $_POST['v3AuthPassphrase'] == "" ? $config->ParameterArray["v3AuthPassphrase"] : $_POST['v3AuthPassphrase'];
    $v3PrivProtocol = $_POST['v3PrivProtocol'] == "" ? $config->ParameterArray["v3PrivProtocol"] : $_POST['v3PrivProtocol'];
    $v3PrivPassphrase = $_POST['v3PrivPassphrase'] == "" ? $config->ParameterArray["v3PrivPassphrase"] : $_POST['v3PrivPassphrase'];
    // Init the snmp handler
    $snmpHost = new OSS_SNMP\SNMP($_POST['PrimaryIP'], $community, $version, $v3SecurityLevel, $v3AuthProtocol, $v3AuthPassphrase, $v3PrivProtocol, $v3PrivPassphrase);
    // Try to connect to keep us from killing the system on a failure
    $error = false;
    try {
        $snmpresults = $snmpHost->useSystem()->name();
    } catch (Exception $e) {
        $error = true;
    }
    // Show the end user something to make them feel good about it being correct
    if (!$error) {
        foreach ($snmpHost->realWalk('1.3.6.1.2.1.1') as $oid => $value) {
            print "{$oid} => {$value} <br>\n";
        }
    } else {
        print __("Something isn't working correctly");
    }
    exit;
}
// Get CDU uptime
if (isset($_POST['cduuptime'])) {
    $pdu = new PowerDistribution();
    $pdu->PDUID = $_POST['DeviceID'];
    echo $pdu->GetSmartCDUUptime();
    exit;
}
// Get log entries