Operating System - HP-UX
1753546 Members
5491 Online
108795 Solutions
New Discussion

Need to have Mail alerts for Service being Stopped

 

Need to have Mail alerts for Service being Stopped

Hi,


For Example , if my cron service is stopped on server , i want mail alert for same in my mailbox 

can anyone help me with how to configure the same

 

 

P.S. This thread has been moved from General to HP-UX > sysadmin. - Hp Forum Moderator

2 REPLIES 2
Bill Hassell
Honored Contributor

Re: Need to have Mail alerts for Service being Stopped

I have attached a general purpose script called adminalert.sh which has several features including monitoring processes by name. Save it in a scripts directory, make it executable and then run it one time with -c. It will create a commented config file in /etc/adminalert.config like this:

 

    EMAILFREQ=60
    EMAIL=somebody1@mycompany.com
    EMAILFROM=root@mycompany.com
    LogFile=true
    LoadAlert=0                         # Default = 0, change to 1 to enable
       LOADLIMIT=2.0
    DiskFull=0                          # Default = 0, change to 1 to enable
       MOUNTS=/:90,/opt:85,/tmp:90,/var:90
    NFSalert=0                          # Default = 0, change to 1 to enable
       NFSWAITSECS=3
       NFSMOUNTS=/mnt1,/mnt2
    PingTest=0                          # Default = 0, change to 1 to enable
       PINGHOSTS=yoda:4,skywalker,jaba:2:3:20:true,mycon2:4:4:40:false
    ProcMon=0                           # Default = 0, change to 1 to enable
       PROCS=http:2:16,cron,lvmkd:4
    UserLockCheck=0
       LOCKED=root,admin,lp,www,oracle,sapuser,dba

Now edit /etc/adminalert.config and change these lines:

 

EMAILFREQ = minutes between the same message

EMAIL = destination email address. Multiple addresses separated by commas, no spaces

EMAILFROM = a valid reply address to bypass spam filters

 

    EMAILFREQ=60
    EMAIL=somebody1@mycompany.com
    EMAILFROM=root@mycompany.com

 

The variable called ProcMon enables process monitoring.

    ProcMon=1   
       PROCS=cron:1:1

 The cron:1:1 entry means that one and only one copy of cron must be running.

 

Then start this script from a terminal session that will never finish (can't use cron to monitor cron):

# while :
do
   /usr/contrib/bin/adminalert.sh
   sleep 30
done

If cron is disappearing, you may have a very old version that needs a patch.

Or something run by root is killing the cron process.



Bill Hassell, sysadmin
chindi
Respected Contributor

Re: Need to have Mail alerts for Service being Stopped

Hi Bill ,

 

Its an excellent script.

But somehow its not running for one of my process .

 

ps -ef |grep -i str F0004

 

test 28899 1 0 13:31:02 pts/3 0:00 str F0004
rte 28254 1 0 May 21 ? 0:01 str F0004
dfr 3509 16295 1 15:58:12 pts/0 0:00 grep -i F0004
ddk17349 1 0 May 21 ? 0:04 str F0004

 

when am mentioning ;

ProcMon=1
PROCS=F0004:1:2

 

Where do i put second argument "str" ??