Page 1 of 1
Checking Process on System
Posted: Mon Oct 02, 2006 12:21 am
by binaer
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

Posted: Mon Oct 02, 2006 1:36 am
by KS-Soft Europe
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/mfra ... 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
Posted: Mon Oct 02, 2006 3:17 am
by binaer
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?
Posted: Mon Oct 02, 2006 7:34 am
by binaer
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
Posted: Mon Oct 02, 2006 12:26 pm
by KS-Soft
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/mfra ... eshell_cmd
You may use proccnt.sh script as example.
Have tried to modify the Check # Process, but doesn't help.
How exactly you have modified the script?
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
Posted: Tue Oct 03, 2006 12:54 am
by binaer
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
Posted: Tue Oct 03, 2006 3:47 am
by KS-Soft Europe
What output shows you the 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
Posted: Tue Oct 03, 2006 4:24 am
by binaer
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: Select all
#!/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.
Posted: Tue Oct 03, 2006 4:43 am
by KS-Soft Europe
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
Posted: Tue Oct 03, 2006 4:46 am
by binaer
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.
Posted: Tue Oct 03, 2006 3:50 pm
by KS-Soft
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: Select all
#!/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
Posted: Wed Oct 04, 2006 12:55 am
by binaer
Hello Alex
Wow, nice Support, thank you.
Running now with this:
Code: Select all
#!/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