Skip to content

Testing Environment: Fedora

Mark Brugnoli-Vinten edited this page Mar 20, 2018 · 9 revisions

This page documents the process for installation of Cacti 1.x on Fedora Version 27

It follows the conventions documented in the Test Environments: Before You Start

Fedora 27

System setup

Configure the network

hostname _ssh_host_
echo "_ssh_host_" > /etc/hostname
yum install -y screen git
useradd _ssh_user_
passwd _ssh_user_
echo "_ssh_user_     ALL=(ALL)     ALL" > /etc/sudoers.d/_ssh_user_

Note: Do NOT use a filename with a fullstop in it as sudo will ignore these by default

Enable SSH login via keys

Create the authorized_keys file with the appropriate SSH keys

mkdir -p ~/.ssh
touch ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

If you have predefined keys you wish to insert, simply edit the ~/.ssh/authorized_keys file

Install Apache, SQL and PHP

Package selection may be overkill but to ensure they are definitely installed.

yum install -y httpd openssl mariadb mariadb-server php php-xml php-mbstring php-cli php-common php-pdo php-gd php-process php-snmp php-gmp
yum install -y net-snmp net-snmp-utils rrdtool

systemctl restart php-fpm
systemctl enable mariadb
systemctl restart mariadb
systemctl enable httpd
systemctl restart httpd

Website basics

Create some required directories

mkdir -p /var/log/cacti \
/usr/share/cacti/site \
/usr/share/cacti/develop \
/usr/share/cacti/feature \
/etc/pki/tls/cacti/

Clone Cacti

Run the following as _ssh_user_

sudo su - _ssh_user_
cd /usr/share/cacti
git clone https://github.com/netniv/cacti/ site
cd site/
git remote add upstream https://github.com/cacti/cacti/ && git fetch --all 
cd ../
cp -Rv site develop
cp -Rv site feature

cd /usr/share/cacti/develop && git branch develop --set-upstream upstream/develop && git checkout develop
cd /usr/share/cacti/feature && git branch feature/1.2.x --set-upstream upstream/feature/1.2.x && git checkout feature/1.2.x

Change default permissions

Run the following as root

chown _ssh_user_:apache -Rv /usr/share/cacti/
chmod u+rw,g+r,g-w,a+r -Rv /usr/share/cacti
chmod u+rw,g+rw,a+r -Rv \
/usr/share/cacti/site/cache \
/usr/share/cacti/feature/cache \
/usr/share/cacti/develop/cache \
/usr/share/cacti/site/log \
/usr/share/cacti/feature/log \
/usr/share/cacti/develop/log \
/usr/share/cacti/site/rra \
/usr/share/cacti/feature/rra \
/usr/share/cacti/develop/rra \
/usr/share/cacti/site/resource/ \
/usr/share/cacti/feature/resource/ \
/usr/share/cacti/develop/resource/ \
/usr/share/cacti/site/scripts/ \
/usr/share/cacti/feature/scripts/ \
/usr/share/cacti/develop/scripts/ 

Checkout specific versons

cd /usr/share/cacti/site/ && git checkout release/_cacti_version_ 
cd /usr/share/cacti/develop && git branch develop --set-upstream upstream/develop && git checkout develop
cd /usr/share/cacti/feature && git branch feature/1.2.x --set-upstream upstream/feature/1.2.x && git checkout 

Create SSL Certificate

cd /etc/pki/tls/cacti/

openssl req -new -sha256 -nodes -out _cacti_host_.csr -newkey rsa:2048 -keyout _cacti_host_.key -config <(
cat <<-EOF
[req]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn

[dn]
C = GB
ST = Alive
L = The World
O = netniV
OU = CentOS6
emailAddress = netniv@hotmail.com
CN = _cacti_host_

[req_ext]
subjectAltName = @alt_names

[alt_names]
DNS.1 = develop._cacti_host_
DNS.2 = feature._cacti_host_
EOF
)
openssl x509 -req -days 1825 -in _cacti_host_.csr -signkey _cacti_host_.key -out _cacti_host_.crt

