# SNMP & MRTG made in easy

## khazad-dum

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:

```

/bin/cat -s > /foo/bar

```

0) Switch User

```

/bin/su -

```

Enter Password

1) Begin

```

/usr/bin/mkdir /etc/mrtg

/usr/bin/mkdir /etc/cron.mrtg

/usr/bin/mkdir /var/www/localhost/mrtg

```

2) Edit

```

/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:

```

-c /etc/snmp/snmpd.conf

```

in SNMPD_FLAGS line 

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

3) Daemon

```

/etc/init.d/snmpd start

/sbin/rc-update add snmpd default

```

4) Configuration

Traffic:

```

/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:

```

/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:

```

/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:

```

/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:

```

/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:

```

/bin/cat -s > /etc/cron.mrtg/traffic.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/traffic.cfg

```

Now just press [ctrl+d].

Cpu:

```

/bin/cat -s > /etc/cron.mrtg/cpu.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/cpu.cfg

```

Now just press [ctrl+d].

Mem:

```

/bin/cat -s > /etc/cron.mrtg/mem.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/mem.cfg

```

Now just press [ctrl+d].

Swap:

```

/bin/cat -s > /etc/cron.mrtg/swap.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/swap.cfg

```

Now just press [ctrl+d].

Ping:

```

/bin/cat -s > /etc/cron.mrtg/ping.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/ping.cfg

```

ping.sh

```

/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].

```

/bin/chmod +x /etc/cron.mrtg/*.sh

/bin/chmod +x /etc/mrtg/ping.sh

```

Run each script 3 times (don't care warnings)

```

/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

```

/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

```

/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:

```

/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:

```

roberto@moira mrtg $ snmpwalk -v 1 -c public localhost mgmt.1.2.2.1.10.2

IF-MIB::ifInOctets.2 = Counter32: 140021440

```

* Translating: 

```

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:

```

/usr/share/doc/net-snmp

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

- man mrtg

- man snmpd

- man snmpwalk

- man crontab

- man cat

```

Enjoy,

khazad-dum

----------

## s970501

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?

----------

## Smegma

excellent and easy howto

good job   :Wink: 

----------

## Regor

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

```
/var/www/localhost/mrtg
```

to

```
/var/www/localhost/htdocs/mrtg
```

but otherwise it seems to work fine.

Thanks  :Smile: 

----------

## kpoman

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

i typed this:

```

snmpwalk -v 1 -c public localhost 

```

 to find out what was the var name of my different disks and could see this

```

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:

```

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  :Smile:  i would prefer maybe to have disk usage percentage ! if someone  has an idea  :Smile: 

----------

## majonnes

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

----------

## Smegma

majonnes:

You must write Target sentence  just  in a line.

----------

## majonnes

EDIT

I fixed it, thank you!

This line:

```
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:

```
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost

```

----------

## nautical9

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).

```

# /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:

```

#/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?

----------

## presto8

Very nice HOW-TO.  I am up and running after only 10 minutes!   Thanks.

----------

## _benj_

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  :Smile: 

here it is

enjoy.

----------

## fE_rdy

 *_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 
> ...

 

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

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

```

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

----------

## _benj_

make sure that the  /var/www/localhost/mrtg/ dir exists.

that's the only prob i can see

----------

## fE_rdy

 *_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...

```
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

----------

## seand

nicely done!

i had to append public@localhost at the end of the cfgmaker line for it to work, but besides that?  PERFECTO!

----------

## neutcomp

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   :Cool: 

----------

## Tuinslak

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...

----------

## eASy_

Hello,

first, very good Howto.  :Smile: 

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

----------

## anidabi

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

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.  :Shocked: 

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?

----------

## anidabi

Solved, look at the other mrtg thread.

----------

## mOoh

thx

----------

## loonix

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

----------

## loonix

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

----------

## Sibben

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.

----------

## Dreadfull

executed:

```

/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:

```

--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:

```

###########################################################################

#

# 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

```

----------

## lskbr

Great howto!

Just a small tip for cat and cut & paste...

Replace all cat -s with cat -s <<EOF  and write EOF at the end. Yes EOF.

Example:

Where you read:

```
/bin/cat -s  > /etc/cron.mrtg/swap.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/swap.cfg

```

Write:

```
/bin/cat -s <<EOF > /etc/cron.mrtg/swap.sh

#!/bin/sh

/usr/bin/mrtg /etc/mrtg/swap.cfg

EOF

```

The <<EOF version is ok to cut & paste.

I hope it helps copy & pasters  :Smile: 

LSK

----------

## sskimb

When I tried as recommended, I got the error as follows:

WARNING: "Title[-]" not specified

WARNING: "MaxBytes[-]" not specified

WARNING: I can't find a "target[-]" definition

ERROR: Please fix the error(s) in your config file

To avoid this problem, I used the following command:

cfgmaker --global 'WorkDir: /var/www/localhost/htdocs/mrtg' \

              --global 'Options[_]: bits,growright' \

              --output /etc/mrtg/traffic.cfg \

              localhost

----------

## WhoopeeCushion

After looking into how memory is managed by Linux I concluded that what I originaly typed in this post is kinda bullshit. I do however want to say that the OID used in the starting post gives limited information about memory usage. (Depends ofcourse what you want to see and personally I want to see everything). 

in short... ignore this post from this point on or use it as an example on how it should not be...  :Wink: 

###########################################################

Hi all,

I believe there is an error in the following part.  

```
/bin/cat -s > /etc/mrtg/mem.cfg

LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt

[b]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[/b]

.

.

.

Legend1[localhost.mem]: Free memory, not including swap, in bytes 
```

The graph and the above code states :  	Free memory, not including swap, in bytes

but the OID used:

UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 574992

Means all the mem including the swap.

I believe it is meant to be the 

```

tux mrtg # snmpwalk -v 1 -c public 192.168.1.11  .1.3.6.1.4.1.2021.4

.

.

UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 73528

.

.

```

which is OID:  .1.3.6.1.4.1.2021.4.6.0

(Edited the post because of an error I made)

----------

## xaez

Great tutorial, it helped me a lot! Everything worked perfectly.. But now im trying to monitor cpu and fan temp. I have the OID's for my sensors, but when i get mrtg to log and graph it, it seems to keep overwriting the log file. It doesnt throw any error, it just seems to not store anything more than the latest value in the log file!

This is my fanspeed config file:

```
LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt

Target[localhost.fan]: .1.3.6.1.4.1.2021.13.16.3.1.3.1&.1.3.6.1.4.1.2021.13.16.3.1.3.1:public@localhost

PageTop[localhost.fan]: <H1>CPU Fan Speed</H1>

WorkDir: /var/www/localhost/htdocs/mrtg

Options[localhost.fan]:    gauge, absolute, nopercent, integer, noinfo, growright, pngdate

PNGTitle[localhost.fan]: CPU Fan Speed

Title[localhost.fan]: CPU Fan Speed

MaxBytes[localhost.fan]: 100

YLegend[localhost.fan]: rpm

ShortLegend[localhost.fan]: rpm

LegendI[localhost.fan]:  CPU Fan Speed:

LegendO[localhost.fan]:

Legend1[localhost.fan]: CPU Fan Speed
```

and when i do an snmpwalk on that OID, it returns:

```
snmpwalk -v 1 -c public 192.168.0.7  .1.3.6.1.4.1.2021.13.16.3.1.3.1

LM-SENSORS-MIB::lmFanSensorsValue.1 = Gauge32: 4326
```

After running the config for a few hours, this is all that is in the log file:

```
1126060501 4326 4326

1126060501 0 0 0 0

1126060202 0 0 0 0

1126060200 0 0 0 0

1126059900 0 0 0 0

1126059600 0 0 0 0

1126059300 0 0 0 0

...
```

The graphs are located here.

http://novak.no-ip.org/mrtg/localhost.fan.html

Any help would be greatly appreciated!

----------

## ahorn

xaez: do you got it working? can you please add your temperature and fan configs/settings to this thread or to the wiki?

and why is there no ram/swap graph http://aquapeter.zapto.org/mrtg/

is it a bug that ping doesnt have a green stomache?

----------

## xaez

Hi ahorn, i did infact get it working. Not sure what the problem was exactly, i just deleted my config and re-set it up. As for my fanspeed and cpu temp's; i had to sift through the snmpwalk output until i found something that resembled the OID which related to my fan and cpu. To monitor these sensors, you need lm_sensors installed (emerge -avt lm_sensors). Currently my OID for the fan controller is: .1.3.6.1.4.1.2021.13.16.3.1.3.1

Im sure yours will be different.

The same problem may be occuring for your ram and swap. Make sure that you have the correct OID. Try something like this is the command line: 

```
snmpwalk -v 1 -c public localhost  .1.3.6.1.4.1.2021 | grep memAvailReal
```

if it returns something, you may have to sit there manually finding out the OID for that particcular variable.

The OID numbers are in a tree style format, whereby a number on the right is a child of the number on the left. So the more numbers you add, the more specific you get. Check the output from the command above and then try it without the grep: 

```
snmpwalk -v 1 -c public localhost  .1.3.6.1.4.1.2021
```

The naviagate through the output until you can find the OID you require.. my memory one is currently:

```
.1.3.6.1.4.1.2021.4.6.0
```

As for your ping not having green, it simply means that the ping script is only returning 1 value when it gets called, not 2. mrtg reads 2 numbers, the one which graphs the blue line, and the other which graphs the green chunk. Each can correspond to a different variable, but when they are the same  you can see that the blue line will folllow the top of the green chuck.

Hope this can be of some help for those trying to get this working.

----------

## ahorn

i used the mem.cfg and swap.cfg as described in the wiki. i think it's right for my system, look at following output:

```

aquapeter ~ # snmpwalk -v 1 -c public localhost  memAvailSwap.0

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 2031944

aquapeter ~ # snmpwalk -v 1 -c public localhost  .1.3.6.1.4.1.2021.4.11.0

UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 2040924

```

----------

## xaez

Hmm, your memory seems to be working now. Not sure why the swap isnt working. Strange. Is the swap shell script executable? try running it manually via:

```
/etc/mrtg/swap.sh
```

if its not executable just type:

```
chmod +x /etc/mrtg/swap.sh
```

Short of remaking the config script im not sure what else could be wrong.

----------

## ahorn

ok, i got the mem with .1.3.6.1.4.1.2021.4.6.0.

swap is executable. no errors at runing the script.

another question is, how you did a right temperature graph? is there some other formating needed?

edit: i tried it the swap with .1.3.6.1.4.1.2021.4.4.0 but still no graph.

----------

## xaez

Well, using lm_sensors i get this:

```
sensors
```

```
CPU Temp:    +49 C  (low  =   +15 C, high =   +40 C)   sensor = diode
```

and when i do an snmpwalk on the correct OID it returns a much larger value:

```
snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.13.16.2.1.3.1
```

```
LM-SENSORS-MIB::lmTempSensorsValue.1 = Gauge32: 49000
```

since its exactly 1000 times larger than the actual value, i just set the factor option in my config:

```
Factor[localhost.temp]: 0.001
```

which converts it to something more like the temperature, not some stupid value.

--- As for your swap config, make sure you have MaxBytes set fairly large.

```
MaxBytes[localhost.swap]: 1000000
```

If it isnt, sometimes it wont record the values.

----------

## ahorn

I got the temp, now only the swap is left.

All seems clear ..

```

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

Target[localhost.swap]: .1.3.6.1.4.1.2021.4.4.0&.1.3.6.1.4.1.2021.4.4.0:public@localhost

PageTop[localhost.swap]: <H1>Swap Memory</H1>

WorkDir: /var/www/localhost/htdocs/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
```

```

aquapeter ~ # snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.4.4.0

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 2032180
```

----------

## xaez

Strange... Ill post my swap config file.

```

WorkDir: /var/www/localhost/htdocs/mrtg

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>

Options[localhost.swap]: nopercent,growright,gauge,noinfo,pngdate

PNGTitle[localhost.swap]: Free Swap Memory

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

```

```

crete ~ # snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.4.4.0

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 1000336

```

or

```

crete ~ # snmpwalk -v 1 -c public localhost memAvailSwap.0

UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 1000336

```

----------

## xaez

Also, how did you get it to display °C ? Mine comes up on the temperature graph as strange ascii characters. This is what my config has in it:

```
kMG[localhost.temp]: °C
```

----------

## ahorn

 *xaez wrote:*   

> Also, how did you get it to display °C ? Mine comes up on the temperature graph as strange ascii characters. This is what my config has in it:
> 
> ```
> kMG[localhost.temp]: °C
> ```
> ...

 

this is my config, i guess it's similar to yours

```
LoadMIBs: /usr/share/snmp/mibs/LM-SENSORS-MIB.txt

Target[localhost.cpu-temp]: .1.3.6.1.4.1.2021.13.16.5.1.3.2&.1.3.6.1.4.1.2021.13.16.5.1.3.2:public@localhost

PageTop[localhost.cpu-temp]: <H1>CPU Temperature</H1>

WorkDir: /var/www/localhost/htdocs/mrtg

Options[localhost.cpu-temp]: nopercent,growright,gauge,noinfo,pngdate

Factor[localhost.cpu-temp]: 0.001

PNGTitle[localhost.cpu-temp]: CPU Temperature

Title[localhost.cpu-temp]: CPU Temperature

kMG[localhost.cpu-temp]: °C

MaxBytes[localhost.cpu-temp]: 100000

YLegend[localhost.cpu-temp]: Temperature

ShortLegend[localhost.cpu-temp]: 

LegendI[localhost.cpu-temp]:  CPU Temperature:

LegendO[localhost.cpu-temp]:

Legend1[localhost.cpu-temp]: CPU Temperature
```

----------

## ahorn

i did also for hdd-temps. you need the tool 'hddtemp':

```
nano /etc/mrtg/hda-temp.sh

#!/bin/bash

/usr/sbin/hddtemp -q -n /dev/hda

/usr/sbin/hddtemp -q -n /dev/hda

---

nano /etc/mrtg/hda-temp.cfg

WorkDir: /var/www/localhost/htdocs/mrtg

Title[localhost.hda-temp]: /dev/hda Temperature

PageTop[localhost.hda-temp]: <H1>/dev/hda Temperature</H1>

Target[localhost.hda-temp]: `/etc/mrtg/hda-temp.sh`

MaxBytes[localhost.hda-temp]: 200000

Options[localhost.hda-temp]: growright,nopercent,gauge,pngdate

PNGTitle[localhost.hda-temp]: /dev/hda Temperature

kMG[localhost.hda-temp]: °C

YLegend[localhost.hda-temp]: Temperature

ShortLegend[localhost.hda-temp]:

LegendI[localhost.hda-temp]:  /dev/hda Temperatur:

LegendO[localhost.hda-temp]:

Legend1[localhost.hda-temp]: /dev/hda Temperature
```

my hdc is not official supporrted by hddtemp but it works:

```
nano /etc/mrtg/hdc-temp.cfg

#!/bin/bash

/usr/sbin/hddtemp -n -q /dev/hdc | cut -c 28-29

/usr/sbin/hddtemp -n -q /dev/hdc | cut -c 28-29
```

The is a way with smartctl, too, but i prefer hddtemp.

don't forget to chmod+x the *.sh files. the files for cronjob should be similar and easy.

it would be good if someone add our temperature-stuff to the wiki.

----------

## ahorn

xaez: i see, you got uptime and user count graphs, that's nice, how can i do that?

----------

## xaez

Hey ahorn, sorry i havent checked this thread in a while. 

The uptime graphs are generated with php (not the most effecient way, but it works).

my mrtg config looks like this:

```
Target[nubia_uptime]:    `php /srv/www/phpscripts/up.php`

YTicsFactor[nubia_uptime]: 0.00069444444444444055555555555556

Factor[nubia_uptime]: 0.00069444444444444055555555555556

MaxBytes[nubia_uptime]:    100000

Title[nubia_uptime]: Up/Idle time for crete

PNGTitle[nubia_uptime]: Up/Idle time for crete

Options[nubia_uptime]:    gauge, absolute, noinfo, growright, pngdate, nopercent

YLegend[nubia_uptime]: Up-Idle time(days)

ShortLegend[nubia_uptime]:   Days

LegendI[nubia_uptime]:    Uptime:

LegendO[nubia_uptime]:    Idle time:

PageTop[nubia_uptime]: <H1>Up/Idle time for crete</H1>

```

This config then executes the php binary on my php script called up.php.

up.php contains:

```

<?php

$value = "0\n0";

$uptime = exec("cat /proc/uptime");

$v = explode(" ",$uptime);

$up = explode(".",$v[0]);

$up2 = explode(".",$v[1]);

$uppy = round($up[0] / 60);

$uppy2 = round($up2[0] / 60);

echo $uppy . "\n" . $uppy2;

?>

```

it graphs the uptime, and the amount of time the machine is idle.

My usercount script is pretty much the same. I used php to do this one too.

my mrtg user count config file:

```

Target[users]:   `php /srv/www/phpscripts/users.php `

AbsMax[users]: 15

MaxBytes[users]:   10

PNGTitle[users]: Users for crete

Title[users]: users on crete

Options[users]:    gauge, absolute, integer, noinfo, growright, pngdate, noperce

nt

ShortLegend[users]:     users

YLegend[users]: users

LegendI[users]:    users:

LegendO[users]:

PageTop[users]: <H1>User count on crete</H1>

```

And the user count php script:

```

<?php

$var = shell_exec("uptime");

$v = explode(" user",$var);

$res = explode(", ",$v[0]);

$var2 = $res[count($res)-1];

echo trim($var2) . "\n" . trim($var2);

?>

```

You can achieve the same result in C, but i don't know C - so i used php

----------

## xaez

I have also found the snmp variable for user count. Provided you have the correct sensors on and such..

Give it a try:

```
xaez@latvia ~ $ snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.11.9

 UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 4

```

----------

## mephist0

hi,

I installed it and it works, great how-to !

but, on my desktop pc snmpd needs 13-15% cpu under X ???

If I shut down X snmpd needs only 0.1 - 1.0% cpu under console

but on my server I installed it too, and snmpd need max 1% cpu all time, even when X is loaded ????

my desktop is Pentium IV 3.00GHZ and my server is Pentium IV 1,7GHZ

any advice ?

EDIT : Solved ! The log file was 200KByte, I moved it to .log.old and now works fine with 0 - 1% cpu  :Smile: 

EDIT #2 : hmmm, didnt work well just deleting the .log, now since 2 days snmpd got 15% cpu usage, and my net-snmp.log is about 75MB !!

the only thing it writes to the log is :

Connection from UDP: [127.0.0.1]:32785

but that thousands of times

but when I close X server, snmpd got 0% cpu usage ?!?!

kinda strange 

any ideas ?

thx in advance

----------

## Dreadfull

anyone knows why would i get this?

```

WARNING: Could not match host:'1:public@localhost:' ref:'Descr' key:'eth0'

WARNING: Could not match host:'2:public@localhost:' ref:'Descr' key:'eth0'

```

```

### Interface 1 >> Descr: 'eth0' | Name: 'uplink' | Ip: '86.55.7.210' | Eth: '00-50-bf-b3-89-12' ###

Target[localhost_eth0]: \eth0:public@localhost:

SetEnv[localhost_eth0]: MRTG_INT_IP="86.55.7.210" MRTG_INT_DESCR="eth0"

MaxBytes[localhost_eth0]: 12500000

Title[localhost_eth0]: 86.55.55.210 -- phantom.sunshells.ro

PageTop[localhost_eth0]: <H1>86.55.55.210 -- phantom.sunshells.ro</H1>

 <TABLE>

   <TR><TD>System:</TD>     <TD>phantom.sunshells.ro in Bucharest</TD></TR>

   <TR><TD>Maintainer:</TD> <TD>Dreadfull &lt;dreadfull@sunshells.ro&gt;</TD></TR>

   <TR><TD>Description:</TD><TD>eth0  </TD></TR>

   <TR><TD>ifType:</TD>     <TD>ethernetCsmacd (6)</TD></TR>

   <TR><TD>ifName:</TD>     <TD></TD></TR>

   <TR><TD>Max Speed:</TD>  <TD>100.0 Mbits/s</TD></TR>

   <TR><TD>Ip:</TD>         <TD>86.55.7.210 (uplink.sunshells.ro)</TD></TR>

 </TABLE>

### Interface 2 >> Descr: 'eth1' | Name: '' | Ip: '192.168.65.254' | Eth: '00-50-bf-b3-89-0d' ###

Target[localhost_eth1]: \eth1:public@localhost:

SetEnv[localhost_eth1]: MRTG_INT_IP="192.168.65.254" MRTG_INT_DESCR="eth1"

MaxBytes[localhost_eth1]: 12500000

Title[localhost_eth1]: 192.168.65.254 -- phantom.sunshells.ro

PageTop[localhost_eth1]: <H1>192.168.65.254 -- phantom.sunshells.ro</H1>

 <TABLE>

   <TR><TD>System:</TD>     <TD>phantom.sunshells.ro in Bucharest</TD></TR>

   <TR><TD>Maintainer:</TD> <TD>Dreadfull &lt;dreadfull@sunshells.ro&gt;</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>100.0 Mbits/s</TD></TR>

   <TR><TD>Ip:</TD>         <TD>192.168.65.254 (phantom.sunshells.ro)</TD></TR>

 </TABLE>

### Interface 3 >> Descr: 'eth0:1' | Name: 'sunshells.ro' | Ip: '86.55.25.128' | Eth: '00-50-bf-b3-89-12' ###

Target[localhost_eth0:1]: \eth0:1:public@localhost:

SetEnv[localhost_eth0:1]: MRTG_INT_IP="86.55.25.128" MRTG_INT_DESCR="eth0:1"

MaxBytes[localhost_eth0:1]: 12500000

Title[localhost_eth0:1]: 86.55.25.128 -- sunshells.ro

PageTop[localhost_eth0:1]: <H1>86.55.25.128 -- sunshells.ro</H1>

 <TABLE>

   <TR><TD>System:</TD>     <TD>sunshells.ro in Bucharest</TD></TR>

   <TR><TD>Maintainer:</TD> <TD>Dreadfull &lt;dreadfull@sunshells.ro&gt;</TD></TR>

   <TR><TD>Description:</TD><TD>eth0:1  </TD></TR>

   <TR><TD>ifType:</TD>     <TD>ethernetCsmacd (6)</TD></TR>

   <TR><TD>ifName:</TD>     <TD></TD></TR>

   <TR><TD>Max Speed:</TD>  <TD>100.0 Mbits/s</TD></TR>

   <TR><TD>Ip:</TD>         <TD>86.55.25.128 (sunshells.ro)</TD></TR>

 </TABLE>

### Interface 4 >> Descr: 'eth0:2' | Name: 'dreadfull.b.evolvatelecom.net' | Ip: '86.55.25.129' | Eth: '00-50-bf-b3-89-12' ###

Target[localhost_eth0:2]: \eth0:2:public@localhost:

SetEnv[localhost_eth0:2]: MRTG_INT_IP="86.55.25.129" MRTG_INT_DESCR="eth0:2"

MaxBytes[localhost_eth0:2]: 12500000

Title[localhost_eth0:2]: 86.55.25.129 -- dreadfull.b.evolvatelecom.net

PageTop[localhost_eth0:2]: <H1>86.55.25.129 -- dreadfull.b.evolvatelecom.net</H1>

 <TABLE>

   <TR><TD>System:</TD>     <TD>sunshells.ro in Bucharest</TD></TR>

   <TR><TD>Maintainer:</TD> <TD>Dreadfull &lt;dreadfull@sunshells.ro&gt;</TD></TR>

   <TR><TD>Description:</TD><TD>eth0:2  </TD></TR>

   <TR><TD>ifType:</TD>     <TD>ethernetCsmacd (6)</TD></TR>

   <TR><TD>ifName:</TD>     <TD></TD></TR>

   <TR><TD>Max Speed:</TD>  <TD>100.0 Mbits/s</TD></TR>

   <TR><TD>Ip:</TD>         <TD>86.55.25.129 (dreadfull.b.evolvatelecom.net)</TD></TR>

 </TABLE>

### Interface 5 >> Descr: 'eth0:3' | Name: 'dreadfull.evolva.ro' | Ip: '86.55.25.130' | Eth: '00-50-bf-b3-89-12' ###

Target[localhost_eth0:3]: \eth0:3:public@localhost:

SetEnv[localhost_eth0:3]: MRTG_INT_IP="86.55.25.130" MRTG_INT_DESCR="eth0:3"

MaxBytes[localhost_eth0:3]: 12500000

Title[localhost_eth0:3]: 86.55.25.130 -- dreadfull.evolva.ro

PageTop[localhost_eth0:3]: <H1>86.55.25.130 -- dreadfull.evolva.ro</H1>

 <TABLE>

   <TR><TD>System:</TD>     <TD>sunshells.ro in Bucharest</TD></TR>

   <TR><TD>Maintainer:</TD> <TD>Dreadfull &lt;dreadfull@sunshells.ro&gt;</TD></TR>

   <TR><TD>Description:</TD><TD>eth0:3  </TD></TR>

   <TR><TD>ifType:</TD>     <TD>ethernetCsmacd (6)</TD></TR>

   <TR><TD>ifName:</TD>     <TD></TD></TR>

   <TR><TD>Max Speed:</TD>  <TD>100.0 Mbits/s</TD></TR>

   <TR><TD>Ip:</TD>         <TD>86.55.25.130 (dreadfull.evolva.ro)</TD></TR>

 </TABLE>

```

and so on .. doesn't mrtg support this define type ? like eth0:3 ? or what ?

----------

## kevinverma

Hello,

I will be very much thankful if someone can please hint me special case of a non-static ppp interface, so that it can be monitored via mrtg. I suppose this is a non-snmp interface as well. 

Many Thanks for reading,

----------

## novazur

Hi,

I can't understand why I can't have my fans speed with :

```
WorkDir: /var/log/www/mrtg

LoadMIBs: /usr/share/snmp/mibs/LM-SENSORS-MIB.txt

Target[localhost.cpu-fan]: lmFanSensorsValue.2&lmFanSensorsValue.1:public@localhost

Options[localhost.cpu-fan]:    nopercent,growright,gauge,noinfo

Title[localhost.cpu-fan]: CPU Fan Speed

PageTop[localhost.cpu-fan]: <H1>CPU Fan Speed</H1>

MaxBytes[localhost.cpu-fan]: 10000

YLegend[localhost.cpu-fan]: rpm

ShortLegend[localhost.cpu-fan]: rpm

LegendI[localhost.cpu-fan]:  CPU Fan Speed:

LegendO[localhost.cpu-fan]: Other Fan Speed

Legend1[localhost.cpu-fan]: CPU Fan Speed:

Legend2[localhost.cpu-fan]: Other Fan Speed

Language: french
```

```
# /usr/bin/mrtg /etc/mrtg/fan.cfg

Use of uninitialized value in concatenation (.) or string at /usr/bin/../lib/mrtg2/SNMP_util.pm line 1266, <MIB> line 31.

Use of uninitialized value in concatenation (.) or string at /usr/bin/../lib/mrtg2/SNMP_util.pm line 1266, <MIB> line 33.

Use of uninitialized value in concatenation (.) or string at /usr/bin/../lib/mrtg2/SNMP_util.pm line 1266, <MIB> line 262.

cannot encode Object ID .16.3.1.3.2: first subid too big in Object ID 16.3.1.3.2 at /usr/bin/mrtg line 1849

ERROR: Target[localhost.cpu-fan][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

ERROR: Target[localhost.cpu-fan][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data
```

```
# /usr/bin/snmpwalk -v 1 -c public localhost lmFanSensors

LM-SENSORS-MIB::lmFanSensorsIndex.1 = INTEGER: 0

LM-SENSORS-MIB::lmFanSensorsIndex.2 = INTEGER: 1

LM-SENSORS-MIB::lmFanSensorsIndex.3 = INTEGER: 2

LM-SENSORS-MIB::lmFanSensorsDevice.1 = STRING: fan1

LM-SENSORS-MIB::lmFanSensorsDevice.2 = STRING: CPU Fan

LM-SENSORS-MIB::lmFanSensorsDevice.3 = STRING: fan3

LM-SENSORS-MIB::lmFanSensorsValue.1 = Gauge32: 6026

LM-SENSORS-MIB::lmFanSensorsValue.2 = Gauge32: 3924

LM-SENSORS-MIB::lmFanSensorsValue.3 = Gauge32: 0
```

Help ?

<edit Solved>

I got it

</edit>

----------

## ayem

strange thing for me - maybe its ok but...

My server is Dual Pentium3 450MHz machine on chipset n440bx by intel

SMP is correct - compilation is running on both processors.

now if i run one process mprime its running on one processor, and 'top' describes cpu load as 49.9%, but on myy mrtg i see 78%

is there any explanation of this fact? could and eventually how, can i make it work corectly?

MRTG

edit: is this because CPU shows system load insted of raw CPU %?

----------

## anidabi

I have a little problem. Yesterday I decited to "tweak" my mrtg graphs a little bit, so I schanget colors and made some withpeak and some other minor adjustments. Anyway, the broplem is that, when I update the graphs by running the mrtg script, it shows the graphs right. But after cron has updated the graphs after that, the colors are all wrong and also the size of the graphs.

Anyone has any clue why it behaves like that?

----------

## Woody2143

Gentlemen,

I have been playing around with this for a short time now, though I've not followed the guide at the start of this thread. Maybe later I'll convert over to use rddtool.

Anyway, in my haxing about with the config files I found a pretty good overview of the config files and what settings mean what. Well worth reading through:   http://www.linuxhomenetworking.com/linux-hn/mrtg-advanced.htm

Just thought I'd pass it along....

----------

## jkroon

Very nice.

The uptime script works nicely as well, although, I'd suggest a small inline bash command in the config file:

```
Target[xacatecas.uptime]:    `sed -e 's,\.[0-9]*,,g' < /proc/uptime | (read C1 C2; echo $(( $C1 / 60 )); echo $(( $C2 / 60 )))`
```

It was written from the php script and does exactly the same thing.

Also, Gentoo allows one to run mrtg in daemon mode if instead of a bunch of seperate config files you create one big config file.  I haven't done this but the option is available.  This also allows one to make use of the global "Fork" option, which will allow a small speed improvement in the case where you are doing many remote queries (My mrtg updates takes well over a minute already with almost no CPU usage).

Instead of the bunch of shell scripts that does this I've instead got a single command stored in cron:

```
*/5 * * * * for i in /etc/mrtg/*.cfg; do /usr/bin/mrtg $i; done
```

Also, I'm running mrtg as a non-root user.  Just do:

```
# useradd mrtg -g daemon -G cron -d /dev/null

# passwd -l mrtg
```

The passwd -l part is optional, I suspect it's the default.  The home directory of /dev/null is just there for some added security.  It does need a legal shell though.  Then to set up the crontab do:

```
# crontab -e -u mrtg
```

or pass --user to mrtg.

Then I also need some help.  I'm trying to get the hrSystemUptime working so that I can monitor the uptime of remote machines without the need of ssh hacks and tunnels.

```
xacatecas ~ # snmpwalk -v 1 -c public localhost hrSystemUptime

HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (292802531) 33 days, 21:20:25.31

xacatecas ~ # 
```

So that gives the correct value, now that is in Timeticks and the value in brackets does match up with that from /proc/uptime.

```
xacatecas mrtg # cat /proc/uptime && snmpwalk -v 1 -c public localhost hrSystemUptime

2928616.04 2881494.04

HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (292861618) 33 days, 21:30:16.18

xacatecas mrtg # 
```

However, whenever I try to use this value I get weird errors:

```
xacatecas mrtg # mrtg pug-uptime.cfg.tmp 

WARNING: Expected a number but got '3 days, 13:15:46'

WARNING: Expected a number but got '3 days, 13:15:46'

ERROR: Target[pug.uptime][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

ERROR: Target[pug.uptime][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data

xacatecas mrtg # 
```

I've found a thread that makes a comment about this behaviour here.  Now the question is where to place the string:

```
$BER::pretty_print_timeticks=0
```

since it deffinately doesn't work in the mrtg config file.  I'm suspecting /usr/lib/mrtg2/BER.pm, but then it would simply be without the $BER:: leading it.  Indeed, changing this on line 67 to just 0 does indeed fix the errors produced by mrtg.  However, what other side effects could there be?

----------

## mephist0

anyone got CPU Active Load working on amd64 ?

all other charts are working well

except this %$U($ cpu graph

here is my config :

http://rafb.net/paste/results/9r0oDb14.html

it always shows 21% usage, but I am compiling right now and it should display 100% usage ?!?!?

any idea whats wrong ?

the same config file worked fine for my old system, a P4 3GHZ with HT

thanks in advance !!

----------

## jkroon

There is a further state the CPU can be in.  Waiting for IO.  Afaik this isn't included in any of the three options you have.  Try compiling with -j2 which will push your actual usage up a bit.  Also try running a command such as the following for an extended period of time:

```
while true; do echo -n ""; done
```

Which will munch 100% cpu without doing any I/O whatsoever.

Also, does that 21% come down when you are not doing anything?

What does top say?

Remember that the values mrtg displays is averages over certain time periods (5 mins for the /day display).

----------

## mephist0

I aborted the merge, waited 30minutes, resumed emerge and I dont know why, but now it works fine  :Smile: 

thanks anyways  :Wink: 

----------

## ConiKost

Hello!

I got problems with cpu.sh

```

BlackBox mrtg # /usr/bin/mrtg /etc/mrtg/cpu.cfg

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

Friday, 1 September 2006 at 1:13: ERROR: Target[localhost.cpu][_OUT_] ' $target->[0]{$mode}  + ssCpuRawSystem.0&ssCpuRawSystem.' (warn): Ambiguous use of & resolved as operator & at (eval 14) line 1.

```

What I am doing wrong?

----------

## jkroon

It would help if you also supplied your config file.

----------

## ConiKost

 *jkroon wrote:*   

> It would help if you also supplied your config file.

 

See the first thread! I copyied it!

----------

## jkroon

Hmm, I do recall some similar issues.  Anyhow, here is my cpu config (well, the orriginal one I did from this example) so you can just do an "eye diff" and see what's wrong:

```
WorkDir: /var/www/hackerpages.lan/htdocs/mrtg

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

Target[pug.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@pug.lan + ssCpuRawSystem.0&ssCpuRawSystem.0:public@pug.lan + ssCpuRawNice.0&ssCpuRawNice.0:public@pug.lan

RouterUptime[pug.cpu]: public@pug.lan

MaxBytes[pug.cpu]: 100

Title[pug.cpu]: pug: CPU Load

PageTop[pug.cpu]: <H1>pug: Active CPU Load %</H1>

Unscaled[pug.cpu]: ymwd

ShortLegend[pug.cpu]: %

YLegend[pug.cpu]: CPU Utilization

Legend1[pug.cpu]: Active CPU in % (Load)

Legend2[pug.cpu]:

Legend3[pug.cpu]:

Legend4[pug.cpu]:

LegendI[pug.cpu]:  Active

LegendO[pug.cpu]:

Options[pug.cpu]: growright,nopercent,noinfo,unknaszero
```

----------

## zdreantza

I have the following errors when trying to use the cpu.cfg

 *Quote:*   

> Singularity mrtg # mrtg cpu.cfg
> 
> Unknown SNMP var ssCpuRawUser.0
> 
>  at /usr/bin/mrtg line 2035
> ...

 

My cpu.cfg file looks like this:

 *Quote:*   

> WorkDir: /var/www/localhost/htdocs/mrtg
> 
> LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
> 
> Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1+ ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1+ ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1
> ...

 

swap.cfg gives no errors, yet my graphic isnt populated.

 *Quote:*   

> LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
> 
> Target[localhost.swap]: .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@localhost
> 
> PageTop[localhost.swap]: <H1>Swap Memory</H1>
> ...

 

Anyone having any ideas?

----------

## jkroon

Did you generate the indexes?  Does the user you're running this as have rw access to the WorkDir?  Did you actually leave it for a while (running every 5 minutes) to give it time to actually collect some data?  Those errors do look like ones I got when I tried to graph uptime though.  The errors before that is rather worrysome though and is probably an indication that the first two lines returned are in what should be lines 3 and 4, with the first two lines being omitted.  I'm thinking you're not loading the appropriate resource description, my mrtg.conf file contains the following:

```
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
```

Please check whether adding that helps.

Then just another tip that I've seen a couple of times here.  It's possible to combine all the *.conf files into a single config file, something like this:

```
WorkDir: /var/lib/mrtg

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt

Forks: 4

Extension[_]: php

PageTop[_]: \n<!-- PAGE TOP -->\n

PageFoot[_]: \n<!-- PAGE FOOT -->\n

Options[^]: growright,unknaszero,nopercent

#Suppress[_]: ym

RouterUptime[_]: public@localhost

Target[cpu]: ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost

MaxBytes[cpu]: 100

Title[cpu]: CPU Utilization

ShortLegend[cpu]: %

YLegend[cpu]: CPU Utilization

Legend1[cpu]: CPU Utilization

LegendI[cpu]: CPU:

LegendO[cpu]:

Options[cpu]: nopercent

Unscaled[cpu]: dwmy

Include: /var/lib/mrtg/netmrtg.conf

Include: /var/lib/mrtg/stormrtg.conf

Include: /var/lib/mrtg/diskiomrtg.conf

Options[mysql]: perminute, integer

Target[mysql]: `${mysql_to_load} -u maildb`

MaxBytes[mysql]: 2000000

Title[mysql]: MySQL Utilization

Shortlegend[mysql]: q/m

YLegend[mysql]: Queries per minute

LegendI[mysql]: Queries

LegendO[mysql]: Slow queries

Legend1[mysql]: Queries per minute

Legend2[mysql]: Slow queries per minute
```

Upon every run I recreate this Include: config files based on various system states, although for most operations they'll stay consistent, but if things like the physical disks change, partitions gets altered, network config changes etc I want those files to automatically reflect the changes.  Thus I generate them using a small script.

Obviously I've been playing around a bit recently.  I've now got some nice looking graphs, most of these things are auto-detected, mapping cpu usage, MySQL utilization, all storage devices's usage (mounted partitions and RAM), network devices IO rates, as well as all block devices IO rates.  For those that care, you're welcome to take a look at:

http://mail.kroon.co.za/mrtg.php

Most of those were created using info from this page, the disk IO ones were created using a bit of vmstat -d and some awk magic (single invocation of vmstat every 5 minutes ... not bad imho).  This info is quite possibly also available via snmp which would be a better option imho as that gets rid of the "local system" requirement and would thus allow one to keep these stats for remote servers as well.

And for those that are wondering, yes, that is a Gentoo-based server.  It got rebooted once shortly after it got installed about a month back, and has been giving me about a hundreth of the grief the previous Linux server (distro shall remain unnamed) gave me.

----------

## PaveQ

Hmm how can I get hourly graph?   :Question: 

----------

## jkroon

Use rrdtool.

mrtg by default only takes samples every five minutes, which is 12 samples an hour.  Not quite sufficient for an hourly graph I would reckon.  If however you use rrdtool then you can take samples as often as you like (every minute?) and then you'd have 60 data samples for an hour, which should be usable for an hourly graph.

----------

## a1exus

```
Legend1[CPU-IU]: CPU - USER

Legend2[CPU-IU]: CPU - IDLE

Legend3[CPU-IU]: CPU - NICE

Legend4[CPU-IU]: CPU - SYSTEM

LegendI[CPU-IU]: USER

LegendO[CPU-IU]: NICE

MaxBytes[CPU-IU]: 100

Options[CPU-IU]: growright,nopercent,gauge

PageTop[CPU-IU]: <H1>CPU</H1>

RouterUptime[CPU-IU]: public@127.0.0.1

ShortLegend[CPU-IU]: %

Target[CPU-IU]:ssCpuRawUser.0&ssCpuRawIdle.0:public@127.0.0.1+ssCpuRawNice.0&ssCpuRawSystem.0:public@127.0.0.1

Title[CPU-IU]: CPU (User,Idle,Nice,System)

Unscaled[CPU-IU]: ymwd

YLegend[CPU-IU]: CPU (User,Idle,Nice,System)
```

few questions...

1) i only seeing User and Idle (my idle almost never change, even i'm pretty sure my server is kind of busy, not all the time but i get on average 25% of user, so i think idle should somehow be vary rather then just be all the way at the top all the time...)

2) as i mention i only seeing user and idle not the other two (nice and system)

3) at the bottom of each graph, i only see in legend just LegendI[CPU-IU]: USER, how can i put there stuff from other 2?

4) and at the very bottom of the page, i seeing GREEN ###  	CPU - USER, not any others period...

----------

## jkroon

mrtg only renders two graphs.  You're adding User and Nice together, and Idle and System.  Adding the 4 up should always end up at 100%.

For CPU I usually just do this:

```
Target[cpu]: ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost

MaxBytes[cpu]: 100

Title[cpu]: CPU Utilization

ShortLegend[cpu]: %

YLegend[cpu]: CPU Utilization

Legend1[cpu]: CPU Utilization

LegendI[cpu]: CPU:

LegendO[cpu]:

Options[cpu]: nopercent

Unscaled[cpu]: dwmy
```

Adjust the MaxBytes according to the number of CPUs you have (100 * nr_cpus/cores/hts).

----------

## a1exus

um.. not true..

http://alexus.org/qmail/mrtg/

i have 4 graphs here..

----------

## jkroon

Sorry, wrong wording  :Smile: .  You can render as many graphs as you want, but only two series on each graph.

Btw, how did you do the smtp counter one?  I'm guessing you're using qmail, but I'm pretty sure that given an example I'd be able to implement it for exim as well.

----------

## a1exus

http://www.inter7.com/index.php?page=qmailmrtg7

----------

## a1exus

what does that mean two series?

----------

## jkroon

2 series of numbers (each line on a graph is called a series, short for a series of sequenced numbers).  But it seems I'm wrong on that, I looked again at those graphs and on one or two of the year graphs I can actually see 4 seperate series.  Will need to investigate that.

----------

## LiquidRain

 *kevinverma wrote:*   

> Hello,
> 
> I will be very much thankful if someone can please hint me special case of a non-static ppp interface, so that it can be monitored via mrtg. I suppose this is a non-snmp interface as well. 
> 
> Many Thanks for reading,

 

Have MRTG monitor the ethernet device instead.  This is what worked for me.

----------

## jkroon

Why does mrtg have issues with ppp interfaces?  It simply keeps on saying that it's all zero ... why?  No clue actually.  Would also appreciate some advice, cause ifconfig correctly shows increasing byte counters.

----------

## LiquidRain

 *jkroon wrote:*   

> Why does mrtg have issues with ppp interfaces?  It simply keeps on saying that it's all zero ... why?  No clue actually.  Would also appreciate some advice, cause ifconfig correctly shows increasing byte counters.

 

As I told kevinverma, you can have MRTG monitor the ethernet device if it's PPPoE.  However I am having difficulty myself, as MRTG is not giving the right bandwidth stats for the device, it seems it always reads the same, or nearly the same, values.  I'm trying to solve this myself by learning the SNMP tools, though, so hopefully I can get somewhere and let people here know.

I should also throw in that none of the CPU, swap, or memory configurations worked for me as provided in the OP.

----------

## jkroon

That wasn't my question, but yea, monitoring the connecting interface does give approximate results.  Keep in mind that there may well be other traffic flowing over that interface as well, and as such the traffic will always be an over-estimate.

----------

## LiquidRain

Sorry to say but I cannot get it working at all with SNMP.  I'll write a simple shell script later that just grabs the information from ifconfig and feeds it to MRTG that way.  Hopefully that's accurate enough.  I also can't get cpu/memory info working at all, and I don't have the patience or will to learn SNMP just for MRTG, so I'm just going to write scripts for those as well.

----------

## jkroon

Ok, snmp configuration:

```
com2sec local 127.0.0.1/32      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 ULS Offices

syscontact Jaco Kroon <jaco@kroon.co.za>
```

Not sure exactly what all of that does, but it's all read-only as far as I can tell, and only to 127.1/32 anyway, so that is restrictive enough for me.

Then I've got the following mrtg config files on this particular machine (auto-generated using a script):

 *mrtg.conf wrote:*   

> WorkDir: /var/lib/mrtg/
> 
> LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
> 
> Forks: 4
> ...

 

 *netmrtg.conf wrote:*   

> # Config for lo:
> 
> Title[lo]: lo
> 
> Target[lo]: 1:public@localhost:
> ...

 

 *stormrtg.conf wrote:*   

> # Config for Physical memory (1)
> 
> Target[stor_physical_memory]: hrStorageUsed.1&hrStorageSize.1:public@localhost * hrStorageAllocationUnits.1&hrStorageAllocationUnits.1:public@localhost
> 
> LegendI[stor_physical_memory]: Used:
> ...

 

 *diskiomrtg.conf wrote:*   

> # Config for sda
> 
> Target[diskio_sda]: `echo -e "2459277\n29377248"`
> 
> Title[diskio_sda]: sda
> ...

 

Note that since I regen these config files every 5 minutes when I actually run mrtg I can sometimes get away with just doing an echo for obtaining the values (which I sometimes obtain from commands like vmstat whilst generating the config files - so it's simpler to obtain the values and the desired target values in one go).  The script I use automatically decides what configurations etc to construct.  Yea, it's probably not the most efficient way to do it, but considering that this still takes up near zero CPU compared to what exim/courier/spamd/clamd takes out of my machines and they are on average all idling at < 10% with one or two going to 50 % during peak (and maybe once a week hit 80 %) I'm not too worried about it.

The script itself uses snmpwalk to determine what the network interfaces and storage locations are that is monitorable, and vmstat for the diskio stuff.  The command "snmpwalk -Os -c public -v 2c localhost hrStorageDescr" should give you an idea of what I'm doing to determine what goes where.  From there sed and grep are rather handy. ppp* are the only graphs that does not produce the desired results, and upon reboots i sometimes get nasty spikes.

The results for a different machine is visible on http://mail.kroon.co.za/system/serverstats (this particular case doesn't have a ppp device though).

----------

## jkroon

Hmm, I just had an epiphany.  MRTG assumes the byte counter needs to always keep on incrementing right?  What happens when it actually decreases?  In ZA ppp connections for ADSL cannot last longer than 24 hours.  So what happens if in a 24 hour session I download say 100MB, after which the byte counters resets ... either mrtg is going to assume something went wrong and graph zero, or it's going to "overflow" causing the result to be larger than maxbytes, and still plot zero.  Does this make sense?  Is there a way to work around this?

Whilst the above does make sense in a strange way, I'm still not convinced that it's an mrtg issue however, since I can run the following command:

watch -d -n 1 -- "snmpwalk -Os -c public -v 2c localhost | grep ^if.*\\\\.2\ "

And observe ethadsl actually showing changing byte counters that are in sync with those shown in ifconfig ethadsl.  However, doing the same but for interface 5 shows that the byte counters are out of sync with ifconfig, both the RX and TX byte counters are much _higher_ in snmp than in ifconfig:

```
ppp0      Link encap:Point-to-Point Protocol

          inet addr:196.209.79.222  P-t-P:196.209.64.1  Mask:255.255.255.255

          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1

          RX packets:68815 errors:0 dropped:0 overruns:0 frame:0

          TX packets:63869 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:3

          RX bytes:35760423 (34.1 Mb)  TX bytes:12684844 (12.0 Mb)
```

```
ifIndex.5 = INTEGER: 5

ifDescr.5 = STRING: ppp0

ifType.5 = INTEGER: ppp(23)

ifInOctets.5 = Counter32: 127945692

ifInUcastPkts.5 = Counter32: 215629

ifOutOctets.5 = Counter32: 48721733

ifOutUcastPkts.5 = Counter32: 212804

ifHCInOctets.5 = Counter64: 127945692

ifHCInUcastPkts.5 = Counter64: 215629

ifHCOutOctets.5 = Counter64: 48721733

ifHCOutUcastPkts.5 = Counter64: 212804
```

Bug in snmp?

Or perhaps take a look at this:

```
ifName.1 = STRING: lo

ifName.2 = STRING: ethadsl

ifName.3 = STRING: ethtt

ifName.4 = STRING: ethlan

ifName.15 = STRING: ppp0
```

Those numbers are NOT consecutive.  This is directly after restarting snmpd, earlier I had this:

```
ifName.1 = STRING: lo

ifName.2 = STRING: ethadsl

ifName.3 = STRING: ethtt

ifName.4 = STRING: ethlan

ifName.5 = STRING: ppp0

ifName.6 = STRING: ppp0

ifName.7 = STRING: ppp0

ifName.8 = STRING: ppp0

ifName.9 = STRING: ppp0

ifName.10 = STRING: ppp0

ifName.11 = STRING: ppp0

ifName.12 = STRING: ppp0

ifName.13 = STRING: ppp0

ifName.14 = STRING: ppp0

ifName.15 = STRING: ppp0
```

Which to me indicates that one needs to locate the currently "up" ppp0 interface.  However, why does snmp keep on adding more and more interfaces?  Anyhow, the current numbers can be found with the following command it seems:

```
# ip link show | awk -F'[: ]+' '$1 != "" { print $1 " " $2 }'

1 lo

2 ethadsl

3 ethtt

4 ethlan

15 ppp0
```

Or by inspecting the ifAdminStatus or the ifOperStatus fields in snmp.

Right, I'll adjust my script to use the ip link show hack to determine the matchups with device numbers to device names and report back in a couple of days (just post if I forget - which I probably will).  In the meantime, I reckon it's still a bug that snmpd doesn't purge dead devices from being exposed.  It'll eventually lead to exhaustion of memory resources imho.  Probably.

----------

## LiquidRain

Well, these little scripts seem to do the job for monitoring PPP devices.

/etc/mrtg/ppp0.pl :

```
#!/usr/bin/perl

open (TX, "/sbin/ifconfig ppp0 | /bin/grep 'RX bytes' |");

($garbage, $work, $work2) = split(":", <TX>);

($rx, $garbage) = split(" ", $work);

($tx, $garbage) = split(" ", $work2);

print "$rx\n$tx\n";

close (TX);
```

/etc/mrtg/ppp0.cfg :

```
EnableIPv6: no

WorkDir: /var/www/mrtg/

Options[_]: growright

Target[localhost_ppp0]: `/etc/mrtg/ppp0.pl`

MaxBytes[localhost_ppp0]: 1000000

Title[localhost_ppp0]: DSL Internet - ppp0

PageTop[localhost_ppp0]: <h1>DSL</h1>
```

It's fugly but it does the job for my PPP connection.

----------

## jkroon

Not remotely it doesn't  :Smile: .  But yes, it'll do the job if you don't have that need.  For remote my ip link show trick also doesn't work and you need to use snmpwalk to find all the up interfaces, something like:

```
eval "$(snmpwalk -Os -c public -v 2c localhost ifName | awk -F'[.= ]+' '{ print "devname[" $2 "]=" $4 }')"

eval "$(snmpwalk -Os -c public -v 2c localhost ifOperStatus | awk -F'[. (]+' '$5=="up" { print "echo " $2 " ${devname[" $2 "]}" }')"
```

Which will output the following:

 *Quote:*   

> 1 lo
> 
> 2 ethadsl
> 
> 3 ethtt
> ...

 

Even though device 15 also maps to ppp0.  Monitoring the appropriate device number seems to be working so far, but Monday will tell for sure when there is actually a bunch of traffic going over the particular line.  So far the only strangeness I've seen was on the ppp reconnect where I've somehow managed to obtain 120Mbps over a 4Mbps ADSL line ... <sarcasm>sure</sarcasm>.  I'm betting this is something to do with wrapping, and I recall there being some mrtg option to mitigate this effect I'm seeing.

----------

## suprnaut

Hi. I have the same problem as Tuinslak; "(...) also my cpu is quite idle (nonstop 0%), this isn't correct as it should be at least have 10% load..." (I see now that he has figured it out, or atleast his CPU load is updating - as seen on his mrtg site; http://mrtg.rootspirit.com/ - I'll PM him).

I have a dual p3 CPU, running on a gentoo install with 2.6 kernel. Everything besides Active CPU load works great. 

My /etc/mrtg/cpu.cfg is as follows; 

```
WorkDir: /var/www/localhost/htdocs/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,gauge,pngdate

```

Trying to run 

```
while true; do echo -n " "; done
```

generates a steady 25-30% usage (seen in top), but nothing is generated on the MRTG cpu graph.

My cpu job is at

```
 #!/bin/sh

/usr/bin/mrtg /etc/mrtg/cpu.cfg
```

and I know it works, because pngdate is updating the image with the right date, but the load showing on the graph is at a steady 0%..

Any ideas how I can fix this? I have tried to use ssCpuRawUser.1&ssCpuRawUser.1: etc. instead of 0 (because I have multiple CPUs i thought maybe perhaps, though I don't know exactly what I was doing and I know it was a long shot, it would work, but it only returned error messages that SNMP could not find ssCpuRawUser.1 or something..)

Haven't seen any other one with this problem! I have looked in both mrtg threads in this forum and searched all over the place. Please reply.

----------

## jkroon

dual p3.

That means MaxBytes needs to be 200.

----------

## suprnaut

Well, I tried that as well. The only thing that happened was that the Y axis grew in height to 200. . But I haven't tried it with 200 in the *.cfg and running it over time. Thanks for the tip, but if that does not solve my problem? 

There is absolutely no sign of MRTG capturing any work load on my CPUs, but I'll try with MaxBytes = 200 when I get home from school   :Razz: 

UPDATE: changing MaxBytes to 200 had absolutely no impact. .. 

----------

## jkroon

Drop the gauge option.  My options are merely "nopercent" and it's working as intented.

```
$ snmpwalk -Os -c public -v 2c localhost ssCpuRawUser.0

ssCpuRawUser.0 = Counter32: 50216
```

----------

## suprnaut

Yeah, removing gauge fixed it.

```
Options[localhost.cpu]: growright,nopercent,pngdate

```

And it is working. Thank you for your help.

----------

## anidabi

Need help, my MRTG is counting the traffic wrong!

I recently upgraded my network to 1Gbit and made the nessesary changes in mrtg.cfg file. For some reason it doesnt work and mrtg is counting the traffic wrong.

Here is my example of cfg file:

```

#------------eth2 Stats--------------

Colours[eth2]: GREEN#00c00c,BLUE#1000ff,DARK MAGENTA#007c79,MAGENTA#00d0cb

Options[eth2]: growright, nobanner, pngdate, noinfo, nopercent

Target[eth2]: \eth2:public@localhost:

SetEnv[eth2]: MRTG_INT_IP="192.168.0.1" MRTG_INT_DESCR="eth2"

MaxBytes[eth2]: 125000000

AbsMax[eth2]: 250000000

Title[eth2]: eth2 -- assrammers.org

PageTop[eth2]: <H1>eth2 -- assrammers.org</H1>

 <TABLE>

    <TR><TD>Maintainer:</TD> <TD>vader &lt;<a href="mailto:vader@gmail.com" target="_blank">vader@gmail.com</a>&gt;</TD></TR>

    <TR><TD>Description:</TD><TD>Intel Corporation 82541PI Gigabit Ethernet Controller</TD></TR>

    <TR><TD>Max Speed:</TD>  <TD>1 Gbits/s</TD></TR>

    <TR><TD>Ip:</TD>         <TD>192.168.0.1 (CRS-1.assrammers.org)</TD></TR>

 </TABLE>

YLegend[eth2]: Traffic eth2

ShortLegend[eth2]:

LegendI[eth2]: In:

LegendO[eth2]: Out:

Legend1[eth2]: Inbound traffic

Legend2[eth2]: Outbound traffic

Legend3[eth2]: Maximal Inbound traffic

Legend4[eth2]: Maximal Outbound traffic

WithPeak[eth2]: wmy

#Unscaled[eth2]: y

#------------End eth2 Stats----------

```

Okay, so this worket fine before with my 100mbit LAN connection. I only changed the MaxBytes[eth2]: 125000000, AbsMax[eth2]: 250000000 by adding one digit more and Target[eth2]: \eth2:public@localhost:, SetEnv[eth2]: MRTG_INT_IP="192.168.0.1" MRTG_INT_DESCR="eth2" to correspond the right nic.

The funny thing is that mrtg counts the traffic right for a breaf monemt when I manually update the graphs with this line:

```

/etc/cron.mrtg/mrtg.sh && /etc/cron.mrtg/mrtg.sh && /etc/cron.mrtg/mrtg.sh && /usr/bin/indexmaker --output=/var/www/localhost/htdocs/mrtg/index.html --title="<center>Carrier Routing System - CRS-1</center>" --subtitle="<center>" --sort=descr --enumerate /etc/mrtg/mrtg.cfg --nolegend --sort=descr  --pageend "</center><br><br><center><font face="arial" size="-1" color="#999999">MRTG stats powered by gentoo<br>Copyright 2007 by Vader</font></CENTER>"
```

Any ideas what's wrong?

----------

## jkroon

Shouldn't absmax be 125000000?

----------

## anidabi

 *jkroon wrote:*   

> Shouldn't absmax be 125000000?

 

Doesn't change anything, still reports speed around 8MB/s.

----------

## jkroon

Are you maxing the 1Gbps link out?  Remember that the counters are 32-bit (byte counters, so 35-bit bit counters).  So working in MB we can get to 125MB in exactly 1 second, 1GB in 8 seconds, and 4GB in 32 seconds.  To be exact, you can wrap that counter around in 34.35 seconds.  At 100Mbps this would take 343.5 seconds.  The difference?  At Gbps speeds this is less than the mrtg 5 min interval.  So if you are running at anything faster than 14316557 bytes/s (14MB/s) you are going to be running into wrapping issues, and you need to use the higher-precision values, can't remember where exactly to obtain then from, but you can no longer accurately use the standard 32-bit counters.

----------

## anidabi

Yes, you are right, it is because the 32bit counters aren't big enought. What changes I have to make to use the 64bit counters?

----------

## jkroon

I wish I knew ...

----------

## anidabi

Help! I can't get 64bit counters to work.  :Sad: 

----------

## anidabi

Arrgh... It couldn't be any simpler... good damn!   :Confused:   :Rolling Eyes: 

I changet 

```
Target[eth2]: \eth2:public@localhost
```

to 

```
Target[eth2]: \eth2:public@localhost:::::2
```

and now it works.

----------

## Spinner_Kontrol

I too kept having problems with ppp counters stopping coz the ppp index would change in snmp and there would be multiple ppp0 entries, with only one of them being up.

I found that doing a restart on snmpd, all the ifname ppp0's that were down were flushed out leaving just the 1 ppp0 entry, the one that I want to monitor - i.e. Target[ppp0]: \ppp0:public@localhost::::2

```
cat /etc/cron.mrtg/traffic.sh 

#!/bin/sh

if (( `snmpwalk -v2c -Os -c public localhost ifname | grep ppp | wc -l` != 1 )) ; then

 /etc/init.d/snmpd restart &>/dev/null

fi

/usr/bin/mrtg /etc/mrtg/traffic.cfg
```

obviously, this is really only any good if you're monitoring the local machine, but I'd say that's the case most of the time anyway. If anyone else has a better way to work around ppp IFs that keep changing their index and sneakily avoid monitoring, I'd be interested to see how it's done.

PS. if you have more than 1 ppp device, you might want to change the "!= 1" part of it to however many ppp devices you expect to be running

----------

## rek2

Hi I have mrtg installed working fine.. most of the servers I monitor have a cap bandwidth of 10M, the nic cards are 10/100,

so after talking with the ISP they put the cap at 20M now.. but the mrtg graphs have not changed and sometimes when it peeks it gets

to the max of the graphic an can't see were it really when to..

how can I increment the cap?

----------

## aztech

I can't get my cpu.cfg to work.

When running 

```
mrtg cpu.cfg
```

the result is ..

```

bionic mrtg # mrtg cpu.cfg                                                      

ERROR: CFG Error Unknown Option "sscpurawsystem.0&sscpurawsystem.0" on line 5 or

 above.                                                                         

           Check doc/reference.txt for Help

```

I've tried with having the Target[localhost.cpu]: .... on the same line, break it up in to several line,

but the result is still the same.

My cpu.cfg

```

WorkDir: /var/www/localhost/htdocs/mrtg                                         

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB-txt                                 

Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1+           

ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1+                             

ssCpuRawNice.0%ssCpuRawNice.0:public@127.0.0.1                                  

RouterUptime[localhost.cpu]: public@127.0.0.1                                   

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

```

I can't se whats wrong, can you, anyone ?

BR

Andreas

----------

## sleepingsun

I installed MRTG but i have problems with CPU, Mem, Swap ! 

When i type :

 *Quote:*   

> 
> 
> /etc/cron.mrtg/cpu

 

i get error massage :

```
Unknown SNMP var ssCpuRawUser.0

 at /usr/bin/mrtg line 2202

Unknown SNMP var ssCpuRawUser.0

 at /usr/bin/mrtg line 2202

2008-07-20 12:18:48: WARNING: Expected a number but got '0:04:24'

2008-07-20 12:18:48: WARNING: Expected a number but got 'bloodflowerz'

Unknown SNMP var ssCpuRawSystem.0

 at /usr/bin/mrtg line 2202

Unknown SNMP var ssCpuRawSystem.0

 at /usr/bin/mrtg line 2202

2008-07-20 12:18:48: WARNING: Expected a number but got '0:04:24'

2008-07-20 12:18:48: WARNING: Expected a number but got 'bloodflowerz'

Unknown SNMP var ssCpuRawNice.0

 at /usr/bin/mrtg line 2202

Unknown SNMP var ssCpuRawNice.0

 at /usr/bin/mrtg line 2202

2008-07-20 12:18:48: WARNING: Expected a number but got '0:04:24'

2008-07-20 12:18:48: WARNING: Expected a number but got 'bloodflowerz'

2008-07-20 12:18:48: ERROR: Target[localhost.cpu][_IN_] ' $target->[0]{$mode}  +                                             $target->[1]{$mode}  +  $target->[2]{$mode} ' (warn): Use of uninitialized val                                           ue in addition (+) at (eval 21) line 1.

2008-07-20 12:18:48: ERROR: Target[localhost.cpu][_OUT_] ' $target->[0]{$mode}                                             +  $target->[1]{$mode}  +  $target->[2]{$mode} ' (warn): Use of uninitialized va                                           lue in addition (+) at (eval 22) line 1.

```

Also for Memory i get this one massage :

/etc/cron.mrtg/mem

```
Unknown SNMP var memAvailReal.0

 at /usr/bin/mrtg line 2202

Unknown SNMP var memAvailReal.0

 at /usr/bin/mrtg line 2202

2008-07-20 12:20:07: WARNING: Expected a number but got '0:05:44'

2008-07-20 12:20:07: WARNING: Expected a number but got 'bloodflowerz'

2008-07-20 12:20:07: ERROR: Target[localhost.mem][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

2008-07-20 12:20:07: ERROR: Target[localhost.mem][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data

```

and for swap i get this:

/etc/cron.mrtg/swap

```
Unknown SNMP var memAvailSwap.0

 at /usr/bin/mrtg line 2202

Unknown SNMP var memAvailSwap.0

 at /usr/bin/mrtg line 2202

2008-07-20 12:21:15: WARNING: Expected a number but got '0:06:52'

2008-07-20 12:21:15: WARNING: Expected a number but got 'bloodflowerz'

2008-07-20 12:21:15: ERROR: Target[localhost.swap][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

2008-07-20 12:21:15: ERROR: Target[localhost.swap][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data

```

This work till i dont decide to put CPU Temperature and emerge net-snmp with flags lm_sensors ! 

Is it any way that all works together ?

----------

## sdutky

Many thanks for the information here: I did it, it worked.

I have list of particular interfaces on each of several cisco devices:

Is there any simple way of feeding them into cfgmaker?

I have looked for an at the filter-template options: they seem like overkill.

I could use cfgmaker to produce a file with all up interfaces and then edit that to prune the ones I don't care about.

Is there a simpler way to accomplish this?

Thanks.

----------

## sdutky

not intuitive, not pretty, but it worked:

cfgmaker --global "WorkDir: /home/here/.mrtg" --global "Options[_]: growright,bits" --ifref=name --ifdesc=alias --community=public --subdirs=core_HOSTNAME --noreversedns \

--if-filter='$target_name=~m/Fa0_(?:2|5|6|7|9|10)$/' dhcp@169.254x.214.63 \

--if-filter='$target_name=~m/(?:Fa0_22|Gi0_[12])$/' 169.254x.1.1 \

--if-filter='$target_name=~m/(?:Gi0_1)$/' 169.254x.1.2 \

--if-filter='$target_name=~m/(?:Fa0_(?:11|21|20|22|23)|Gi0_1)$/' 169.254x.1.3 \--if-filter='$target_name=~m/_Fa/' 169.254x.1.4 \

--if-filter='$target_name=~m/Gi0_(?:8|9|10)$/' 169.254x.1.5 \

--if-filter='$target_name=~m/Gi0_(?:7|9|10)$/' 169.254x.1.6

----------

## dcreatorx

Can somebody tell me a very simple thing : how do you configure snmpd.conf to permit an SNMP request from another host that is not localhost ?

I'm trying to modify the file and restarting with what I have read, but I can't get it to work !! 

Thanks.

----------

## hikarinoko

Hi everyone !

First, i'd like to thanks the people that created this HOW-TO, it helped me a LOT with MRTG !

still, i'm facing a problem that i can't solve, i've been looking for a lot of ways to get it to work but it just doesn't !

i'm using MRTG @Work, it runs on a SUNOS environement (SunOS 10 i guess)

i wanted to poll some specific data onto an Ironport C660.

As it wasn't on the MIB, i decided to create a script and do like the "PING" part so i did the following :

i tried to test a simple thing that just doesn't work :

script test.sh :

```

#!/bin/ksh

retour=`wc -l /usr/local/mrtg-2/bin/pydmm1_conn_state.txt | gawk '{print $1}'`

echo $retour

echo $retour

echo $retour >> /usr/local/mrtg-2/bin/debug.txt

echo

echo

```

This script count lines in a file (i let this "static" to 197) , running this scripts returns :

```

197

197

```

so i get the "right values" for what i want to do, i then create a config file :

```

WorkDir: /usr/local/mrtg-2/www

Include: base-options.inc

### Global Defaults

Options[_]: growright

EnableIPv6: no

Target[test3.cursess]:`/usr/local/mrtg-2/bin/test.sh`

MaxBytes[test3.cursess]: 200000

YLegend[test3.cursess]: whatever

ShortLegend[test3.cursess]: whatever

Options[test3.cursess]:gauge, growright, nopercent

Title[test3.cursess]: whatever ironport

PageTop[test3.cursess]: <H1>whatever ironport</H1>

```

then i run indexmaker :

```
./indexmaker ../conf/testscript.conf --output ../www/test.html

```

and then i run the thing :

```
./mrtg ../conf/testscript.conf --logging test.log
```

this runs FINE and do the graph with no problem

then i add this to crontabs to get the thing right, THIS IS WHERE THE PROBLEM BEGINS

i go to my crontabs and add the line :

```
2,7,12,17,22,27,32,37,42,47,52,57 * * * *  /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/conf/testscript.conf --logging /usr/local/mrtg-2/log/testscript.log
```

i wait a few minute and my graph stays @ 0, when i cat the log file i get : 

```

2009-09-29 14:13:16 -- Started mrtg with config '/usr/local/mrtg-2/conf/testscript3.conf'

2009-09-29 14:13:17 -- WARNING: Problem with External get '/usr/local/mrtg-2/bin/test.sh':

   Expected a Number for 'in' but got ''

2009-09-29 14:13:17 -- WARNING: Problem with Externale get '/usr/local/mrtg-2/bin/test.sh':

   Expected a Number for 'out' but got ''

2009-09-29 14:13:17 -- ERROR: Target[test3.cursess][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

2009-09-29 14:13:17 -- ERROR: Target[test3.cursess][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data

```

i can see that my script doesn't return any data when crontab, after serching for a while i try to change my script with :

```

#!/bin/ksh

echo hello

echo world

echo

echo

```

i obtain

```

hello

world

```

after a few minutes... this is what i get in the logfile...

```
2009-09-29 14:13:16 -- Started mrtg with config '/usr/local/mrtg-2/conf/testscript3.conf'

2009-09-29 14:13:17 -- WARNING: Problem with External get '/usr/local/mrtg-2/bin/test.sh':

   Expected a Number for 'in' but got 'hello'

2009-09-29 14:13:17 -- WARNING: Problem with Externale get '/usr/local/mrtg-2/bin/test.sh':

   Expected a Number for 'out' but got 'world'

```

i really don't understand why with some basic echo it works and why when i try to echo a variable it doesn't ....

i also tried to write my variables into a file whenever my script is used, and so far all i'm getting is an empty file with blank lines at every execution of crontabs....

if someone could help me out...  :Smile:  THX A LOOOTTTTTT !!!

----------

