Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: How-To MRTG bandwidth monitoring utility

  1. #16
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by andrewak View Post
    Can't find .html files. In the specified directory appeared three files:

    mrtg-l.png
    mrtg-m.png
    mrtg-r.png

    and no one .html

    In /opt/etc/mrtg.cfg (which was left 'as-is' after creation) have two uncommented interfaces - eth0, eth1

    Processes snmpd and mrtg are running.

    Any sudgessions how to check what's wrong?

    May be I've not installed some additional libraryes? Can you paste here output of 'ipkg list_installed' from your router?
    hmm, are you sure mrtg has enough rights to write to that directory?
    how long did you wait before checking? it might take 5 minutes

  2. #17
    Quote Originally Posted by wpte View Post
    hmm, are you sure mrtg has enough rights to write to that directory?
    I hope Yes:-)) - mrtg did write three files there. And I did chmod a+w

    Quote Originally Posted by wpte View Post
    how long did you wait before checking? it might take 5 minutes
    I was absent for more then hour - nothing new:-((

    SOLVED

    Commented string 'RunAsDaemon: Yes' in config and started from terminal - it told me what it need - libjpeg & fontconfig packages

    SOLVED

    Anyway thank You for attention

    ONE MORE TIP (I've spend some time to overcome)

    When your uncommenting some interface in mrtg.cfg you MUST remove '#' sign and following SPACE simbol. String '_Target[localhost .....' will be ignored by mrtg
    Last edited by andrewak; 06-03-2010 at 06:45.

  3. #18
    Join Date
    Jul 2010
    Location
    Prague, Czech Republic
    Posts
    10

    Lightbulb

    Some interesting MRTG settings and scripts...

    CPU



    MRTG settings
    Code:
    Target[cpu]: `/opt/etc/mrtg/cpu.sh`
    MaxBytes[cpu]: 500
    Title[cpu]: server CPU Load (5 minute average)
    YLegend[cpu]: Load*100
    ShortLegend[cpu]: load
    Legend1[cpu]: CPU Load (x 100)
    Legend2[cpu]:
    LegendI[cpu]: 1min load
    LegendO[cpu]: 5min load
    PageTop[cpu]: server 5-minute average CPU Load
    Options[cpu]: gauge,nopercent,integer,growright
    cpu.sh
    Code:
    #!/bin/sh
    
    awk </proc/loadavg '{print (100*$1) "\n" (100*$2) }'
    hostname;
    echo "loadavg";
    Memory


    (blue - RAM, green - Swap)

    MRTG settings
    Code:
    Target[memory]: `/opt/etc/mrtg/memory.sh`
    Title[memory]: Mem and Swap Usage
    PageTop[memory]: <h1>Memory and Swap Usage</h1>
    MaxBytes[memory]: 100000000000
    ShortLegend[memory]: B
    YLegend[memory]: Memory
    LegendI[memory]: Swap
    LegendO[memory]: Mem
    Legend1[memory]: Swap
    Legend2[memory]: Mem
    Options[memory]: gauge,growright,nopercent
    memory.sh
    Code:
    #!/bin/sh
    /usr/bin/free | awk '\
    NR==2 {ramUsed = $3 * 1000 }\
    NR==3 {swapUsed = $3 * 1000 }\
    END { print swapUsed "\n" ramUsed "\n0\n0" }'

    Ping



    MRTG settings
    Code:
    Title[ping]: RTT to google.com
    PageTop[ping]: <H1>Round Trip Time</H1>
    Target[ping]: `/opt/etc/mrtg/ping.sh`
    MaxBytes[ping]: 2000
    Options[ping]: growright,unknaszero,nopercent,gauge
    LegendI[ping]: Pkt loss %
    LegendO[ping]: Avg RTT
    YLegend[ping]: RTT (ms)
    ping.sh
    Code:
    #!/bin/sh
    PING="/bin/ping"
    ADDR="google.com"
    DATA=`$PING -c10 $ADDR -q `
    LOSS=`echo $DATA | awk '{print $18 }' | tr -d %`
    echo $LOSS
    if [ $LOSS = 100 ];
            then echo 0
    else
            echo $DATA | awk -F/ '{print $5 }'
    fi
    /opt usage



    MRTG settings
    Code:
    Target[df_opt]: `/opt/etc/mrtg/df_opt.sh`
    Title[df_opt]: /opt usage
    PageTop[df_opt]: <h1>/opt usage</h1>
    MaxBytes[df_opt]: 100000000000
    ShortLegend[df_opt]: M
    YLegend[df_opt]: /opt
    LegendI[df_opt]: Free
    LegendO[df_opt]: Used
    Legend1[df_opt]: Free
    Legend2[df_opt]: Used
    Options[df_opt]: gauge,growright,nopercent
    df_opt.sh
    Code:
    #!/bin/sh
    
    /bin/df | awk '\
    NR==5 {used = $2 / 1024}\
    NR==5 {free = $3 / 1024}\
    END { print free "\n" used "\n0\n0" }'
    /tmp/harddisk usage



    MRTG settings
    Code:
    Target[df_harddisk]: `/opt/etc/mrtg/df_harddisk.sh`
    Title[df_harddisk]: /tmp/harddisk usage
    PageTop[df_harddisk]: <h1>/tmp/harddisk usage</h1>
    MaxBytes[df_harddisk]: 100000000000
    ShortLegend[df_harddisk]: M
    YLegend[df_harddisk]: /tmp/harddisk
    LegendI[df_harddisk]: Free
    LegendO[df_harddisk]: Used
    Legend1[df_harddisk]: Free
    Legend2[df_harddisk]: Used
    Options[df_harddisk]: gauge,growright,nopercent
    df_harddisk.sh
    Code:
    #!/bin/sh
    
    /bin/df | awk '\
    NR==7 {used = $2 / 1024}\
    NR==7 {free = $3 / 1024}\
    END { print free "\n" used "\n0\n0" }'
    Last edited by kolaCZek; 12-11-2010 at 10:55.
    WL-500gPv2 - 1.9.2.7-d-r2381

  4. #19
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Very nice post kolaCZek!
    they all work very well

    Just a note for the memory script: it shows that I'm using 124kb, but according to free that is supposed to be in megabytes

  5. #20
    Quote Originally Posted by andrewak View Post
    Can't find .html files. In the specified directory appeared three files:

    mrtg-l.png
    mrtg-m.png
    mrtg-r.png

    and no one .html

    In /opt/etc/mrtg.cfg (which was left 'as-is' after creation) have two uncommented interfaces - eth0, eth1

    Processes snmpd and mrtg are running.
    i have a similarly problem, i get the 3 files from above and no html. (i waited, restart router several times and after several 10 minute period and still no html)
    Code:
    SNMP running
    [admin@rtn root]$ pss | grep snmpd
      559 pts/0    S+     0:00          \_ grep snmpd
      215 ?        S      0:00 snmpd -c /tmp/snmpd.conf
    
    MRTG running
    [admin@rtn root]$ pss | grep mrtg
      561 pts/0    S+     0:00          \_ grep mrtg
    
    rights for mrtg folder
    [admin@rtn root]$ ls -la /mnt/www/
    total 20
    drwxr--r-- 4 admin root 4096 Dec 12 10:51 .
    drwxr--r-- 5 admin root 4096 Dec 11 21:40 ..
    drwxr-xr-x 3 admin root 4096 Dec 11 23:32 cgi-bin
    -rwxrw-rw- 1 admin root   28 Dec 11 18:28 index.php
    drwxr-xr-x 2 admin root 4096 Dec 12 11:05 mrtg

    my mrtg.cfg file is:
    /mnt/www/mtg - indicated by me because I have lighttpd & samba shares in place. I could not see the interfaces to uncomment ! What do i miss ?
    Code:
    # Created by
    # /opt/bin/cfgmaker --global "WorkDir: /mnt/www/mrtg" --global "RunAsDaemon: Yes" --global "Options[_]: bits,growright" --output /opt/etc/mrtg.cfg public@localhost
    
    
    ### Global Config Options
    
    #  for UNIX
    # WorkDir: /home/http/mrtg
    
    #  or for NT
    # WorkDir: c:\mrtgdata
    
    ### Global Defaults
    
    #  to get bits instead of bytes and graphs growing to the right
    # Options[_]: growright, bits
    
    EnableIPv6: no
    WorkDir: /mnt/www/mrtg
    RunAsDaemon: Yes
    Options[_]: bits,growright
    
    ######################################################################
    # System:
    # Description:
    # Contact:
    # Location:
    ######################################################################
    SOLVED

    Commented string 'RunAsDaemon: Yes' in config and started from terminal - it told me what it need - libjpeg & packages
    1) I've tried with this, but my ipkg says the 2 packs above are installed and up to date (I ran ipkg update first).

    2) i killed the mrtg daemon and started it manually. I get this:
    Code:
    [admin@rtn root]$ /opt/etc/init.d/S99mrtg
    Segmentation fault
    Daemonizing MRTG ...
    
    [admin@rtn root]$ pss | grep mrtg
      579 pts/0    S+     0:00          \_ grep mrtg
      577 ?        Ss     0:00 /opt/bin/perl -w /opt/bin/mrtg /opt/etc/mrtg.cfg

  6. #21
    Unfortunately I've stopped to use mrtg because of hi processor load, but as I remember I can suggest
    Quote Originally Posted by bigphantom View Post
    my mrtg.cfg file is:
    /mnt/www/mtg - indicated by me because I have lighttpd & samba shares in place. I could not see the interfaces to uncomment ! What do i miss ?
    First of all stop mrtg, then rename or remove your mrgt.cfg (as if it just empty) and run:

    /opt/bin/cfgmaker --global "WorkDir: /opt/share/www/mrtg" --global "RunAsDaemon: Yes" --global "Interval: 5" --global "Options[_]: bits,growright" --output /opt/etc/mrtg.cfg public@localhost

    with Your WorkDir.

    This must create new mrtg.cfg with such sections:

    Code:
    ### Interface 1 >> Descr: 'lo' | Name: '' | Ip: '127.0.0.1' | Eth: '' ###
    ### The following interface is commented out because:
    ### * it is a Software Loopback interface
    # 
    # Target[localhost_1]: 1:public@localhost:
    # SetEnv[localhost_1]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo"
    # MaxBytes[localhost_1]: 1250000
    # Title[localhost_1]: Traffic Analysis for 1 -- noone-gateway
    # PageTop[localhost_1]: <h1>Traffic Analysis for 1 -- noone-gateway</h1>
    # 		<div id="sysdetails">
    # 			<table>
    # 				<tr>
    # 					<td>System:</td>
    # 					<td>noone-gateway in Unknown</td>
    # 				</tr>
    # 				<tr>
    # 					<td>Maintainer:</td>
    # 					<td>Administrator</td>
    # 				</tr>
    # 				<tr>
    # 					<td>Description:</td>
    # 					<td>lo  </td>
    # 				</tr>
    # 				<tr>
    # 					<td>ifType:</td>
    # 					<td>softwareLoopback (24)</td>
    # 				</tr>
    # 				<tr>
    # 					<td>ifName:</td>
    # 					<td></td>
    # 				</tr>
    # 				<tr>
    # 					<td>Max Speed:</td>
    # 					<td>10.0 Mbits/s</td>
    # 				</tr>
    # 				<tr>
    # 					<td>Ip:</td>
    # 					<td>127.0.0.1 (localhost.localdomain)</td>
    # 				</tr>
    # 			</table>
    # 		</div>
    This is what you need to uncomment (not all, but what you need).

    Like this - remember that you need to remove leading spaces too:

    Code:
    Target[localhost_4]: 4:public@localhost:
    SetEnv[localhost_4]: MRTG_INT_IP="" MRTG_INT_DESCR="eth1"
    MaxBytes[localhost_4]: 1250000
    Title[localhost_4]: Traffic Analysis for 4 -- noone-gateway
    PageTop[localhost_4]: <h1>Traffic Analysis for 4 -- noone-gateway</h1>
    		<div id="sysdetails">
    			<table>
    				<tr>
    					<td>System:</td>
    					<td>noone-gateway in Unknown</td>
    				</tr>
    				<tr>
    					<td>Maintainer:</td>
    					<td>Administrator</td>
    				</tr>
    				<tr>
    					<td>Description:</td>
    					<td>eth1  </td>
    				</tr>
    				<tr>
    					<td>ifType:</td>
    					<td>ethernetCsmacd (6)</td>
    				</tr>
    				<tr>
    					<td>ifName:</td>
    					<td></td>
    				</tr>
    				<tr>
    					<td>Max Speed:</td>
    					<td>10.0 Mbits/s</td>
    				</tr>
    			</table>
    		</div>
    Quote Originally Posted by bigphantom View Post
    1) I've tried with this, but my ipkg says the 2 packs above are installed and up to date (I ran ipkg update first).
    Then you must comment line:
    #RunAsDaemon: Yes

    in your mrtg.cfg and run

    /opt/bin/mrtg /opt/etc/mrtg.cfg

    you will see the whole process, But I think that your main problem is that you have no interfaces in mrtg.cfg

    Quote Originally Posted by bigphantom View Post

    2) i killed the mrtg daemon and started it manually. I get this:
    Code:
    [admin@rtn root]$ /opt/etc/init.d/S99mrtg
    Segmentation fault
    
    Daemonizing MRTG ...
    
    [admin@rtn root]$ pss | grep mrtg
      579 pts/0    S+     0:00          \_ grep mrtg
      577 ?        Ss     0:00 /opt/bin/perl -w /opt/bin/mrtg /opt/etc/mrtg.cfg
    I think that "Segmentation fault" mean that you shell check (with fsck) your harddisk - I've did it on my linux desktop.

  7. #22
    Simply perfect.

    Working like a charm.
    Cpu load is acceptable.

    Thank you wpte.

    Regards
    Rumen

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Bandwidth Management, static leases not working
    By AugustsZ in forum WL-500w Q&A
    Replies: 1
    Last Post: 12-01-2011, 04:26
  2. Bandwidth management
    By smarttowers in forum WL-500gP Q&A
    Replies: 0
    Last Post: 07-12-2008, 08:13

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •