Utility MIB Examples
This topic presents examples of show
command output
and SNMP MIB walk results using the utility MIB for power readings
on a Junos OS device.
Show Command Output for Power Readings
user@host> show chassis environment pem
PEM 0 status:
State Online
Temperature OK
AC Input: OK
DC Output Voltage Current Power Load
50 12 600 35
PEM 1 status:
State Online
Temperature OK
AC Input: OK
DC Output Voltage Current Power Load
50 13 650 38
PEM 2 status:
State Present
PEM 3 status:
State Present
In the following example, the index is PEM pem number type of reading.
SNMP MIB Walk Results for the jnx-utility MIB Populated with Power Readings
user@host> show snmp mib walk jnxUtil ascii
jnxUtilStringValue."PEM0dc-current" = 12
jnxUtilStringValue."PEM0dc-load" = 35
jnxUtilStringValue."PEM0dc-power" = 600
jnxUtilStringValue."PEM0dc-voltage" = 50
jnxUtilStringValue."PEM1dc-current" = 13
jnxUtilStringValue."PEM1dc-load" = 38
jnxUtilStringValue."PEM1dc-power" = 650
jnxUtilStringValue."PEM1dc-voltage" = 50
jnxUtilStringTime."PEM0dc-current" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM0dc-load" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM0dc-power" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM0dc-voltage" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM1dc-current" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM1dc-load" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM1dc-power" = 07 d9 09 15 0a 10 2d 00 2b 00 00
jnxUtilStringTime."PEM1dc-voltage" = 07 d9 09 15 0a 10 2d 00 2b 00 00
Sample Script
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"; match / { <op-script-results> { var $command="get-environment-pem-information"; var $pem = jcs:invoke($command); var $chassis= "get-chassis-inventory"; var $getchassis = jcs:invoke($chassis); if ( contains( $getchassis , "EX") or contains( $getchassis , "M10") or contains( $getchassis , "M7")) { <xsl:message terminate="yes"> "Power readings not supported"; } /* if PEM is empty then exit and terminate*/ if( jcs:empty( $pem) ) { <xsl:message terminate="yes"> "Power readings not reported"; } for-each ($pem/environment-component-item) { var $pemslot = substring-after(name, " "); for-each (./dc-information/dc-detail/*) { var $info=name(); var $valueofinfo = .; call snmp_set($instance = "PEM" _ $pemslot _ $info, $value = $valueofinfo); } } } } template snmp_set($instance, $value = "0", $type = "string" ) { var $set_rpc = <request-snmp-utility-mib-set> { <object-type> $type; <object-value> $value; <instance> $instance; } var $out = jcs:invoke($set_rpc); }
Configuration on the Device
user@host> show configuration event-options
generate-event { 1-min time-interval 60; } policy powerUtil { events 1-min; then { event-script power.slax; } }