Community Talk

 View Only
last person joined: yesterday 

Learn how to best utilize the Elevate community and hear first about community updates.
  • 1.  Slax script for rpd

    Posted 05-28-2024 05:52

    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";
     
    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];
     
                    if ($cpu_usage) {
                        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
    ------------------------------