Cradle
0.3.3
Simple library for creating Web-based applications
|
SNMP protocol wrapper. More...
Public Member Functions | |
__construct ($config) | |
__destruct () | |
open ($config=null) | |
close () | |
getAgentVersion () | |
getAgentReadCommunity () | |
getAgentStatus () | |
getLastError () | |
set ($oid, $value) | |
get ($oid) | |
getParsed ($oid) | |
getValue ($oid) | |
Static Public Member Functions | |
static | parseValue ($value) |
static | parseTimeTicks ($stringValue, $inSeconds=false) |
static | parseTime ($seconds, $format=null) |
static | parseIpAddr ($oid) |
Data Fields | |
const | ERROR_UNKNOWN_VERSION = 1 |
const | ERROR_UNKNOWN_OID = 2 |
const | ERROR_UNKNOWN_TYPE = 3 |
const | ERROR_CATNT_SET_OID = 4 |
$host | |
$readCommunity | |
$writeCommunity | |
$version = 0 | |
$timeout = 2 | |
$retries = 2 | |
$oidOutputFormat = SNMP_OID_OUTPUT_NUMERIC | |
$version3 | |
Protected Member Functions | |
init ($config) | |
setError ($code=null) | |
getTypeCode ($type) | |
snmpget ($oid, $version=null, $community=null) | |
snmpset ($oid, $value, $type=null, $version=null, $community=null) | |
Protected Attributes | |
$agentStatus | |
$agentVersion | |
$agentReadCommunity | |
$errors | |
$typeCodes | |
SNMP protocol wrapper.
A simple class to send SNMP protocol requests.
__construct | ( | $config | ) |
Constructor
array | $config | An array of properties to initialize the class. |
__destruct | ( | ) |
Destructor
close | ( | ) |
Close current SNMP session
get | ( | $oid | ) |
Get a raw value of SNMP object. This method is equal of snmpwalk.
string | $oid | SNMP object id (OID). |
getAgentReadCommunity | ( | ) |
Tries to define a real "read community" of SNMP agent.
List of possible "read community" values to detect should be set in property $readCommunity.
getAgentStatus | ( | ) |
Returns a current SNMP agent status - "alive" or "unreacheble".
getAgentVersion | ( | ) |
Tries to define a real version of SNMP agent.
List of possible version values should be set in property $version. By default (if property $version = 0) list of possible version values wille be set to [2,1] and this method will try to auto detect what version is correct for current SNMP agent.
getLastError | ( | ) |
Returns a last error
getParsed | ( | $oid | ) |
Get a value of SNMP object and parse it. This method is equal of snmpwalk.
string | $oid | SNMP object id (OID). |
getValue | ( | $oid | ) |
Get a single value of SNMP object. This method is equal of snmpget.
string | $oid | SNMP object id (OID). |
|
protected |
Init the class
open | ( | $config = null | ) |
Open new SNMP session
array | string | $config | An array of properties to initialize the class. If $config is a string it will be interpreted as a host (same as $config = [ 'host' => $config ]). |
|
static |
Extract an IP address from SNMP OID.
string | $oid | SNMP Object ID (OID) ends with IP address value. |
|
static |
Converts seconds to output format.
int | $seconds | Input seconds. |
string | $format | A string contains a keys for replacement: [D] - days [H] - hours [M] - minutes [S] - seconds |
|
static |
Parse a raw value of SNMP object contains a TimeTicks
string | $stringValue | value of SNMP object of format: "(3454566544) ..." |
boolean | $inSeconds | =TRUE if you need to convert the result in seconds. |
|
static |
Parse a raw value of SNMP object
string | $value | value of SNMP object of format: "TYPE: Some value" |
set | ( | $oid, | |
$value | |||
) |
Set a value for SNMP object
string | $oid | SNMP object id (OID). |
mixed | $value | Value to set. (Type of value will get from SNMP agent). |
|
protected |
Set an error by error code.
int | $code | Error code |
$host |
string Target hostname or IP address
$oidOutputFormat = SNMP_OID_OUTPUT_NUMERIC |
int the OID output format Acceptable values: SNMP_OID_OUTPUT_NUMERIC | SNMP_OID_OUTPUT_FULL
$readCommunity |
string SNMP read community. You may to set an array of possible values, for auto detect a correct one.
$retries = 2 |
int The number of times to retry if timeouts occur.
$timeout = 2 |
int The number of seconds until the first timeout.
|
protected |
array SNMP object value types
$version = 0 |
array An array of possible SNMP agent versions to use. =0 - auto detect the correct SNMP agent version.
$version3 |
SNMP v3 params
array
$writeCommunity |
string SNMP write community.