Skip to content

Instantly share code, notes, and snippets.

@murrant
Created December 6, 2016 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save murrant/d3aad3a0bd2709fc143423942b9dc5e9 to your computer and use it in GitHub Desktop.
Save murrant/d3aad3a0bd2709fc143423942b9dc5e9 to your computer and use it in GitHub Desktop.
Prototype snmp interface
namespace LibreNMS;
class SNMP
{
/**
* @param array $device
* @param string|array $oids single or array of oids to get
* @param string $mib Additional mibs to search, optionally you can specify full oid names
* @param string $mib_dir Additional mib directory, should be rarely needed, see definitions to add per os mib dirs
* @return array array or object of results, format to be determined
*/
public static function get($device, $oids, $mib = null, $mib_dir = null)
{
// return cached result or get from device
// parse data
// return formatted array or object
}
/**
* @param array $device
* @param string|array $oids single or array of oids to walk
* @param string $mib Additional mibs to search, optionally you can specify full oid names
* @param string $mib_dir Additional mib directory, should be rarely needed, see definitions to add per os mib dirs
* @return string exact results from snmpget
*/
public static function getRaw($device, $oids, $options = null, $mib = null, $mib_dir = null)
{
// snmpget data from device
}
/**
* @param array $device
* @param string|array $oids single or array of oids to walk
* @param string $mib Additional mibs to search, optionally you can specify full oid names
* @param string $mib_dir Additional mib directory, should be rarely needed, see definitions to add per os mib dirs
* @return array array or object of results, format to be determined
*/
public static function walk($device, $oids, $mib = null, $mib_dir = null)
{
// return cached result or get from device
// parse data
// return formatted array or object
}
/**
* @param array $device
* @param string $oid single oid to walk
* @param string $options Options to send to snmpwalk
* @param string $mib Additional mibs to search, optionally you can specify full oid names
* @param string $mib_dir Additional mib directory, should be rarely needed, see definitions to add per os mib dirs
* @return string exact results from snmpwalk
*/
public static function walkRaw($device, $oid, $options = null, $mib = null, $mib_dir = null)
{
// snmpwalk data from device
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment