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

Checking Process on System

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



Joined: 28 Feb 2006
Posts: 39

PostPosted: Mon Oct 02, 2006 12:21 am    Post subject: Checking Process on System Reply with quote

Hello Community

I've now the following "Problem":
we've SpamAssassin on our Machine installed. Now, I want to monitor this. How can I do this?
ps -ax | grep spamd give's me the following:
$ ps -ax | grep spamd
5965 ?? Ss 0:01.14 /usr/bin/spamd -d --allowed-ips=127.0.0.1 --pidfile=/
5972 ?? S 2:13.48 spamd child (perl)
5973 ?? I 0:10.71 spamd child (perl)

Have tried to modify the Check # Process, but doesn't help. I don't need a "MaxLimit", I need a "MinLimit", because min. one Process should run

kind regards
binaer
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Mon Oct 02, 2006 1:36 am    Post subject: Reply with quote

As I see, you have tried Schell script method, right? I would recommend you to use Process test Method:
http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#chkProcess
Just select appropriate RMA agent from "Test By" dropdown, leave "<local computer>" in "Check process on" and enable "Alert when less than 1" spamd "are runnung". It might help.

Regards,
Max
Back to top
View user's profile Send private message Send e-mail Visit poster's website
binaer



Joined: 28 Feb 2006
Posts: 39

PostPosted: Mon Oct 02, 2006 3:17 am    Post subject: Reply with quote

Hello

thank you, for response. Yes, I've tried to using it via Shell-Test and Process-Test. But both doesn't work.

I've now the Process-Test activated. Now, when I enter the following, the response is "0", even the ps -ax shows the output above.

spamd child
spamd
spamc
/usr/bin/spamd

nothing helps. Any more idea?
Back to top
View user's profile Send private message
binaer



Joined: 28 Feb 2006
Posts: 39

PostPosted: Mon Oct 02, 2006 7:34 am    Post subject: Reply with quote

Hello

No, I've not selected it from the List, I've manual entered it. Have now checked using the Drop-Down Box but can't find the Process. ps -A show's me:
ps -A | grep spamd
5965 ?? Ss 0:09.19 /usr/bin/spamd -d --allowed-ips=127.0.0.1 --pidfile=/
26952 ?? S 1:43.01 spamd child (perl)
52908 ?? S 0:19.79 spamd child (perl)
at the same time....

edit: using FreeBSD 5.4
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Mon Oct 02, 2006 12:26 pm    Post subject: Reply with quote

If you are using "ps -A | grep spamd " as a script, then it cannot work because it does not follow the rules.
1) it does not really count the number of processes
2) it does not provide result in correct format
Please read "Requirements to the script" section of the manual
http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#createshell_cmd
You may use proccnt.sh script as example.

Quote:
Have tried to modify the Check # Process, but doesn't help.


How exactly you have modified the script?

Quote:
ps -ax | grep spamd give's me the following:

As you may see proccnt.sh script uses the following command "ps -axco command". What result is produced by this command on your system?

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
binaer



Joined: 28 Feb 2006
Posts: 39

PostPosted: Tue Oct 03, 2006 12:54 am    Post subject: Reply with quote

Good morning

Well, I've modified it in some ways.

First in
ps -ax $1

and after in
ps -ax | grep $1

This was only for Tests and I think, this is wrong

ps -axco command | grep spam
show's me nothing.

ps -axo command | grep spam
show's me:

/usr/bin/spamd -d --allowed-ips=127.0.0.1 --pidfile=/var/run/spamd.pid --max-ch
spamd child (perl)
spamd child (perl)
/usr/bin/spamc
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Tue Oct 03, 2006 3:47 am    Post subject: Reply with quote

What output shows you the command:
Code:
ps -axco command


To use "Process: #of instances" script, you just should find out the correct params for "ps" command. Desired output is one process name on each line without additional information. Just processes's names:
bash
smamd
ps
mingetty
...

Perhaps, "ps -axco command" really does not work on your system, but I am sure, there should be another params, that do the same. Please, run "man ps" to figure it out.

Regards,
MAx
Back to top
View user's profile Send private message Send e-mail Visit poster's website
binaer



Joined: 28 Feb 2006
Posts: 39

PostPosted: Tue Oct 03, 2006 4:24 am    Post subject: Reply with quote

