3. Adding new devices to cacti
A device can be anything which is SNMP enabled. It could be a router, a switch….
In our example, we are going to add the server we configured in the first part of this tutorial. The server is on localhost, but it could be anywhere on a network, as long as our manager host is allowed to connect to its SNMP port.
3.1. Creating a new device
To create a new device, first make sure you are in the “Console”, if not, click on the “Console” tab on the top left and click on Create devices for network.
This will bring you to a new page where you are going to give details about the SNMP host.
Fill up the form and make sure you have the following value properly set:
- Hostname to localhost or whichever url/address your SNMP server can be found at
- Host Template to ucd/net SNMP Host
- SNMP Community to mycommunity or whatever your community is called
- SNMP Version to Version 1
- SNMP Port default is 161 which should be fine for 99% settings. Change accordingly to your SNMP server settings
Then Click create and you should get to a page where you get something similar to:
MySNMPServer (snmp.server.ip) SNMP Information System: Linux hostname kernel-version #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686 Uptime: 980871 (0 days, 2 hours, 43 minutes) Hostname: hostname Location: Unknown (configure /etc/snmp/snmpd.local.conf) Contact: Root [email protected] (configure /etc/snmp/snmpd.local.conf)
and not like:
SNMP Information SNMP error
If you get the latest output, this means that the connection between the manager and the SNMP host could not be established, either firewalled or refused by the host. Use snmpwalk -Os -c mycommunity -v 1 snmp.server.ip system to troubleshoot.
3.2. Creating a new Graph for a device
OK, sweet, we have enabled our first host to be monitored by cacti. Now, let’s add a few graphs.
Click the “Create Graphs for this Host” and check the boxes you want to monitor (CPU Usage, Load Average, Memory Usage).
Under “Data Query [SNMP - Interface Statistics]”, check the interfaces you want to monitor and finaly in “Select a graph type” choose the kind of stats you want. I chose “In/Out Bytes with Total Bandwidth”.
Validate, and that’s it, you will start monitoring some componenets of your device.
Now, lets organize our graph tree.
3.3. Creating a Graph Tree
Cacti graphs are organied in a tree. Each host could be a branch of that tree. We are now going to create a branch for our device.
Create a graph tree by going to the left menu and click on “Graph Tree” and “add” on the right side of the new page.
Enter a name to describe your device and click create.
Add a “Tree Item” and select:
Parent Item *[root]* Tree Item Type *Host* Host *yourhost* Graph Grouping Style *Graph Template*
Here we are!!! Now click on the “Graph” tab and select your host from the tree.
Voila! Mind that you will need some times before you can see datas.
Once you have been able to set up a first host to work with cacti, it is fairly easy to add other host from your network. Simply cnfigure the snmp server in such a way that the machine hosting cacti will be able to contact them.
In this tutorial, the security was preserved by binding the service to localhost and changing the default community name from public to mycommunity. If you start deploying SNMP over the network, I would recommend that you only accept traffic to port 161 (default SNMP port) to trusted host. Iptbables will become of great help.