Create HTTPD configuation

echo 'NameVirtualHost *:443
NamevirtualHost *:80
SSLStrictSNIVHostCheck on

<VirtualHost *:443>
        ErrorLog /var/log/cacti/site-error.log
        TransferLog /var/log/cacti/site-access.log
        CustomLog /var/log/cacti/site/site-request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

        SSLEngine on
        SSLProtocol all -SSLv2 -SSLv3
        SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
        SSLCertificateFile /etc/pki/tls/cacti/_cacti_host_.crt
        SSLCertificateKeyFile /etc/pki/tls/cacti/_cacti_host_.key

        <Files ~ "\.(cgi|shtml|phtml|php3?)$">
                SSLOptions +StdEnvVars
        </Files>

        <Location />
                Required all granted
        </Location>

        <Directory /usr/share/cacti/site>
                AllowOverride All
                Required all granted
        </Directory>

        DocumentRoot /usr/share/cacti/site
        ServerName _cacti_host_
</VirtualHost>
<VirtualHost *:443>
        ErrorLog /var/log/cacti/develop-error.log
        TransferLog /var/log/cacti/site/develop-access.log
        CustomLog /var/log/cacti/site/develop-request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

        SSLEngine on
        SSLProtocol all -SSLv2 -SSLv3
        SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
        SSLCertificateFile /etc/pki/tls/cacti/_cacti_host_.crt
        SSLCertificateKeyFile /etc/pki/tls/cacti/_cacti_host_.key

        <Files ~ "\.(cgi|shtml|phtml|php3?)$">
                SSLOptions +StdEnvVars
        </Files>

        <Location />
                Required all granted
        </Location>

        <Directory /usr/share/cacti/develop>
                AllowOverride All
                Required all granted
        </Directory>

        DocumentRoot /usr/share/cacti/develop
        ServerName _cacti_host_
</VirtualHost>
<VirtualHost *:443>
        ErrorLog /var/log/cacti/feature-error.log
        TransferLog /var/log/cacti/site/feature-access.log
        CustomLog /var/log/cacti/site/feature-request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

        SSLEngine on
        SSLProtocol all -SSLv2 -SSLv3
        SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
        SSLCertificateFile /etc/pki/tls/cacti/_cacti_host_.crt
        SSLCertificateKeyFile /etc/pki/tls/cacti/_cacti_host_.key

        <Files ~ "\.(cgi|shtml|phtml|php3?)$">
                SSLOptions +StdEnvVars
        </Files>

        <Location />
                Required all granted
        </Location>

        <Directory /usr/share/cacti/feature>
                AllowOverride All
                Required all granted
        </Directory>

        DocumentRoot /usr/share/cacti/feature
        ServerName _cacti_host_
</VirtualHost>
' > /etc/httpd/conf.d/cacti.conf

Enable through firewall

firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanent
firewall-cmd --reload

Configuration MySQL

Enable custom configurations

echo "[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_allowed_packet=18M
max_heap_table_size=98M
tmp_table_size=64M
join_buffer_size=64M
innodb_buffer_pool_size=488M
innodb_doublewrite=OFF
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16
default_time_zone='+00:00'
" > /etc/my.cnf.d/cacti.cnf

systemctl restart mariadb
mysql_secure_installation

Create databases and users

cacti_sql=`mktemp -t XXXXXXXXXXXX -u`

echo "use mysql;
create database if not exists cacti_site; 
create database if not exists cacti_feature; 
create database if not exists cacti_develop;
use cacti_site;
source /usr/share/cacti/site/cacti.sql;
use cacti_feature;
source /usr/share/cacti/feature/cacti.sql;
use cacti_develop;
source /usr/share/cacti/develop/cacti.sql;
" > $cacti_sql;

cacti_pw_site=`mktemp -t XXXXXXXXXXXX -u | sed 's/\/tmp\///'`
cacti_pw_develop=`mktemp -t XXXXXXXXXXXX -u | sed 's/\/tmp\///'`
cacti_pw_feature=`mktemp -t XXXXXXXXXXXX -u | sed 's/\/tmp\///'`

