Page 1 of 1

linux rma

Posted: Tue Jan 19, 2016 1:05 pm
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

Posted: Tue Jan 19, 2016 2:23 pm
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

Posted: Wed Jan 20, 2016 3:08 am
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.

Posted: Wed Jan 20, 2016 7:06 am
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]

Posted: Wed Jan 20, 2016 8:35 am
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

Posted: Wed Jan 20, 2016 8:45 am
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