hmm, I think I see the Problem:
$ ps awuxfo command | grep spam
root 8283 2.6 1.3 29112 27516 ?? S 11:33AM 0:47.60 spamd child (per spamd child (perl)
root 5965 0.0 1.0 23056 20416 ?? Ss Mon07AM 0:36.53 /usr/bin/spamd - /usr/bin/spamd -d --allowed-ips=127.0.0.1 --pidfi
root 44032 0.0 1.0 23056 20456 ?? S 12:20PM 0:00.00 spamd child (per spamd child (perl)

When I use the "c"-Option, then only "perl" is displayed. I've now modified the Check Process Script as the follow:

Code:
#!/bin/sh
if [ $# -ge 2 ]
then
  OS=`uname`
  case $OS in
    Linux) PSLIST='ps -eo ucmd';;
    FreeBSD) PSLIST='ps awuxo command | grep';;
    SunOS) PSLIST='ps -eo fname';;
    *) echo 'ScriptRes:Unknown:script is not designed for '$OS
       exit;;
  esac
  $PSLIST | awk 'BEGIN { cnt=0 } $1=="'$1'"{cnt++} \
  END {if (cnt='$2') {printf("ScriptRes:Ok:%d\n",cnt)} else {printf("ScriptRes:Bad:%d\n",cnt)} }'
else
  echo 'ScriptRes:Unknown:not enough parameters specified'
fi


What I want to do? I'd like to Check if the Process "/usr/bin/spamd" is running at the minimum one time.
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Tue Oct 03, 2006 4:43 am    Post subject: Reply with quote

binaer wrote:
What I want to do? I'd like to Check if the Process "/usr/bin/spamd" is running at the minimum one time.

Have you read my previous post? You just need to find out, what params command "ps" uses to show you the list of processes, that contains then NAMES ONLY. Without "root 8283", without "child (per spamd child", without "12:20PM 0:00.00". We do not have FreeBSD 5.4 installed in our environment, so you should do it by yourself. Please, read "man ps" to figure it out. When you will find the appropriate params for command "ps", you should insert it into script instead of "FreeBSD) PSLIST='ps -axco command';;".

Regards,
Max
Back to top
View user's profile Send private message Send e-mail Visit poster's website
binaer



Joined: 28 Feb 2006
Posts: 39

PostPosted: Tue Oct 03, 2006 4:46 am    Post subject: Reply with quote

Hello Max

Yes sure I've read it. But at the Moment, I can't find a Parameter for this. I'll look forward and give you Feedback as soon I've found anything.

Thank you.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Tue Oct 03, 2006 3:50 pm    Post subject: Reply with quote

If you cannot find such option for ps command, then you may modify awk command.
E.g. if "ps -ax" command shows name of the process in 5th row, then you may change
awk 'BEGIN { cnt=0 } $1=="'$1'" {cnt++} END {printf cnt}'
to
awk 'BEGIN { cnt=0 } $5=="'$1'" {cnt++} END {printf cnt}'

So, script may look like
Code:

#!/bin/sh

if [ $# -ne 0 ]
then
  OS=`uname`
  case $OS in
    Linux) PSLIST='ps -eo ucmd';;
    FreeBSD) PSLIST='ps -ax';;
    SunOS) PSLIST='ps -eo fname';;
    *) echo 'ScriptRes:Unknown:script is not designed for '$OS
       exit;;
  esac
  $PSLIST | awk 'BEGIN { cnt=0 } $5=="'$1'" {cnt++} END {printf cnt}'
else
  echo 'Name of the process should be specified'
fi

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
binaer



Joined: 28 Feb 2006
Posts: 39

PostPosted: Wed Oct 04, 2006 12:55 am    Post subject: Reply with quote

Hello Alex

Wow, nice Support, thank you.

Running now with this:
Code:
#!/bin/sh

if [ $# -ne 0 ]
then
  OS=`uname`
  case $OS in
    Linux) PSLIST='ps -eo ucmd';;
    FreeBSD) PSLIST='ps -axo command';;
    SunOS) PSLIST='ps -eo fname';;
    *) echo 'ScriptRes:Unknown:script is not designed for '$OS
       exit;;  esac
  $PSLIST | awk 'BEGIN { cnt=0 } $1=="'$1'"{cnt++} \
  END {if (cnt>='$2') {printf("ScriptRes:Ok:%d\n",cnt)} else {printf("ScriptRes:Bad:%d\n",cnt)} }'
else
  echo 'Name of the process should be specified'
fi


Parameters:
<ProcName> <MinLimit>

kind regards
Pascal
Back to top
View user's profile Send private message
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