- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help
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
06-24-2003 08:56 PM
06-24-2003 08:56 PM
There are 2 java process running on my server.
I want to monitor them:
# ps -ef|grep java
root 20222 1 0 11:38:40 pts/0 0:26 /usr/java1.3.1/bin/../bin/sparc/n
ative_threads/java -classpath /usr/java1.3.1/l
root 20293 20187 0 12:55:05 pts/0 0:00 grep java
root 20173 1 0 11:37:30 pts/0 1:26 /usr/java1.3.1/bin/../bin/sparc/n
ative_threads/java -DproxySet=true -DproxyHost
If any of the 2 java was down, then email to
abc@123.com
Any idea?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 09:08 PM
06-24-2003 09:08 PM
Re: script help
ps -ef | grep java > /tmp/javamon
# You may need something more unique than java, but you'll have to tweak it.
javaproc=`wc -l` /tmp/javamon
if [ javaproc le 3 ] then
mailx -s "java process problem" abc@123.com
fi
there are a lot of better script writers out there. I am certain someone will top me.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 09:12 PM
06-24-2003 09:12 PM
Re: script help
That's easy if you have your Sendmail configured OK!
if ps -ef|grep -v $$|grep "java"
then
echo ""
else
mailx -s "At least one java service is down" abc@123.com fi
Have a good day!
-ux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 09:12 PM
06-24-2003 09:12 PM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 09:12 PM
06-24-2003 09:12 PM
Re: script help
PROC_CHK=$(ps -ef | grep [j]ava | wc -l)
if [ $PROC_CHK -ne 2 ]
then
echo "Jave Processes Running: $PROC_CHK" | mailx -s "Jave Process Problem" abc@123.com
fi
Cheers
Con
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 09:13 PM
06-24-2003 09:13 PM
Re: script help
I will try it later,pls reply so I can give you
10 points if it works. :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 09:18 PM
06-24-2003 09:18 PM
Re: script help
#!/usr/bin/sh
pjavan=ps -ef|grep -v $$|grep -i java |wc -l
if [ $pjavan -ln 2 ]
then
echo "Some msg you want!"|mailx -s "At least one Java process down!" abc@123.com
fi
-ux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 11:06 PM
06-24-2003 11:06 PM
Re: script help
#!/usr/bin/ksh
if [ `ps -ef|grep -v grep|grep -c java` -lt 2 ]
then
/usr/bin/mailx -s "java process down" abc@123.com
fi
Not that it's so different from the other solutions you've had, but people always forget to use the "grep -c" command...
FiX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 11:53 PM
06-24-2003 11:53 PM
Re: script help
when I run your script, it seems hang,
I can not get the mail. any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2003 11:57 PM
06-24-2003 11:57 PM
Solution/usr/bin/mailx -s "java process down" abc@mail.com < filename, if you want a plain body, simply replace the filename with /dev/null.
Kenneth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2003 12:01 AM
06-25-2003 12:01 AM
Re: script help
yes, I have an idea: I'm stoopid ;-P
You need to have a body for the mailx command.
the correct script is:
#!/usr/bin/ksh
if [ `ps -ef|grep -v grep|grep -c java` -lt 2 ]
then
echo "this is what I forgot in the last message"|/usr/bin/mailx -s "java process down" abc@123.com
fi
Sorry, my bad...
FiX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2003 10:52 PM
06-25-2003 10:52 PM
Re: script help
# crontab -e
0,15,30,45 * * * * expr $(ps -ef|grep java|grep -v grep|wc -l) != 2 >/dev/null && mail -s "Java proc. down" abc@123.com