Sponsored Content
Full Discussion: Lightwight Process monitor
Top Forums Shell Programming and Scripting Lightwight Process monitor Post 10553 by LivinFree on Friday 16th of November 2001 06:18:19 AM
Old 11-16-2001
Lightwight Process monitor

We've been having some problems with a specific program in our nightly processing, so I whipped up a little script to run to monitor it, and send an e-mail when it's complete (failure or not). My primary problem is that I cannot modify the binary or the script that calls it, since the developers probably wouldn't be too happy about that. So it has to be stand-alone. My goal is a reliable script, fairly simple, and above all, very lightweight (I don't want to use any more cycles than are absolutely neccessary). Here's what I have running right now:
Code:
#!/usr/bin/sh
trap '' 1
bail_out () {
mail myself@mycompany <<!done
Subject: My_Job has finished
Importance: high
X-Priority: 1


My_Job has finished running.
If {program) reports that the process is still running, there
may be a problem. Go to \\\\path_to\samba_share and make sure that
the file is an appropriate size before continuing with the
{other_program} jobs.

Call somebody right away if there is a problem.
.
!done
exit 0
}
check_it () {
while :
do
ps -e | grep [M]y_Job >/dev/null 2>&1
case $? in
0) sleep 120 ;;
*) bail_out; exit 1 ;;
esac
done
}
check_it&

I want to be able to let other night operators run this during the weekend (that's why I wrote the instruction in the mail). Also, since none of them are very Unix literate (we only have a few Unix servers around - we're mostly NT), I wanted to make it simple to run. Just type name_of_script, and it'll background itself...

My question is: Can this be written to take even less resources?

Oh yeah, BTW, in case people are wondering:
This is a midrange HP-UX server in a key production environment...
 

10 More Discussions You Might Find Interesting

1. Programming

How to monitor if a process is running

I would like to know if i can monitor if a process is running. I have one program wich is running all the time, called oliba, but sometimes it goes down, and I have to launch it again. Is there a way to monitor the pid of the program, and if the program goes down, to lauch it again? Can you give... (3 Replies)
Discussion started by: Pedro Tavares
3 Replies

2. Shell Programming and Scripting

not able to monitor the process

hi all I am running a script monitor using source command. the shell script monitor is used to execute a pl/sql procedure. when i do source monitor and then ps -ef | grep <procedure name> i do not get any info but when i do sh monitor and then ps -ef | grep <procedure name> i... (8 Replies)
Discussion started by: infyanurag
8 Replies

3. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

4. UNIX for Dummies Questions & Answers

Monitor Memory of a process

Hi, I need to monitor the memory usage of a particular process continuously. As of now I am using the following command: ps -fu <user name> -o pid,comm,vsz | grep <process_name> | grep -v grep The output of this command gives me what i need except i want the output to keep getting updated... (3 Replies)
Discussion started by: archana485
3 Replies

5. UNIX for Advanced & Expert Users

code to monitor a process

hi, I need to change the code such that it becomes configurable to send email or sms or both. At the moment the code works like sending both email and sms for any alert now want to change it to send email/sms as per my demand. 1. Like for a particular alert I only want email 2. If the alert... (2 Replies)
Discussion started by: madfox
2 Replies

6. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

7. Shell Programming and Scripting

Script to Monitor a Process with Top.

Hi, I have written a script to monitor a Process with the help of top command. This is my script. ====================== #!/bin/sh DATE=`date +%Y%m%d%H%M%S` HOME=/home/xmp/testing/xmp_report RADIUS_PID=`xms -xmp sh pr | grep "RADIUS.iamsp02ldv" |awk '{ print $3 }'` PSE_PID=`xms -xmp sh... (5 Replies)
Discussion started by: Siddheshk
5 Replies

8. Shell Programming and Scripting

Script to monitor the process

Hi, I need help to monitoring a process using the shell script The same output is below oracle 32578 32577 0 Feb27 ? 00:06:47 java -cp .:lib/ant.jar:lib/ojdbc5.jar:lib/log4j-1.2.17.jar:/ORACLE_HOME/server/lib/wlfullclient.jar:/ORACLE _HOME/server/lib/weblogic.jar:Alerts.jar... (9 Replies)
Discussion started by: ajothi
9 Replies

9. Shell Programming and Scripting

Monitor and restart UNIX process

Hi all, Tearing my hair out..! I have a requirement to monitor and restart a unix process via a simple watchdog script. I have the following 3 scripts that dont work for me.. script 1 (only produces 1 output if process is up or not)... (4 Replies)
Discussion started by: jonnyd
4 Replies

10. Shell Programming and Scripting

Monitor log when Process comes UP

Hi, I need to grep a pattern in the log file of a process and send a mail if pattern found.But I am not able to figure out how do I detect when the process comes UP,it is started several times a day and each time it is started I need to perform this action. Please suggest something. (3 Replies)
Discussion started by: vishal bhargava
3 Replies
monitor(1)							  monitor command							monitor(1)

NAME
monitor - receive logging information from LPD SYNOPSIS
monitor [ -u ] [ -t ] [ port ] DESCRIPTION
The monitor program is a template for a printer status monitoring program. It will open the specified TCP and/or UDP port, and then wait for accounting or other information to be sent. It prints this information on it standard output. OPTIONS
-u wait for connections on the UDP port. -t wait for connections on the TCP port. port Use the specified port number. EXIT STATUS
The following exit values are returned: zero (0) Successful completion. non-zero (!=0) An error occurred. SEE ALSO
lpd.conf(5), lpc(8), lpd(8), checkpc(8), lpr(1), lpq(1), lprm(1), printcap(5), lpd.conf(5), pr(1), lprng_certs(1), lprng_index_certs(1). AUTHOR
Patrick Powell <papowell@lprng.com>. HISTORY
LPRng is a enhanced printer spooler system with functionality similar to the Berkeley LPR software. The LPRng developer mailing list is lprng-devel@lists.sourceforge.net; subscribe by visiting https://lists.sourceforge.net/lists/listinfo/lprng-devel or sending mail to lprng- request@lists.sourceforge.net with the word subscribe in the body. The software is available via http://lprng.sourceforge.net LPRng 2006-12-09 monitor(1)
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy