Installation of Cacti on ubuntu 18.04

Installation

Installation of Cacti on ubuntu 18.04 with apt-get could’t be more easy

apt-get install snmp snmpd snmp-mibs-downloader rrdtool cacti cacti-spine

you should get a few prompts in the installation process

Choose Apache2

Choose yes

Create a Strong password for this, it will be used for MYSQL authenticaction for the database and admin account for cacti, it will be stored as clear text in /etc/cacti/debian.conf

Optional is to leave the password field blank and a random password will be generated, after the installation you can run this command to retrieve password for admin account and mysql cacti user, and print password to cli and /root/password.txt

echo “” ; database_password=$(cat /etc/cacti/debian.php | grep “\$database_password” | sed “s/’;//” | sed “s/.*’//”) ; echo “Cacti Admin Password: $database_password” ; echo “” ; echo “Cacti Admin Password: $database_password” >> /root/passwords.txt ; echo “Mysql Cacti Password: $database_password” >> /root/passwords.txt

Best practice would be to set an password on the root mysql account, this command this set a random generated password on the mysql root account and print password to cli and /root/password.txt

mysql_root_password=$(shuf -zer -n20 {a..z} {A..Z} {0..9} | tr -d ‘\0’) && mysql -u root -e “UPDATE mysql.user SET authentication_string=PASSWORD(‘$mysql_root_password’), plugin=’mysql_native_password’ WHERE User=’root'” ; service mysql restart && echo “” ; echo Mysql Root Password: $mysql_root_password ; echo “” ; echo “Mysql Root Password $mysql_root_password” >> /root/passwords.txt

remember to store the passwords safely somewhere and delete the file located under /root/passwords.txt

now open a browser and navigate to http://SERVERIP/cacti

username: admin

password is the same as the one you created for the mysql in the installation process.

Change Url (optional)

in order to change the url from http://serverip/cacti to http://serverip

sed ‘s/DocumentRoot.*/DocumentRoot \/usr\/share\/cacti\/site/’ -i /etc/apache2/sites-enabled/000-default.conf

sed “s/^\$url_path.*/\$url_path = ‘\/’;/” -i /etc/cacti/debian.php

Leave a Reply

Your email address will not be published. Required fields are marked *