Monday, March 31, 2014

How can I use a script to customize the snmp utility mib?

Juniper has a custom mib called the utility-mib where you can populate this with any value you want. This could be useful if say you want to create a custom counter. Your snmp server can then retrieve this information and use it.

example via cli

jnpr@Chef-RE0> request snmp utility-mib set instance test object-type string object-value ABC
Utility mib result: successfully populated utility mib database

jnpr@Chef-RE0> show snmp mib walk jnxUtil
jnxUtilStringValue.116.101.115.116 = ABC

jnpr@Chef-RE0> request snmp utility-mib clear instance test object-type string
Utility mib result: successfully de-populated utility mib database

jnpr@Chef-RE0> show snmp mib walk jnxUtil

----------
via script:


jnpr@Chef-RE0> op mib-util value "Hello World"

jnpr@Chef-RE0> show snmp mib walk jnxUtil
jnxUtilStringValue.116.101.115.116 = Hello World


---------------------------------------------------








version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
ns ext = "http://xmlsoft.org/XSLT/namespace";

import "../import/junos.xsl";

var $arguments = <argument> {
    <name> "value";
    <description> "object value";
}
param $value;

match / {

        <op-script-results> {



                var $mibset-subs = <request-snmp-utility-mib-set> {

                    <object-type> "string";

                    <instance> "test";

                    <object-value> $value;

                }

                var $result=jcs:invoke($mibset-subs);

                }

No comments:

Post a Comment