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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VM LOGS

Status
Not open for further replies.

dvknn

IS-IT--Management
Mar 11, 2003
94
US
Hi I have a directory, which has bunch of VM logs like this.. (see below)

I want to grep for 'Out Of Memory' in ONLY the latest day files and send a mail.

How can I do that??

-rw-r--r-- 1 t1 t1 127817 Apr 19 07:15 vm_EJBServerVMConfig_9390.log
-rw-r--r-- 1 t1 t1 128832 Apr 19 07:15 vm_EJBServerVMConfig_9389.log
-rw-r--r-- 1 t1 t1 121646 Apr 19 07:15 vm_EJBServerVMConfig_9388.log
-rw-r--r-- 1 t1 t1 122657 Apr 19 07:15 vm_EJBServerVMConfig_9387.log
-rw-r--r-- 1 t1 t1 129014 Apr 19 07:15 vm_EJBServerVMConfig_9386.log
-rw-r--r-- 1 t1 t1 8816 Apr 19 07:15 vm_EJBServerVMConfig_15381.log
-rw-r--r-- 1 t1 t1 8736 Apr 19 07:15 vm_EJBServerVMConfig_15380.log
-rw-r--r-- 1 t1 t1 8736 Apr 19 07:15 vm_EJBServerVMConfig_15379.log
-rw-r--r-- 1 t1 t1 8736 Apr 19 07:15 vm_EJBServerVMConfig_15378.log
-rw-r--r-- 1 t1 t1 8736 Apr 19 07:15 vm_EJBServerVMConfig_15377.log
-rw-r--r-- 1 t1 t1 84777 Apr 23 07:15 vm_EJBServerVMConfig_15490.log
-rw-r--r-- 1 t1 t1 84928 Apr 23 07:15 vm_EJBServerVMConfig_15488.log
-rw-r--r-- 1 t1 t1 86268 Apr 23 07:15 vm_EJBServerVMConfig_15487.log
-rw-r--r-- 1 t1 t1 87318 Apr 23 07:15 vm_EJBServerVMConfig_15486.log
-rw-r--r-- 1 t1 t1 90592 Apr 23 07:15 vm_EJBServerVMConfig_15489.log
-rw-r--r-- 1 t1 t1 8736 Apr 23 07:15 vm_EJBServerVMConfig_22841.log
-rw-r--r-- 1 t1 t1 8736 Apr 23 07:15 vm_EJBServerVMConfig_22838.log
-rw-r--r-- 1 t1 t1 8736 Apr 23 07:15 vm_EJBServerVMConfig_22836.log
-rw-r--r-- 1 t1 t1 8736 Apr 23 07:15 vm_EJBServerVMConfig_22834.log
-rw-r--r-- 1 t1 t1 8741 Apr 23 07:15 vm_EJBServerVMConfig_22918.log
-rw-r--r-- 1 t1 t1 31996 Apr 23 13:48 vm_EJBServerVMConfig_22943.log
-rw-r--r-- 1 t1 t1 34664 Apr 23 13:49 vm_EJBServerVMConfig_22944.log
-rw-r--r-- 1 t1 t1 30040 Apr 23 13:49 vm_EJBServerVMConfig_22947.log
-rw-r--r-- 1 t1 t1 33063 Apr 23 13:49 vm_EJBServerVMConfig_22946.log
-rw-r--r-- 1 t1 t1 31926 Apr 23 13:49 vm_EJBServerVMConfig_22945.log


Thank You,
 
Disclaimer: I am not where I can get to my UNIX box, so this is from memory untested. It should give you the idea.

find . -mtime +0 -name 'vm_EJB*.log' -print | xargs grep -l 'Out Of Memory'

This gives you the name of the file. You then need to pipe it to mail like so:
mail -s &quot;Out of Memory detected&quot; Mike@BobsBigBoy.com < outofmemoryfile.log

If you are looking for the full script, let me know and I will look in the morning. (USA/PA here)
 
Thanks a bunch. Could you please post the script...Also could you please explain the 'find' that you have written (I mean, does it grep the 'Out Of Memory' string from todays' files?)

Thanks again.
 
I will hunt up the script. The short answer on the find:

Find all files created in the current 24 hour period where the name is like 'vm_EJB*.log'. Then in those files look for &quot;Out of Memory&quot; and ignore the case.
 
OK..How can we find the logs created ONLY TODAY..(In the example logs..you may not have the files for today..

These files are created every day. I want to find 'Out Of Memory' string in ONLY todays files.....

 
touch -t $(date +%Y%m%d0000) /tmp/.timestamp
find $FILE -newer /tmp/.timestamp -print | xargs grep 'Out Of Memory'

Now it says look for anything created after midnight this morning and grep it for out of memory. If you want to get specific to a time, man touch and man find. You will see the options available.

-Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top