Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SNMP & MRTG made in easy (Power Under Control ;)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4, 5, 6  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
tagore
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 77
Location: Uruguay

PostPosted: Sat Jan 10, 2004 6:04 pm    Post subject: Reply with quote

how to add apache stats like your webpage?
Back to top
View user's profile Send private message
NeuralRelay
n00b
n00b


Joined: 04 Sep 2003
Posts: 6

PostPosted: Sat Jan 10, 2004 10:36 pm    Post subject: Reply with quote

khazad-dum wrote:
I think we'll have to wait for the new OID (Object IDentifier) from net-snmp.sf.net for 2.6.x branch.

Work around
cat and cut are your friends :) !!

Code:

root@guardian proc # cat /proc/meminfo  | grep SwapFree | cut -d ' ' -f 8
224884


Look into /proc/meminfo (and /proc/stat or /proc/* too) and cat&cut your $VARIABLES

Code:

Target[localhost.mem]: `cat /proc/meminfo  | grep  |MemTotal cut -d ' ' -f 8`



Enjoy
:-D :-D


When trying to use this for both SwapFree and MemFree, I get this error:

Code:

WARNING: Problem with External get 'cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 7':
   Expected a Number for 'out' but nothing'

ERROR: Target[localhost.swap][_OUT_] ' $$target[0]{$mode} ' did not eval into defined data
WARNING: Skipping Update of localhost.swap, outlast is not defined


Any ideas?
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Mon Jan 12, 2004 8:45 am    Post subject: Reply with quote

Tagore:

For your Apache stats download the

Apache Server Status contrib

from

Code:

http://lab.xpto.org/apache.mrtg/


khazad-dum
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Mon Jan 12, 2004 9:20 am    Post subject: Reply with quote

NeuralRelay:

I've found a mistake in your code:

Code:

 'cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 7'


mrtg use the "simple shell syntax" for get a simple result from code like this:

Code:

`cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 7`


Look the inverse apexes.

Use the key:

AltGr and '

or cut&paste this:

Code:
`cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 8`


Let me know.
khazad-dum
Back to top
View user's profile Send private message
tagore
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 77
Location: Uruguay

PostPosted: Mon Jan 12, 2004 2:28 pm    Post subject: Reply with quote

khazad-dum wrote:
Tagore:

For your Apache stats download the

Apache Server Status contrib

from

Code:

http://lab.xpto.org/apache.mrtg/


khazad-dum


This not work for my, i'get this :

Code:

./apache.mrtg.pl -url http://localhost/server-status?auto -info BUSYSERVERS
Undefined subroutine &main::get called at ./apache.mrtg.pl line 61.

i'm able to view the status page with lynx.

For mysql load recomend this
http://www.bitbybit.dk/mysqlfaq/mrtg-mysql-load/


Cheers.
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Mon Jan 12, 2004 2:46 pm    Post subject: Reply with quote

You need some perl-libs:

Code:

dev-perl/Getopt-Long
dev-perl/libwww-perl
dev-perl/Digest-MD5


Thx for mrtg-mysql link ;)

You know Squdi-mrtg?
http://howto.aphroland.de/HOWTO/MRTG/SquidMonitoringWithMRTG

khazad-dum
Back to top
View user's profile Send private message
tagore
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 77
Location: Uruguay

PostPosted: Mon Jan 12, 2004 4:46 pm    Post subject: Reply with quote

Thx i'm installing libraries
WOW, but not using squid :(

Thx, cheers.
Back to top
View user's profile Send private message
Seather
Apprentice
Apprentice


Joined: 23 May 2003
Posts: 194
Location: South Africa

PostPosted: Wed Jan 28, 2004 12:46 am    Post subject: Reply with quote

Okay, I have set up the default that khazad-dum wrote.

Now I want to run this on my router/gateway to see which box on the local area network uses how much of our bandwidth and when.

Any help on doing this please?
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Wed Jan 28, 2004 9:11 am    Post subject: Reply with quote

Add your hosts (or network too) in snmpd.conf like step 2 at:

https://forums.gentoo.org/viewtopic.php?p=648066#648066

(for example: com2sec local 10.10.10.0/24 public)
Now, restart your /etc/init.d/snmpd and configure your .cfg files like this:

host1.cfg

Code:

/usr/bin/cfgmaker  \
--output=/etc/mrtg/traffic.cfg \
--ifdesc=ip \
--ifref=descr \
--global "WorkDir: /var/www/localhost/mrtg/host1" \
--global "Options[_]: bits,growright" \
public@host1


host2.cfg

Code:

/usr/bin/cfgmaker  \
--output=/etc/mrtg/traffic.cfg \
--ifdesc=ip \
--ifref=descr \
--global "WorkDir: /var/www/localhost/mrtg/host2" \
--global "Options[_]: bits,growright" \
public@host2


and go ahead....
The most important "area" is:

Code:
public@host2


public = Community string (see man snmpd.conf for other options)
@host = Single host

Look man pages for little examples (or post here :-P)

khazad-dum
Back to top
View user's profile Send private message
Seather
Apprentice
Apprentice


Joined: 23 May 2003
Posts: 194
Location: South Africa

PostPosted: Wed Jan 28, 2004 1:04 pm    Post subject: Reply with quote

Sorry for being stupid again,

Went through the mostly-greek manpages again, tried it and still no luck. This is what I have in my /etc/snmp/snmpd.conf at the moment:
Code:
com2sec local     127.0.0.1/32    public
com2sec local     10.10.10.0/24   public
com2sec local     192.168.0.45/24 public
com2sec local     192.168.0.69/24 public

group MyROGroup v1         local
group MyROGroup v2c        local
group MyROGroup usm        local

view all    included  .1                               80

access MyROGroup ""      any       noauth    exact  all    none   none

syslocation MyLocation
syscontact Me <me@somewhere.org>


and the cfgmaker command that I tried to run:
Code:
/usr/bin/cfgmaker  --output=/etc/mrtg/traffic.cfg --ifdesc=ip --ifref=descr --global "WorkDir: /var/www/localhost/htdocs/mrtg/host1" --global "Options[_]: bits,growright" public@host1


If you meant that I have to install snmpd on all of my machines and run it and change public@host1 to say for example public@192.168.0.69, I cannot run snpd on all of the machines unfortunately...

Where am I totally pissing the point?
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Wed Jan 28, 2004 1:45 pm    Post subject: Reply with quote

It's necessary snmpd daemon (or another snmp server) in all the machines that you want to get statistics.

Unfortunally it isn't possible to collect statistics from hosts without snmpd daemon.
Back to top
View user's profile Send private message
Seather
Apprentice
Apprentice


Joined: 23 May 2003
Posts: 194
Location: South Africa

PostPosted: Wed Jan 28, 2004 3:35 pm    Post subject: Reply with quote

Isn't it possible to let snmp count how many packets were sent to a certain ip address?
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Wed Jan 28, 2004 3:43 pm    Post subject: Reply with quote

Is not possible; snmp can only manage (and/or control) machines via snmp query.

But there are many network analyzer on the net (sounds like a sniffer). Surf it (by google, naturally :) ) or try to query @sf.net or @freshmeat.net

khazad-dum
Back to top
View user's profile Send private message
lapaluun
n00b
n00b


Joined: 30 Jan 2004
Posts: 2

PostPosted: Fri Jan 30, 2004 12:18 am    Post subject: Reply with quote

Since I have migrated to kernel 2.6.2-r2, mrtg doesn't show any stats for mem and swap values. Actually, graphs are progressing well, but always returning 0 as "Current Free Memory" details.

However, other informations like CPU or disk usage are updated properly.

I'd like to know if there have been changes in /proc fs with kernel 2.6 versions, that could lead to this problem.
Back to top
View user's profile Send private message
aab1016
n00b
n00b


Joined: 01 Feb 2004
Posts: 66

PostPosted: Sun Feb 08, 2004 3:48 am    Post subject: I do not recieve information Reply with quote

Whats wrong,,, i dont receive anything,,,whyyyy,,,,i configure it like this steps


i
Back to top
View user's profile Send private message
aab1016
n00b
n00b


Joined: 01 Feb 2004
Posts: 66

PostPosted: Sun Feb 08, 2004 4:00 am    Post subject: Nothing Reply with quote

I dont receive nothing,,,,,,,,,,,,,,whats wrong
Back to top
View user's profile Send private message
Strom
n00b
n00b


Joined: 01 Mar 2003
Posts: 36
Location: Estonia, Tallinn

PostPosted: Sun Feb 08, 2004 11:02 pm    Post subject: Reply with quote

I have 2.6.1-love5, and i got swap, mem and such stuff working, but what i havent got working is CPU.
I recive these messages:
Code:

SNMP Error:
no response received
SNMPv1_Session (remote host: "localhost" [127.0.0.1].161)
                  community: "public"
                 request ID: 1521672888
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 487
SNMPGET Problem for ssCpuRawUser.0 ssCpuRawUser.0 sysUptime sysName on public@localhost::::::v4only
 at /usr/bin/mrtg line 1835
WARNING: skipping because at least the query for ssCpuRawUser.0 on  localhost did not succeed
WARNING: no data for ssCpuRawUser&ssCpuRawUser:public@localhost. Skipping further queries for Host localhost in this round.
ERROR: Target[localhost.cpu][_IN_] ' $target->[0]{$mode}  +  $target->[1]{$mode}  +  $target->[2]{$mode} ' (warn): Use of uninitialized value in addition (+) at (eval 6) line 1.
ERROR: Target[localhost.cpu][_OUT_] ' $target->[0]{$mode}  +  $target->[1]{$mode}  +  $target->[2]{$mode} ' (warn): Use of uninitialized value in addition (+) at (eval 7) line 1.
SNMP Error:
no response received
SNMPv1_Session (remote host: "localhost" [127.0.0.1].161)
                  community: "public"
                 request ID: 1142331004
                PDU bufsize: 8000 bytes
                    timeout: 2s

[/                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 487
SNMPGET Problem for sysUptime sysName on public@localhost
 at /usr/bin/mrtg line 518

_________________
This is my signature.
Back to top
View user's profile Send private message
Strom
n00b
n00b


Joined: 01 Mar 2003
Posts: 36
Location: Estonia, Tallinn

PostPosted: Sun Feb 08, 2004 11:20 pm    Post subject: Reply with quote

When i appended
Code:
:::::2
to my targets then i didn't get those errors anymore.
(Now it uses protocol v2)

But the graph doesn't show anything, it's empty .. NO data :(
_________________
This is my signature.
Back to top
View user's profile Send private message
Strom
n00b
n00b


Joined: 01 Mar 2003
Posts: 36
Location: Estonia, Tallinn

PostPosted: Mon Feb 09, 2004 2:52 pm    Post subject: Reply with quote

OK! I got everything workin the way i like it ...
How? Well i just read the whole f--king manual ;)
_________________
This is my signature.
Back to top
View user's profile Send private message
Naspe
Guru
Guru


Joined: 10 Dec 2003
Posts: 321
Location: Genova - Italy

PostPosted: Sat Feb 14, 2004 11:14 pm    Post subject: Reply with quote

Hi all!
Grats for the very nice how-to!

I have some problems/questions:

1 - My mem and swap graphs doesn't work. I have a 2.6.1-gentoo kernel. I tried with this:
Code:
`cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 7`

but i get this message:
Code:
plutone txt # /etc/cron.mrtg/mem.sh
WARNING: Problem with External get 'cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 8':
   Expected a Number for 'out' but nothing'

ERROR: Target[localhost.mem][_OUT_] ' $$target[0]{$mode} ' did not eval into defined data
WARNING: Skipping Update of localhost.mem, outlast is not defined

but in the mem.cfg file the apexes are inverted...
How to make it work? Storm told that mem and swap are working with his 2.61 kernel...

2 - I added the disk usage... but i see the graph move from left to right... others are from right to left... how to change it? And i can't see the disk size...

3 - Is it possible to view info from winsux PC and from other network devices like a Router?

4 - Where should i put the option language? In the cfg files?
_________________
God Is Real... Unless Declared As Integer...

Provoca Il Più Bravo... Morirai Come Uno Schiavo!!!

Hai Evocato Il Tuono!!! Ora Raccogli Tempesta!!!
Back to top
View user's profile Send private message
axxackall
l33t
l33t


Joined: 06 Nov 2002
Posts: 651
Location: Toronto, Ontario, 3rd Rock From Sun

PostPosted: Sun Feb 15, 2004 6:46 am    Post subject: Reply with quote

Excelent guide!

I did not manage to display multiple CPUs individually (SNMP complains on any number if CPU if it is not 0),but I've found more patterns to display more information about CPU usage, namely "User vs Idle CPU usage" and "User vs System CPU usage".

Also I didn't manage to display partition usage (the chart doesn't grow), but I've created my own one for folder sizes. I have two huge folders, one for samba shares, the other for cvs repository and I gotta watch out the growth.

/etc/mrtg/shared.cfg:
Code:

WorkDir: /var/www/localhost/mrtg
Title[localhost.shared]: shared folders
PageTop[localhost.shared]: <H1>Shared Folders</H1>
Target[localhost.shared]: `/etc/mrtg/shared.sh`
MaxBytes[localhost.shared]: 69972132000
kilo[localhost.shared]: 1000
Options[localhost.shared]: growright,unknaszero,nopercent,gauge
LegendI[localhost.shared]: samba
LegendO[localhost.shared]: cvs
Legend1[localhost.shared]: Maximum size in B
Legend2[localhost.shared]: Minimum size in B
Legend3[localhost.shared]: Maximal 5 Minute Maximum size in B
Legend4[localhost.shared]: Maximal 5 Minute Minimum size in B
YLegend[localhost.shared]: size (B)
ShortLegend[localhost.shared]: B


/etc/mrtg/shared.sh:
Code:

#!/bin/sh
du -sk /opt/files /opt/cvs |awk '{print $1"000"}'


The size is not precize - I had too adapt kilobytes to bytes and did not have time for anything smarter. Suggestions for improving it are welcome.

/etc/cron.mrtg/shared.sh:
Code:

#!/bin/sh
/usr/bin/mrtg /etc/mrtg/shared.cfg


I still have to debug why my disk-usage chart from the originally posted guide doesn't grow. Any idea?
_________________
"Lisp is a programmable programming language." - John Foderaro, CACM, September 1991
Back to top
View user's profile Send private message
axxackall
l33t
l33t


Joined: 06 Nov 2002
Posts: 651
Location: Toronto, Ontario, 3rd Rock From Sun

PostPosted: Sun Feb 15, 2004 6:51 am    Post subject: Reply with quote

Another question: how to process disk-related statistics hourly? 5 minutes is a bit too often IMHO. I mean I know how to change crontab, but is it enough? Will it breake anything in MRTG database?

Edit: I found the option for cfg files:
Code:

Interval: 60

And now I run disk statistics from /etc/cron.hourly instead of /etc/cron.mrtg

But now I am facing another problem: if my interval is 60 minutes, then how will it work for week charts where the average is based on 30 minutes?
_________________
"Lisp is a programmable programming language." - John Foderaro, CACM, September 1991


Last edited by axxackall on Sun Feb 15, 2004 7:22 am; edited 2 times in total
Back to top
View user's profile Send private message
axxackall
l33t
l33t


Joined: 06 Nov 2002
Posts: 651
Location: Toronto, Ontario, 3rd Rock From Sun

PostPosted: Sun Feb 15, 2004 7:08 am    Post subject: Reply with quote

I've got various log files growing in my system. Well, they are being rotated. Is it possible to feed such files to MRTG? It would be nice to add stats about mail routing, infection, spam, web-usage and so on.

I am thinking to write some parsing scripts extractig such statistics, it's not actually that big deal, but the problem is in rotating logs after that. Again, it will be too big overhead to rotate logs once each 5 minutes.

Edit: Can I use "Interval: 1440" option for daily updates?
_________________
"Lisp is a programmable programming language." - John Foderaro, CACM, September 1991
Back to top
View user's profile Send private message
lonegd
Apprentice
Apprentice


Joined: 07 Dec 2003
Posts: 185
Location: UK

PostPosted: Sat Feb 21, 2004 9:25 pm    Post subject: Reply with quote

Anyone have an example config for monitoring disk IO read/write's??? :)
_________________
Mark Cooper
http://pvrhw.goldfish.org/ - Open Source PVR Hardware Database
Back to top
View user's profile Send private message
khazad-dum
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 148
Location: Moria

PostPosted: Mon Feb 23, 2004 5:19 pm    Post subject: Reply with quote

Folks,

i've finally get memory stat with 2.6 kernel IN MY MACHINE

Code:

guardian proc # cat meminfo
MemTotal:       321380 kB
MemFree:          6760 kB
Buffers:         14052 kB
Cached:         145624 kB
SwapCached:       7076 kB
Active:         167652 kB
Inactive:        86192 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       321380 kB
LowFree:          6760 kB
SwapTotal:      248968 kB
SwapFree:       229056 kB
Dirty:               0 kB
Writeback:           0 kB
Mapped:         125376 kB
Slab:            57784 kB
Committed_AS:   137320 kB
PageTables:       1116 kB
VmallocTotal:   712504 kB
VmallocUsed:       284 kB
VmallocChunk:   712116 kB


Memory
Code:

guardian proc # cat /etc/mrtg/mem2.sh
#!/bin/sh
cat /proc/meminfo | grep MemTotal | cut -d ' ' -f 8
cat /proc/meminfo | grep MemFree | cut -d ' ' -f 11


Code:

guardian proc #  /etc/mrtg/mem2.sh
321380
6760


Swap
Code:

guardian proc # cat /etc/mrtg/swap2.sh
#!/bin/sh
cat /proc/meminfo | grep SwapFree | cut -d ' ' -f 8
cat /proc/meminfo | grep SwapTotal | cut -d ' ' -f 7


Code:

guardian proc #  /etc/mrtg/swap2.sh
248968
229056


This is a workaround. A bug request is opened at official snmp-net mailing list. A "little" info here:

Memory support missing for linux 2.6
The 2.6 kernel changed the /proc/stat interface, breaking memory statistics.
http://sourceforge.net/mailarchive/message.php?msg_id=7091107

IMPORTANT: man cut !!! The value of fields are different for every /proc/stat.

REMEMBER:
Code:

guardian contrib # pwd
/usr/doc/mrtg-2.9.29/contrib
guardian contrib # ls
00INDEX.gz         ascendget           distrib              ircstats2             mrtg.php         portmasters
14all              atmmaker            gentcucci-1.0.0      jm                    mrtg_php_portal  procmem
GetSNMPLinesUP     cfgmaker_ATM        get-active           linux_stat            mrtgidx          rdlog2
IxDisk             cfgmaker_cisco      get-equi             meminfo               mrtgindex.cgi    routers
NSI                cfgmaker_dlci       get-multiserial      monitor               mrtglog          rumb-stat
PMLines            cisco_BPX_MGX       ipchainacc           mrtg-archiver         mrtgmk           snmpping
TCH                cisco_ipaccounting  ipchains             mrtg-archiver-script  mrtgrq           stat
TTrafic            cisco_tftp          ipfilter             mrtg-blast            net-hosts        stfc
TotalControlModem  ciscoindex          iptables-accounting  mrtg-dynip            nt-services      switchmaker
accesslistmon      cpuinfo             iptables_acc         mrtg-ipacc            nt_n_cisco       whodo
adm-mrtg           cpumon              iptables_acc_snmp    mrtg-ipget            ovmrtg           xlsummary
apc_ups            diskmon             ircstats             mrtg-mail             ping-probe


Look into this dir! Many powerful scripts for your stat!

Link
A good pdf:
http://www.enterastream.com/whitepapers/mrtg/mrtg-implementation-manual.pdf

Another important link:
http://www.snmplink.org/

Ehy..man google ;)

Enjoy


@lonegd

Look here:
Code:

/usr/share/snmp/mibs/UCD-DISKIO-MIB.txt
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 3 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum