- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Need to Monitor File Writes
Operating System - HP-UX
1753765
Members
6064
Online
108799
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
Discussions
Discussions
Forums
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
тАО08-29-2007 10:52 AM
тАО08-29-2007 10:52 AM
Need to Monitor File Writes
We have an application that writes to a logfile in the /tmp directory. If the application stops functioning, this logfile no longer is written to.
Any suggestions as to how I can monitor this logfile? 'Are You Functioning' writes occur approximately 15 seconds from within the application. Over a 7 day period, the file will grow in size to approximately 200MB.
TIA.
Steve Lowe
Aurora University
Any suggestions as to how I can monitor this logfile? 'Are You Functioning' writes occur approximately 15 seconds from within the application. Over a 7 day period, the file will grow in size to approximately 200MB.
TIA.
Steve Lowe
Aurora University
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2007 11:09 AM
тАО08-29-2007 11:09 AM
Re: Need to Monitor File Writes
Hi Steve:
Look at the manpages for 'touch' and 'sh-posix'.
One way is to create a reference point (file) with 'touch -r' that captures your file's last modification timestamp. Then compare what you last saw with the current value using something like 'myfile -nt reffile'. If the you file has been updated, then your application is running.
Your script can loop, sleeping for 30-seconds; wake-up; compare the file timestamps; update the reference file timestamp to be that of your monitored log if they differ; and return to sleep.
If n-number of loops find that the log timestamp has not changed, email yourself an alert.
Regards!
...JRF...
Look at the manpages for 'touch' and 'sh-posix'.
One way is to create a reference point (file) with 'touch -r' that captures your file's last modification timestamp. Then compare what you last saw with the current value using something like 'myfile -nt reffile'. If the you file has been updated, then your application is running.
Your script can loop, sleeping for 30-seconds; wake-up; compare the file timestamps; update the reference file timestamp to be that of your monitored log if they differ; and return to sleep.
If n-number of loops find that the log timestamp has not changed, email yourself an alert.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2007 11:13 AM
тАО08-29-2007 11:13 AM
Re: Need to Monitor File Writes
You could do an ls -l filename every few minutes and compare the size to the last size. If that is constant then the log has stpped growing:
#!/usr/bin/sh
FILENAME=/aaa/bbb/myfile
typeset -i LAST_SIZE=-1
typeset DELAY=300 # 5 minutes
typeset -i SIZE=0
LAST_SIZE=$(ls -l ${FILENAME} | awk '{print $5}')
while [[ 1 -eq 1 ]] # loop forever
do
sleep ${DELAY}
SIZE=$(ls -l ${FILENAME} | awk '{print $5}')
if [[ ${SIZE} -eq ${LAST_SIZE} ]]
then
echo "File ${FILENAME} ain't growing." >&2
fi
LAST_SIZE=${SIZE}
done
A little checking needs to be done such as does the file exist? but this should get you started.
#!/usr/bin/sh
FILENAME=/aaa/bbb/myfile
typeset -i LAST_SIZE=-1
typeset DELAY=300 # 5 minutes
typeset -i SIZE=0
LAST_SIZE=$(ls -l ${FILENAME} | awk '{print $5}')
while [[ 1 -eq 1 ]] # loop forever
do
sleep ${DELAY}
SIZE=$(ls -l ${FILENAME} | awk '{print $5}')
if [[ ${SIZE} -eq ${LAST_SIZE} ]]
then
echo "File ${FILENAME} ain't growing." >&2
fi
LAST_SIZE=${SIZE}
done
A little checking needs to be done such as does the file exist? but this should get you started.
If it ain't broke, I can fix that.
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP