Alert for monitoring


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Alert for monitoring
# 1  
Old 10-26-2012
Alert for monitoring

Dear All,

I am new to unix scripting, i need to develop a alert system which get trigger when my scripts don't find any *.log file to copy from one directory to other directory.
In detail my scripts run every day and it create a dummy file and check all those *.log file 1 day old and copy them to other directory for processing.
I want to aaply alter if *.log doesn't exist or have not come in for the day.

my code is as below

Code:
touch -t `date +%Y%m%d0000` dummy
find . -newer dummy -type f  |
while read fname
do
  mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
done

How can i check if it has something to copy and do it else email me so that i will be alert.

Any help will be appreciated

Last edited by Scott; 10-26-2012 at 07:43 AM.. Reason: This is the 17th time a moderator has edited one of your posts to add code tags
# 2  
Old 10-26-2012
Hi,

There are several options, check out the "test" and "if" in built variables for your shell.

Or you can check the return code from a command.

Try

Code:
man bash

Regards

Dave
# 3  
Old 10-26-2012
Code:
found=0
touch -t `date +%Y%m%d0000` dummy
for fname in $(find . -newer dummy -type f );do
   found=1
   mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
done
if [ $found -eq 0 ] ; then
   sendmail -t  <<EOM
From: warning@file_host
To: admin@this.site
Subject: Couldn't move file

Dear Me,
This is the text of the mail
.
EOM
fi

# 4  
Old 10-26-2012
Hi,

I tried the solution and have changed from and to part of sendmail. but sendmail is not working can you please tell me is anysetting required for sendmail to work
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Cybersecurity

**ALERT**ALERT* Whats app requesting users to upgrade to latest version as; its vulnerability found.

Hello All, Want to share here an article for Whats app users that team whats app is requesting users to upgrade to its latest version since they have found a vulnerability; where Hacker could turn on a cell's camera, mic and scan messages and emails. Here is an article from "THE VERGE" for... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies

2. What is on Your Mind?

Script to alert with email after a job got successful in monitoring tool

Hi guyz, Please send me a script which is to be sending an automatic email to particular mail id's when a job get complete with status successful. Please send me your script to my mail id : rehan.csjmu@gmail.com Thanks in Advance. ---------- Post updated at 11:33 AM ----------... (1 Reply)
Discussion started by: Rehan Ahmad
1 Replies

3. HP-UX

HP -UX 11.31 monitoring

Hi, i have joined newly as a hp-ux admin... previously worked in linux environment can anyone tell me how to monitor memory and cpu utilization in hpux?? hp-ux is not as flexible as linux as i understand... please help me out by giving the commands needed and way of troubleshooting if the... (12 Replies)
Discussion started by: Prasad@hp-ux
12 Replies

4. Shell Programming and Scripting

Help with a monitoring script

I currently have a shellscript to check the size of a filesystem and email me if the size is over a certain percentage (80%). I have this script on crontab and executes the shell every 10 mins. I have the above in place on 8 servers. It so happens that a file system on one of the servers is... (1 Reply)
Discussion started by: goddevil
1 Replies

5. Infrastructure Monitoring

Alert / Monitoring / Historial Data Open Source

hi guys my boss asked me for a tool to monitor and alert my Linux boxes... and some Win boxes... but not only monitor for high CPU Usage, hign memory usage and so on....he also wants a tool for historical data I mean something like I want to know the CPU Usage and memory usage for the last... (1 Reply)
Discussion started by: karlochacon
1 Replies

6. Linux

Memory monitoring and sending alert mail to users in network using shell script

i m workiing on a shell script which may monitors network memory and send alert to user if it increase a threshold (1 Reply)
Discussion started by: navdeep5673
1 Replies

7. Infrastructure Monitoring

Monitoring and Alert System

hi, i serarch monitoring and alert system. when HDD and services are down. Send email and sms alert to me and help desk. but i don't find any program. Can you help me ? Thanks. (1 Reply)
Discussion started by: oulutas
1 Replies

8. Shell Programming and Scripting

Bash Monitoring Alert Script

Done some google search on this, and I can find a ton that just search for a domain, like yahoo.com, google.com, etc... But I need to take one I found, and modify it to include port number. I have a bunch of apache instances that I manage and it's a pretty consolidated environment, so lots of... (10 Replies)
Discussion started by: cbo0485
10 Replies

9. AIX

Monitoring

Hi Can any one helpe me in obtaining commands , which enables me to know the following : Monitor Storage Monitor RAM & CPU Utilization Monitor Power Supply Best wishes (1 Reply)
Discussion started by: magasem
1 Replies

10. UNIX for Dummies Questions & Answers

ALERT!!! ALERT!!! I messed up the UNIX!!!

Hello If you want a short description read my last thread! I have no root access anymore. No remote access! By user access i get a programm started and when i close it, i got logged off! So I guess I messed up the passwd file! is there a chance of booting a unix system (SCO-UNIX UnixWare... (15 Replies)
Discussion started by: Fwurm
15 Replies
Login or Register to Ask a Question