- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: process monitoring script help...
Operating System - HP-UX
1753359
Members
6338
Online
108792
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2010 01:59 PM
05-24-2010 01:59 PM
Re: process monitoring script help...
ok, lets check this idea little later...
for testing i used this option:
Count=`ps -ef | grep -i $i | grep -v grep | wc -l`
its mailing fine. the second question is what the issue. ie, mailing once when all processes are running fine. i am thinking this idea:
1. processes goes down, it gets updated into the process-to-be-mailed file, it gets mailed.
2. in every loop, it checks for the same list of processes, so, if the file size zero(means, all processes are running fine) then one mail should be sent as "All processes are running fine at `date`"
3. in other loops, it should not send an email even if file size is zero. it looks like we should use a "flag".
please check this idea and help me implement(i am bit good at troubleshooting if there is any script, but not good in writing a new script).
for testing i used this option:
Count=`ps -ef | grep -i $i | grep -v grep | wc -l`
its mailing fine. the second question is what the issue. ie, mailing once when all processes are running fine. i am thinking this idea:
1. processes goes down, it gets updated into the process-to-be-mailed file, it gets mailed.
2. in every loop, it checks for the same list of processes, so, if the file size zero(means, all processes are running fine) then one mail should be sent as "All processes are running fine at `date`"
3. in other loops, it should not send an email even if file size is zero. it looks like we should use a "flag".
please check this idea and help me implement(i am bit good at troubleshooting if there is any script, but not good in writing a new script).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2010 04:33 PM
05-24-2010 04:33 PM
Re: process monitoring script help...
Hi (again) Sekar:
> the second question is what the issue. ie, mailing once when all processes are running fine. i am thinking this idea:
1. processes goes down, it gets updated into the process-to-be-mailed file, it gets mailed.
2. in every loop, it checks for the same list of processes, so, if the file size zero(means, all processes are running fine) then one mail should be sent as "All processes are running fine at `date`"
3. in other loops, it should not send an email even if file size is zero. it looks like we should use a "flag".
For this you could use something like:
# cat ./mymonitor
#!/usr/bin/sh
RSLT=/tmp/MAILER
INPF=/tmp/PROCLIST
WAIT=10 #...wakeup interval in seconds...
OK=0
while true
do
cat /dev/null > ${RSLT}
while read PROC
do
[ -z "$(UNIX95= ps -C ${PROC} -opid=)" ] && echo ${PROC} >> ${RSLT}
done < ${INPF}
if [ -s "${RSLT}" ]; then
echo mailx -s "processes not running" ssundaram22@xyz.com < ${RSLT}
OK=0
elif [ "${SENT}" = 0 ]; then
echo mailx -s "all processes ok" ssundarm22@xyz.com < /dev/null
OK=1
fi
sleep ${WAIT}
done
exit
...
This will run infinitely, waking up every 'WAIT' seconds. Kill the script with a Control_C interrupt. You will need to adjust the variable values to your needs. You will also need to remove the 'echo' statement before the 'mailx' command when you are ready to actually send mail. Using the 'echo' is useful in debugging since you can see what's happening as you start and stop various processes in another session.
When everything works the way you want, you could encapsulate this script in a run-control/start-up wrapper to "daemonize" it.
Regards!
...JRF...
> the second question is what the issue. ie, mailing once when all processes are running fine. i am thinking this idea:
1. processes goes down, it gets updated into the process-to-be-mailed file, it gets mailed.
2. in every loop, it checks for the same list of processes, so, if the file size zero(means, all processes are running fine) then one mail should be sent as "All processes are running fine at `date`"
3. in other loops, it should not send an email even if file size is zero. it looks like we should use a "flag".
For this you could use something like:
# cat ./mymonitor
#!/usr/bin/sh
RSLT=/tmp/MAILER
INPF=/tmp/PROCLIST
WAIT=10 #...wakeup interval in seconds...
OK=0
while true
do
cat /dev/null > ${RSLT}
while read PROC
do
[ -z "$(UNIX95= ps -C ${PROC} -opid=)" ] && echo ${PROC} >> ${RSLT}
done < ${INPF}
if [ -s "${RSLT}" ]; then
echo mailx -s "processes not running" ssundaram22@xyz.com < ${RSLT}
OK=0
elif [ "${SENT}" = 0 ]; then
echo mailx -s "all processes ok" ssundarm22@xyz.com < /dev/null
OK=1
fi
sleep ${WAIT}
done
exit
...
This will run infinitely, waking up every 'WAIT' seconds. Kill the script with a Control_C interrupt. You will need to adjust the variable values to your needs. You will also need to remove the 'echo' statement before the 'mailx' command when you are ready to actually send mail. Using the 'echo' is useful in debugging since you can see what's happening as you start and stop various processes in another session.
When everything works the way you want, you could encapsulate this script in a run-control/start-up wrapper to "daemonize" it.
Regards!
...JRF...
- « Previous
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP