- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Looking for a better Unix Process Monitoring Scrip...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Discussion Boards
Community
Resources
Forums
Blogs
- 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
10-01-2009 10:43 AM
10-01-2009 10:43 AM
We are running a HP-UX Machine on PA/RISC Server. My "uname -r" command reveals that the version is B.11.23 and my "uname -m" command reveals that it is U 9000/800. This Server is running Peoplesoft Applications.
I want to write a script to monitor "BBL" processes, I am using the following command to check the existence of a process. If the count is 0, then I am sending an email to the administrator.
RC=$(ps -ef |grep BBL |grep $USER |grep $INSTANCE |grep -v grep |grep PSUNX|wc -l)
if [ $sendmail -eq 1 ];
then
$MAIL -s "BBL Service Down @ $(hostname)" $ADMINEMAIL
fi
(Note that Variables are already defined earlier.)
Now, the question, is it the same logic used by you? Do you have any other ideas?
Regards
Vijay Chinnasamy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 10:43 AM
10-01-2009 10:43 AM
Re: Looking for a better Unix Process Monitoring Script...
I will assign points. Thank you in advance.
Regards
Vijay Chinnasamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 10:49 AM
10-01-2009 10:49 AM
Re: Looking for a better Unix Process Monitoring Script...
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 10:57 AM
10-01-2009 10:57 AM
Re: Looking for a better Unix Process Monitoring Script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 11:19 AM
10-01-2009 11:19 AM
SolutionInstead of all these 'grep's to discard false matches, use the UNIX95 (XPG4) behavior of 'ps' to grab _exactly_ the process by name you want.
For example, if I want information about the 'cron' caemon:
# UNIX95= ps -C cron -o pid,pid,user,vsz,time,comm
(or) if I don't want output with headings:
# UNIX95= ps -C cron -o pid= -o pid= -o user= -o vsz= -o time= -o comm=
Set the UNIX95 behavior only for the duration of the command line! Hence the space (no semicolon) after the '=' and before the 'ps' command.
See the 'ps' manpages for the arguments you can display with the '-o' format.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 02:10 PM
10-01-2009 02:10 PM
Re: Looking for a better Unix Process Monitoring Script...
Also, Here are the values and the complete script...
###################################
USER=c290100
INSTANCE=ORAC290
MAIL=/usr/bin/mailx
sendmail=$(ps -ef |grep BBL |grep $USER |grep $INSTANCE |grep -v grep |grep PSUNX|wc -l)
if [ $sendmail -eq 1 ];
then
$MAIL -s "BBL Service Down @ $(hostname)" $ADMINEMAIL
fi
###################################
Regards
Vijay Chinnasamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 02:11 PM
10-01-2009 02:11 PM
Re: Looking for a better Unix Process Monitoring Script...
Points will be assigned later when I am ready to close the thread and got as many options possible...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 02:59 PM
10-01-2009 02:59 PM
Re: Looking for a better Unix Process Monitoring Script...
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2009 08:11 PM
10-01-2009 08:11 PM
Re: Looking for a better Unix Process Monitoring Script...
If you know the order of these various words, you can use one grep:
grep "BBL.*$USER.*$INSTANCE.*PSUNX"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2009 06:01 AM
10-02-2009 06:01 AM
Re: Looking for a better Unix Process Monitoring Script...
1) You might save the 'wc -l' pipe using the -c option of the grep command which counts its results.
2) You might use the -u option of the ps command instead of -e :
ps -fu $USER
3) You might also save the 'grep -v grep' pipe by writting :
ps -fu $USER | grep '[B]BL' | ...
so that the 'grep BBL' process be not selected.
4) Except if you intend to reuse the value of the sendmail variable, you might save the use of this variable by directly writting sommething like :
if ! ps -fu $USER | egrep -q "[B]BL.*$INSTANCE.*PSNUX" ; then
$MAIL -s "BBL Service Down @ $(hostname)" $ADMINEMAIL
fi
Otherwise, taking into account Dennis' remark about the order of the words, I would write :
integer sendmail=$( ps -fu $USER | egrep -c "[B]BL.*$INSTANCE.*PSNUX" )
(( sendmail == 0 )) && $MAIL -s "BBL Service Down @ $(hostname)" $ADMINEMAIL
Cheers,
Jean-Philippe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2009 08:55 AM
10-02-2009 08:55 AM
Re: Looking for a better Unix Process Monitoring Script...
Regards
Vijay Chinnasamy