Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

SNMP & MRTG made in easy

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
99 posts
  • 1
  • 2
  • 3
  • 4
  • Next
Author
Message
khazad-dum
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 148
Joined: Mon May 26, 2003 9:48 am
Location: Moria

SNMP & MRTG made in easy

  • Quote

Post by khazad-dum » Fri Nov 14, 2003 3:43 pm

Object required:
* [net-analyzer/net-snmp]
* [media-libs/libgd]
* [net-analyzer/mrtg]
* [sys-apps/dcron]

Optionally:
* [net-www/mini_httpd] or [net-www/apache]

WARNING: Do not Cut&Paste commands that begin with:

Code: Select all

/bin/cat -s > /foo/bar
0) Switch User

Code: Select all

/bin/su -
Enter Password

1) Begin

Code: Select all

/usr/bin/mkdir /etc/mrtg
/usr/bin/mkdir /etc/cron.mrtg
/usr/bin/mkdir /var/www/localhost/mrtg
2) Edit

Code: Select all

/bin/cat -s > /etc/snmp/snmpd.conf

com2sec local     127.0.0.1/32    public
com2sec local     10.10.10.0/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>
Now just press [ctrl+d].

Edit /etc/conf.d/snmpd file, and add:

Code: Select all

-c /etc/snmp/snmpd.conf
in SNMPD_FLAGS line
(like this: SNMPD_FLAGS="-c /etc/snmp/snmpd.conf")

3) Daemon

Code: Select all

/etc/init.d/snmpd start
/sbin/rc-update add snmpd default
4) Configuration
Traffic:

Code: Select all

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

Code: Select all

/bin/cat -s > /etc/mrtg/cpu.cfg
WorkDir: /var/www/localhost/mrtg
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.
0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost
RouterUptime[localhost.cpu]: public@localhost
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: CPU Load
PageTop[localhost.cpu]: <H1>Active CPU Load %</H1>
Unscaled[localhost.cpu]: ymwd
ShortLegend[localhost.cpu]: %
YLegend[localhost.cpu]: CPU Utilization
Legend1[localhost.cpu]: Active CPU in % (Load)
Legend2[localhost.cpu]:
Legend3[localhost.cpu]:
Legend4[localhost.cpu]:
LegendI[localhost.cpu]:  Active
LegendO[localhost.cpu]:
Options[localhost.cpu]: growright,nopercent
Now just press [ctrl+d].

Mem:

Code: Select all

/bin/cat -s > /etc/mrtg/mem.cfg
LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
Target[localhost.mem]: .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@localhost
PageTop[localhost.mem]: <H1>Free Memory </H1>
WorkDir: /var/www/localhost/mrtg
Options[localhost.mem]: nopercent,growright,gauge,noinfo 
Title[localhost.mem]: Free Memory 
MaxBytes[localhost.mem]: 1000000 
kMG[localhost.mem]: k,M,G,T,P,X 
YLegend[localhost.mem]: bytes 
ShortLegend[localhost.mem]: bytes 
LegendI[localhost.mem]:  Free Memory: 
LegendO[localhost.mem]: 
Legend1[localhost.mem]: Free memory, not including swap, in bytes
Now just press [ctrl+d].

Swap:

Code: Select all

/bin/cat -s > /etc/mrtg/swap.cfg
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.swap]: memAvailSwap.0&memAvailSwap.0:public@localhost
PageTop[localhost.swap]: <H1>Swap Memory</H1>
WorkDir: /var/www/localhost/mrtg
Options[localhost.swap]: nopercent,growright,gauge,noinfo 
Title[localhost.swap]: Free Memory 
MaxBytes[localhost.swap]: 1000000 
kMG[localhost.swap]: k,M,G,T,P,X 
YLegend[localhost.swap]: bytes 
ShortLegend[localhost.swap]: bytes 
LegendI[localhost.swap]:  Free Memory: 
LegendO[localhost.swap]: 
Legend1[localhost.swap]: Swap memory avail, in bytes
Now just press [ctrl+d].

Ping:

Code: Select all

/bin/cat -s > /etc/mrtg/ping.cfg
WorkDir: /var/www/localhost/mrtg
Title[mithril.ping]: Round Trip Time
PageTop[mithril.ping]: <H1>Round Trip Time</H1>
Target[mithril.ping]: `/etc/mrtg/ping.sh`
MaxBytes[mithril.ping]: 2000
Options[mithril.ping]: growright,unknaszero,nopercent,gauge
LegendI[mithril.ping]: Pkt loss %
LegendO[mithril.ping]: Avg RTT
Legend1[mithril.ping]: Maximum Round Trip Time in ms
Legend2[mithril.ping]: Minimum Round Trip Time in ms
#Legend3[mithril.ping]: Maximal 5 Minute Maximum Round Trip Time in ms
#Legend4[mithril.ping]: Maximal 5 Minute Minimum Round Trip Time in ms
YLegend[mithril.ping]: RTT (ms)
Now just press [ctrl+d].

5) Make the jobs
Traffic:

Code: Select all

/bin/cat -s > /etc/cron.mrtg/traffic.sh
#!/bin/sh
/usr/bin/mrtg /etc/mrtg/traffic.cfg
Now just press [ctrl+d].

Cpu:

Code: Select all

/bin/cat -s > /etc/cron.mrtg/cpu.sh
#!/bin/sh
/usr/bin/mrtg /etc/mrtg/cpu.cfg
Now just press [ctrl+d].

Mem:

Code: Select all

/bin/cat -s > /etc/cron.mrtg/mem.sh
#!/bin/sh
/usr/bin/mrtg /etc/mrtg/mem.cfg
Now just press [ctrl+d].

Swap:

Code: Select all

/bin/cat -s > /etc/cron.mrtg/swap.sh
#!/bin/sh
/usr/bin/mrtg /etc/mrtg/swap.cfg
Now just press [ctrl+d].

Ping:

Code: Select all

/bin/cat -s > /etc/cron.mrtg/ping.sh
#!/bin/sh
/usr/bin/mrtg /etc/mrtg/ping.cfg

ping.sh

Code: Select all

