Monday, October 28, 2013

Use a script to customize the snmp utility mib

Example of snmp utility mib via CLI
-----------------------

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

user@router> show snmp mib walk jnxUtil
jnxUtilStringValue.116.101.115.116 = ABC

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


user@router> show snmp mib walk jnxUtil

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

Now 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

Source Code:
------------







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