View Full Version : MRTG Config ??
spiderman 09-07-2001, 02:09 PM I am trying to install MRTG on my server. I have installed all LIBRARY and compiled MRTG. Right now, I am trying setup the configuration. When when I type in the following command. It returns "bash: cfgmaker: command not found"
cfgmaker --global 'WorkDir: /home/httpd/mrtg' \
--global 'Options[_]: bits,growright' \
--output /home/mrtg/cfg/mrtg.cfg \
community@router.abc.xyz
I would be appreciated if someone could give me a direction.
netserve 09-07-2001, 04:58 PM You've tried the obvious one of putting ./ in front of it?
To be honest last time I set up mrtg I copied the cfg files from the demo sites that were on the links page for mrtg. Seemed a lot quicker and much less hasstle than trying to build them from scratch.
(email me off the site john@domaincity.co.uk and I'll give you some samples if it helps.)
Planet Z 09-07-2001, 05:11 PM Building the config files with cfgmaker is easy. All you really need to do is modify the given line with the right directories and IPs.
Inspa.net 09-09-2001, 12:06 PM Make sure you're in mrtg-2/bin and not just mrtg-2, and also make sure you run ./configure just in case :).
You'll also need to make sure you set the right name(hint:- community@router.blah is wrong. It'll probably be public@yourname.com).
The settings should be in snmpd.conf - try running snmpwalk and see what it kicks up.
Good link (http://people.ee.ethz.ch/~oetiker/webtools/mrtg/unix-guide.html) for MRTG on Linux. Also make sure you're running the snmpd daemon, else Linux won't get any info off your server. I set up my first MRTG config 2 days ago - I thought it would go smoother than it did :rolleyes: :).
Good luck!
--Rich
RutRow 09-09-2001, 09:08 PM Also make sure you're running the snmpd daemon, else Linux won't get any info off your server
You DON'T need SNMPD running on your box to get MRTG stats. Why open the security hole? You can grab the info easily from /proc/net/dev using a simple shell script.
Fremont Servers 09-09-2001, 09:24 PM I haven't installed MRTG before, but is it really hard to install if you follow the instruction at www.mrtg.org?
Fremont Servers 09-10-2001, 01:48 AM I just tried to install MRTG, and I too got stuck on cfgmaker part.
If you have Linux 7.1, do you need to install other scripts listed on MRTG Installation for Linux? I read something in there that most likely it is already installed if you are on BSD or Linux.
RutRow 09-10-2001, 10:03 AM Here is a sample mrtg.conf file:
WorkDir: /home/mrtg/public_html/
Target[mrtg]: `/home/mrtg/bin/getstats.sh`
MaxBytes[mrtg]: 96000
Title[mrtg]: Traffic Analysis for my computer
PageTop[mrtg]: <H1>Traffic Analysis for my computer</H1>
XSize[mrtg]: 400
YSize[mrtg]: 200
Options[mrtg]: growright, bits
Here is a simple script get the output mrtg wants:
#!/bin/bash
# Get transmit and receive bytes.
#
INFO=`grep eth0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
# Get uptime.
#
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
# Final output to MRTG
#
echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "MY_SERVER"
You will need to modify:
WorkDir, to reflect where you want your html output.
Target, to point to the script shown above.
Also, read about all the config options on their web page for further customization.
netserve 09-12-2001, 05:09 PM hmmm...
I like the little bash script and have it working via the command line. Problem is that mrtg isn't picking up all of the date from it.
http://mrtg.nsnoc.com/eth0/mrtg.html
It's been typical. I've got several scripts for use with MRTG all producing 4 lines of output stats but once I get the config file set up I'm only getting part of the output.
Someone must have seen this before, any clues?
RutRow 09-12-2001, 10:38 PM I am not sure what you mean by "all of the date". What part of the date are you missing? Your page looks normal to me, except that you probably want to change the MY_SERVER part in the script, and that you also need to copy the *.png files over from the source dist, into the dir where your html output is located. This will fix the missing images at the bottom of the page.
netserve 09-13-2001, 03:41 PM 'date' should have been 'data'
I think I've fixed the problem.
I think that I've got ' instead of ` in the cfg files surounding the commands.
Planet Z 09-13-2001, 04:12 PM Originally posted by RutRow
You DON'T need SNMPD running on your box to get MRTG stats. Why open the security hole? You can grab the info easily from /proc/net/dev using a simple shell script.
Since not all OS's have a /proc/net/dev
RutRow 09-13-2001, 08:33 PM Since not all OS's have a /proc/net/dev
Ahh, so true. But you don't have to use /proc/net/dev. You can also use your firewall logging tools to track bits in/out. In fact you could get more specific traffic analysis that way, i.e. traffic on port 80 or any other. Shame on you if you don't have a firewall .. ;)
Fremont Servers 09-14-2001, 12:27 AM Originally posted by RutRow
Here is a sample mrtg.conf file:
WorkDir: /home/mrtg/public_html/
Target[mrtg]: `/home/mrtg/bin/getstats.sh`
MaxBytes[mrtg]: 96000
Title[mrtg]: Traffic Analysis for my computer
PageTop[mrtg]: <H1>Traffic Analysis for my computer</H1>
XSize[mrtg]: 400
YSize[mrtg]: 200
Options[mrtg]: growright, bits
Here is a simple script get the output mrtg wants:
#!/bin/bash
# Get transmit and receive bytes.
#
INFO=`grep eth0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
# Get uptime.
#
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
# Final output to MRTG
#
echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "MY_SERVER"
You will need to modify:
WorkDir, to reflect where you want your html output.
Target, to point to the script shown above.
Also, read about all the config options on their web page for further customization.
Hello,
Is the above script "getstats.sh"?
RutRow 09-14-2001, 12:47 AM Yes, that is what I named it, but you can call it what you want. You would just have to modify the "Target" line in the mrtg.conf file.
Fremont Servers 09-14-2001, 12:53 AM Originally posted by RutRow
Yes, that is what I named it, but you can call it what you want. You would just have to modify the "Target" line in the mrtg.conf file.
Thanks, RutRow
Fremont Servers 09-14-2001, 05:48 AM Originally posted by RutRow
Here is a sample mrtg.conf file:
WorkDir: /home/mrtg/public_html/
Target[mrtg]: `/home/mrtg/bin/getstats.sh`
MaxBytes[mrtg]: 96000
Title[mrtg]: Traffic Analysis for my computer
PageTop[mrtg]: <H1>Traffic Analysis for my computer</H1>
XSize[mrtg]: 400
YSize[mrtg]: 200
Options[mrtg]: growright, bits
Here is a simple script get the output mrtg wants:
#!/bin/bash
# Get transmit and receive bytes.
#
INFO=`grep eth0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
# Get uptime.
#
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
# Final output to MRTG
#
echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "MY_SERVER"
You will need to modify:
WorkDir, to reflect where you want your html output.
Target, to point to the script shown above.
Also, read about all the config options on their web page for further customization.
After I created getstats.sh using the "simple script" above, I put it in "/home/mrtg/bin/getstats.sh"
I also create mrtg.conf and put it in "/home/mrtg/public_html/".
What do I do after this?
netserve 09-14-2001, 06:07 AM Run this
/usr/local/mrtg-2/bin/mrtg /home/mrtg/public_html/mrtg.cfg --logging /var/log/mrtg.log
I'm guessing that /usr/local/mrtg-2/bin/mrtg is the correct path to mrtg.
You'll need to run it at least 3 times. On the first two occasions it will give you some errors about log files but after that they should clear and you should start to see some graphs in your working directory.
Fremont Servers 09-14-2001, 06:24 AM Originally posted by john@domaincity
Run this
/usr/local/mrtg-2/bin/mrtg /home/mrtg/public_html/mrtg.cfg --logging /var/log/mrtg.log
I'm guessing that /usr/local/mrtg-2/bin/mrtg is the correct path to mrtg.
You'll need to run it at least 3 times. On the first two occasions it will give you some errors about log files but after that they should clear and you should start to see some graphs in your working directory.
john@domaincity,
You are up this late?
What do you do after this?
How do you view it via html?
How do you set it to track eack port?
After I tried the command below, I didn't get an error.
/usr/local/mrtg-2/bin/mrtg /home/mrtg/public_html/mrtg.cfg --logging /var/log/mrtg.log
netserve 09-14-2001, 07:14 AM >You are up this late?
It's lunchtime in the UK. :-)
>What do you do after this?
>How do you view it via html?
If you look at the WorkDir via your web browser you should see the reports.
>How do you set it to track eack port?
Run the command as a cron job every 5 or 10 mins.
RutRow 09-14-2001, 09:38 AM Unless you are running mrtg as root, you may have difficulty writing to /var/log, depending on how your system is configured.
Personally, I would choose a different dir for your mrtg.cfg, like /home/mrtg or /etc, but I guess it really doesn't matter. WorkDir does have to point to your html dir, though.
This is what I use for my cron job...
*/5 * * * * /usr/local/mrtg-2/bin/mrtg /home/mrtg/mrtg.conf
If I get some time this weekend, I will create a HOWTO web page that goes through the entire process and explains things a little better.
Fremont Servers 09-14-2001, 10:05 AM Thanks RutRow & john@domaincity,
You know each port on the switch connects to each server.
If I have 5 ports on the switch to connect to 5 servers, how do I measure transfer rate (bandwidth) from each port or each server?
Do I install MRTG (5) times, which is not practical, or how can I configure (1) MRTG installation to measure transfer rate (bandwidth) for these (5) servers?
RutRow 09-14-2001, 10:37 AM That would require SNMP running on either the switch or all of the individual servers. This whole discussion came about, though, because I was offering a solution other than SNMP. It is not difficult, or impractical, to install MRTG on all the individual servers. Heck, it only takes about 5 min per server after you get the first one set up.... privided they are all running httpd.
Fremont Servers 09-14-2001, 02:01 PM If you provide dedicated server service, then install MRTG on each server is not a very good idea. If clients have root access, then they can remove mrtg.
RutRow 09-14-2001, 04:03 PM True, also, they could uninstall SNMP. Your best bet is to monitor at the router or switch level.
Fremont Servers 09-14-2001, 09:07 PM Hello,
Is anyone using 95.pl?
How does it look like?
========
This is a patch to add 95th percentile metering to MRTG. This is not as simple a feature as one might think. MRTG normally saves only one day worth of 5-minute samples. It is not possible to accurately calculate the 95th percentile without having all of the samples for a one month period. In order to calculate the 95th percentile for a 30-day period, it is necessary to save an entire 30 days worth of the 5-minute samples.
My first approach was to figure out the MRTG/rateup source code, and integrate my modification with MRTG. After getting into it, I realized that there was a much simpler "quick hack" that would work fine. So here it is:
95.pl is a program that you run every hour. You can run it more often if you like, but it's not necessary since the 95th percentile usually changes *very* gradually over time. The script first takes a "snapshot" of each MRTG log file, and saves them by date. Then, it goes through each of these snapshot files, which contain all of the 5-minute samples, and sorts the last 30 days worth of data. Finally, it saves the 95th percentile of these data as a file called mrtg_target.95.
Finally, a simple modification to mrtg is all that is needed to incorporate the number into the HTML page
So, here are the files you need. Probably the best place to install 95.pl is wherever you installed mrtg. If you happen to be running MRTG-2.8.6, download the modified version, below. If you're running the latest 2.9.10, download the patch. The changes to MRTG are only two or three lines to incorporate the number stored in the .95 file into the output page. If you want to find the changes, just search for "$nf", "NF", and "95".
95.pl - run this every hour (there are some paths you need to set at the top of the file)
Modified MRTG 2.8.6 - just run this as usual
Patch for mrtg-2.9.10, submitted by Matthew Deatherage. To apply the patch, place it in the same directory as mrtg, and then type: " patch <mrtg-2.9.10_95pct_patch "
Here's an example crontab:
# Run MRTG every five minutes:
*/5 * * * * sadams /www/www.seanadams.com/mrtg /www/www.seanadams.com/mrtg.conf
# Run 95.pl every hour, at one minute past the hour
1 * * * * sadams /www/www.seanadams.com/95.pl
Fremont Servers 09-16-2001, 08:37 PM I got this error after I executed the below command.
Any clue?
================
]# /usr/local/mrtg-2/bin/mrtg /home/mrtg/www/mrtg.cfg
Rateup WARNING: /usr/local/mrtg-2/bin rateup The backup log file for mrtg was invalid as well
Rateup WARNING: /usr/local/mrtg-2/bin rateup Can't remove updating log file
Rateup WARNING: /usr/local/mrtg-2/bin rateup Can't rename mrtg.log to mrtg.old updating log file.
===============
RutRow 09-16-2001, 10:52 PM It is normal to get warning messages the first 2 times you run mrtg.
Fremont Servers 09-16-2001, 11:14 PM Now it works. :D
If you want to record transfer rate (bandwidth) every month, do you save it once every month?
RutRow 09-17-2001, 08:29 PM I prefer to look at the long term trend. My month to month looks pretty much the same, but I guess you could do what ever makes you happy.. :)
Fremont Servers 09-17-2001, 08:39 PM You know services that provide dedicated server and server colocation, they charge month-by-month.
I tried 2 nights to setup MRTG to graph 16 IP adresses (sites) which run over 1 eth card - but i could not get it to run.
It mesured just on the main IP and just the incoming Traffic.
Doh..
Possible to setup MRTG this way so i can monitor all of my sites?
thx
Greets
ZYE
Ohh almost forgot
thx a lot RutRow your solution works fine :D
RutRow 10-11-2001, 09:54 AM You can measure traffic per IP address on one NIC, but I think you will have to use something other than /proc/net/dev. I would suggest setting up ipchains (or similar) rules to count traffic and use a script to extract the required data.
-Rut
Originally posted by RutRow
You can measure traffic per IP address on one NIC, but I think you will have to use something other than /proc/net/dev. I would suggest setting up ipchains (or similar) rules to count traffic and use a script to extract the required data.
-Rut
Yeah i guess i have to go with ipchain solution :bawling: to measure my virtual sites.
Greets
ZYE
Hi Rut,
I think I am almost there using /proc/net/dev
However, I think my /proc/net/dev is different format?
I have
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 704 8 0 0 0 0 0 0 704 8 0 0 0 0 0 0
venet0: 394212 991 0 0 0 0 0 0 394212 991 0 0 0 0 0 0
What changes do I need to make to the getstats.sh script? Thanks a lot.
I just installed mrtg, good info on the install and this forum helped alot also..
small problem
I added /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/bin/mrtg.cfg --logging /var/log/mrtg.log
to crontab set to run every 5 min..
it works great but get an email every 5 min with the following error
====
Option logging requires an argument
====
I deleted the logging feature from crontab to save my inbox but does anybody know what to use for an argument?
example running at
http://www.acelaweb.com/mrtg/mrtg.html
Thanks
Gil
RutRow 10-26-2001, 09:45 AM Myst,
Change these lines:
INFO=`grep venet0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | awk '{print $1}'`
TRANSMIT=`echo $INFO | awk '{print $9}'`
That should work. Let me know.
RutRow 10-26-2001, 09:57 AM gil,
I have not tried logging, but a couple things to check.
Do you have write permission to /var/log?
Also, try re-arranging the command line.... ie
/usr/local/mrtg-2/bin/mrtg --logging
/var/log/mrtg.log /usr/local/mrtg-2/bin/mrtg.cfg
Originally posted by RutRow
gil,
I have not tried logging, but a couple things to check.
Do you have write permission to /var/log?
Also, try re-arranging the command line.... ie
/usr/local/mrtg-2/bin/mrtg --logging
/var/log/mrtg.log /usr/local/mrtg-2/bin/mrtg.cfg
I changed the line and got an interesting email
=====
Usage: mrtg <config-file>
mrtg-2.9.17 is the Multi Router Traffic Grapher.
If you want to know more about this tool, you might want
to read the docs. They came together with mrtg!
Home: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/
=====
The log is not that important to me after seeing what it contained (not much) so I will do without. Thanks for the reply
ReliableServers 10-26-2001, 06:26 PM Which SNMPd do you install on freebsd? Is there a packaged one?...
Thanks
mrtg out (blue) measurement not working
http://www.acelaweb.com/mrtg/mrtg.html
from other logs I know that I am at least doing 60 meg a day, light I know but should still show up on the graph.
I used the script posted earlier in this thread by RutRow with a few changes. anybody have any idea?
Thanks
Gil
conf
---------------------------------
WorkDir: /home/sites/site9/web/mrtg/
Target[mrtg]: `/usr/local/mrtg-2/bin/getstats.sh`
MaxBytes[mrtg]: 193000
Title[mrtg]: Traffic Analysis for Acelaweb
PageTop[mrtg]: <H1>Acelaweb Traffic Analysis</H1>
XSize[mrtg]: 400
YSize[mrtg]: 200
Options[mrtg]: growright, bits
-----------------------------------
script
-----------------------------------
#!/bin/bash
# Get transmit and receive bytes.
#
INFO=`grep eth0 /proc/net/dev | tr -s ' ' ' ' | cut -d: -f2`
RECEIVE=`echo $INFO | cut -d" " -f1`
TRANSMIT=`echo $INFO | cut -d" " -f9`
# Get uptime.
#
UPTIME=`uptime | tr -s ' ' ' ' | cut -d" " -f4-`
# Final output to MRTG
#
echo $RECEIVE
echo $TRANSMIT
echo $UPTIME
echo "Acelaweb"
-----------------------------------
RutRow 10-28-2001, 08:13 PM When you run the script by itself, what is the output?
Also, you may want to make this modification in the script. Under certain circumstances I think the old one may fail.
RECEIVE=`echo $INFO | awk '{print $1}'`
TRANSMIT=`echo $INFO | awk '{print $9}'`
you mean just running this..
/usr/local/mrtg-2/bin/getstats.sh
output is
605073
4
2 days, 6:22, 1 user, load average: 0.07, 0.11, 0.11
Acelaweb
RutRow 10-28-2001, 08:18 PM What is the contents of /proc/net/dev?
sh: /proc/net/dev: Permission denied
guess that answers that now how to fix, cant change permissions on a vitual system file can i
RutRow 10-28-2001, 08:26 PM Try `cat /proc/net/dev`
It appears to me we are grabbing the wrong data from that file.
with that i get
Inter-| Receive | Transmit
face |packets errs drop fifo frame|packets errs drop fifo colls carrier
lo: 237835 0 0 0 0 237835 0 0 0 0 0
eth0: 610847 0 0 0 0 706265 58 0 4 17860 35
eth0:0: 4030 0 0 0 0 15 0 0 0 0 0
but tried to change script ant get errors
with
cat /proc/net/dev
grep: cat: No such file or directory
WARNING: Problem with Externale get '/usr/local/mrtg-2/bin/getstats.sh':
Expected a Number for 'out' but got ''
with
/bin/cat /proc/net/dev
WARNING: Problem with Externale get '/usr/local/mrtg-2/bin/getstats.sh':
Expected a Number for 'out' but got ''
RutRow 10-28-2001, 08:53 PM Hmm.... interesting.
What OS and version is this?
Doesn't appear that your /proc/net/dev contains a "bytes" field. The only thing we can track with yours is "packets".... not all that useful.
Unless you have some other way of tracking bytes, you may have to resort to installing snmp.
Sawwy.. :(
RaQ2 Cobalt OS playing around with the script now, might just be a typo?
using this
--------------
INFO=`grep eth0 `cat /proc/net/dev`| tr -s ' ' ' ' | cut -d: -f2`
--------------
get this
---------------
/usr/local/mrtg-2/bin/getstats.sh: syntax error near unexpected token `|'
/usr/local/mrtg-2/bin/getstats.sh: command substitution: line 1: `| tr -s ' ' ' ' | cut -d: -f2'
RutRow 10-28-2001, 09:08 PM If you change these lines, you can at least track packets in/out..
INFO=`grep eth0 /proc/net/dev | cut -d: -f2`
RECEIVE=`echo $INFO | awk '{print $1}'`
TRANSMIT=`echo $INFO | awk '{print $6}'`
hi, how often does the /proc/net/dev file refresh?
i mean the bytes shown there is total for minute, day, month, or total since reboot?
RutRow 10-29-2001, 12:43 AM Information in /proc is real-time..... provided by the kernel.
but how do i intepret the bytes? is it total per minute?
RutRow 10-29-2001, 04:25 PM It is just bytes...... not 'per' anything. It is just like the odometer on your car; it keeps going up and up until eventually it rolls over.
MRTG runs every 5 min, so it looks at the current bytes and the last bytes, then it takes the difference and divides by 300 sec (5 min). This is bytes/sec, which must be multiplied by 8 to get bits/sec.
anyone has some expirience with graphing CPU, RAM disk and swap file usage maybe also processes... ? would be interesting....
then it is strange...
my host's figure for my bandwidth usage for the month is higher than what is shown in /proc/net/dev when the reverse should be true right?
RutRow 10-30-2001, 10:29 AM You cannot compare the numbers in your /proc/net/dev file to the numbers from your host. You CAN compare your 1 month average from MRTG to your host's numbers. They should be reasonably close.
why is that so? can explain more?
i mean, the figure in /proc/net/dev should be total through history and so should be higher than that given by my host right?
RutRow 10-30-2001, 11:33 PM Yes, it is a total cumulation since your last boot, or since the last time it rolled over...... therefore not a reliable number. MRTG takes the delta between time 0 and 300 seconds later, then logs that data to a running file.
jahsh 11-23-2001, 07:30 PM ok i have it running however am still unable to get the graphs to come up. how do i get the scripts (above) to show graphical representation in html page?
|