Operating System - HP-UX
1752786 Members
5952 Online
108789 Solutions
New Discussion

e-mail notification when number of files in directory increases more than 100

 
SOLVED
Go to solution
T Jose
Advisor

e-mail notification when number of files in directory increases more than 100

Hi,

 

I need help on email notification from HP-UX v3 server.

If my /tmp/ftp/incoming folder is having more than 100 files then I should get email allert.

This check should happen every 10min everyday.

 

I have already configured sendmail.

 

thanks n regards,

 

Jos

 

 

P.S. This thread has been moevd from System Administration to HP-UX > languages. - Hp Forum MOderator

4 REPLIES 4
Patrick Wallek
Honored Contributor
Solution

Re: e-mail notification when number of files in directory increases more than 100

This script should get you started:

 

# cat filecount.sh
#!/usr/bin/sh

FILE_COUNT=$(find /tmp/ftp/incoming -type f | wc -l)
if (( $FILE_COUNT > 100 )) ; then
echo "More than 100 files. Current file count: ${FILE_COUNT}" | mailx -s "Incoming FTP File Count" you@yourdomain.com
fi

 

 

 

Put this script in a directory somewhere, make sure it has execute permission set and then run it via cron.

 

0,10,20,30,40,50 * * * * /some/dir/filecount.sh

 

 

T Jose
Advisor

Re: e-mail notification when number of files in directory increases more than 100

Thanks Patrick,

 

Can you please help me with a script with mail notification if my NFS server is not available.

 

Thanks n Regards,

Jos

T Jose
Advisor

Re: e-mail notification when number of files in directory increases more than 100

Hi,

 

Please help me to configure email notification from my NFS client server to send when NFS server is not available

 

Thanks n Regards,

Jos

Bill Hassell
Honored Contributor

Re: e-mail notification when number of files in directory increases more than 100

NFS not available is not easy to detect. If you run bdf or check for a file, it will just hang so your script won't complete.

 

Attached is a general purpose sysadmin alert script that will handle the following conditions:

 

-- CPU load limit exceeded

-- Mountpoints too full

-- NFS not responding

-- ping test

-- Process monitor (not enough or too many)

 

This script is particularly useful in that it prevents sending hundreds of messages when the problem(s) can't be immediately fixed. Each notification starts a timer and if the problem has not been resolved, another message won't be sent until the EMAILFREQ (in minutes) has been exceeded. So even though the script can be run every 5 minutes, only one email per monitored event will be sent during the EMAILFREQ period.

 

Running the script the first time creates the config file automatically. You then edit the config script to turn on whatever features you'd like to monitor. Be sure to put the script in /usr/contrib/bin and make it executable.

 



Bill Hassell, sysadmin