Hi,
I'm following this example as the goal is identical:
http://www.juniper.net/techpubs/en_US/junos11.3/topics/task/operational/snmp-best-practices-utility-mib-using.html
But instead of "show system buffers", I use "show chassis routing-engine".
Problem:
When I do the line-count for "show chassis routing-engine", I get only 2 lines.
Goal:
Get the output of control-plane memory (percentage).
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";
match / {
<op-script-results> {
var $rpc = <command> "show chassis routing-engine";
var $result = jcs:invoke($rpc);
var $lines = jcs:break-lines($result);
for-each( $lines ) {
var $line = .;
<output> "line " _ position() _ ": " _ $line;
}
<output> $result;
}
}
On CLI:
root@kim> op memory
line 1:
line 2:
OK
44 degrees C / 111 degrees F
48 degrees C / 118 degrees F
1024
645
63
594
327
55
430
318
74
1
16
1
82
RE-J2320-2000
XXXXXX
2016-09-06 00:41:51 UTC
1 day, 16 hours, 14 minutes, 17 seconds
0x1:power cycle/failure
0.01
0.04
0.01
I suspect there is a difference between these two outputs and that's the cause, but how can I select only a single value from "show chassis routing-engine"? As I won't be able to match a keyword, I'll need to grab the Xth line from the output, but $result[X] also shows empty value:
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.2R4/junos">
<route-engine-information xmlns="http://xml.juniper.net/junos/10.2R4/junos-chassis">
<route-engine>
<status>OK</status>
<temperature junos:celsius="44">44 degrees C / 111 degrees F</temperature>
<cpu-temperature junos:celsius="48">48 degrees C / 118 degrees F</cpu-temperature>
<memory-system-total>1024</memory-system-total>
<memory-system-total-used>645</memory-system-total-used>
<memory-system-total-util>63</memory-system-total-util>
<memory-control-plane>594</memory-control-plane>
<memory-control-plane-used>327</memory-control-plane-used>
<memory-control-plane-util>55</memory-control-plane-util>
<memory-data-plane>430</memory-data-plane>
<memory-data-plane-used>318</memory-data-plane-used>
<memory-data-plane-util>74</memory-data-plane-util>
<cpu-user>0</cpu-user>
<cpu-real-time>12</cpu-real-time>
<cpu-system>6</cpu-system>
<cpu-idle>82</cpu-idle>
<model>RE-J2320-2000</model>
<serial-number>XXXXXX</serial-number>
<start-time junos:seconds="1473122511">2016-09-06 00:41:51 UTC</start-time>
<up-time junos:seconds="144707">1 day, 16 hours, 11 minutes, 47 seconds</up-time>
<last-reboot-reason>0x1:power cycle/failure </last-reboot-reason>
<load-average-one>0.07</load-average-one>
<load-average-five>0.06</load-average-five>
<load-average-fifteen>0.02</load-average-fifteen>
</route-engine>
</route-engine-information>
<cli>
<banner></banner>
</cli>
</rpc-reply>
vs.
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.2R4/junos">
<output>
6/519/525 mbufs in use (current/cache/total)
4/306/310/20640 mbuf clusters in use (current/cache/total/max)
0/128 mbuf+clusters out of packet secondary zone in use (current/cache)
0/0/0/0 4k (page size) jumbo clusters in use (current/cache/total/max)
0/0/0/0 9k jumbo clusters in use (current/cache/total/max)
0/0/0/0 16k jumbo clusters in use (current/cache/total/max)
9K/741K/751K bytes allocated to network (current/cache/total)
0/0/0 requests for mbufs denied (mbufs/clusters/mbuf+clusters)
0/0/0 requests for jumbo clusters denied (4k/9k/16k)
0/3/640 sfbufs in use (current/peak/max)
0 requests for sfbufs denied
0 requests for sfbufs delayed
0 requests for I/O initiated by sendfile
0 calls to protocol drain routines
</output>
<cli>
<banner></banner>
</cli>
</rpc-reply>
Thanks,
Roberts