$v2) { $v = explode(": ", $v2); $ret[$k] = $v[1]; } return $ret; } else { $v = explode(": ", $val); return $v[1]; } } function walk($id) { return $this->sanitize(snmpwalk($this->ip, "public", $id, SNMPTIMEOUT, SNMPTRIES)); } function get($id) { return $this->sanitize(snmpget($this->ip, "public", $id, SNMPTIMEOUT, SNMPTRIES)); } function snmpIntf($ip) { $this->ip = $ip; } function isAlive() { $a = @snmpget($this->ip, "public", "sysLocation.0", SNMPTIMEOUT, SNMPTRIES); if($a == false) return false; else return true; } function sysName() { return $this->get("sysName.0"); } function sysLocation() { return $this->get("sysLocation.0"); } function sysDesc() { return $this->get("sysDescr.0"); } function sysServices() { /* sysServices OBJECT-TYPE SYNTAX INTEGER (0..127) MAX-ACCESS read-only STATUS current DESCRIPTION "A value indicating the set of services that this entity potentially offers. The value is a sum. This sum initially takes the value zero. Then, for each layer, L, in the range 1 through 7, that this node performs transactions for, 2 raised to (L - 1) is added to the sum. For example, a node which performs only routing functions would have a value of 4 (2^(3-1)). In contrast, a node which is a host offering application service would have a value of 72 (2^(4-1) + 2^(7-1)). Note that in the context of the Internet suite of protocols, values should be calculated accordingly: layer functionality 1 physical (e.g., repeaters) 2 datalink/subnetwork (e.g., bridges) 3 internet (e.g., supports the IP) 4 end-to-end (e.g., supports the TCP) 7 applications (e.g., supports the SMTP) For systems including OSI protocols, layers 5 and 6 can also be counted." ::= { system 7 } */ return $this->get("sysServices.0"); } function sysUptime() { return $this->get("sysUpTimeInstance"); } function sysContact() { return $this->get("sysContact.0"); } function ethIf() { $c = $this->walk("ifIndex"); $intf = array(); foreach($c as $if) { $intf[] = array( "desc" => $this->get("ifDescr.$if"), "type" => $this->get("ifType.$if"), "mtu" => $this->get("ifMtu.$if"), "speed" => $this->get("ifSpeed.$if"), "mac" => $this->get("ifPhysAddress.$if"), "enabled" => $this->get("ifAdminStatus.$if"), "link" => $this->get("ifOperStatus.$if"), "lastchange" => $this->get("ifLastChange.$if") ); } return $intf; } function ipaddr() { return $this->walk("ipAdEntAddr"); } function ipForwarding() { return $this->get("ipForwarding.0"); } function tcpconn() { $ret = array(); $state = $this->walk("tcpConnState"); $localip = $this->walk("tcpConnLocalAddress"); $localport = $this->walk("tcpConnLocalPort"); $remoteip = $this->walk("tcpConnRemAddress"); $remoteport = $this->walk("tcpConnRemPort"); for($i=0; $i < count($state); $i++) { $ret[] = array( "state" => $state[$i], "localip" => $localip[$i], "localport" => $localport[$i], "remoteip" => $remoteip[$i], "remoteport" => $remoteport[$i] ); } return $ret; } function udpconn() { $ret = array(); $localip = $this->walk("udpLocalAddress"); $localport = $this->walk("udpLocalPort"); for($i=0; $i < count($localip); $i++) { $ret[] = array( "localip" => $localip[$i], "localport" => $localport[$i] ); } return $ret; } function ram() { return $this->get("hrMemorySize.0"); } function storage() { $ret = array(); $ind = $this->walk("hrStorageIndex"); foreach($ind as $i) { $ret[] = array( "type" => $this->get("hrStorageType.$i"), "desc" => $this->get("hrStorageDescr.$i"), "allocationUnits" => $this->get("hrStorageAllocationUnits.$i"), "size" => $this->get("hrStorageSize.$i"), "used" => $this->get("hrStorageUsed.$i"), "allocationFailures" => $this->get("hrStorageAllocationFailures.$i") ); } return $ret; } function devices() { $ret = array(); $ind = $this->walk("hrDeviceIndex"); foreach($ind as $i) { $ret[] = array( "type" => $this->get("hrDeviceType.$i"), "desc" => $this->get("hrDeviceDescr.$i"), "status" => $this->get("hrDeviceStatus.$i"), "errors" => $this->get("hrDeviceErrors.$i") ); } return $ret; } function processes() { $ret = array(); $ind = $this->walk("hrSWRunIndex"); foreach($ind as $i) { $ret[] = array( "name" => $this->get("hrSWRunName.$i"), "path" => $this->get("hrSWRunPath.$i"), "parameters" => $this->get("hrSWRunParameters.$i"), "type" => $this->get("hrSWRunType.$i"), "status" => $this->get("hrSWRunStatus.$i"), "cputime" => $this->get("hrSWRunPerfCPU.$i"), "meminfo" => $this->get("hrSWRunPerfMem.$i") ); } return $ret; } # Windows Only function apps() { $ret = array(); // $ret["lastupdate"] = $this->sanitize(snmpget($this->ip, "public", "hrSWInstalledLastUpdateTime.0", SNMPTIMEOUT)); // $ret["lastchange"] = $this->sanitize(snmpget($this->ip, "public", "hrSWInstalledLastChange.0", SNMPTIMEOUT)); $ind = $this->walk("hrSWInstalledIndex"); foreach($ind as $i) { $ret[] = array( "name" => $this->get("hrSWInstalledName.$i"), "type" => $this->get("hrSWInstalledType.$i"), "installDate" => $this->get("hrSWInstalledDate.$i") ); } return $ret; } } ?>