In this article, you will learn how to install Cacti network monitoring server on CentOS 8. This article provides the complete installation steps including SELinux configuration.
This Article Provides:
What is Cacti? :
Cacti is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-source, industry-standard data logging tool RRDtool.
Cacti uses a Poller to collect system metrics at a predetermined intervals and graph the resulting data. Cacti can use one of two back ends: "cmd.php", a PHP script suitable for smaller installations, or "Spine" (formerly Cactid), a C-based poller which can scale to thousands of hosts.
The front end can handle multiple users, each with their own graph sets, so it is sometimes used by web hosting providers to display bandwidth statistics for their customers. Cacti can be extended to monitor any source via shell scripts and executables.
Cacti is maintained by The Cacti Group, Inc. and distributed under GNU GPL license.
Cacti Features:
Some of the popular features of Cacti network monitoring software are:
- unlimited graph items
- auto-padding support for graphs
- graph data manipulation
- flexible data sources
- data gathering on a non-standard timespan
- custom data-gathering scripts
- built-in SNMP support
- graph, devices and data sources templates
- tree, list, and preview views of graph data
- user and user group based management and security
- remote data collection
- graph aggregation
- device, graph and tree automation
- network discovery
Environment Specification:
We are using a minimal CentOS 8 KVM machine with following specification.
- CPU - 3.4 Ghz (2 cores)
- Memory - 2 GB
- Storage - 20 GB
- Operating System - CentOS 8.2
- Hostname – cacti-01.centlinux.com
- IP Address - 192.168.116.206 /24
Upgrade CentOS 8 Software Packages:
Connect with cacti-01.centlinux.com as root user by using a ssh tool.
First of all, we are upgrading the existing software packages of our CentOS 8 server.
[root@cacti-01 ~]# dnf update -y
...
Upgraded:
libdrm-2.4.100-1.el8.x86_64
libmaxminddb-1.2.0-7.el8.x86_64
libmspack-0.7-0.3.alpha.el8.4.x86_64
libxkbcommon-0.9.1-1.el8.x86_64
open-vm-tools-11.0.0-4.el8.x86_64
plymouth-0.9.3-16.el8.x86_64
plymouth-core-libs-0.9.3-16.el8.x86_64
plymouth-scripts-0.9.3-16.el8.x86_64
python3-newt-0.52.20-11.el8.x86_64
python3-unbound-1.7.3-11.el8_2.x86_64
rsyslog-8.1911.0-3.el8.x86_64
unbound-libs-1.7.3-11.el8_2.x86_64
xkeyboard-config-2.28-1.el8.noarch
NetworkManager-1:1.22.8-4.el8.x86_64
NetworkManager-libnm-1:1.22.8-4.el8.x86_64
NetworkManager-team-1:1.22.8-4.el8.x86_64
NetworkManager-tui-1:1.22.8-4.el8.x86_64
audit-3.0-0.17.20191104git1c2f876.el8.x86_64
audit-libs-3.0-0.17.20191104git1c2f876.el8.x86_64
bind-export-libs-32:9.11.13-3.el8.x86_64
centos-gpg-keys-8.2-2.2004.0.1.el8.noarch
centos-release-8.2-2.2004.0.1.el8.x86_64
centos-repos-8.2-2.2004.0.1.el8.x86_64
coreutils-8.30-7.el8_2.1.x86_64
coreutils-common-8.30-7.el8_2.1.x86_64
crypto-policies-20191128-2.git23e1bf1.el8.noarch
cryptsetup-libs-2.2.2-1.el8.x86_64
curl-7.61.1-12.el8.x86_64
device-mapper-8:1.02.169-3.el8.x86_64
device-mapper-event-8:1.02.169-3.el8.x86_64
device-mapper-event-libs-8:1.02.169-3.el8.x86_64
device-mapper-libs-8:1.02.169-3.el8.x86_64
device-mapper-persistent-data-0.8.5-3.el8.x86_64
dhcp-client-12:4.3.6-40.el8.x86_64
dhcp-common-12:4.3.6-40.el8.noarch
dhcp-libs-12:4.3.6-40.el8.x86_64
diffutils-3.6-6.el8.x86_64
dmidecode-1:3.2-5.el8.x86_64
dnf-4.2.17-6.el8.noarch
dnf-data-4.2.17-6.el8.noarch
dnf-plugins-core-4.0.12-3.el8.noarch
dracut-049-70.git20200228.el8.x86_64
dracut-config-rescue-049-70.git20200228.el8.x86_64
dracut-network-049-70.git20200228.el8.x86_64
dracut-squash-049-70.git20200228.el8.x86_64
e2fsprogs-1.45.4-3.el8.x86_64
e2fsprogs-libs-1.45.4-3.el8.x86_64
elfutils-default-yama-scope-0.178-7.el8.noarch
elfutils-libelf-0.178-7.el8.x86_64
elfutils-libs-0.178-7.el8.x86_64
file-5.33-13.el8.x86_64
file-libs-5.33-13.el8.x86_64
firewalld-0.8.0-4.el8.noarch
firewalld-filesystem-0.8.0-4.el8.noarch
glib2-2.56.4-8.el8.x86_64
glibc-2.28-101.el8.x86_64
glibc-common-2.28-101.el8.x86_64
glibc-langpack-en-2.28-101.el8.x86_64
gnutls-3.6.8-10.el8_2.x86_64
grub2-common-1:2.02-81.el8.noarch
grub2-pc-1:2.02-81.el8.x86_64
grub2-pc-modules-1:2.02-81.el8.noarch
grub2-tools-1:2.02-81.el8.x86_64
grub2-tools-efi-1:2.02-81.el8.x86_64
grub2-tools-extra-1:2.02-81.el8.x86_64
grub2-tools-minimal-1:2.02-81.el8.x86_64
grubby-8.40-38.el8.x86_64
hwdata-0.314-8.4.el8.noarch
info-6.5-6.el8.x86_64
initscripts-10.00.6-1.el8_2.1.x86_64
ipcalc-0.2.4-4.el8.x86_64
iproute-5.3.0-1.el8.x86_64
iptables-1.8.4-10.el8.x86_64
iptables-ebtables-1.8.4-10.el8.x86_64
iptables-libs-1.8.4-10.el8.x86_64
iwl100-firmware-39.31.5.1-97.el8.1.noarch
iwl1000-firmware-1:39.31.5.1-97.el8.1.noarch
iwl105-firmware-18.168.6.1-97.el8.1.noarch
iwl135-firmware-18.168.6.1-97.el8.1.noarch
iwl2000-firmware-18.168.6.1-97.el8.1.noarch
iwl2030-firmware-18.168.6.1-97.el8.1.noarch
iwl3160-firmware-1:25.30.13.0-97.el8.1.noarch
iwl3945-firmware-15.32.2.9-97.el8.1.noarch
iwl4965-firmware-228.61.2.24-97.el8.1.noarch
iwl5000-firmware-8.83.5.1_1-97.el8.1.noarch
iwl5150-firmware-8.24.2.2-97.el8.1.noarch
iwl6000-firmware-9.221.4.1-97.el8.1.noarch
iwl6000g2a-firmware-18.168.6.1-97.el8.1.noarch
iwl6050-firmware-41.28.5.1-97.el8.1.noarch
iwl7260-firmware-1:25.30.13.0-97.el8.1.noarch
kernel-tools-4.18.0-193.6.3.el8_2.x86_64
kernel-tools-libs-4.18.0-193.6.3.el8_2.x86_64
kexec-tools-2.0.20-14.el8.x86_64
kmod-25-16.el8.x86_64
kmod-libs-25-16.el8.x86_64
kpartx-0.8.3-3.el8.x86_64
krb5-libs-1.17-18.el8.x86_64
libblkid-2.32.1-22.el8.x86_64
libcap-2.26-3.el8.x86_64
libcap-ng-0.7.9-5.el8.x86_64
libcom_err-1.45.4-3.el8.x86_64
libcomps-0.1.11-4.el8.x86_64
libcurl-7.61.1-12.el8.x86_64
libdnf-0.39.1-5.el8.x86_64
libfdisk-2.32.1-22.el8.x86_64
libgcc-8.3.1-5.el8.0.2.x86_64
libgomp-8.3.1-5.el8.0.2.x86_64
libldb-2.0.7-3.el8.x86_64
libmodulemd1-1.8.16-0.2.8.2.1.x86_64
libmount-2.32.1-22.el8.x86_64
libndp-1.7-3.el8.x86_64
libnfsidmap-1:2.3.3-31.el8.x86_64
libnftnl-1.1.5-4.el8.x86_64
libnl3-3.5.0-1.el8.x86_64
libnl3-cli-3.5.0-1.el8.x86_64
librepo-1.11.0-2.el8.x86_64
libreport-filesystem-2.9.5-10.el8.x86_64
libselinux-2.9-3.el8.x86_64
libselinux-utils-2.9-3.el8.x86_64
libsemanage-2.9-2.el8.x86_64
libsmartcols-2.32.1-22.el8.x86_64
libsolv-0.7.7-1.el8.x86_64
libss-1.45.4-3.el8.x86_64
libsss_autofs-2.2.3-20.el8.x86_64
libsss_certmap-2.2.3-20.el8.x86_64
libsss_idmap-2.2.3-20.el8.x86_64
libsss_nss_idmap-2.2.3-20.el8.x86_64
libsss_sudo-2.2.3-20.el8.x86_64
libstdc++-8.3.1-5.el8.0.2.x86_64
libtalloc-2.2.0-7.el8.x86_64
libtdb-1.4.2-2.el8.x86_64
libteam-1.29-1.el8.x86_64
libtevent-0.10.0-2.el8.x86_64
libuuid-2.32.1-22.el8.x86_64
libxml2-2.9.7-7.el8.x86_64
libxslt-1.1.32-4.el8.x86_64
linux-firmware-20191202-97.gite8a0f4c9.el8.noarch
lshw-B.02.18-23.el8.x86_64
lvm2-8:2.03.08-3.el8.x86_64
lvm2-libs-8:2.03.08-3.el8.x86_64
microcode_ctl-4:20191115-4.20200602.2.el8_2.x86_64
mozjs52-52.9.0-2.el8.x86_64
mozjs60-60.9.0-4.el8.x86_64
newt-0.52.20-11.el8.x86_64
nftables-1:0.9.3-12.el8.x86_64
numactl-libs-2.0.12-9.el8.x86_64
openssl-1:1.1.1c-15.el8.x86_64
openssl-libs-1:1.1.1c-15.el8.x86_64
openssl-pkcs11-0.4.10-2.el8.x86_64
pam-1.3.1-8.el8.x86_64
passwd-0.80-3.el8.x86_64
pigz-2.4-4.el8.x86_64
platform-python-3.6.8-23.el8.x86_64
platform-python-pip-9.0.3-16.el8.noarch
policycoreutils-2.9-9.el8.x86_64
polkit-0.115-11.el8.x86_64
polkit-libs-0.115-11.el8.x86_64
python3-cryptography-2.3-3.el8.x86_64
python3-dnf-4.2.17-6.el8.noarch
python3-dnf-plugins-core-4.0.12-3.el8.noarch
python3-firewall-0.8.0-4.el8.noarch
python3-hawkey-0.39.1-5.el8.x86_64
python3-libcomps-0.1.11-4.el8.x86_64
python3-libdnf-0.39.1-5.el8.x86_64
python3-librepo-1.11.0-2.el8.x86_64
python3-libs-3.6.8-23.el8.x86_64
python3-libselinux-2.9-3.el8.x86_64
python3-libxml2-2.9.7-7.el8.x86_64
python3-perf-4.18.0-193.6.3.el8_2.x86_64
python3-pip-wheel-9.0.3-16.el8.noarch
python3-ply-3.9-8.el8.noarch
python3-rpm-4.14.2-37.el8.x86_64
python3-syspurpose-1.26.17-1.el8_2.x86_64
rng-tools-6.8-3.el8.x86_64
rpm-4.14.2-37.el8.x86_64
rpm-build-libs-4.14.2-37.el8.x86_64
rpm-libs-4.14.2-37.el8.x86_64
rpm-plugin-selinux-4.14.2-37.el8.x86_64
rpm-plugin-systemd-inhibit-4.14.2-37.el8.x86_64
selinux-policy-3.14.3-41.el8_2.4.noarch
selinux-policy-targeted-3.14.3-41.el8_2.4.noarch
setup-2.12.2-5.el8.noarch
sg3_utils-1.44-5.el8.x86_64
sg3_utils-libs-1.44-5.el8.x86_64
sqlite-3.26.0-6.el8.x86_64
sqlite-libs-3.26.0-6.el8.x86_64
sssd-client-2.2.3-20.el8.x86_64
sssd-common-2.2.3-20.el8.x86_64
sssd-kcm-2.2.3-20.el8.x86_64
sssd-nfs-idmap-2.2.3-20.el8.x86_64
sudo-1.8.29-5.el8.x86_64
systemd-239-30.el8_2.x86_64
systemd-libs-239-30.el8_2.x86_64
systemd-pam-239-30.el8_2.x86_64
systemd-udev-239-30.el8_2.x86_64
teamd-1.29-1.el8.x86_64
tuned-2.13.0-6.el8.noarch
tzdata-2020a-1.el8.noarch
util-linux-2.32.1-22.el8.x86_64
which-2.21-12.el8.x86_64
xfsprogs-5.0.0-2.el8.x86_64
yum-4.2.17-6.el8.noarch
yum-utils-4.0.12-3.el8.noarch
zlib-1.2.11-13.el8.x86_64
Installed:
kernel-4.18.0-193.6.3.el8_2.x86_64
kernel-core-4.18.0-193.6.3.el8_2.x86_64
kernel-modules-4.18.0-193.6.3.el8_2.x86_64
elfutils-debuginfod-client-0.178-7.el8.x86_64
libzstd-1.4.2-2.el8.x86_64
python3-nftables-1:0.9.3-12.el8.x86_64
Removed:
kernel-4.18.0-80.11.2.el8_0.x86_64
kernel-core-4.18.0-80.11.2.el8_0.x86_64
kernel-modules-4.18.0-80.11.2.el8_0.x86_64
Complete!
Our CentOS 8.1 machine has been upgraded to CentOS 8.2. We can confirm it by using following commands.
[root@cacti-01 ~]# uname -a
Linux cacti-01.centlinux.com 4.18.0-193.6.3.el8_2.x86_64 #1 SMP Wed Jun 10 11:09:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@cacti-01 ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
You can follow our previous post to upgrade CentOS 7 to CentOS 8 Server.
Install Apache HTTP Server on CentOS 8:
Cacti network monitoring server is a PHP based web application, therefore, we need a PHP supported web browser to run it.
We are using the popular Apache HTTP Server for this purpose.
[root@cacti-01 ~]# dnf install -y httpd httpd-devel
...
Installed:
apr-1.6.3-9.el8.x86_64
apr-devel-1.6.3-9.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-devel-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
centos-logos-httpd-80.5-2.el8.noarch
cyrus-sasl-2.1.27-1.el8.x86_64
cyrus-sasl-devel-2.1.27-1.el8.x86_64
expat-devel-2.2.5-3.el8.x86_64
httpd-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64
httpd-devel-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64
httpd-filesystem-2.4.37-21.module_el8.2.0+382+15b0afa8.noarch
httpd-tools-2.4.37-21.module_el8.2.0+382+15b0afa8.x86_64
libdb-devel-5.3.28-37.el8.x86_64
mailcap-2.1.48-3.el8.noarch
mod_http2-1.11.3-3.module_el8.2.0+307+4d18d695.x86_64
openldap-devel-2.4.46-11.el8_1.x86_64
perl-Carp-1.42-396.el8.noarch
perl-Errno-1.28-416.el8.x86_64
perl-Exporter-5.72-396.el8.noarch
perl-File-Path-2.15-2.el8.noarch
perl-IO-1.38-416.el8.x86_64
perl-PathTools-3.74-1.el8.x86_64
perl-Scalar-List-Utils-3:1.49-2.el8.x86_64
perl-Socket-4:2.027-3.el8.x86_64
perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch
perl-Unicode-Normalize-1.25-396.el8.x86_64
perl-constant-1.33-396.el8.noarch
perl-interpreter-4:5.26.3-416.el8.x86_64
perl-libs-4:5.26.3-416.el8.x86_64
perl-macros-4:5.26.3-416.el8.x86_64
perl-parent-1:0.237-1.el8.noarch
perl-threads-1:2.21-2.el8.x86_64
perl-threads-shared-1.58-2.el8.x86_64
Complete!
Enable and start Apache service.
[root@cacti-01 ~]# systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service â /usr/lib/systemd/system/httpd.service.
Allow the Apache Service in Linux firewall, to make it accessible from the network computers.
[root@cacti-01 ~]# firewall-cmd --permanent --add-service=http
success
[root@cacti-01 ~]# firewall-cmd --reload
success
Install MariaDB Server on CentOS 8:
Cacti requires a MySQL database for its metadata repository. Therefore, we are installing MariaDB server. Please follow our previous article, if you want to install latest version of MariaDB on CentOS 8.
[root@cacti-01 ~]# dnf install -y mariadb-server
...
Installed:
mariadb-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
mariadb-backup-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
mariadb-common-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
mariadb-connector-c-3.0.7-1.el8.x86_64
mariadb-connector-c-config-3.0.7-1.el8.noarch
mariadb-errmsg-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
mariadb-gssapi-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
mariadb-server-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
mariadb-server-utils-3:10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
perl-DBD-MySQL-4.046-3.module_el8.1.0+203+e45423dc.x86_64
perl-DBI-1.641-3.module_el8.1.0+199+8f0a6bbd.x86_64
perl-Data-Dumper-2.167-399.el8.x86_64
perl-Digest-1.17-395.el8.noarch
perl-Digest-MD5-2.55-396.el8.x86_64
perl-Encode-4:2.97-3.el8.x86_64
perl-File-Temp-0.230.600-1.el8.noarch
perl-Getopt-Long-1:2.50-4.el8.noarch
perl-HTTP-Tiny-0.074-1.el8.noarch
perl-IO-Socket-IP-0.39-5.el8.noarch
perl-IO-Socket-SSL-2.066-4.el8.noarch
perl-MIME-Base64-3.15-396.el8.x86_64
perl-Math-BigInt-1:1.9998.11-7.el8.noarch
perl-Math-Complex-1.59-416.el8.noarch
perl-Mozilla-CA-20160104-7.el8.noarch
perl-Net-SSLeay-1.88-1.el8.x86_64
perl-Pod-Escapes-1:1.07-395.el8.noarch
perl-Pod-Perldoc-3.28-396.el8.noarch
perl-Pod-Simple-1:3.35-395.el8.noarch
perl-Pod-Usage-4:1.69-395.el8.noarch
perl-Storable-1:3.11-3.el8.x86_64
perl-Term-ANSIColor-4.06-396.el8.noarch
perl-Term-Cap-1.17-395.el8.noarch
perl-Text-ParseWords-3.30-395.el8.noarch
perl-Time-Local-1:1.280-1.el8.noarch
perl-URI-1.73-3.el8.noarch
perl-libnet-3.11-3.el8.noarch
perl-podlators-4.11-1.el8.noarch
psmisc-23.1-4.el8.x86_64
Complete!
Enable and start MariaDB database service.
[root@cacti-01 ~]# systemctl enable --now mariadb.service
Created symlink /etc/systemd/system/mysql.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service â /usr/lib/systemd/system/mariadb.service.
Configure MariaDB Server and set the password of root user.
[root@cacti-01 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Install PHP on CentOS 8:
Cacti is developed in PHP programming language, thus it requires a PHP supported web server to run. We have already installed Apache HTTP Server and now we are installing PHP on CentOS 8.
[root@cacti-01 ~]# dnf install -y php-fpm php-common php-mysqlnd php-xml php-ldap php-json php-cli php-gd php-gmp php-mbstring php-process
...
Installed:
nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-ldap-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
gd-2.2.5-6.el8.x86_64
jbigkit-libs-2.1-14.el8.x86_64
libXpm-3.5.12-8.el8.x86_64
libjpeg-turbo-1.5.3-10.el8.x86_64
libtiff-4.0.9-17.el8.x86_64
libwebp-1.0.0-1.el8.x86_64
php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-gmp-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
Complete!
Enable and start PHP-FPM Service.
[root@cacti-01 ~]# systemctl enable --now php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service â /usr/lib/systemd/system/php-fpm.service.
Install SNMP on CentOS 8:
SNMP (Simple Network Management Protocol) is an Internet standard protocol for collecting and organizing information about managed devices on IP networks.
Install net-snmp and net-snmp-utils packages to install SNMP and php-snmp to enable PHP support for SNMP.
[root@cacti-01 ~]# dnf install -y net-snmp php-snmp net-snmp-utils
...
Installed:
lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64
net-snmp-1:5.8-14.el8.x86_64
net-snmp-agent-libs-1:5.8-14.el8.x86_64
net-snmp-libs-1:5.8-14.el8.x86_64
php-snmp-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
net-snmp-utils-1:5.8-14.el8.x86_64
Complete!
Install RRDTool on CentOS 8:
Cacti requires RRDTool (RRD stands for Round Robin Database) for maintaining system metrics data. Therefore, we are installing rrdtool package using dnf command.
[root@cacti-01 ~]# dnf install -y rrdtool
...
Installed:
cairo-1.15.12-3.el8.x86_64
dejavu-fonts-common-2.35-6.el8.noarch
dejavu-sans-mono-fonts-2.35-6.el8.noarch
fontconfig-2.13.1-3.el8.x86_64
fontpackages-filesystem-1.44-22.el8.noarch
fribidi-1.0.4-8.el8.x86_64
graphite2-1.3.10-10.el8.x86_64
harfbuzz-1.7.5-3.el8.x86_64
libX11-1.6.8-3.el8.x86_64
libX11-common-1.6.8-3.el8.noarch
libXau-1.0.8-13.el8.x86_64
libXext-1.3.3-9.el8.x86_64
libXft-2.3.2-10.el8.x86_64
libXrender-0.9.10-7.el8.x86_64
libdatrie-0.2.9-7.el8.x86_64
libthai-0.1.27-2.el8.x86_64
libxcb-1.13.1-1.el8.x86_64
pango-1.42.4-6.el8.x86_64
pixman-0.38.4-1.el8.x86_64
rrdtool-1.7.0-16.el8.x86_64
Complete!
Configure PHP Settings for Cacti:
To use Cacti network monitoring server, we need to customize PHP settings accordingly.
Edit /etc/php.ini configuration file and configure it for using Cacti.
[root@cacti-01 ~]# vi /etc/php.ini
Locate and set following parameters therein.
safe_mode = Off ; Disable safe mode
date.timezone = "Asia/Karachi" ; Define timezone to avoid warnings on time/date functions
file_uploads = On ; Allow import of templates
memory_limit = 400M ; maximum amount of memory a PHP script can consume
max_execution_time = 60 ; maximum execution time (in seconds) of a PHP script
Install Cacti on CentOS 8:
We are downloading latest stable version of Cacti from their official website.
[root@cacti-01 ~]# cd /tmp
[root@cacti-01 tmp]# wget https://www.cacti.net/downloads/cacti-1.2.12.tar.gz
--2020-06-19 09:50:55-- https://www.cacti.net/downloads/cacti-1.2.12.tar.gz
Resolving www.cacti.net (www.cacti.net)... 104.28.9.127, 172.67.196.107, 104.28.8.127, ...
Connecting to www.cacti.net (www.cacti.net)|104.28.9.127|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25126474 (24M) [application/octet-stream]
Saving to: âcacti-1.2.12.tar.gzâ
cacti-1.2.12.tar.gz 100%[===================>] 23.96M 2.34MB/s in 11s
2020-06-19 09:51:08 (2.12 MB/s) - âcacti-1.2.12.tar.gzâ saved [25126474/25126474]
Extract downloaded tarball into default DOCUMENT_ROOT.
[root@cacti-01 tmp]# tar -C /var/www/html -xzf cacti-1.2.12.tar.gz
[root@cacti-01 tmp]# cd
Rename the Cacti directory to a simple name for easy accessibility.
[root@cacti-01 ~]# mv /var/www/html/cacti-1.2.12 /var/www/html/cacti
Create a MariaDB Database for Cacti:
Connect with MariaDB server as root user.
[root@cacti-01 ~]# mysql -u root -p123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.17-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
Create a database for Cacti network monitoring server.
MariaDB [(none)]> create database cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.112 sec)
Create a user for Cacti software and grant complete rights on cacti database.
MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'Str0ngPa55word';
Query OK, 0 rows affected (0.254 sec)
Grant Time Zone selection privilege to cacti user.
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
Query OK, 0 rows affected (0.042 sec)
Reload privileges tables.
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.083 sec)
Exit from MySQL shell.
MariaDB [(none)]> QUIT
Bye
Cacti tarball also contains a SQL script for creating the necessary database objects. We can use this script to create tables and other objects in the cacti database.
[root@cacti-01 ~]# mysql -D cacti -u cacti -pStr0ngPa55word < /var/www/html/cacti/cacti.sql
Before moving forward, we need to load the MariaDB timezone tables. Otherwise, the Cacti web installer will give you warning on timezones.
Use following command to load timezone tables with available timezones from CentOS 8 operating system.
[root@cacti-01 ~]# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p123 mysql
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
Timezones has been successfully loaded into MariaDB tables. Don't worry about the warnings, it is because these files do not contain a valid timezone.
Edit MariaDB configuration file.
[root@cacti-01 ~]# vi /etc/my.cnf.d/mariadb-server.cnf
Set following global variables under [mysqld] section, as required by Cacti network monitoring software.
join_buffer_size=30M
innodb_file_format=Barracuda
innodb_buffer_pool_size=256M
innodb_buffer_pool_instances=1
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16
innodb_io_capacity=5000
innodb_io_capacity_max=10000
innodb_large_prefix=1
character_set_client=utf8mb4
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci
Configure Cacti on CentOS 8:
Edit config.php file and update parameters according to your environment.
[root@cacti-01 ~]# vi /var/www/html/cacti/include/config.php
Locate and update following parameters.
$database_username = 'cacti';
$database_password = 'Str0ngPa55word';
Make apache user as owner of the Cacti software directory.
[root@cacti-01 ~]# chown -R apache:apache /var/www/html/cacti/
Restart Apache and PHP services to apply changes.
[root@cacti-01 ~]# systemctl restart httpd.service php-fpm.service
Configure SELinux for Cacti on CentOS 8:
Install required SELinux commands i.e. semanage by using dnf command..
[root@cacti-01 ~]# dnf install -y policycoreutils-python-utils-2.9-9.el8.noarch
...
Installed:
checkpolicy-2.9-1.el8.x86_64
policycoreutils-python-utils-2.9-9.el8.noarch
python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64
python3-libsemanage-2.9-2.el8.x86_64
python3-policycoreutils-2.9-9.el8.noarch
python3-setools-4.2.2-2.el8.x86_64
Complete!
Configure SELinux to allow read/write on the following directories.
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/log(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/resource/snmp_queries(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/resource/script_server(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/resource/script_queries(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/scripts(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/cache/boost(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/cache/mibcache(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/cache/realtime(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/cache/spikekill(/.*)?"
[root@cacti-01 ~]# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/rra(/.*)?"
Reapply the filecontexts on the cacti directory.
[root@cacti-01 ~]# restorecon -R /var/www/html/cacti/
Configure a cron job to run poller.php script in every 5 minutes. This script will collect and update the system metrics in /rra directory.
[root@cacti-01 ~]# echo "*/5 * * * * apache /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1" >> /etc/crontab
Open URL http://cacti-01.centlinux.com/cacti in a client's browser such as Google Chrome.
Login by using default username/password i.e. admin/admin
Since, we are login to Cacti web interface for the first time, therefore, we are required to change the default password of admin user.
Read and accept the License Agreement of Cacti network monitoring software.
If you have followed the installation steps in this article correctly, then you won't found any warning on this page.
We are skipping a warning about innodb_buffer_pool_instances, a MariaDB global variable, because we are installing MariaDB on a machine with limited memory. If you install MariaDB on a machine with more than 1 GB RAM available for InnoDB buffer, you won't see this warning.
Choose your preferred installation type. Since, this is our first Cacti server therefore, we have selected "New Primary Server".
If you have configured the SELinux correctly, then there won't be any warnings.
Setup is checking for required binaries, their locations and required versions.
Setup will inform you about a security concern and how to handle it. Accept it and continue.
Adjust your default profile and continue.
Select the required device templates and continue.
Setup is checking the MariaDB server and database collation.
If your configurations are fine, then Cacti setup will display this page and it will ask you to start installation.
Cacti network monitoring server has been installed on CentOS 8.
After successful installation, you will reached at the Cacti Dashboard.
You can see some graphs by clicking on the Graphs tab.
We have successfully installed and configured Cacti network monitoring software on CentOS 8. Before you begin using the Cacti network monitoring server, we recommend that you should read Cacti Beginner's Guide - Second Edition by Packt Publishing. It will be really helpful to understand the Cacti web interface and it's usage.
Such a wonderful tutorial. Need some extra knowledge on Linux before start the play.
ReplyDeleteThank you and Best of Luck.
DeleteIndeed, i followed so many articles, but this one went through without any issues. Seamless and clear instructions with snapshots. Many thanks for the publisher.
ReplyDeleteThanks for the appreciation.
DeleteI changed the data directory location in database, how to change socket location in php?
ReplyDeletePHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/app/cactiserver/cactidb/mysql/mysql.socket' (2)' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('mysql:host=loca...', 'cactiuser', 'Cacti*102030')
#1 {main}
thrown in Command line code on line 1
You can customize these settings in /var/www/html/cacti/include/config.php
DeleteI made changes to below parameter and then database connection was successful.
Deletechange database_hostname = "localhost";
to database_hostname = "127.0.0.0";