echo "
GRANT ALL PRIVILEGES ON cacti_site.* TO 'cacti_site'@'localhost' IDENTIFIED BY '$cacti_pw_site';
GRANT ALL PRIVILEGES ON cacti_develop.* TO 'cacti_develop'@'localhost' IDENTIFIED BY '$cacti_pw_develop';
GRANT ALL PRIVILEGES ON cacti_feature.* TO 'cacti_feature'@'localhost' IDENTIFIED BY '$cacti_pw_feature';
GRANT SELECT ON mysql.time_zone_name TO 'cacti_site'@'localhost';
GRANT SELECT ON mysql.time_zone_name TO 'cacti_develop'@'localhost';
GRANT SELECT ON mysql.time_zone_name TO 'cacti_feature'@'localhost';
FLUSH PRIVILEGES
" >> $cacti_sql

cat /usr/share/cacti/site/include/config.php.dist | sed "s/^\(\\\$database_default.*=[ ']*\)cacti\([';]*$\)/\1cacti_site\2/g"| sed "s/^\(\\\$database_username.*=[ ']*\)cactiuser\([';]*$\)/\1cacti_site\2/g" | sed "s/^\(\\\$database_password.*=[ ']*\)cactiuser\([';]*$\)/\1$cacti_pw_site\2/g" > /usr/share/cacti/site/include/config.php

cat /usr/share/cacti/develop/include/config.php.dist | sed "s/^\(\\\$database_default.*=[ ']*\)cacti\([';]*$\)/\1cacti_develop\2/g"| sed "s/^\(\\\$database_username.*=[ ']*\)cactiuser\([';]*$\)/\1cacti_develop\2/g" | sed "s/^\(\\\$database_password.*=[ ']*\)cactiuser\([';]*$\)/\1$cacti_pw_develop\2/g" > /usr/share/cacti/develop/include/config.php

cat /usr/share/cacti/feature/include/config.php.dist | sed "s/^\(\\\$database_default.*=[ ']*\)cacti\([';]*$\)/\1cacti_feature\2/g"| sed "s/^\(\\\$database_username.*=[ ']*\)cactiuser\([';]*$\)/\1cacti_feature\2/g" | sed "s/^\(\\\$database_password.*=[ ']*\)cactiuser\([';]*$\)/\1$cacti_pw_feature\2/g" > /usr/share/cacti/feature/include/config.php

mysql -u root -p < $cacti_sql
mysql -u root -p mysql < /usr/share/mariadb/mysql_test_data_timezone.sql;

Set cacti defaults

sed -i "s/^\(\\\$url_path.*=[ ']*\)\/cacti\/\([';]*$\)/\1\/\2/g" /usr/share/cacti/site/include/config.php
sed -i "s/^\(\\\$url_path.*=[ ']*\)\/cacti\/\([';]*$\)/\1\/\2/g" /usr/share/cacti/develop/include/config.php
sed -i "s/^\(\\\$url_path.*=[ ']*\)\/cacti\/\([';]*$\)/\1\/\2/g" /usr/share/cacti/feature/include/config.php

Set Timezones

sed -i "s/^[; ]*date\.timezone[ ]*=.*$/date.timezone = Europe\/London/gm" /etc/php.ini
systemctl restart httpd

Create poller cron

echo 'MAILTO=root
* * * * * 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-site.log' > /etc/cron.d/cacti-site
echo 'MAILTO=root
* * * * * www-data php --define suhosin.memory_limit=512M /usr/share/cacti/develop/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >> /var/log/cacti/poller-develop.log' > /etc/cron.d/cacti-develop
echo 'MAILTO=root
* * * * * www-data php --define suhosin.memory_limit=512M /usr/share/cacti/feature/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >> /var/log/cacti/poller-feature.log' > /etc/cron.d/cacti-feature
You can’t perform that action at this time.