HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: MRTG and scripting issue
Operating System - HP-UX
1834404
Members
2772
Online
110067
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
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-14-2007 02:37 AM
08-14-2007 02:37 AM
MRTG and scripting issue
Okay - I'm generating stats for lp requests and ftp requests.
Every now and then - the numbers are skewed - way to large...
My script:
#!/bin/sh
# generate mrtg file for stats
SERVER=`uname -n`
MRTGLP=/tmp/iprprt.lp.stats.mrtg
mv /tmp/LPSTATCUR /tmp/LPSTATOLD
LPSTATOLD=`cat /tmp/LPSTATOLD`
LPSTATCUR=`/usr/bin/grep ^End /var/adm/lp/log |wc -l'`
echo $LPSTATCUR>/tmp/LPSTATCUR
LPSTATNEW=`expr $LPSTATCUR - $LPSTATOLD`
echo $LPSTATNEW > $MRTGLP
echo 0 >> $MRTGLP
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGLP
echo $SERVER >>$MRTGLP
MRTGFTP=/tmp/iprdbci.ftp.stats.mrtg
mv /tmp/FTPSTATCUR /tmp/FTPSTATOLD
FTPSTATOLD=`cat /tmp/FTPSTATOLD`
FTPSTATCUR=`/usr/bin/grep FTP /var/adm/syslog/syslog.log |wc -l`
echo $FTPSTATCUR>/tmp/FTPSTATCUR
FTPSTATNEW=`expr $FTPSTATCUR - $FTPSTATOLD`
echo $FTPSTATNEW > $MRTGFTP
echo 0 >> $MRTGFTP
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGFTP
echo $SERVER >>$MRTGFTP
That create 2 files which are uploaded to the MRTG server every 5 minutes.
Contents look like this - most of the time:
# cat /tmp/iprprt.lp.stats.mrtg
18
0
74 days 3:51
svr004
root@pc0004 [ /var/adm/lp ]
# cat /tmp/iprdbci.ftp.stats.mrtg
147
0
74 days 3:51
svr004
On the MRTG server - looking in the log (stat) files, I see numbers like this:
1187041800 344746669 0 51711980689 0
1187041500 51711980689 0 51711980689 0
1187041200 51711980689 0 51711980689 0
1187040900 51711980689 0 51711980689 0
1187040600 51194860884 0 51711980689 0
1187040300 228 0 228 0
1187040000 227 0 228 0
Well - it is pretty obvious that I didn't have 51194860884 ftp connections in 1 5 minute period...
So, I have to manually edit thos files later in order for the graph to look right...
Question is - where did that number come from?
In other words - is my script flawed?
Can it be improved?
No matter how many times I run it manually - I can not duplicate the error...
Rgds...Geoff
Every now and then - the numbers are skewed - way to large...
My script:
#!/bin/sh
# generate mrtg file for stats
SERVER=`uname -n`
MRTGLP=/tmp/iprprt.lp.stats.mrtg
mv /tmp/LPSTATCUR /tmp/LPSTATOLD
LPSTATOLD=`cat /tmp/LPSTATOLD`
LPSTATCUR=`/usr/bin/grep ^End /var/adm/lp/log |wc -l'`
echo $LPSTATCUR>/tmp/LPSTATCUR
LPSTATNEW=`expr $LPSTATCUR - $LPSTATOLD`
echo $LPSTATNEW > $MRTGLP
echo 0 >> $MRTGLP
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGLP
echo $SERVER >>$MRTGLP
MRTGFTP=/tmp/iprdbci.ftp.stats.mrtg
mv /tmp/FTPSTATCUR /tmp/FTPSTATOLD
FTPSTATOLD=`cat /tmp/FTPSTATOLD`
FTPSTATCUR=`/usr/bin/grep FTP /var/adm/syslog/syslog.log |wc -l`
echo $FTPSTATCUR>/tmp/FTPSTATCUR
FTPSTATNEW=`expr $FTPSTATCUR - $FTPSTATOLD`
echo $FTPSTATNEW > $MRTGFTP
echo 0 >> $MRTGFTP
uptime | awk '{print $3,$4,$5}' |sed s/,//g >>$MRTGFTP
echo $SERVER >>$MRTGFTP
That create 2 files which are uploaded to the MRTG server every 5 minutes.
Contents look like this - most of the time:
# cat /tmp/iprprt.lp.stats.mrtg
18
0
74 days 3:51
svr004
root@pc0004 [ /var/adm/lp ]
# cat /tmp/iprdbci.ftp.stats.mrtg
147
0
74 days 3:51
svr004
On the MRTG server - looking in the log (stat) files, I see numbers like this:
1187041800 344746669 0 51711980689 0
1187041500 51711980689 0 51711980689 0
1187041200 51711980689 0 51711980689 0
1187040900 51711980689 0 51711980689 0
1187040600 51194860884 0 51711980689 0
1187040300 228 0 228 0
1187040000 227 0 228 0
Well - it is pretty obvious that I didn't have 51194860884 ftp connections in 1 5 minute period...
So, I have to manually edit thos files later in order for the graph to look right...
Question is - where did that number come from?
In other words - is my script flawed?
Can it be improved?
No matter how many times I run it manually - I can not duplicate the error...
Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2007 06:22 AM
08-14-2007 06:22 AM
Re: MRTG and scripting issue
Okay - turns out it was my mrtg.cfg file - not the incoming date.
I was using options: nopercent,growright,perhour
Well, the data was already being supplied as the difference between the last 5 minute snapshot.
Mrtg by default treats variable as a counter and calculates the difference between the current and the previous value and divides that by the elapsed time between the last two readings to get the value to be plotted.
With the perhour, it was also multiplying that result by 3600!
So, I changed it to: nopercent, growright, gauge
And from the host I do my own calculation to get a "per hour"
LPSTATNEW=`expr \( $LPSTATCUR - $LPSTATOLD \) \* 12`
Rgds...Geoff
I was using options: nopercent,growright,perhour
Well, the data was already being supplied as the difference between the last 5 minute snapshot.
Mrtg by default treats variable as a counter and calculates the difference between the current and the previous value and divides that by the elapsed time between the last two readings to get the value to be plotted.
With the perhour, it was also multiplying that result by 3600!
So, I changed it to: nopercent, growright, gauge
And from the host I do my own calculation to get a "per hour"
LPSTATNEW=`expr \( $LPSTATCUR - $LPSTATOLD \) \* 12`
Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2007 06:57 AM
08-14-2007 06:57 AM
Re: MRTG and scripting issue
See above...
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
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
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP