# MRTG, can anyone get it to work?

## KraziKid

I have recently got MRTG from portage, and no luck.  I cannot get this thing to work.  This is the error I get when running cfgmaker:

 *Quote:*   

> --base: Get Device Info on community@router:
> 
> SNMP Error:
> 
> no response received
> ...

 

Any help is welcome.

----------

## Nitro

You have a snmp server running on 192.168.1.1 right?  If you have no clue what I'm talking about, you need to emerge either net-snmp or ucd-snmp (I recommend you choose net-snmp unless you have any specific requirements).  After you have one emerged, you need to start it up. IE: `/etc/init.d/net-snmpd start` for net-snmp, and for ucd-snmp, just remove "net-".

Tell me how it goes after that.

----------

## KraziKid

Still does not work.  I get the same error.  Is there a specific community name I should be using?

----------

## Nitro

You've checked that the snmp daemon is listening on tcp port 161?  Do you have a firewall up? If so, is it allowing connections to port 161?  Which snmp package did you emerge?  Does doing an snmpwalk from the box connect and display data okay?

----------

## KraziKid

Okay, I was just able to get it up and running, with a very rudimentary snmpd.conf file.  But, the graphs show nothing whatsoever, they are blank.  Would you mind sending me your snmpd.conf file, so I can create one based upon one that is working?  Also, would you mind sending me your mrtg.cfg file?  That would be greatly appreciated.  I am using net-snmp like you suggested.

----------

## Nitro

 *KraziKid wrote:*   

> But, the graphs show nothing whatsoever, they are blank. 

   Graphs span over hours to a a few weeks.  You will need to give it a few hours before it can start collecting enough data to draw a graph.  You do have mrtg setup in a crontab to run ever 5 minutes or running mrtg in daemon mode right?

 *KraziKid wrote:*   

> Would you mind sending me your snmpd.conf file, so I can create one based upon one that is working?

 Snmpd.conf doesn't matter much as far as MRTG is concerned.  A nice simple snmpd.conf file will work fine, I suggest you take a peak at snmpconf to assist you in setup.

 *KraziKid wrote:*   

> Also, would you mind sending me your mrtg.cfg file?  That would be greatly appreciated.

 My mrtg.cfg files are kind of old and I'm starting to move towards RRDTool.  Just search around on google, you will find alot of examples.

----------

## KraziKid

Okay, I got it to work.  I went on my friends ClarkConnect box, and copied the mrtg.cfg files from his.  Then I edited them to suite my needs on Gentoo.  Thanks for all your help.

----------

## Rroet

editing a friends mrtg.cfg usually doesn't happen in a correct way if you have ppp devices or multiple networkcards.

You should really be considering using cfgmaker which is the standard mrtg.conf creation tool.

----------

## KraziKid

 *Rroet wrote:*   

> editing a friends mrtg.cfg usually doesn't happen in a correct way if you have ppp devices or multiple networkcards.
> 
> You should really be considering using cfgmaker which is the standard mrtg.conf creation tool.

 

I got it working by using the mrtg.cfg files from my friends ClarkConnect box (which has two NIC's like my gentoo box).  I did this over using cfgmaker, because I really didn't want to mess with snmp.  Now that I have it installed, I can mess around with it, but for the time being, I'm happy with the graphs that are being spitted out.  Also, Nitro was helping me out, and I got some graphs running off of a cfg example he gave me.  So thanks Nitro, and to Rroet, for trying to help too.  I will use cfgmaker, once I get snmp running nicely, but as of right now, I just wanted MRTG to be running.

----------

## kashani

I wrote a few scripts and some explainations on my website. It also includes a Gentoo compatible init script for MRTG... it does need a bit a work, but does the job. 

http://www.badapple.net/tech/mrtg.html

kashani

----------

## crevette

I have the same problem. I copied the example conf to /usr/share/docs/snmpd/, started net-snmpd and launched

```

cfgmaker public@10.1.253.45 --output mrtg.cfg

```

I've got this error

```

SNMPv1_Session (remote host: "10.1.253.45" [10.1.253.45].161)

                  community: "public"

                 request ID: 1915024909

                PDU bufsize: 8000 bytes

                    timeout: 2s

                    retries: 5

                    backoff: 1)

 at /usr/bin/../lib/mrtg2/SNMP_util.pm line 571

SNMPWALK Problem for 1.3.6.1.2.1.2.2.1.7 on public@10.1.253.45:

 at /usr/bin/cfgmaker line 107

--base: Walking ifOperStatus

SNMP Error:

no response received

```

and the file mrtg.conf is empty or so (just the comments of the file)

----------

## kashani

[quote="crevette"]

```

SNMP Error:

no response received

```

The above would be the source of your problems. Why that is happening could be any number of reasons. snmp deamon not running, snmp device filtering, firewall in the middle filtering, etc.

kashani

----------

## crevette

my snmpd daemon is running (I ckecked it with netstat), I retreive my statistics in local, so there is no firewall in the middle.

I don't know what is the problem

----------

## Hellfire

Assuming you have already correctly installed either net-snmp or ucd-snmp (I recommend net) and mrtg -

/usr/share/snmp run `snmpconf` and it will walk you through the generation of a correct and functional snmpd.conf file. 

Most people who are going to ACL the daemon or firewall it off will simply use "public" and "private" for the read-only and read/write strings. It shouldn't take you more than 5 minutes to set the half-dozen options required even for a first-timer.

After you end that program fire up the daemon through init.d and run `cfgmaker public@localhost --output=/etc/mrtg-canopus.cfg` or whatever you you would like your filename to be. That will autogenerate a proper interface-only configuration file for all the devices that respond in snmp. That *should* include all nic and ppp adapters as well as loopback.

Comment in/out the ones you want to see and edit the "WorkDir" directory to "/home/httpd/mrtg" and make sure that the directory is created. I prefer to let mrtg daemonize myself so "RunAsDaemon: Yes"

in your mrtg-yadda.cfg:

```
WorkDir: /home/httpd/mrtg

Forks: 6

RunAsDaemon: Yes

Options[_]: growright, bits
```

Then create this little bad-boy and be sure to add the appropriate #include into your apache.conf file.

*/etc/apache/conf/addon-modules/apache.mrtg*

```
# password /mrtg/*

<Directory /home/httpd/mrtg>

    Options FollowSymLinks

    Order deny,allow

    Deny from all

    Allow from 127.0.0.1

    Allow from *mylocalsubnet*/255.255.255.0

    AuthType Basic

    AuthUserFile /etc/apache/htpasswd.users

    AuthGroupFile /etc/apache/htpasswd.groups

    AuthName "Papers Please."

    require group admin

    satisfy any

</Directory>

<IfModule mod_alias.c>

        Alias /mrtg "/home/httpd/mrtg"

</IfModule>

# EOF
```

Assuming snmpd is still running you can now run `mrtg /etc/mrtg-yadda.cfg` and it should daemonize itself and begin normal operation. The first time mrtg is run with a new dataset (in this case new interfaces) it will generate some errors but continue to run. If `ps -ef | grep "mrtg"` reveals that it is not running you have an error in your .cfg file or you forgot to create the output directory - it's pretty self-explanatory.

That's all there is to it to do basic monitoring, if you're looking for a few more advanced topics check out the mrtg homepage for some great external links like Somix

Because MRTG accepts programatic inputs you can write perl or bash scripts to put nearly *any* stat in. On various servers around my shop I monitor mySQL load, cpu load, TCP/UDP connections, ntp and dns queries, connected users, system uptime, all kinds of ram/drive stats and so forth.

In short (or long...) MRTG = luv. 

-h

----------

## crevette

It's not working  :Crying or Very sad:   :Crying or Very sad:   :Crying or Very sad:   :Crying or Very sad:   :Crying or Very sad: 

I've checked the port with netstat -lapute and I have this :

```

udp 0 0 *:snmp *:* root 159516  28820/snmpd

```

snmpd is running but not listening!!!!!!

----------

## Hellfire

Try resetting your snmpd.conf and restarting the daemon. I supplied my "blank" config which will enable a fully functional snmp set with a public (read-only) and private (read/write) user for snmp v1..3.

Note: There are no IP-based ACL's in this config so if you're on the net someone could write snmp data using the "default" private r/w user.

From /usr/share/snmp/snmpd.conf:

```
#   this token in the snmpd.conf file will disable write access to

#   the variable.

#   arguments:  contact_string

syscontact  "root"

syscontact  root@localhost

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

# 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  private

# rouser: a SNMPv3 read-only user

#   arguments:  user [noauth|auth|priv] [restriction_oid]

rouser  public

# rocommunity: a SNMPv1/SNMPv2c read-only access community name

#   arguments:  community [default|hostname|network/bits] [oid]

rocommunity  public

# rwcommunity: a SNMPv1/SNMPv2c read-write access community name

#   arguments:  community [default|hostname|network/bits] [oid]

rwcommunity  private
```

-h

----------

## kashani

 *crevette wrote:*   

> my snmpd daemon is running (I ckecked it with netstat), I retreive my statistics in local, so there is no firewall in the middle.
> 
> I don't know what is the problem

 

Is MRTG running on the local machine you are trying to query or a remote host?

If it's on a remote host here's a quick way to see if you're getting anything from the command line. In gentoo you'll need to have one of the snmp packages installed to get snmpwalk

[code}

kashani@azul kashani $ snmpwalk -Os -c snmpstring -v 1 rtr1.lax system

sysDescr.0 = STRING: Cisco Internetwork Operating System Software 

IOS (tm) 7200 Software (C7200-IK9O3S-M), Version 12.2(13)T,  RELEASE SOFTWARE (fc1)

TAC Support: http://www.cisco.com/tac

Copyright (c) 1986-2002 by cisco Systems, Inc.

Compiled Sat 16-Nov-02 03:39 by ccai

sysObjectID.0 = OID: enterprises.9.1.222

sysUpTime.0 = Timeticks: (262774940) 30 days, 9:55:49.40

[/code]

kashani

----------

## crevette

Ok,  I took the snmpd.conf from Hellfire (Thanks a lot   :Wink:   :Wink:   :Wink:   :Wink:  ), and I generated my config file for mrtg with

```

cfgmaker private@localhost > localhost.cfg

```

and ... it's worked, Yesssssssss.

```

### Interface 2 >> Descr: 'eth0' | Name: '' | Ip: '10.1.253.45' | Eth: '00-a0-c9-db-30-a4' ###

Target[localhost_2]: 2:private@localhost:

SetEnv[localhost_2]: MRTG_INT_IP="10.1.253.45" MRTG_INT_DESCR="eth0"

MaxBytes[localhost_2]: 1250000

Title[localhost_2]: Traffic Analysis for 2 -- staff.navlink.com

PageTop[localhost_2]: <H1>Traffic Analysis for 2 -- staff.navlink.com</H1>

 <TABLE>

   <TR><TD>System:</TD>     <TD>staff.navlink.com in Unknown</TD></TR>

   <TR><TD>Maintainer:</TD> <TD>root@localhost</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>1250.0 kBytes/s</TD></TR>

   <TR><TD>Ip:</TD>         <TD>10.1.253.45 ()</TD></TR>

 </TABLE>

```

----------

## crevette

I noticed the problem about the system's name.

How can I resolve it???

----------

## Hellfire

That info is all set in your snmpd.conf file, now that you have a working one as your base either edit it directly (check the net-snmpd site) or go through the snmpconf util and set it there. The information you're looking for is part of the "system" OID.

-h

----------

## crevette

Ok (2) I did a

```

snmpconf -g basic_setup

```

Very interesting command !!!!! 

 :Razz:   :Razz:   :Razz:   :Razz:   :Razz: 

----------

## crevette

So, now it's a little bit working

http://staff.navlink.com/stats/eth0.html

Now,  I would like that mrtg display the others parameters I set up, (disk space, cpu, ...)

----------

## Richards

 *Hellfire wrote:*   

> Try resetting your snmpd.conf and restarting the daemon. I supplied my "blank" config which will enable a fully functional snmp set with a public (read-only) and private (read/write) user for snmp v1..3.
> 
> Note: There are no IP-based ACL's in this config so if you're on the net someone could write snmp data using the "default" private r/w user.
> 
> From /usr/share/snmp/snmpd.conf:
> ...

 

Since you seem the most knowledgeable about this, and I had problems trying to use snmpconf -g basic_setup ( it woudnt write... )

I used your 'basic' snmpd.conf, and I tried getting my fbsd machine to get MRTG stats from it.

su-2.05b# /usr/local/bin/cfgmaker public@192.168.1.110

--base: Get Device Info on public@192.168.1.110:

SNMP Error:

no response received

SNMPv1_Session (remote host: "192.168.1.110" [192.168.1.110].161)

                  community: "public"

                 request ID: -143914427

                PDU bufsize: 8000 bytes

                    timeout: 2s

                    retries: 5

                    backoff: 1)

 at /usr/local/lib/perl5/site_perl/5.6.1/SNMP_util.pm line 621

SNMPWALK Problem for 1.3.6.1.2.1.1 on public@192.168.1.110::::::v4only

 at /usr/local/bin/cfgmaker line 825

WARNING: Skipping public@192.168.1.110: as no info could be retrieved

Now, snmpd worked perfectly fine for the fbsd machine, but im having problems getting it to work on the gentoo machine. I feel im either doing something wrong, or totally missing a step  :Smile: 

----------

## Richards

*bump*

----------

