In this article, I will explain how to install and configure Cacti 0.8.8f on Ubuntu 16.04. Cacti is a network monitoring tool, and the weather map plugin shows active maps of your network, with colored links that represent the actual load of the links. When you hover the mouse over a link, a graph will be shown representing the last day load for this link.
The reason I choose Ubuntu 16.04 is because this distribution will install the version 0.8.8f of cacti, compatible with latest version Weathermap plugin (0.98a) at time of this writing. On the other hand, installing Ubuntu 18.04 or later will install version 1.x of Cacti that does not support Weathermap plugin (0.98a) at time of this writing.
Overview
Install ubuntu 16.04.6
Install LAMP server and SSH server during installation process
Configure Ubuntu network
nano /etc/network/interfaces
# The primary network interface
auto ens32
iface ens32 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.20
dns-search lan.local
Check that cacti resolves FQDN and Netbios names from AD and that it exists in forward and reverse DNS zone on DC
Install Prerequisite
This article is mainly based on following internet articles
https://linoxide.com/ubuntu-how-to/install-setup-cacti-ubuntu-16-04/
# Update your system repository list #
sudo apt-get update
sudo apt-get upgrade
# Install php (php-gd will be needed by Weathermap plugin)
sudo apt-get install php php-gd
# Install prerequisite #
sudo apt-get install snmp snmpd rrdtool
# Configure SNMP (this is optional, only if you want to monitor the cacti host) #
Edit file /etc/snmp/snmp.conf and comment/uncomment following lines
# Full access from the local host
rocommunity public localhost
# Default access to basic system info
# rocommunity public default -V systemonly
# rocommunity6 is for IPv6
# rocommunity6 public default -V systemonly
Restart SNMP service
sudo service snmpd restart
Install Cacti
# Install cacti package (cacti-spine is an optional poller system) #
apt-get install cacti cacti-spine
# Restart the services #
sudo service snmpd restart
sudo service mysql restart
sudo service apache2 restart
# Log on to cacti web site (http://<your-server-ip-address>/cacti) with admin/admin and change your password#
Validate plugin architecture
Download from https://docs.cacti.net/plugin:rrdclean
Copy archive to /usr/share/cacti/site/plugins
Extract archive
tar -xvzf rrdclean-v0.41.tgz
Verify that archive is present on Web Interface (Console – Plugin Management)
Install and enable this plugin (click on icons bellow Actions)
Install Weathermap plugin
Download from https://github.com/howardjones/network-weathermap/releases/tag/version-0.98a
Unzip archive and copy content to /usr/share/cacti/site/plugins/weathermap
Install and enable the plugin from Web Interface (Console – Plugin Management)
Verify that the requirements for the plugin are met by opening a browser to
http://<your-server-ip-address>/cacti/plugins/weathermap/check.php
It should show following message
Configure Cacti to poll every minute
By default, Cacti will poll your network every 5 minutes, we want to change this to 1 minute,
https://www.tolaris.com/2013/07/09/cacti-and-1-minute-polling/
Delete all existing Round Robin Archives an create three new ones (Datasources – RRA)
This will give you following result
Then change the "Associated RRA's", "Step" and "Heartbeat" for all Data Template that you use
Remark : Alternatively you could use following commands to do the job by logging directly into the database (saves time)
mysql -u root -p
Use the following commands to update the cacti tables for the new rra's.
USE cacti;
UPDATE data_template_rrd SET rrd_heartbeat = 120;
UPDATE data_template_data SET rrd_step = 60;
DELETE from data_template_data_rra;
INSERT into data_template_data_rra (data_template_data_id, rra_id)
SELECT data_template_data.id, rra.id FROM data_template_data CROSS JOIN rra;
Then change the cron by editing /etc/cron.d/cacti
sudo nano /etc/cron.d/cacti
* * * * * www-data php --define suhosin.memory_limit=512M /usr/share/cacti/site/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >> /var/log/cacti/poller-error.log
Repopulate the poller cache (Console – System Utilities – Rebuilt Poller Cache)
Delete all existings RRA's
sudo rm /var/lib/cacti/rra/*
Reboot the server
Check the log (Console – System Utilities – View Cacti Log File)
Correct the permission problem
sudo chown -R www-data:www-data /usr/share/cacti/site/plugins/weathermap/
Looks a lot better !
Monitor a device
For that purpose, we will monitor the Windows Host LAN.DC1 (Feature SNMP has to be installed and configured : https://blog.paessler.com/how-to-enable-snmp-on-your-operating-system)
Add three graphs for this host, one for each CPU and one for the ethernet interface (Create Graphs for this Host)
Add the graphs to the default tree (Console – Graph Tree – Default Tree)
Create the Weather map
Add the default map (Console – Manage Weathermap – Add – simple.conf) and wait 1 minute to get it in the Weathermap tab
Click on editor (Bottom – Right) to create a copy of the "simple.conf" map
Delete all nodes and links and create three nodes and two links.
The first node is for LAN-DC1 and the Info URL will show the CPU load
The second node is for LAN-CACTI and the Info URL will show the CPU load
The third node is for Internet and it has no Info URL
The first link is from LAN-DC1 to Internet and the Info URL shows the load of the LAN-DC1 interface
The first link is from LAN-CACTI to Internet and the Info URL shows the load of the LAN-CACTI interface
Return to Cacti, add mymap.conf to Weathermap and deactivate the simple.conf map
Your map is now shown in the Weathermap Tab
Add colored host status
Follow the instructions provided at following link to get host status information on the map (https://forum.network-weathermap.com/t/cacti-host-status-for-nodes/34)
/usr/share/cacti/site/plugins/weathermap/configs/mymap.conf will be updated to the following
# Automatically generated by php-weathermap v0.98a
#
# Begin of global section
#
FONTDEFINE 100 docs/example/Vera.ttf 10
BACKGROUND images/background1_950x625_197.jpg
WIDTH 950
HEIGHT 625
HTMLSTYLE overlib
KEYFONT 100
TITLE My Map with Host status
TIMEPOS 311 447 Created: %b %d %Y %H:%M:%S
KEYPOS DEFAULT 690 394 Traffic Load
KEYTEXTCOLOR 0 0 0
KEYOUTLINECOLOR 0 0 0
KEYBGCOLOR 255 255 255
BGCOLOR 255 255 255
TITLECOLOR 0 0 0
TIMECOLOR 0 0 0
#
SCALE DEFAULT 0 0 192 192 192
SCALE DEFAULT 0 1 255 255 255
SCALE DEFAULT 1 10 140 0 255
SCALE DEFAULT 10 25 32 32 255
SCALE DEFAULT 25 40 0 192 255
SCALE DEFAULT 40 55 0 240 0
SCALE DEFAULT 55 70 240 240 0
SCALE DEFAULT 70 85 255 192 0
SCALE DEFAULT 85 100 255 0 0
#
SCALE cactiupdown 0 0.5 192 192 192
SCALE cactiupdown 0.5 1.5 255 0 0
SCALE cactiupdown 1.5 2.5 0 0 255
SCALE cactiupdown 2.5 3.5 0 255 0
SCALE cactiupdown 4.5 5.5 128 128 128
SET nowarn_clipping 1
#
# End of global section
#
# TEMPLATE-only NODEs:
NODE DEFAULT
LABELFONT 100
MAXVALUE 100
#
# TEMPLATE-only LINKs:
LINK DEFAULT
WIDTH 5
BWFONT 100
COMMENTFONT 100
BWLABEL bits
BANDWIDTH 1M
#
# regular NODEs:
NODE LAN-DC1
LABEL LAN-DC1
INFOURL /cacti/graph.php?rra_id=all&local_graph_id=10
OVERLIBGRAPH /cacti/graph_image.php?rra_id=0&graph_height=100&graph_width=300&local_graph_id=10 /cacti/graph_image.php?rra_id=0&graph_height=100&graph_width=300&local_graph_id=11
ICON images/Host.png
TARGET cactihost:3
USESCALE cactiupdown in percent
POSITION 118 203
NODE Internet
LABEL Internet
ICON images/Cloud-Filled.png
POSITION 794 305
NODE LAN-CACTI
LABEL LAN-CACTI
INFOURL /cacti/graph.php?rra_id=all&local_graph_id=2
OVERLIBGRAPH /cacti/graph_image.php?rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300&local_graph_id=2
ICON images/Host.png
TARGET cactihost:1
USESCALE cactiupdown in percent
POSITION 129 392
#
# regular LINKs:
LINK LAN-DC1-Internet
INFOURL /cacti/graph.php?rra_id=all&local_graph_id=12
OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=12&rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300
TARGET /var/lib/cacti/rra/lan-dc1_traffic_in_17.rrd
NODES LAN-DC1 Internet
LINK LAN-CACTI-Internet
INFOURL /cacti/graph.php?rra_id=all&local_graph_id=6
OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=6&rra_id=0&graph_nolegend=true&graph_height=100&graph_width=300
TARGET /var/lib/cacti/rra/localhost_traffic_in_9.rrd
NODES LAN-CACTI Internet
Remark : OVERLIBGRAPH for LAN-DC1 has been manually updated to show both graphics for CPU0 and CPU1
Allow guest access
To allow everyone access to your maps, modify the security (Console – Weathermap management)
Enable the guest account (Console – User management)
And specify a name for guest user (Console – Settings – Authentication)
Your map is now visible without authentication
Enable access through Active Directory
You should create following objects in Active Directory
-
A user to allow LDAP bind
- DN: CN=svc-ldap,CN=Users,DC=LAN,DC=LOCAL
-
A group containing users that can log on to Cacti with admin rights
- DN : CN=G-Cacti-Admin,OU=MyGroups,OU=Enterprise,DC=LAN,DC=LOCAL
Install php-ldap package
apt-get install php-ldap
Edit /etc/php/7.0/apache2/php.ini, and enable ldap by removing the semicolon before "extension=php_ldap.dll"
Enable LDAP authentication from the console (Console – Settings – Authentication)
You can now log in with your Active Directory Account if you are member of the group G-Cacti-Admin