HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- search syslog for errors with perl
Operating System - HP-UX
1827313
Members
4922
Online
109961
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2002 07:56 AM
12-18-2002 07:56 AM
Hi
I have a perl script which searches syslog for error message.In this case i have just used "vmunix" but what i want to be able to do is only list error's for set date.
For example if i run script now it will only check for messages in the last 24 hours.
Regards
Simon
I have a perl script which searches syslog for error message.In this case i have just used "vmunix" but what i want to be able to do is only list error's for set date.
For example if i run script now it will only check for messages in the last 24 hours.
Regards
Simon
Solved! Go to Solution.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2002 04:09 PM
12-18-2002 04:09 PM
Solution
Here's one I wrote:
This requires 2 additional files, one of which is a "filter" file, and the other a list of email addys.
#!/bin/ksh
# Loganalyzer
# July 2002 by C. Vail
# Analyze system logs and email the results
# Arguments to the grep -v command should be placed in
# $FFILE. These is a simple text file with one argument per line.
IAM=`uname -n`
PPATH=/root/work/logs # Path to this file
LPATH=/var/adm/syslog # Path to the log file
MFILE=$PPATH/loganalyzer.mail # List of email addys
FFILE=$PPATH/loganalyzer.filters # Filter file
LFILE=$LPATH/syslog.log # Log file name
TFILE=$PPATH/loganalyzer.tmp # Temporary files
UFILE=$PPATH/loganalyzer.tmp2
if test -f $TFILE
then
rm $TFILE
fi
# This script is designed to run a minute after midnight each day.
# Hence, we need yesterday's date. This gets tricky because of
# end of month and year considerations.
TMONTH=`date -u +%m`
TDAY=`date -u +%d`
if test "$TDAY" = "01"
then
case $TMONTH in
01) MONTH=Dec;YSDAY=31;;
02) MONTH=Jan;YSDAY=31;;
03) MONTH=Feb;YSDAY=28;;
04) MONTH=Mar;YSDAY=31;;
05) MONTH=Apr;YSDAY=30;;
06) MONTH=May;YSDAY=31;;
07) MONTH=Jun;YSDAY=30;;
08) MONTH=Jul;YSDAY=31;;
09) MONTH=Aug;YSDAY=31;;
10) MONTH=Sep;YSDAY=30;;
11) MONTH=Oct;YSDAY=31;;
12) MONTH=Nov;YSDAY=30;;
esac
else
YSDAY=`echo "$TDAY - 1"|bc`
MONTH=`date -u +%b`
fi
case $YSDAY in
1) DAY=" 1";;
2) DAY=" 2";;
3) DAY=" 3";;
4) DAY=" 4";;
5) DAY=" 5";;
6) DAY=" 6";;
7) DAY=" 7";;
8) DAY=" 8";;
9) DAY=" 9";;
*) DAY=$YSDAY
esac
grep "$MONTH $DAY" $LFILE>$TFILE
NUM1=`wc -l $TFILE|awk '{ print $1 }'`
for FILTER in `cat $FFILE`
do
cat $TFILE|grep -v $FILTER>$UFILE
mv $UFILE $TFILE
done
pr -n -t $TFILE>$UFILE
mv $UFILE $TFILE
NUM2=`wc -l $TFILE|awk '{ print $1 }'`
NUM3=`echo "$NUM1 - $NUM2"|bc`
echo "Total Lines: $NUM1 Filtered: $NUM3">>$TFILE
for ADDY in `cat $MFILE`
do
cat $TFILE|mailx -s "{SYSLOG} $IAM" Logs for $MONTH $DAY" $ADDY
done
This requires 2 additional files, one of which is a "filter" file, and the other a list of email addys.
#!/bin/ksh
# Loganalyzer
# July 2002 by C. Vail
# Analyze system logs and email the results
# Arguments to the grep -v command should be placed in
# $FFILE. These is a simple text file with one argument per line.
IAM=`uname -n`
PPATH=/root/work/logs # Path to this file
LPATH=/var/adm/syslog # Path to the log file
MFILE=$PPATH/loganalyzer.mail # List of email addys
FFILE=$PPATH/loganalyzer.filters # Filter file
LFILE=$LPATH/syslog.log # Log file name
TFILE=$PPATH/loganalyzer.tmp # Temporary files
UFILE=$PPATH/loganalyzer.tmp2
if test -f $TFILE
then
rm $TFILE
fi
# This script is designed to run a minute after midnight each day.
# Hence, we need yesterday's date. This gets tricky because of
# end of month and year considerations.
TMONTH=`date -u +%m`
TDAY=`date -u +%d`
if test "$TDAY" = "01"
then
case $TMONTH in
01) MONTH=Dec;YSDAY=31;;
02) MONTH=Jan;YSDAY=31;;
03) MONTH=Feb;YSDAY=28;;
04) MONTH=Mar;YSDAY=31;;
05) MONTH=Apr;YSDAY=30;;
06) MONTH=May;YSDAY=31;;
07) MONTH=Jun;YSDAY=30;;
08) MONTH=Jul;YSDAY=31;;
09) MONTH=Aug;YSDAY=31;;
10) MONTH=Sep;YSDAY=30;;
11) MONTH=Oct;YSDAY=31;;
12) MONTH=Nov;YSDAY=30;;
esac
else
YSDAY=`echo "$TDAY - 1"|bc`
MONTH=`date -u +%b`
fi
case $YSDAY in
1) DAY=" 1";;
2) DAY=" 2";;
3) DAY=" 3";;
4) DAY=" 4";;
5) DAY=" 5";;
6) DAY=" 6";;
7) DAY=" 7";;
8) DAY=" 8";;
9) DAY=" 9";;
*) DAY=$YSDAY
esac
grep "$MONTH $DAY" $LFILE>$TFILE
NUM1=`wc -l $TFILE|awk '{ print $1 }'`
for FILTER in `cat $FFILE`
do
cat $TFILE|grep -v $FILTER>$UFILE
mv $UFILE $TFILE
done
pr -n -t $TFILE>$UFILE
mv $UFILE $TFILE
NUM2=`wc -l $TFILE|awk '{ print $1 }'`
NUM3=`echo "$NUM1 - $NUM2"|bc`
echo "Total Lines: $NUM1 Filtered: $NUM3">>$TFILE
for ADDY in `cat $MFILE`
do
cat $TFILE|mailx -s "{SYSLOG} $IAM" Logs for $MONTH $DAY" $ADDY
done
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP