Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP - Shell scripting with Networker Log FIles

Status
Not open for further replies.

morgaann

Technical User
Aug 16, 2002
47
0
0
CA
HELP!
I am desperately trying to write a unix shell script (sh) to get information from the daemon.log file.

What I am trying to capture from this file is whenever a tape becomes full it writes to this log something like this;

"media notice: dlt7000 tape abc.123 on /dev/rmt/1ubn if full"

I need to capture that message and parse out the name of the tape that I need to feed to the scipt that's to be spawned off. The other issue with this daemon.log file is it doesn't write one file for each day, so I need to make sure that the message I am capturing is from the last 24 hours.

Also there are 7 dlt tape drives so I need to capture this event for each tape drive.

Any help would be appreciated. My scripting skills are VERY limited.

Thanks.

 
Sorry I forgot to mention that I've posted this on the Solaris Forum and with no luck the advice was to try here hoping someone can help.

Thanks.
 
Use "crontab" to schedule everything.
Step 1 -
Copy the existing /usr/lib/newsyslog to "/nsr/log/rotate_nsr_logs".
Edit out the extra BS in this file, but leave a set of entries that pertain to /nsr/logs/daemon.log. You will see what I mean.
Edit the crontab file "crontab -e" and add a new entry:
"10 3 * * * /nsr/log/rotate_nsr_logs"
Editing the crontab is just like using vi, so when you are done, enter ":wq" to exit.
Now your /nsr/logs/daemon.log file will rotate every morning at 10 past 3am. If you don't like 10 past 3am, change it.
Step 2 -
Create a shell script that uses "grep" to look for a string and then emails to a user. It has been a long time since I did any shell scripts, but something like this might work:
vi /nsr/log/check_if_full.sh

#/bin/csh
Mail -s &quot;Tape is full&quot; email_address < grep &quot;is full&quot; /nsr/log/deamon.log

:wq

Change the permissions on the file to make it runable &quot;chmod 755 /nsr/log/check_if_full.sh&quot; and make a new entry in the crontab &quot;15 3 * * * /nsr/log/check_if_full.sh&quot;.
The &quot;email_address&quot; is any valid address in your domain - maybe yours?

Of course, you want to debug the script by running it a few times. And make sure you fake an entry in the daemon.log file to &quot;find&quot; a full tape.

Or,
Buy a tape library and forget about it.
 
Actually syslog should send emails with networker's alerts to root. if you can forward the root's mails to yourself, does it help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top