![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find one partucular user logs when there are lots of users running on it | ksr.test | UNIX for Advanced & Expert Users | 4 | 10-07-2008 04:39 AM |
| find logs | cromohawk | UNIX for Dummies Questions & Answers | 2 | 10-03-2008 05:27 PM |
| find out the line count over FTP connection | Rita_questions | UNIX for Dummies Questions & Answers | 1 | 03-12-2008 09:25 AM |
| to grep and find the count | arunkumar_mca | UNIX for Dummies Questions & Answers | 4 | 11-12-2007 11:55 AM |
| Find occurances of a directory and count | stringman | Shell Programming and Scripting | 2 | 08-18-2005 04:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
To find out the logs count
Hi,
I am using the below command to find out the mail logs which will grep the repeated message ids: Code:
less /var/log/messages |awk '{print +$6}'| sort | uniq -c | sort -nr
Code:
506 1246382279
404 1246373467
303 1246383457
303 1246382268
300 1246379705
202 1246383452
202 1246383448
202 1246382281
201 1246383456
201 1246382284
201 1246379685
201 1246374656
200 1246383453
Last edited by Yogesh Sawant; 07-01-2009 at 03:33 AM.. Reason: added code tags |
|
||||
|
try:
Code:
count=$(/var/log/messages |awk '{print +$6}'| sort | uniq -c | sort -nr | wc -l)
if [ $count -ge 100 ];then
echo "some body" | mailx -s "WARNING:: Message" "someone@somewhere.com" 2> /dev/null
fi
|
|
||||
|
Hi anchal,
Thank you for your reply. Let me be more specific on my query. Under my /var/log/message, the output will be like Jun 30 09:53:30 server-27 in[28989]: 1246373453|jason@abc.com|djstaffo@yahoo.com|2227|success|1 Jun 30 09:53:31 server-27 in[28989]: 1246373453|jason@abc.com|djstuder@yahoo.com|2227|success|1 Jun 30 09:53:33 server-27 in[28989]: 1246373453|jason@abc.com|djsussma@oakland.edu.uk|2227|success|1 Jun 30 09:53:34 server-27 in[28989]: 1246373453|jason@abc.com|djt1000@aol.com|2227|success|1 Jun 30 09:53:35 server-27 in[28989]: 1246373453|jason@abc.com|djtc7109@aol.com|2227|success|1 Jun 30 09:53:36 server-27 in[28989]: 1246373453|jason@abc.com|djuba9@aol.com|2227|success|1 So, what I am doing is,by using the command, (less /var/log/messages |awk '{print +$6}'| sort | uniq -c | sort -nr), it will give me the ouput as 506 1246373453 404 1246373467 303 1246383457 303 1246382268 300 1246379705 Where: 1246373453 -> 1246373453|jason@abc.com|djstaffo@yahoo.com|2227|success|1 So, the picture of my outcome should be like the output should be redirected to the file and that file should verify the count , if the count exceeds more than of 100, it should send me an email. I hope it make sense. |
|
||||
|
Are you sure you are getting this output:
Code:
506 1246373453 404 1246373467 303 1246383457 303 1246382268 300 1246379705 Code:
1 1246373453|jason@abc.com|djuba9@aol.com|2227|success|1 1 1246373453|jason@abc.com|djtc7109@aol.com|2227|success|1 1 1246373453|jason@abc.com|djt1000@aol.com|2227|success|1 1 1246373453|jason@abc.com|djsussma@oakland.edu.uk|2227|success|1 1 1246373453|jason@abc.com|djstuder@yahoo.com|2227|success|1 1 1246373453|jason@abc.com|djstaffo@yahoo.com|2227|success|1 |
|
||||
|
No, I got only the count and not the email. Okay that not an issue. I am trying with redirecting the output to a file and the file should count which has to be done via shell script. Please help me on this ...
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|