This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

SAM Linux/Unix scripting error

I have a simple SAM Linux/Unix script that when I attempt to run comes back with a scripting error. The return output is there (255965) but it's not being picked up or even seen. I have several other scripts like this which work fine using the same process but this one just doesn't pick up the value. Any thoughts?

Command Line:

perl ${SCRIPT}

Script Body:

$stat = `sudo /opt/vc/bin/getcntr -c natd.pinfo_shmem_free_entries -d vcgwnat.com`;

print "Message: $stat\n";

print "Statistic: $stat\n";

Scripting Error: Script does not contain the expected parameters or is improperly formatted. 'Statistic' missing.

Output: =====================================================

perl /tmp/APM_1422259766.pl

255965

Message:

Statistic:

  • I haven't worked on many perl scripts but when I use Powershell I output the Message and Statistic with a number or description. SAM allows up to 10 different return values.

    e.g.

    print "Message.0: $stat\n";

    print "Statistic.0: $stat\n";

    or

    print "Message.some_description_here: $stat\n";

    print "Statistic.some_description_here: $stat\n";

    This link might help: Linux/Unix Script monitor

  • could you please post a sample output of the command `sudo /opt/vc/bin/getcntr -c natd.pinfo_shmem_free_entries -d vcgwnat.com` that you are running against the machine?

    statistic only accepts integer values afaik

  • Output from machine -

    vcadmin@lasprodvelogw01:~$ sudo /opt/vc/bin/getcntr -c natd.nat_shmem_free_entries -d vcgwnat.com

    892044

    vcadmin@lasprodvelogw01:~$

    SAM output (Statistic value of '0' is from if/then statement below) -

    Output: =====================================================

    perl /tmp/APM_1257760654.pl

    892050

    Message:

    Statistic: 0

    I added a if/then statement to the script to see if anything was being picked up, doesn't appear so.

    pastedImage_0.png

  • I was asked today to update two metrics to a 'preferred' script. While testing, both now display exactly the same issue I've seen previously. The common thread appears to be “/opt/vc/bin/getcntr” for all these scripts. There is output from all scripts but it's not seen - no message, no statistic.

    Tunnel Count: sudo /opt/vc/bin/getcntr -d gwd-mem -c memb.mod_vc_tun_desc_t.obj_cnt

    Route Table Size: sudo /opt/vc/bin/getcntr -d gwd-mem -c memb.mod_gw_route_t.obj_cnt

    Free NAT Table count: sudo /opt/vc/bin/getcntr -c natd.nat_shmem_free_entries -d vcgwnat.com

    Free PAT Table count: sudo /opt/vc/bin/getcntr -c natd.pinfo_shmem_free_entries -d vcgwnat.com

    Tunnel Count Original script:

    vcadmin@laslabvelogw01:~$ sudo /opt/vc/bin/debug.py --ike | wc -l

    14

    SolarWinds Output with same command:

    Output: =======================

    /home/vcadmin/./APM_423238237.pl

    Message: 14

    Statistic: 14

     

    Tunnel Count New script:

    vcadmin@laslabvelogw01:~$ sudo /opt/vc/bin/getcntr -d gwd-mem -c memb.mod_vc_tun_desc_t.obj_cnt

    6

    SolarWinds Output with same command:

    Scripting Error: Script does not contain the expected parameters or is improperly formatted. 'Statistic' missing.

    Output: =======================

    /home/vcadmin/./APM_1399491583.pl

    6

    Message:

    Statistic:


    if/else test to indicate whether SolarWinds is ‘seeing’ any data:

    $stat = `sudo /opt/vc/bin/getcntr -d gwd-mem -c memb.mod_vc_tun_desc_t.obj_cnt`;

    print "Message: $stat\n";

    if ($stat eq ""){

    $stat = 0;

    } else {

    $stat = 1;

    }

    print "Statistic: $stat\n";

    Output: =======================
    perl /home/vcadmin/./APM_2051154199.pl
    6
    Message:
    Statistic: 0

  • Issue resolved. Found this little jewel and all is good.

    To capture a command's STDERR but discard its STDOUT:

        $output = `cmd 2>&1 1>/tmp/answer`;

    So with this -

    $stat = `sudo /opt/vc/bin/getcntr -d gwd-mem -c memb.mod_vc_tun_desc_t.obj_cnt 2>&1 1>/tmp/answer`;

    I get this -

    pastedImage_0.png