View previous topic :: View next topic |
Author |
Message |
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Mon Oct 02, 2006 12:21 am Post subject: Checking Process on System |
|
|
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 |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Mon Oct 02, 2006 1:36 am Post subject: |
|
|
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 |
|
|
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Mon Oct 02, 2006 3:17 am Post subject: |
|
|
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 |
|
|
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Mon Oct 02, 2006 7:34 am Post subject: |
|
|
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 |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Mon Oct 02, 2006 12:26 pm Post subject: |
|
|
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 |
|
|
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Tue Oct 03, 2006 12:54 am Post subject: |
|
|
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 |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Tue Oct 03, 2006 3:47 am Post subject: |
|
|
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 |
|
Back to top |
|
|
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Tue Oct 03, 2006 4:24 am Post subject: |
|
|
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 |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Tue Oct 03, 2006 4:43 am Post subject: |
|
|
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 |
|
|
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Tue Oct 03, 2006 4:46 am Post subject: |
|
|
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 |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Tue Oct 03, 2006 3:50 pm Post subject: |
|
|
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 |
|
|
binaer
Joined: 28 Feb 2006 Posts: 39
|
Posted: Wed Oct 04, 2006 12:55 am Post subject: |
|
|
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 |
|
|
|