Sponsored Content
Top Forums Shell Programming and Scripting How to monitor some UNIX process and send notification in every 10 minutes? Post 302948903 by Don Cragun on Friday 3rd of July 2015 11:30:48 PM
Old 07-04-2015
I fail to see how:
Code:
isRunning=`ps -ef | grep -v grep | grep /home/unispool/bin/main`

(which sets the variable isRunning to the lines reported by ps that contain the string /home/unispool/bin/main (not the number of line that contain that string; the actual lines themselves) would ever be a string that is a numeric string equal in value to the number 3. The same thing can be sad for the other two ps pipelines. So, this script is logically equivalent to:
Code:
#!/bin/ksh
while true ; do
      echo "not running"
      mailx -s "Main process not running correctly" biswajit.nitd@yahoo.in < /dev/null
      echo "not running"
      mailx -s "Cserver process not running correctly" biswajit.nitd@yahoo.in < /dev/null
      echo "not running"
      mailx -s "ciserver process not running correctly" biswajit.nitd@yahoo.in < /dev/null
done

which will mostly just fill your mailbox with meaningless messages as fast as your system can run ps, grep twice, and mailx.

If you're trying to count the number of lines produced by ps as filtered by grep in those pipelines, you need to either add a wc -l to the end of the pipeline or add a -c option to the last grep command in the pipeline. (I strongly prefer the latter option since it uses fewer system resources and will run faster.)

But, I fail to see how draining system resources with a continuous loop to slow down your system when it is working well (and to further slow it down and fill up your mailbox rapidly when something isn't running as expected) is a good idea.

Have you considered putting a sleep in your loop (so your system can perform some meaningful work in addition to looking for an imbalance in the three things you seem to think are the only things that matter on your system)?

Have you considered exiting your loop once mail has been sent so you can find one message in your mailbox, fix the problem, and then restart the loop to wait for the next occurrence of a problem?
 

10 More Discussions You Might Find Interesting

1. HP-UX

Event Monitor notification : Severity Serious : what does that mean ???

Hi I received this mail (root) on my hp-ux 11.00. >------------ Event Monitoring Service Event Notification ------------< Notification Time: Thu Mar 22 08:41:28 2007 hostname sent Event Monitor notification information: /storage/events/disks/default/0_0_1_1.0.0 is >= 3. Its current value... (6 Replies)
Discussion started by: touny
6 Replies

2. Shell Programming and Scripting

Killing of a process and send a mail if the process doesnot come up within 2 minutes

Hi Friends, I am new to this forum as well as new to shell scripting. I have a problem here and i need someone to solve this. Let us consider there are two processes(abc & def).There is a script which kills these two processes(i.e killtheprocess abc). Here abc is the argument . There is a... (1 Reply)
Discussion started by: Prince89
1 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. 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

5. UNIX for Dummies Questions & Answers

Send Fault Alarm SMS Every 30 Minutes

Hi All, I am working in telecom sector. I want to send a fault alarm SMS in every 30 min. Ex.. If one alarm come at say 12:00 and its up say upto 18:00.in this case i want to send a SMS to concern person for every half an hour...can you plz suggest me script which will do the same Awaiting for... (0 Replies)
Discussion started by: sususa
0 Replies

6. Shell Programming and Scripting

check postfix deferred mail and send notification script

Hi Guys, I have a postfix server which is deferring emails. Now I need to send notification to a specific email address if: The sender of the deferred email is: abc@example.com Contains specific subjects: a file (/opt/subjects) contains all the subjects in place Then need to send a... (0 Replies)
Discussion started by: linuxrulz
0 Replies

7. Shell Programming and Scripting

Count the size and send notification

Hello, I want to do something simple, I want to count the dir size (du -sh directoryname) and then check if it is over 100GB. If it is more than 100GB I want to send a notification , if it less than 100GB the script can just stop. I know how to count with du -sh and how to send an email... (5 Replies)
Discussion started by: MaRiOsGR
5 Replies

8. 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

9. HP-UX

Critical Sevices and Process to be monitor on UNIX servers

Need to note the list of critical / important services and process need to monitor on unix server always with one line explanation for severity. Thanks in advance. (5 Replies)
Discussion started by: marunmeera
5 Replies

10. Shell Programming and Scripting

How to send a file in UNIX through email which is created only 15 minutes before the current time?

I wanted to send an email to the client whenever there is failed record created in a /feed/HR-76/failed folder after processing of feed file. I can find out with the help of below script that what is the new file created but that file didn't make just 15 minutes before. ... (1 Reply)
Discussion started by: puneetkhullar
1 Replies
comsat(8)						      System Manager's Manual							 comsat(8)

NAME
comsat - The biff server SYNOPSIS
comsat DESCRIPTION
The comsat server receives reports of incoming mail and notifies users who request this service. comsat is invoked by the inetd(8) daemon when it receives messages on a datagram port associated with the biff(1) service specification in /etc/services(4). The datagram contains a 1-line message of the form: user@mailbox-offset If the user specified is logged in and the associated terminal has the owner execute bit turned on (with biff y), offset is used as a seek offset into the file named in mailbox. The first 7 lines or 560 characters of the mes- sage are printed on the user's system. The message excludes mail header lines other than the From or Subject lines. The comsat command always tries to convert incoming mail messages from the mail interchange codeset to the user's application codeset. It determines the mail interchange code first by checking the mail message itself to see if it contains the required information. Otherwise, the system-wide default mail interchange code in the file /usr/lib/mail-codesets will be used. If no such system file exists, no codeset conversion will be performed. The determination of the user's application code in each terminal session is by one of the following methods. The application codeset defined in the user's Asian tty driver. The codeset name stored in the ~/.codesetdevname file, where devname is the name of the terminal device for the current terminal session. You can obtain the value of devname by issuing the tty command. For example, if the tty command returns /dev/ttys8, use ttys8 as the value for devname. The lang valued option defined in $HOME/.mailrc or /usr/share/lib/Mail.rc. FILES
Specifies the command path. Includes information about logged-in users and their associated ttys. File containing mailx subcommands to customize mailx for a specific user. File containing mailx subcommands to change mailx for all users on the system. RELATED INFORMATION
Commands: biff(1), inetd(8), mailx(1), mh(1) Files: services(4), inetd.conf(4), tty(7) delim off comsat(8)
All times are GMT -4. The time now is 06:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy