LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 02-19-2009, 11:38 AM   #1
zomane
Member
 
Registered: Sep 2005
Location: Bulgaria
Distribution: Debian, CentOS
Posts: 44

Rep: Reputation: 16
Mrtg creates graph for interface, but not for IP


Hello.
I trying to use MRTG to create graphs for every client IP on my gateway, but for some strange reason it creates png and html files, but doesnt get info from script.But it creates graphs and get info from interface script.

System is Debian Etch

This is ls /var/www/mrtg/ -al
PHP Code:
-rw-r--r-- 1 root     root      2373 2009-02-19 19:25 192.168.168.11-day.png
-rw-r--r-- 1 root     root      5901 2009-02-19 19:25 192.168.168.11.html
-rw-r--r-- 1 root     root     48201 2009-02-19 19:25 192.168.168.11.log
-rw-r--r-- 1 root     root      2360 2009-02-19 18:55 192.168.168.11-month.png
-rw-r--r-- 1 root     root     48201 2009-02-19 19:20 192.168.168.11.old
-rw-r--r-- 1 root     root      2272 2009-02-19 19:20 192.168.168.11-week.png
-rw-r--r-- 1 root     root      1653 2009-02-19 00:35 192.168.168.11-year.png
-rw-r--r-- 1 root     root      2753 2009-02-19 19:25 eth0-day.png
-rw-r--r-- 1 root     root      6085 2009-02-19 19:25 eth0.html
-rw-r--r-- 1 root     root     49243 2009-02-19 19:25 eth0.log
-rw-r--r-- 1 root     root      2544 2009-02-19 18:55 eth0-month.png
-rw-r--r-- 1 root     root     49237 2009-02-19 19:20 eth0.old
-rw-r--r-- 1 root     root      2592 2009-02-19 19:20 eth0-week.png
-rw-r--r-- 1 root     root      2668 2009-02-19 00:35 eth0-year.png
-rw-r--r-- 1 root     root      1617 2009-02-19 00:25 eth1-day.png
-rw-r--r-- 1 root     root      6024 2009-02-19 00:25 eth1.html
-rw-r--r-- 1 root     root     48277 2009-02-19 00:25 eth1.log
-rw-r--r-- 1 root     root      1344 2009-02-18 23:55 eth1-month.png
-rw-r--r-- 1 root     root     48269 2009-02-19 00:20 eth1.old
-rw-r--r-- 1 root     root      1509 2009-02-19 00:25 eth1-week.png
-rw-r--r-- 1 root     root      1653 2009-02-18 23:55 eth1-year.png
-rw-r--r-- 1 root     root       538 2009-02-18 23:15 mrtg-l.png
-rw-r--r-- 1 root     root       414 2009-02-18 23:15 mrtg-m.png
-rw-r--r-- 1 root     root      1759 2009-02-18 23:15 mrtg-r.png 
Here is mrtg.cfg

PHP Code:
# This file is for use with mrtg-2.5.4c
WorkDir: /var/www/mrtg
EnableIPv6
no
Options
[_]: bits,growright
Refresh
300
XSize
[eth0]: 600
YSize
[eth0]: 300
RunAsDaemon
Yes
Title
[eth0]: eth0 interface activity
Target
[eth0]: `/usr/local/bin/ifstat.sh eth0`
MaxBytes[eth0]: 1250000
###################################################
WorkDir: /var/www/mrtg
EnableIPv6
no
Options
[_]: bits,growright
Refresh
300
RunAsDaemon
Yes
Title
[192.168.168.11]: 192.168.168.11 traffic
Target
[192.168.168.11]: `/usr/local/bin/checktraffic.sh`
MaxBytes[192.168.168.11]: 1250000
XSize
[192.168.168.11]: 600
YSize
[192.168.168.11]: 300 
This is script for interface graph, mrtg gets everything(traffic,hostname and uptime) from it without problem

PHP Code:
#!/bin/bash
/sbin/ip -s link show dev $1|grep -A 1 RX|tail -n1 |awk '{print $1}'
/sbin/ip -s link show dev $1|grep -A 1 TX|tail -n1 |awk '{print $1}'
echo `uptime | awk '{ print $3,$4,$5 }' | sed 's/,//g'`
echo `
hostname
Script output :

PHP Code:
deb:~# /usr/local/bin/ifstat.sh eth0
484721675
25608561
12 days 2
:09
deb 

Here is script for IP graph, mrtg only create files, but dont put any data in them

PHP Code:
#!/bin/sh
iptables -L traffic_in  -vnx awk '{if (int($1)!=0) print $2}' 
iptables -L traffic_out  -vnx awk '{if (int($1)!=0) print $2}'
echo `uptime | awk '{ print $3,$4,$5 }' | sed 's/,//g'`
echo `
hostname
Script output :
PHP Code:
deb:~# /usr/local/bin/checktraffic.sh 
130887819
5588294
12 days 2
:10
deb 
Not even a word in mrtg.log about wrong paths ,errors ...nothing useful for debuging

Please give me an idea where to search my mistake.

SOLVED:
I dont know why, but when mrtg runs as daemon errors(or at least part of them) doesn't go in log file.So I started mrtg as cronjob and I see where is the problem

PHP Code:
2009-02-20 16:50:02ERRORTarget[192.168.168.11][_OUT_' $target->[1]{$mode} ' did not eval into defined data
/usr/local/bin/checktraffic.shline 2iptablescommand not found
/usr/local/bin/checktraffic.shline 3iptablescommand not found 
In checktraffic iptables was described without full path, so when I change
iptables -L traffic_in -vnx | awk '{if (int($1)!=0) print $2}'
to
/sbin/iptables -L traffic_in -vnx | awk '{if (int($1)!=0) print $2}'
problem was solved.

Last edited by zomane; 02-20-2009 at 11:27 AM. Reason: SOLVED
 
  


Reply

Tags
interface, ip, mrtg


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use mrtg to graph cpu utilization by cores KhurramF Linux - Software 0 04-01-2008 01:50 PM
MRTG Graph Issue predatorz Linux - Software 3 10-06-2007 09:01 PM
problem with mrtg graph orko Linux - Networking 2 02-02-2005 05:31 AM
Statistic MRTG wont show the graph vladimir-dk Linux - Software 4 08-02-2004 09:03 AM
Flat line in MRTG graph orko Linux - Networking 6 06-09-2004 10:40 PM


All times are GMT -5. The time now is 11:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration