I created a script to retrieve the WCPU of RPD in OIDs, but it's not functioning as expected. Could someone assist me with this?
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 $cmd = <command> "show system processes extensive";
var $out = jcs:invoke($cmd);
var $lines = jcs:break-lines($out);
for-each ($lines) {
if (contains(., "rpd{rpd}")) {
var $pattern = "[0-9]+\s+root\s+[0-9]+\s+[0-9]+\s+[0-9]+[MKG]\s+[0-9]+[MKG]\s+CPU1\s+[0-9]+\s+[0-9]+:[0-9]+\s+([0-9]+\.[0-9]+%)\s+rpd\{rpd\}";
var $match = jcs:regex($pattern, .);
var $cpu_usage = $match[1];
var $rpc = <request-snmp-utility-mib-set> {
<object-type> "integer";
<instance> "RPD_normalized_cpu";
<object-value> $cpu_usage;
};
var $res = jcs:invoke($rpc);
}
}
}
}
------------------------------
VIGNESH KANNAN
------------------------------