Log inSign up

Draw long term server and network graphs with Cacti

Install mariadb-server, then cacti, cacti-spine and the SNMP tools from the Ubuntu or Debian repositories and let the package create its database. Open /cacti through an SSH tunnel or an HTTPS site, finish the setup, and add devices that answer SNMPv3 with authentication and encryption. The poller collects every five minutes and Cacti keeps the results in RRD files for years of graphs.

Topic: Monitoring and logs · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13 · Updated 2026-12-03

What is Cacti good at?

Cacti polls devices on a fixed schedule, usually over SNMP, and stores the values in round robin database (RRD) files that never grow. Graphs for interface traffic, load, memory and disk space therefore remain fast and small even after years of collection. It is a natural fit for network gear and for servers you want to compare over long periods, and its template system lets you add a new device with all standard graphs in a few clicks.

Cacti is not an alerting system first; plugins add thresholds, but many people pair it with Nagios or Zabbix for notifications. For a quick look at a single instance, the console Usage graphs tab may already answer your question.

How do I install Cacti and its dependencies?

Install the database server first so the Cacti package can create its schema during setup, then the rest:

sudo apt update
sudo apt install -y mariadb-server
sudo mariadb-secure-installation
sudo apt install -y cacti cacti-spine snmp snmpd
apt policy cacti

The installer asks two things. Pick apache2 as the web server, and answer Yes to configuring the database with dbconfig-common, then give the Cacti database user a long password (or leave it empty to let the package generate one). The package installs PHP, Apache, RRDtool and a cron job that runs the poller every five minutes. Ubuntu 24.04 and 22.04 as well as Debian 12 and 13 all carry Cacti 1.2 releases; the exact minor version is shown by apt policy.

Which MariaDB settings does Cacti want?

Cacti checks a list of database settings and warns when they are too low. Put them in a dedicated file and load the time zone tables it relies on:

sudo nano /etc/mysql/mariadb.conf.d/90-cacti.cnf
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
max_heap_table_size = 64M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_buffer_pool_size = 512M
sudo systemctl restart mariadb
mariadb-tzinfo-to-sql /usr/share/zoneinfo | sudo mariadb mysql
sudo mariadb -e "GRANT SELECT ON mysql.time_zone_name TO cacti@localhost; FLUSH PRIVILEGES;"

On a 1 GB plan, set the buffer pool to 256M instead. Set PHP to your time zone too: date.timezone in both /etc/php/*/apache2/php.ini and /etc/php/*/cli/php.ini, then sudo systemctl restart apache2.

How do I reach the web interface without exposing it?

Keep port 80 closed and use a tunnel for occasional access:

ssh -N -L 8080:127.0.0.1:80 deploy@198.51.100.24

Then open http://localhost:8080/cacti. For regular use, create an Apache site with its own name and a certificate. Point cacti.example.net at the server (see DNS records) and add a minimal site file:

sudo tee /etc/apache2/sites-available/cacti-site.conf > /dev/null <<'EOF'
<VirtualHost *:80>
    ServerName cacti.example.net
    RedirectMatch ^/$ /cacti/
</VirtualHost>
EOF
sudo a2ensite cacti-site
sudo systemctl reload apache2
sudo ufw allow 80/tcp && sudo ufw allow 443/tcp
sudo certbot --apache -d cacti.example.net

Certbot writes the HTTPS site and redirect for you; the Certbot guide explains renewals. To limit access further, edit /etc/cacti/apache.conf and replace the open Require line with Require ip followed by your own address.

How do I finish setup and sign in?

Open the Cacti URL. If the installation wizard appears, it lists any remaining PHP or MariaDB warnings, then asks for paths that the package already filled in; accept them and let it finish. Sign in as admin: depending on the package release the starting password is the one requested during installation or simply admin, and Cacti makes you choose a new one at first login. Then go to Console, Configuration, Settings:

  • Poller tab: set the poller type to spine, which is faster than the PHP poller, and keep the interval at five minutes.
  • Authentication tab: leave guest access off.

Spine reads database credentials from /etc/cacti/spine.conf; make sure they match those in /etc/cacti/debian.php.

How do I prepare a remote server with SNMPv3?

Our servers reach each other only over public IPs, so use SNMPv3 with authentication and privacy (encryption) instead of v2c community strings, and allow UDP 161 only from the Cacti server. On the server you want to graph (here 198.51.100.40):

sudo apt install -y snmpd libsnmp-dev
sudo systemctl stop snmpd
sudo net-snmp-create-v3-user -ro -a SHA -A 'Long-Auth-Pass-1' -x AES -X 'Long-Priv-Pass-2' cactiro

In /etc/snmp/snmpd.conf, comment out the default rocommunity lines and make the agent listen on the public address instead of loopback:

agentaddress udp:161,udp6:[::]:161
sudo systemctl start snmpd
sudo ufw allow from 203.0.113.10 to any port 161 proto udp

From the Cacti server, prove it works with a walk of the system subtree:

snmpwalk -v3 -l authPriv -u cactiro -a SHA -A 'Long-Auth-Pass-1' -x AES -X 'Long-Priv-Pass-2' 198.51.100.40 1.3.6.1.2.1.1

You should see the system description, uptime and host name. The UFW guide covers more source based rules.

How do I add a device and its graphs?

In the Cacti console choose Management, Devices, then the plus icon. Fill in a description, the hostname 198.51.100.40, the device template Net-SNMP Device and SNMP version 3 with the same user, protocols and passwords. Save, and Cacti shows the SNMP system info at the top if it can talk to the device. Click Create Graphs for this Device, tick load average, memory, the network interface traffic graph and the disk partitions under the data queries, and create them. After two or three poller runs the first lines appear under the Graphs tab. Group devices in the tree view so a whole fleet can be browsed by city or role.

How do I check the poller and fix empty graphs?

Run the poller by hand to see errors right away, and read the Cacti log:

sudo -u www-data php /usr/share/cacti/site/poller.php --force --debug | tail -n 20
sudo tail -n 50 /var/log/cacti/cacti.log
  • Graphs stay empty: wait three poller cycles; then check that the cron entry in /etc/cron.d/cacti is present and that the poller reports no SQL errors.
  • SNMP timeout: the remote firewall blocks UDP 161, snmpd still listens on loopback only, or a passphrase differs.
  • Spine not found: set its path to /usr/sbin/spine in Settings, Paths.
  • Gaps in graphs: the poller ran longer than five minutes; switch to spine or raise its thread count.

Back up the database with sudo mariadb-dump cacti and the RRD folder /var/lib/cacti/rra; our daily backups add a full disk copy.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A1-2Cacti for a small fleet1 vCPU, 2 GB RAM, 50 GB NVMe$7.20/mo$43.20 for 6 months
A2-4hundreds of graphs with spine2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months

Questions about Cacti graphs with SNMP

Does Cacti need SNMP?

Mostly, yes. SNMP is the standard way Cacti collects data, though script based data input methods also exist for custom values.

Why SNMPv3 instead of v2c?

Community strings in v2c travel in clear text across the internet. SNMPv3 with authPriv authenticates and encrypts every request.

Can I graph the Cacti server itself?

Yes. Add a device for 127.0.0.1 with the same SNMPv3 user created on the local snmpd, or use the Local Linux Machine template.

How much disk will Cacti use?

RRD files have a fixed size per data source, so usage depends on the number of graphs, not on time. A few hundred graphs fit in well under a gigabyte.

Is this the same as the console graphs?

No. The Usage graphs tab comes from the platform; Cacti graphs what each server reports about itself over SNMP.