From:
http://library.linode.com/server-monitoring/cacti/ubuntu-10.04-lucid
Begin by setting the timezone of your server if it isn't already set.
Set your server to your timezone or to that of the bulk of your users.
If you're unsure which timezone would be best, consider using
Universal Coordinated Time (or UTC, ie. Greenwich Mean Time). Keep in mind
that Cacti uses the timezone set on the monitoring machine when generating
its graphs. Run the following command to set the timezone:
dpkg-reconfigure tzdata
First, make sure you have the
universe repositories enabled on your system. Your
/etc/apt/sources.list should
resemble the following (you may have to uncomment or add the
universe lines):
File:/etc/apt/sources.list
## main & restricted repositories
deb http://us.archive.ubuntu.com/ubuntu/ lucid main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid main restricted
deb http://security.ubuntu.com/ubuntu lucid-security main restricted
deb-src http://security.ubuntu.com/ubuntu lucid-security main restricted
## universe repositories - uncomment to enable
deb http://us.archive.ubuntu.com/ubuntu/ lucid universe
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid universe
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates universe
deb http://security.ubuntu.com/ubuntu lucid-security universe
deb-src http://security.ubuntu.com/ubuntu lucid-security universe
If you had to enable new repositories, issue the following command to update your package lists:
apt-get update
apt-get upgrade
Before installing Cacti we must install a few basic dependencies that are
critical to the installation of Cacti. Cacti uses the Simple Network
Management Protocol (SNMP) to poll the devices it tracks. We'll need to
install the
snmpd and
snmp packages to allow Cacti to use SNMP.
Cacti's web interface requires a database, web server, and PHP to be
installed. Issue the following command to install these prerequisites:
apt-get install snmpd snmp mysql-server apache2 libapache2-mod-php5 \
php5-mysql php5-cli php5-snmp
You will need to create a password for the
root user of your MySQL
database during the installation. After the installation completes, be
sure to run
mysql_secure_installation to disable some of MySQL's less
secure components. Also consider reading our
MySQL installation guide
for configuration recommendations.
The above command will additionally install the Apache web server. Consider
our documentation on
installing the Apache HTTP server
for more information regarding this server. Additionally Cacti can function
with alternate web server configurations, including
Apache with PHP
running as a CGI process
and with
nginx running PHP as a FastCGI
process.
SNMPD binds to
localhost by default. If you only plan on using Cacti
to monitor your Linode, you do not need to modify
/etc/default/snmpd.
However, if you'd like to use Cacti to monitor more than one host, you'll
need to edit the
/etc/default/snmpd file. Open the file and find the line that
starts with
SNMPDOPTS= and remove
127.0.0.1 at the end. This line
should now look like this:
File:/etc/default/snmpd
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
At this point SNMPD is configured to listen on all interfaces. Now we'll
open
/etc/snmp/snmpd.conf to establish which host is trusted to receive
data.
We'll create an SNMP "community" to help identify our group of devices
for Cacti. In this instance, our hostname is "bucknell.org",
so we've named the community "Bucknell". The community name choice is up
to the user. Locate the section of
snmpd.conf that begins with
com2sec
and make sure the
readonly line is the only uncommented line. This section
of the file should now look like this:
File:/etc/snmp/snmpd.conf
#com2sec paranoid default public
com2sec readonly localhost Bucknell
#com2sec readwrite default private
If you want a remote machine to connect to Cacti, replace "localhost" with
the IP address of the remote machine.
You need to restart snmpd any time
/etc/snmp/snmpd.conf is modified.
Run the following command after closing the file:
/etc/init.d/snmpd restart
To install the Cacti package from the distribution software
repositories, issue the following command:
apt-get install cacti
You will be presented with several prompts during this installation. On
the "libphp-adodb" prompt you can safely select "Ok". During the "Configuring
Cacti" prompt, make sure to select "Apache2". You will be presented with
an additional "Configuring cacti" prompt that will ask if you'd like
to configure your database with dbconfig-common. Select "Yes" and continue.
On the MySQL prompt, enter the root password you created earlier. On the
next screen, either create your own password for cacti's database access, or
leave it blank for it to automatically generate one for you.
From here we'll continue configuring Cacti through the browser. Visit
the domain you have pointed at your Linode or your Linode's IP address, and
add
/cacti. Follow the instructions shown on each page. Make sure to
select
RRDTool 1.2.x in the "RRDTool Utility Version" drop down. You
should be able to continue through these pages into the login page
without alteration.
At the login screen, enter
admin/admin for the username/password combination.
You'll be prompted to change your password on the next screen. At this point,
Cacti is installed and ready to be configured.
At this point Cacti will contain an entry for
localhost, which we'll
need to modify. Click the "Console" tab in the top left corner, and select
"Create Devices for network". Click the "Localhost" entry to begin making
the needed changes. Select the Host Template drop down and pick the "ucd/net SNMP Host".
Scroll down to SNMP Options and click the drop down box for SNMP Version,
picking "Version 1". Enter "Bucknell" (or the community name you created above)
in the box for the "SNMP Community" field. The "Associated Graph Templates"
section allows you to add additional graphs. Hit "Save" to keep the changes.
Click "Settings" under "Configuration" and set your "SNMP Version" to
"Version 1" in the drop down box. Type the name of your community for
the "SNMP Community" (in this example, "Bucknell") and save.
This section is optional and for those looking to use Cacti to monitor
additional devices. These steps are written for Debian-based distributions,
but with modification, they will work on any flavor of Linux. You will need
to follow these instructions for each client machine you'd like to monitor
with Cacti. Client machines need an SNMP daemon in order to serve Cacti
information. First, install
snmp and
snmpd on the client:
apt-get install snmp snmpd
Next we'll need to modify the
/etc/snmp/snmpd.conf file with the name
of our community. Run the following commands to backup your existing
snmpd.conf
file and replace the contents with the name of your community:
mv /etc/snmp/snmpd.conf /etc/snmp/old.snmpd.conf
echo "rocommunity mycommunity" > /etc/snmp/snmpd.conf
Note that the format is "rocommunity community_name", where
community_name
is the name of the community you originally used with Cacti. Next, we'll
open the
/etc/default/snmpd file and remove the binding on
localhost.
Like the "Configuring SNMP" section above, you'll want to find the line
that begins with
SNMPDOPTS and remove the reference to
127.0.0.1 at
the end. This line should now resemble the one below:
File:/etc/default/snmpd
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
Finally, restart the SNMP daemon to push the changes you've made to these
files:
/etc/init.d/snmpd restart
At this point your machine is ready for polling. Go into the Cacti interface
to add the new "Device". Under the "Console" tab, select "New Graphs" and then
"Create New Host". Enter the pertinent information in the fields required.
Make sure to select "Ping" for "Downed Device Detection". Additionally, ensure
that you've typed the right community name in the "SNMP Community" field.
Click the "create" button to save your configuration. On the "save successful"
screen, select your newly created device and from the drop down next to
"Choose an Action" select "Place on a Tree" and then click "go". Hit "yes"
on the next screen. On the "New Graphs" screen, you'll be able to create
several different types of graphs of your choice. Follow the on-screen
instructions to add these graphs to your tree.
By default, Cacti uses a PHP script to poll the devices it tracks. "Spine"
is a faster replacement for the default polling script written in C++.
Installing Spine is relatively easy and a good idea if you plan on keeping
track of many hosts. Begin the Spine installation by running the following command
apt-get install cacti-spine
After the installation completes, go back to the Cacti administrative
panel and click "Settings" under "Configuration". Click the "Paths" tab
and check to see that Cacti found your spine binary correctly. Click the
"Poller" tab and choose "Spine" from the drop-down for "Poller Type". Click
"Save" to keep these changes. You are now successfully using Spine.