e-mail notification when number of files in directory increases more than 100 (377 Views)
Reply
Advisor
T Jose
Posts: 24
Registered: ‎07-11-2010
Message 1 of 5 (377 Views)
Accepted Solution

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

[ Edited ]

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

Honored Contributor
Patrick Wallek
Posts: 13,787
Registered: ‎06-21-2000
Message 2 of 5 (361 Views)

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

 

 

Advisor
T Jose
Posts: 24
Registered: ‎07-11-2010
Message 3 of 5 (357 Views)

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

Advisor
T Jose
Posts: 24
Registered: ‎07-11-2010
Message 4 of 5 (347 Views)

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

Honored Contributor
Bill Hassell
Posts: 14,225
Registered: ‎05-29-2000
Message 5 of 5 (310 Views)

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

[ Edited ]

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.

 

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.