Freeside:4:Documentation:Developer/FS/part export/snmp

From Freeside
Jump to: navigation, search


This export sends SNMP SETs to a router using the Net::SNMP package. It requires the following custom fields to be defined on a router. If any of the required custom fields are not present, then the export will exit quietly.

Required custom fields

snmp_address - IP address (or hostname) of the router/agent; snmp_comm - R/W SNMP community of the router/agent; snmp_version - SNMP version of the router/agent

Optional custom fields

snmp_cmd_insert - SNMP SETs to perform on insert. See "Formatting"; snmp_cmd_replace - SNMP SETs to perform on replace. See "Formatting"; snmp_cmd_delete - SNMP SETs to perform on delete. See "Formatting"; snmp_cmd_suspend - SNMP SETs to perform on suspend. See "Formatting"; snmp_cmd_unsuspend - SNMP SETs to perform on unsuspend. See "Formatting"


The values for the snmp_cmd_* fields should be formatted as follows:

<OID>||<expr>[||<OID>|<Data Type>|<expr>[...]]

OID - SNMP object ID (ex. If the OID string starts with a '.', then the Private Enterprise OID ( is prepended.; Data Type - SNMP data types understood by Net::SNMP, as well as HEX_STRING for convenience. ex. INTEGER, OCTET_STRING, IPADDRESS, ...; expr - Expression to be eval'd by freeside. By default, the expression is double quoted and eval'd with all FS::svc_broadband fields available as scalars (ex. $svcnum, $ip_addr, $speed_up). However, if the expression contains a non-escaped double quote, the expression is eval'd without being double quoted. In this case, the expression must be a block of valid perl code that returns the desired value.
You must escape non-delimiter pipes ("|") with a backslash.


This is an example for exporting to a Trango Access5830 AP. Newlines inserted for clarity.

snmp_cmd_delete -|INTEGER|50|||INTEGER|1|
snmp_cmd_insert -|INTEGER|50|||HEX_STRING|join("",$radio_addr =~ /[0-9a-fA-F]{2}/g)|||INTEGER|1|
snmp_cmd_replace -|INTEGER|50|||INTEGER|1|||INTEGER|50|||HEX_STRING|join("",$new_radio_addr =~ /[0-9a-fA-F]{2}/g)|||INTEGER|1|


Plenty, I'm sure.