- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to grep string from the dynamic file and send ...
Categories
Company
Local Language
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
Forums
Discussions
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
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО07-17-2007 10:59 PM
тАО07-17-2007 10:59 PM
How to grep string from the dynamic file and send it by mail on real time
I have a huge file(131 GB ) which is written logs on every secs . I need to capture certain string like 'error' from that logs and wanted to send it by mail whenever encountered with min resource .
Any idea how to do that
Thanx
With regds,
Subrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2007 11:26 PM
тАО07-17-2007 11:26 PM
Re: How to grep string from the dynamic file and send it by mail on real time
grep criteria > file
http://www.hpux.ws/mailfile2
Use the attachment feature of that program to send the file as an attachment. Its production code, fully documented.
perhaps tail -n 500 | grep critera > file
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2007 12:32 AM
тАО07-18-2007 12:32 AM
Re: How to grep string from the dynamic file and send it by mail on real time
we have implemented something similar for monitoring of our Oracle Database log file.
See if you can adapt for your own environment.
file attached.
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2007 12:34 AM
тАО07-18-2007 12:34 AM
Re: How to grep string from the dynamic file and send it by mail on real time
Forgot script.
Also, try to review the size of the "huge file". Not too practical performance wise. You may wish to use the logrotate tool so that it creates better managed file sizes.
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2007 01:25 AM
тАО07-18-2007 01:25 AM
Re: How to grep string from the dynamic file and send it by mail on real time
The following script monitors
# cat filemon.sh
#!/usr/bin/sh
EMAIL=your@email.addr
if [ ${#} -lt 2 ]
then
echo "usage: ${0}
exit 1
fi
MONFILE=${1}
PATFILE=${2}
if [ ! -r ${2} ]
then
echo "error: file ${2} does not exist or is not readable" >&2
exit 2
fi
tail -f ${MONFILE} |&
CPID=${!}
trap "kill -9 ${CPID}" 1 2 3 15
while read -p LINE
do
echo ${LINE} | grep -f ${PATFILE} -F -q -i
RC=${?}
if [ ${RC} -eq 0 ]
then
echo ${LINE} | mailx -m -s "Error!" ${EMAIL:=root}
echo error reported: ${LINE}
fi
done
exit 0
Syntax is:
filemon.sh
where
You can pseudo-daemonize the script via:
# nohup filemon.sh hugefile patfile &
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2007 03:25 AM
тАО07-18-2007 03:25 AM
Re: How to grep string from the dynamic file and send it by mail on real time
Note that I have intentionally not written the code for you because that really does you no favors.