KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

linux rma

 
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX
View previous topic :: View next topic  
Author Message
Arto



Joined: 19 Jan 2016
Posts: 3

PostPosted: Tue Jan 19, 2016 1:05 pm    Post subject: linux rma Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12791
Location: USA

PostPosted: Tue Jan 19, 2016 2:23 pm    Post subject: Reply with quote

Linux version?
What exactly script code do you use? Exactly like this?
Code:
#!/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
Back to top
View user's profile Send private message Visit poster's website
Arto



Joined: 19 Jan 2016
Posts: 3

PostPosted: Wed Jan 20, 2016 3:08 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12791
Location: USA

PostPosted: Wed Jan 20, 2016 7:06 am    Post subject: Reply with quote

Code:
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/mframe.htm#tests.htm#createshellscript

Regards
Alex[/quote][/code]
Back to top
View user's profile Send private message Visit poster's website
Arto



Joined: 19 Jan 2016
Posts: 3

PostPosted: Wed Jan 20, 2016 8:35 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12791
Location: USA

PostPosted: Wed Jan 20, 2016 8:45 am    Post subject: Reply with quote

<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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index