/bin/cat -s > /etc/mrtg/ping.sh
#!/bin/sh
PING="/bin/ping"
# Google, for example
ADDR="google.com"
DATA=`$PING -c10 -s500 $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
Now just press [ctrl+d].

Code: Select all

/bin/chmod +x /etc/cron.mrtg/*.sh
/bin/chmod +x /etc/mrtg/ping.sh
Run each script 3 times (don't care warnings)

Code: Select all

/etc/cron.mrtg/traffic.sh
/etc/cron.mrtg/cpu.sh
/etc/cron.mrtg/mem.sh
/etc/cron.mrtg/swap.sh
/etc/cron.mrtg/ping.sh
6) Make the index

Code: Select all

/usr/bin/indexmaker --output=/var/www/localhost/mrtg/index.html \
--title="Power Under Control :)" \
--sort=name \
--enumerate \
/etc/mrtg/traffic.cfg \
/etc/mrtg/cpu.cfg \
/etc/mrtg/mem.cfg \
/etc/mrtg/swap.cfg \
/etc/mrtg/ping.cfg
7) Cronjob

Code: Select all

/bin/cat >> /var/spool/cron/crontabs/root
*/5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null
Now just press [ctrl+d].
(or /usr/bin/crontab -e)

Power Under Control
Open Mozilla (I love it) and browse:

Code: Select all

/var/www/localhost/www/index.html
(or use yours httpd server)

http://localhost/mrtg

# Advanced Users#

For other targets (and other stat), try with other object identifier (OID)

* Polling:

Code: Select all

roberto@moira mrtg $ snmpwalk -v 1 -c public localhost mgmt.1.2.2.1.10.2
IF-MIB::ifInOctets.2 = Counter32: 140021440
* Translating:

Code: Select all

roberto@moria mrtg $ snmptranslate -IR -Td mgmt.1.2.2.1.10.2
IF-MIB::ifInOctets.2
ifInOctets OBJECT-TYPE
  -- FROM       IF-MIB, RFC1213-MIB
  SYNTAX        Counter32
  MAX-ACCESS    read-only
  STATUS        current
  DESCRIPTION   "The total number of octets received on the interface,
            including framing characters.

            Discontinuities in the value of this counter can occur at
            re-initialization of the management system, and at other
            times as indicated by the value of
            ifCounterDiscontinuityTime."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) interfaces(2) ifTable(2) ifEntry(1) ifInOctets(
10) 2 }
* Most important files:

Code: Select all

/usr/share/doc/net-snmp
/usr/share/doc/mrtg-*/contrib

- man mrtg
- man snmpd
- man snmpwalk
- man crontab
- man cat
Enjoy,

khazad-dum
Top
s970501
n00b
n00b
Posts: 38
Joined: Mon Dec 01, 2003 12:14 pm
Contact:
Contact s970501
Website

net-snmp doesn't work in kernel 2.6?

  • Quote

Post by s970501 » Fri Jul 09, 2004 12:00 am

When I run cfgmaker, cfgmaker doesn't get snmp information from servers w/ kernel 2.6. Everything is working okay, but not in 2.6 system.
Is there any issue about this?
z9To5o!@wOrms.
Top
Smegma
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 111
Joined: Fri Apr 25, 2003 10:14 am

  • Quote

Post by Smegma » Wed Jul 14, 2004 6:15 am

excellent and easy howto

good job :wink:
Smegma
Top
Regor
Guru
Guru
User avatar
Posts: 545
Joined: Tue Aug 06, 2002 5:25 am
Location: 39° 2' 48" N, 120° 59' 2" W

  • Quote

Post by Regor » Wed Jul 14, 2004 10:10 am

For use with apache, I had to change everything that referred to

Code: Select all

/var/www/localhost/mrtg
to

Code: Select all

/var/www/localhost/htdocs/mrtg
but otherwise it seems to work fine.

Thanks :)
Sometimes the appropriate response to reality is to go insane.
-Philip K. Dick, Valis
Top
kpoman
Apprentice
Apprentice
User avatar
Posts: 209
Joined: Thu May 15, 2003 5:30 pm
Location: Buenos Aires, Argentina
Contact:
Contact kpoman
Website

  • Quote

Post by kpoman » Wed Jul 14, 2004 8:12 pm

i am trying to monitor free disk space but get errors !
i typed this:

Code: Select all

snmpwalk -v 1 -c public localhost 
to find out what was the var name of my different disks and could see this

Code: Select all

HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: /sys
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /mnt/win2k
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: /home
HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: /proc/bus/usb
HOST-RESOURCES-MIB::hrStorageDescr.9 = STRING: /export
HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: /media
HOST-RESOURCES-MIB::hrStorageDescr.11 = STRING: /mnt/shuttle/home
HOST-RESOURCES-MIB::hrStorageDescr.12 = STRING: /mnt/smart/contenu
HOST-RESOURCES-MIB::hrStorageDescr.13 = STRING: /mnt/smart/dev
HOST-RESOURCES-MIB::hrStorageDescr.14 = STRING: /mnt/smart/share
HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.4 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.5 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 8192 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.7 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.8 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.9 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.10 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.11 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.12 = INTEGER: 512 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.13 = INTEGER: 512 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.14 = INTEGER: 512 Bytes
HOST-RESOURCES-MIB::hrStorageSize.2 = INTEGER: 189284
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 393544
HOST-RESOURCES-MIB::hrStorageSize.4 = INTEGER: 1440904
HOST-RESOURCES-MIB::hrStorageSize.5 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.6 = INTEGER: 127384
HOST-RESOURCES-MIB::hrStorageSize.7 = INTEGER: 990236
HOST-RESOURCES-MIB::hrStorageSize.8 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.9 = INTEGER: 2048223
HOST-RESOURCES-MIB::hrStorageSize.10 = INTEGER: 14419375
HOST-RESOURCES-MIB::hrStorageSize.11 = INTEGER: 4807069
HOST-RESOURCES-MIB::hrStorageSize.12 = INTEGER: 282229180
HOST-RESOURCES-MIB::hrStorageSize.13 = INTEGER: 26727348
HOST-RESOURCES-MIB::hrStorageSize.14 = INTEGER: 60772258
HOST-RESOURCES-MIB::hrStorageUsed.2 = INTEGER: 168788
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 122084
HOST-RESOURCES-MIB::hrStorageUsed.4 = INTEGER: 1231157
HOST-RESOURCES-MIB::hrStorageUsed.5 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.6 = INTEGER: 2
HOST-RESOURCES-MIB::hrStorageUsed.7 = INTEGER: 849900
HOST-RESOURCES-MIB::hrStorageUsed.8 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.9 = INTEGER: 1726622
HOST-RESOURCES-MIB::hrStorageUsed.10 = INTEGER: 12743561
HOST-RESOURCES-MIB::hrStorageUsed.11 = INTEGER: 3951579
HOST-RESOURCES-MIB::hrStorageUsed.12 = INTEGER: 82128576
HOST-RESOURCES-MIB::hrStorageUsed.13 = INTEGER: 17444928
HOST-RESOURCES-MIB::hrStorageUsed.14 = INTEGER: 48783682
so i created a /etc/mrtg/hd.cfg and put this on it:

Code: Select all


WorkDir: /var/www/localhost/mrtg
LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
Target[localhost.hd]:hrStorageSize.9&hrStorageUsed.9:public@localhost
RouterUptime[localhost.hd]: public@localhost
YLegend[localhost.hd]: DISK Utilization
Legend1[localhost.hd]: Root disk
Legend2[localhost.hd]: /usr disk
Legend3[localhost.hd]:
Legend4[localhost.hd]:
LegendI[localhost.hd]:  Root disk
LegendO[localhost.hd]:  /usr disk
Options[localhost.hd]: growright,gauge,nopercent

MaxBytes[localhost.hd]: 3000
Title[localhost.hd]: DISK / USAGE
PageTop[localhost.hd]: <H1>DISK / Usage</H1>
ShortLegend[localhost.hd]: B
kMG[localhost.hd]: k,M,G,T,P
kilo[localhost.hd]: 1024

i dont get what i would like to have and actually i dont really know how to do this :) i would prefer maybe to have disk usage percentage ! if someone has an idea :)
please, help me, pity on me :'(
Top
majonnes
n00b
n00b
Posts: 4
Joined: Tue Feb 03, 2004 9:22 pm
Contact:
Contact majonnes
Website

Errors in cpu.sh

  • Quote

Post by majonnes » Thu Jul 15, 2004 8:47 pm

First, thanks for a nice howto!

All my scripts except cpu.sh works fine, I get this error when run:

ERROR: Target[localhost.cpu][_IN_] ' $target->[0]{$mode} + ssCpuRawSystem.0&ssCpuRawSystem.' (warn): Ambiguous use of & resolved as operator & at (eval 6) line 1.

Anyone know what may cause this?
I use the same settings as in the howto with the exception of the workdir
Top
Smegma
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 111
Joined: Fri Apr 25, 2003 10:14 am

  • Quote

Post by Smegma » Fri Jul 16, 2004 1:49 am

majonnes:

You must write Target sentence just in a line.
Smegma
Top
majonnes
n00b
n00b
Posts: 4
Joined: Tue Feb 03, 2004 9:22 pm
Contact:
Contact majonnes
Website

  • Quote

Post by majonnes » Fri Jul 16, 2004 7:08 am

EDIT

I fixed it, thank you!

This line:

Code: Select all

Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.
0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost
Should be like this:

Code: Select all

Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost
Top
nautical9
n00b
n00b
User avatar
Posts: 22
Joined: Mon Feb 24, 2003 12:47 am
Location: Calgary, Alberta, Canada
Contact:
Contact nautical9
Website

SNMP Problems

  • Quote

Post by nautical9 » Tue Jul 20, 2004 11:05 am

Thanks for the wonderful how-to! I've always wanted to get MRTG up and running, but unfortunately I'm still having some basic problems after following your instructions. I think they're way back in snmpd.

I followed all your instructions, replacing only the work-dir in your examples to a different apache directory, but here's the error I get for cpu.sh (I get almost identical errors for mem.sh and swap.sh - traffic.sh and ping.sh seem to work).

Code: Select all

# /etc/cron.mrtg/cpu.sh
SNMP Error:
no response received
SNMPv1_Session (remote host: "localhost" [127.0.0.1].161)
                  community: "public"
                 request ID: 1813541724
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 490
SNMPGET Problem for ssCpuRawUser.0 ssCpuRawUser.0 sysUptime sysName on public@localhost::::::v4only
 at /usr/bin/mrtg line 1866
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: 143882839
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 490
SNMPGET Problem for sysUptime sysName on public@localhost
 at /usr/bin/mrtg line 524
Also related I'm sure, but I get a similar error running the cfgmaker command, which basically generates a useless traffic.cfg file for me:

Code: Select all

#/usr/bin/cfgmaker --output=/etc/mrtg/traffic.cfg --ifdesc=ip --ifref=descr --global "WorkDir: /home/www/pub/admin/mrtg" --global "Options[_]: bits,growright" public@localhost
--base: Get Device Info on public@localhost:
SNMP Error:
no response received
SNMPv1_Session (remote host: "localhost" [127.0.0.1].161)
                  community: "public"
                 request ID: 489553356
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 627
SNMPWALK Problem for 1.3.6.1.2.1.1 on public@localhost::::::v4only
 at /usr/bin/cfgmaker line 827
WARNING: Skipping public@localhost: as no info could be retrieved

--base: Writing /etc/mrtg/traffic.cfg
Sorry for such a newbie question, but I'm not at all familiar with SNMP. There's nothing in my syslog from snmpd, nor in /var/log/net-snmpd.log.

Any ideas?
Top
presto8
n00b
n00b
Posts: 35
Joined: Fri Jan 03, 2003 11:27 pm
Location: Portland, Oregon, USA

  • Quote

Post by presto8 » Thu Jul 22, 2004 5:34 pm

Very nice HOW-TO. I am up and running after only 10 minutes! Thanks.
Top
_benj_
n00b
n00b
Posts: 32
Joined: Wed May 05, 2004 11:51 am
Contact:
Contact _benj_
Website

  • Quote

Post by _benj_ » Mon Jul 26, 2004 12:01 pm

the how to is great, thanks.

I've done a script to automatize the adding of a new computer when monitoring many of them.

make free to download/use and submit critics/suggestions :)

here it is


enjoy.
we are microsoft: what you are experiencing is an undocumented feature, not a bug.
Top
fE_rdy
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 75
Joined: Fri Feb 14, 2003 7:24 am
Location: Old Europe (m'kay Rummy?)

  • Quote

Post by fE_rdy » Tue Aug 17, 2004 10:29 am

_benj_ wrote:the how to is great, thanks.

I've done a script to automatize the adding of a new computer when monitoring many of them.

make free to download/use and submit critics/suggestions :)

here it is


enjoy.
How bad... Translate the script it into english and I will translate into german if you wish :-)

I'd like to add a question: While making the index-page i get to following error:

Code: Select all

w0t4n ferdy # /usr/bin/indexmaker --output=/var/www/localhost/mrtg/index.html \
> --title="Power Under Control :)" \
> --sort=name \
> --enumerate \
> /etc/mrtg/traffic.cfg \
> /etc/mrtg/cpu.cfg \
> /etc/mrtg/mem.cfg \
> /etc/mrtg/swap.cfg \
> /etc/mrtg/ping.cfg 
ERROR: CFG Error Unknown Option "rkdir" on line 3 or above.
           Check doc/reference.txt for Help

w0t4n ferdy # 
Any suggestions?

bye
ferdy
Top
_benj_
n00b
n00b
Posts: 32
Joined: Wed May 05, 2004 11:51 am
Contact:
Contact _benj_
Website

  • Quote

Post by _benj_ » Tue Aug 17, 2004 11:16 am

make sure that the /var/www/localhost/mrtg/ dir exists.
that's the only prob i can see
we are microsoft: what you are experiencing is an undocumented feature, not a bug.
Top
fE_rdy
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 75
Joined: Fri Feb 14, 2003 7:24 am
Location: Old Europe (m'kay Rummy?)

  • Quote

Post by fE_rdy » Tue Aug 17, 2004 11:48 am

_benj_ wrote:make sure that the /var/www/localhost/mrtg/ dir exists.
that's the only prob i can see
It _does_ exist. It contains also all files except the one that should analyze traffic. I have no clue...

Code: Select all

ferdy@w0t4n /var/www/localhost/mrtg $ ls -la
total 377
drwxr-xr-x  2 root root  1024 Aug 17 12:14 .
drwxr-xr-x  3 root root    72 Aug 17 11:44 ..
-rw-r--r--  1 root root  1400 Aug 17 12:14 localhost.cpu-day.png
-rw-r--r--  1 root root  1401 Aug 17 12:11 localhost.cpu-month.png
-rw-r--r--  1 root root  1422 Aug 17 12:11 localhost.cpu-week.png
-rw-r--r--  1 root root  1754 Aug 17 12:11 localhost.cpu-year.png
-rw-r--r--  1 root root  5517 Aug 17 12:14 localhost.cpu.html
-rw-r--r--  1 root root 48182 Aug 17 12:14 localhost.cpu.log
-rw-r--r--  1 root root 48182 Aug 17 12:13 localhost.cpu.old
-rw-r--r--  1 root root  1375 Aug 17 12:12 localhost.mem-day.png
-rw-r--r--  1 root root  1373 Aug 17 12:12 localhost.mem-month.png
-rw-r--r--  1 root root  1392 Aug 17 12:12 localhost.mem-week.png
-rw-r--r--  1 root root  1747 Aug 17 12:12 localhost.mem-year.png
-rw-r--r--  1 root root  5594 Aug 17 12:12 localhost.mem.html
-rw-r--r--  1 root root 48226 Aug 17 12:12 localhost.mem.log
-rw-r--r--  1 root root 48210 Aug 17 12:12 localhost.mem.old
-rw-r--r--  1 root root  1375 Aug 17 12:12 localhost.swap-day.png
-rw-r--r--  1 root root  1373 Aug 17 12:12 localhost.swap-month.png
-rw-r--r--  1 root root  1392 Aug 17 12:12 localhost.swap-week.png
-rw-r--r--  1 root root  1747 Aug 17 12:12 localhost.swap-year.png
-rw-r--r--  1 root root  5583 Aug 17 12:12 localhost.swap.html
-rw-r--r--  1 root root 48226 Aug 17 12:12 localhost.swap.log
-rw-r--r--  1 root root 48210 Aug 17 12:12 localhost.swap.old
-rw-r--r--  1 root root   538 Aug 17 12:11 mrtg-l.png
-rw-r--r--  1 root root   414 Aug 17 12:11 mrtg-m.png
-rw-r--r--  1 root root  1759 Aug 17 12:11 mrtg-r.png
-rw-r--r--  1 root root    70 Aug 17 12:12 oid-mib-cache.txt
ferdy@w0t4n /var/www/localhost/mrtg $ 
bye
ferdy
Top
seand
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 101
Joined: Thu Jan 29, 2004 9:39 pm

  • Quote

Post by seand » Mon Sep 27, 2004 9:32 pm

nicely done!

i had to append public@localhost at the end of the cfgmaker line for it to work, but besides that? PERFECTO!
Top
neutcomp
Tux's lil' helper
Tux's lil' helper
Posts: 112
Joined: Thu Aug 12, 2004 10:05 am
Location: The Netherlands
Contact:
Contact neutcomp
Website

  • Quote

Post by neutcomp » Mon Oct 11, 2004 3:17 pm

Hello,

I supose that:
Object required:
* [net-analyzer/net-snmp]
* [media-libs/libgd]
* [net-analyzer/mrtg]
* [sys-apps/dcron]

That you need to:
emerge net-analyzer/net-snmp
emerge media-libs/libgd (Could not be found!)
emerge net-analyzer/mrtg
emerge sys-apps/dcron

Everything works (no errors) but still notting to see
http://neutcomp.xs4all.nl/stats.nl

Thanxx
Bjorn 8)
Top
Tuinslak
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 129
Joined: Wed Nov 26, 2003 7:02 pm
Location: Belgium
Contact:
Contact Tuinslak
Website

  • Quote

Post by Tuinslak » Mon Nov 01, 2004 11:08 pm

libgd doesn't exist, indeed
type `emerge gd` instead.

--

Here is mine.
swap, ram and hdd give bad results?
"1kb swap" and in free -m it shows 85mb used...
also my cpu is quite idle (nonstop 0%), this isn't correct as it should be at least have 10% load...
Tuinslak
Top
eASy_
n00b
n00b
Posts: 57
Joined: Mon Aug 16, 2004 10:06 am

  • Quote

Post by eASy_ » Sun Feb 27, 2005 2:38 pm

Hello,

first, very good Howto. :)
But what have I to change in the snmpd.conf if I want use it over the Internet and with auth?

Thanks for Help.

eASy
Top
anidabi
Tux's lil' helper
Tux's lil' helper
Posts: 102
Joined: Sat Feb 05, 2005 10:14 am
Location: Finland

  • Quote

Post by anidabi » Tue Mar 29, 2005 8:09 am

First I have to say that this is very good and easy HOWTO. Thanks for that. :)

But I have a broblem. That being that mrtg doesn't generate the images for the web page. Actually it doesnt generate or have any images on the page, only the slots where they should be. Not even the mrtg advertisement at the bottom of the web page. 8O

I did everything as told and I didn't get any errors what so ever, except "/usr/bin/mrtg: bad interpreter: No such file or directory" when running the scripts. In HOWTO there was said that ignore any errors concerning running the scripts, so I guess that it's perfectly normal? Then I thought that maeby my snmp doesn't work, but when running this command "snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex", it showed all my ethernet ip's correctly. So I guess it isn't that either?

Does anyone gnow what might be the broblem, have I missed something?
How do you do the things you do...
Top
anidabi
Tux's lil' helper
Tux's lil' helper
Posts: 102
Joined: Sat Feb 05, 2005 10:14 am
Location: Finland

  • Quote

Post by anidabi » Wed Mar 30, 2005 3:52 pm

Solved, look at the other mrtg thread.
How do you do the things you do...
Top
mOoh
n00b
n00b
User avatar
Posts: 39
Joined: Fri Jun 20, 2003 2:29 pm
Location: paris

  • Quote

Post by mOoh » Mon Jun 06, 2005 1:25 am

thx
pom.
Top
loonix
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 98
Joined: Thu Nov 18, 2004 8:58 pm
Location: Barrie, Ontario, Canada
Contact:
Contact loonix
Website

  • Quote

Post by loonix » Mon Jul 25, 2005 5:56 pm

Great work! got it to work and even added a mysql monitor.

I would like to measure cpu temperature and fan speed as well but I have no clue how to go about it.

Any thoughts?

Thanks

AR
Top
loonix
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 98
Joined: Thu Nov 18, 2004 8:58 pm
Location: Barrie, Ontario, Canada
Contact:
Contact loonix
Website

  • Quote

Post by loonix » Wed Jul 27, 2005 4:53 pm

I gave up on the fan speed and temperature, but now suddenly my Traffic monitor stopped working, it looks like it still measures (the numbers are there at the bottom) but the graph is not updated nor being ploted! any thoughts?

I used the exact same traffic.cfg script from the how-to above...

AR
Top
Sibben
n00b
n00b
Posts: 40
Joined: Sun Nov 16, 2003 3:50 pm
Location: Sweden
Contact:
Contact Sibben
Website

  • Quote

Post by Sibben » Mon Aug 01, 2005 3:21 pm

I was having problems because run-parts wouldn't run any of the scripts, so I read the manpage and by default it won't run any file with a dot in the filename. Works like a charm when I renamed the scripts. Just in case anyone else has the same problem.
Top
Dreadfull
Tux's lil' helper
Tux's lil' helper
Posts: 139
Joined: Fri Apr 15, 2005 9:18 pm

  • Quote

Post by Dreadfull » Wed Aug 03, 2005 7:30 am

executed:

Code: Select all

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

Code: Select all

--base: Get Device Info on public@localhost:
SNMP Error:
no response received
SNMPv1_Session (remote host: "localhost" [127.0.0.1].161)
                  community: "public"
                 request ID: 719708923
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 627
SNMPWALK Problem for 1.3.6.1.2.1.1 on public@localhost::::::v4only
 at /usr/bin/cfgmaker line 796
WARNING: Skipping public@localhost: as no info could be retrieved

--base: Writing /etc/mrtg/traffic.cfg
also the graphs are updating but not getting any info
my current snmpd.conf:

Code: Select all

###########################################################################
#
# snmpd.conf
#
#   - created by the snmpconf configuration program
#
###########################################################################
# SECTION: System Information Setup
#
#   This section defines some of the information reported in
#   the "system" mib group in the mibII tree.

# syslocation: The [typically physical] location of the system.
#   Note that setting this value here means that when trying to
#   perform an snmp SET operation to the sysLocation.0 variable will make
#   the agent return the "notWritable" error code.  IE, including
#   this token in the snmpd.conf file will disable write access to
#   the variable.
#   arguments:  location_string

syslocation Right here, right now.
syslocation  SunShells

# syscontact: The contact information for the administrator
#   Note that setting this value here means that when trying to
#   perform an snmp SET operation to the sysContact.0 variable will make
#   the agent return the "notWritable" error code.  IE, including
#   this token in the snmpd.conf file will disable write access to
#   the variable.
#   arguments:  contact_string

syscontact Dreadfull <dreadfull@sunshells.org>
syscontact



###########################################################################
# SECTION: Access Control Setup
#
#   This section defines who is allowed to talk to your running
#   snmp agent.

# rwuser: a SNMPv3 read-write user
#   arguments:  user [noauth|auth|priv] [restriction_oid]

rwuser  Dreadfull auth

# rouser: a SNMPv3 read-only user
#   arguments:  user [noauth|auth|priv] [restriction_oid]

rouser  Dreadfull



###########################################################################
# SECTION: Trap Destinations
#
#   Here we define who the agent will send traps to.

# informsink: A SNMPv2c inform (acknowledged trap) receiver
#   arguments: host [community] [portnum]

informsink  "localhost sunshells 5000"  5000

# trapcommunity: Default trap sink community to use
#   arguments: community-string

trapcommunity  sunshells

# authtrapenable: Should we send traps when authentication failures occur
#   arguments: 1 | 2   (1 = yes, 2 = no)

authtrapenable  1



###########################################################################
# SECTION: Monitor Various Aspects of the Running Host
#
#   The following check up on various aspects of a host.

# proc: Check for processes that should be running.
#     proc NAME [MAX=0] [MIN=0]
#
#     NAME:  the name of the process to check for.  It must match
#            exactly (ie, http will not find httpd processes).
#     MAX:   the maximum number allowed to be running.  Defaults to 0.
#     MIN:   the minimum number to be running.  Defaults to 0.
#
#   The results are reported in the prTable section of the UCD-SNMP-MIB tree
#   Special Case:  When the min and max numbers are both 0, it assumes
#   you want a max of infinity and a min of 1.

proc mountd
proc ntalkd 4
proc sendmail 10 1

# disk: Check for disk space usage of a partition.
#   The agent can check the amount of available disk space, and make
#   sure it is above a set limit.
#
#    disk PATH [MIN=100000]
#
#    PATH:  mount path to the disk in question.
#    MIN:   Disks with space below this value will have the Mib's errorFlag set.
#           Can be a raw byte value or a percentage followed by the %
#           symbol.  Default value = 100000.
#
#   The results are reported in the dskTable section of the UCD-SNMP-MIB tree

disk / 10000

# load: Check for unreasonable load average values.
#   Watch the load average levels on the machine.
#
#    load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0]
#
#    1MAX:   If the 1 minute load average is above this limit at query
#            time, the errorFlag will be set.
#    5MAX:   Similar, but for 5 min average.
#    15MAX:  Similar, but for 15 min average.
#
#   The results are reported in the laTable section of the UCD-SNMP-MIB tree

load 12 14 14



###########################################################################
# SECTION: Extending the Agent
#
#   You can extend the snmp agent to have it return information
#   that you yourself define.

# exec: run a simple command using exec()
#   arguments:  [oid] name /path/to/executable arguments

exec echotest /bin/echo hello world






#
# Unknown directives read in from other files by snmpconf
#
com2sec local    localhost      public
com2sec mynetwork 192.168.65.0/28          public
com2sec local     127.0.0.1/32    public
com2sec local     192.168.65.0/24   public
group MyRWGroup        v1        local
group MyRWGroup        v2c       local
group MyRWGroup        usm       local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork
view all   included .1                               80
access MyROGroup ""      any       noauth    exact all    none  none
access MyRWGroup ""      any       noauth    exact all    all   none
CPU: AMD Athlon 64 3200+
RAM: 2 GB DDR 400 Dual channel
HDD: 2x200 GB WDC SATA
OS: Gentoo 2005.1
Compiler: GCC 3.4.5
kernel: 2.6.14-hardened-r5
Top
Post Reply

99 posts
  • 1
  • 2
  • 3
  • 4
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic