SNMP + RRDTool + Cacti on Debian Lenny mini-HOWTO

SNMP is used in network management systems to monitor network-attached devices for conditions that warrant administrative attention. With SNMP + RRDTool + Cacti, you can generate graph for your system dynamically. As compare with other solution, e.g. SNMP + MTRG, RRDTool is more specific for information NOT only about network traffic but support both other information, plus database-like query system so you can fetch report for any time period. This mini-HOWTO will guide you though the setup for SNMP + RRDTool + Cacti on Debian Lenny.

Prepare Debian Lenny

Before start I will assume you have a functional Debian Lenny setup. If you have any question please refer to my mini-HOWTO for upgrade Debian as Lenny.

It is also recommended to install your system with a function xorg. This can be complete with tasksel --new-install where choose both Desktop environment and Standard system. You should also click manual package selection in order to verify your installation before start.

Next, install all required package. You can skip all configuration during installation, soon we will come back for it:

apt-get update apt-get install libapache2-mod-php5 php5-cli php5-mysql php5-snmp rrdtool snmp snmpd mysql-server-5.0

Prepare Apache and PHP for phpMyAdmin

Before install phpMyAdmin we should give some basic configuration for Apache and PHP.

Edit /etc/php5/apache2/php.ini and change the following lines accordingly:

memory_limit = 128M; post_max_size = 32M upload_max_filesize = 32M date.timezone = "Asis/Hong_Kong" display_errors = Off

Edit Apache default site setup with /etc/apache2/sites-enabled/000-default, and change the AllowOverride none with AllowOverride all as follow (note: this setup is just for non-production site):

Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all

Now you can restart your Apache:

/etc/init.d/apache2 restart

Setup root password for MySQL

This is very simple with following command:

mysqladmin -uroot password CHANGE mysql -uroot -p

Install phpMyAdmin

I would like to assist my MySQL setup with phpMyAdmin. First of all, download the package from sourceforge.net:
http://www.phpmyadmin.net/home_page/downloads.php

Prepare your phpMyAdmin:

mv zxvf phpMyAdmin-3.1.2-all-languages.tar.gz /var/www/ cd /var/www tar zxvf phpMyAdmin-3.1.2-all-languages.tar.gz ln -s phpMyAdmin-3.1.2-all-languages phpmyadmin cd phpmyadmin mkdir config cp config.sample.inc.php config/config.inc.php chmod -Rf 777 config

Access http://localhost/phpmyadmin/setup/ and configure with following parameters, and save your setup:

  • Overview -> Servers -> New server -> Save (this will setup localhost by default)
  • Features -> Import/export -> Upload directory -> /tmp
  • Features -> Import/export -> Save directory -> /tmp
  • Features -> Import/export -> Allow character set conversion -> Yes
  • Features -> Import/export -> Default character set -> utf-8

Back to console and run the following commands:

cd /var/www/phpmyadmin mv config/config.inc.php . rm -rf config chmod 644 config.inc.php

Now access your phpmyadmin from http://localhost/phpmyadmin/, and login with your root. Verify all setup.

Configure snmpd

Edit /etc/snmp/snmpd.conf and change as below accordingly:

#com2sec paranoid default public com2sec readonly default public #com2sec readwrite default private syslocation www.example.com syscontact Root

Edit /etc/default/snmpd and change as below accordingly (this change will make snmpd listen to all network interface, beware to protect your server with firewall):

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'

Restart snmpd:

/etc/init.d/snmpd

Verify your setup:

snmpwalk -Os -c public -v 1 localhost system

Install Cacti

Download latest Cacti from official site:
http://www.cacti.net/download_cacti.php

Prepare Cacti source code:

mv cacti-0.8.7c.tar.gz /var/www/ tar zxvf cacti-0.8.7c.tar.gz ln -s cacti-0.8.7c cacti

Now we should create MySQL user and database for cacti. You can setup with phpmyadmin (Privileges -> Add a new User):

  • Username: cacti
  • Host: localhost
  • Password: CHANGE
  • Database for user: Create database with same name and grant ll privileges

Remember to retouch the database as utf8_general_ci

Import Cacti database for MySQL:

mysql -uroot -p cacti < cacti.sql

Edit include/config.php and setup accordingly:

/* make sure these values refect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "CHANGE"; $database_port = "3306";

Access Cacti web interface (http://localhost/cacti/install/) and continuous the installation:

  • Please select the type of installation: New install
  • Confirm all system tools binary exists
  • Login with username admin with password admin

Edit cron jobs for www-data with crontab -u www-data -e, in order to fetch SNMP information:

*/5 * * * * php /var/www/cacti/poller.php > /dev/null 2>&1

After log into Cacti, go to Console -> Cacti Settings -> Poller, and confirm all parameters.

Now create devices for network:

  • Remove localhost setup (we will use SNMP instead)
  • Add new devices
  • Fill in with basic information, and Host Template as ucd/net SNMP Host
  • SNMP Version: Version 1

After save Cacti should report that it can access your SNMP server (for now, it is localhost). Associated Data Queries should display as:

1) SNMP - Interface Statistics (Verbose Query) Uptime Goes Backwards Success [27 Items, 3 Rows] Reload Data Query Delete Data Query Association 2) ucd/net - Get Monitored Partitions (Verbose Query) Uptime Goes Backwards Success [6 Items, 2 Rows] Reload Data Query Delete Data Query Association

It is time for create new graph. Go to Console -> Devices and choose your target device. Within its configuration page click on Create Graphs for this Host and add all graph that you decided for this host.

Next we should add your graphs into graph trees. Go to Console -> Graph Tree and choose Default Tree, press add. For Tree Item Type choose Host and your target host. Well, all done basically :D

After cron job run for around 10 minutes, access your http://localhost/cacti/graph_view.php and you should find your graphs. Yes you get it :D

Enable anonymous access

By default Cacti disable guest (anonymous) access (http://docs.cacti.net/node/493). In order to activate it:

By default in 0.8.7 and later of Cacti, Guest or Anonymous access is disabled. This is shift from previous release that came with the "Guest" user enabled and set.

Enabling "Guest" access is easy. But, you must understand that you should only allow the designated "Guest" user access to what you authorized. It is not sugguested that you give the designated "Guest" user more than just access to graphs. To enable guest access, first, need a designated "Guest" user. Cacti by default comes with one already created that has access to only graphs. It is important to note that the default guest user has access to all graphs on the system. Once you have created the "Guest" user, you need to tell Cacti what the "Guest" user is. This is done by updating the Authenication Settings and selecting the "Guest" user you have designated. The "Guest" user must be enabled and be set as the guest user for anonymous access to work.

Comments

Tazz's picture

Thanks for:

/etc/default/snmpd

i don't remember this file in any of my last installations, but yes on this ;)

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.