linux rma

Remote Monitoring Agent for Linux, FreeBSD, and other UNIX-like platforms.
Post Reply
Arto
Posts: 3
Joined: Tue Jan 19, 2016 12:56 pm

linux rma

Post by Arto »

I have an agent on Linux machine and I try to check number of processes (total). I use " built in" script for that and it works, but reply is always:
Error: Invalid result (number of processes here).
I get the number of processes, but what is this "Error: Invalid result".
Why is the result invalid???
I also tried with ssh test, but reply is the same
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Linux version?
What exactly script code do you use? Exactly like this?

Code: Select all

#!/bin/sh
if [ $# -ge 1 ]
then
  OS=`uname`
  case $OS in
    AIX)    PLIST='ps -A';;
    Linux)  PLIST='ps -ax';;
    FreeBSD)PLIST='ps -ax';;
    NetBSD) PLIST='ps -ax';;
    OpenBSD)PLIST='ps -ax';;
    SunOS)  PLIST='ps -e';;
    *) echo 'ScriptRes:Unknown:script is not designed for '$OS
       exit;;
  esac
  $PLIST | awk 'BEGIN {count=-1} {count++} END { if (count>'$1') {printf("ScriptRes:Bad:%d\n",count)} else {printf("ScriptRes:Ok:%d\n",count)} }'
else
  echo 'ScriptRes:Unknown:not enough parameters specified'
fi
Arto
Posts: 3
Joined: Tue Jan 19, 2016 12:56 pm

Post by Arto »

ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64

command is:
ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'
(like it is in script manager, SYSTEM: # of processes (total)).

if I run it from server console it works fine, no errors just correct result.
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Code: Select all

ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'
(like it is in script manager, SYSTEM: # of processes (total)). 
1) by default script manager does not have such script, its your own script;
2) its not correct script and it returns invalid result

Please use script I posted above (yesterday) - this script comes with HostMonitor. As you may see it uses special keywords like "ScriptRes:Bad", "ScriptRes:Ok".

Please check the manual: "Requirements to the script" section
http://www.ks-soft.net/hostmon.eng/mfra ... hellscript

Regards
Alex[/quote][/code]
Arto
Posts: 3
Joined: Tue Jan 19, 2016 12:56 pm

Post by Arto »

I tested your script using script Manager "test" button.

if Params field is empty
----------
- Status: Unknown
- Reply: not enough parameters specified
----------

if params field is: <MaxLimit>

awk: cmd. line:1: BEGIN {count=-1} {count++} END { if (count><MaxLimit>) {printf("ScriptRes:Bad:%d\n",count)} else {printf("ScriptRes:Ok:%d\n",count)} }
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: BEGIN {count=-1} {count++} END { if (count><MaxLimit>) {printf("ScriptRes:Bad:%d\n",count)} else {printf("ScriptRes:Ok:%d\n",count)} }
awk: cmd. line:1: ^ syntax error
KS-Soft
Posts: 12869
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

<MaxLimit> is name of the parameter. You should set some specific value - integer NUMBER that tells script when Bad status should be triggered

Regards
Alex
Post Reply