Search My Techie Guy

Tuesday, August 18, 2020

Installing Cacti Network Monitoring Tool on Fedora 32 and Upwards

Summary:

Installing Cacti on Fedora 32
Server Architecture: x86_64 

Problem or Goal:

To install cacti monitoring tool on Fedora

Cause:

Cacti is a very important open source tool for network monitoring

Solution: 

1. Install Apache

[root@localhost ~]# dnf install httpd httpd-devel


2. Install MariaDB (MariaDB is the default implementation of MySQL in RHEL/CentOS 8/7 and Fedora 19 onwards.)

[root@localhost ~]# dnf install mariadb-server -y



3. Install PHP

# dnf install php-mysqlnd php-pear php-common php-gd php-devel php php-mbstring php-cli



4. Install PHP-SNMP

[root@localhost ~]# dnf install php-snmp


5. Install NET-SNMP

[root@localhost ~]# dnf install net-snmp-utils net-snmp-libs


 
6. Install RRDTool

[root@localhost ~]# dnf install rrdtool



7. Start Apache, MariaDB and SNMP Services

[root@localhost ~]# systemctl start httpd.service
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl start snmpd.service

8. Configure Apache, MariaDB and SNMP Services to start on boot.

[root@localhost ~]# systemctl enable httpd.service
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# systemctl enable snmpd.service





9. Install Cacti

[root@localhost ~]# dnf install cacti




10. Configuring and Securing MySQL Server for Cacti Installation

#  mysql_secure_installation

MariaDB root passwd: xxxxxx
username to cacti DB: cacti
passwd to cacti DB: xxxxxx


11. Create MySQL Cacti Database

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
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 database cacti;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'xxxxx';
Query OK, 0 rows affected (0.010 sec)
MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit;
Bye



12. Install Cacti Tables to MySQL

[root@localhost ~]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti/cacti.sql

(Now we’ve of the location of Cacti.sql file, type the following command to install tables, 
here you need to type the Cacti user password)

[root@localhost ~]# mysql -u cacti -p cacti < /usr/share/doc/cacti/cacti.sql   
NOTE:  -u specifies the user 'cacti' and -p specifies the db 'cacti', you will have to enter the passwd to cacti db "xxxxxx"



13. Configure MySQL settings for Cacti

[root@localhost ~] # vi /etc/cacti/db.php



14. Configuring Firewall for Cacti

[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=http
[root@localhost ~]# firewall-cmd --reload


15. Configure Apache Server for Cacti Installation

# vi /etc/httpd/conf.d/cacti.conf

Alias /cacti    /usr/share/cacti

<Directory /usr/share/cacti/>
        <IfModule mod_authz_core.c>
                # httpd 2.4
                Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
                # httpd 2.2
                Order deny,allow
                Deny from all
                Allow from all
        </IfModule>
</Directory>

16. Restart the Apache service

[root@localhost ~]# systemctl restart httpd.service


17. Setting Cronjob for Cacti

[root@localhost ~]#  vi /etc/cron.d/cacti

Uncomment the following line. 
(The poller.php script runs every 5mins and collects data of known host which is used by Cacti application to display graphs)

*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1


18. Running Cacti Installer Setup in your browser

http://192.168.0.149/cacti/

Default login

User: admin
Password: admin

19. If you can't access the HTTP Service on your server, you might want to check your firewall and probably disable it for now.

[root@localhost ~]# service firewalld status
[root@localhost ~]# service firewalld stop





20. Accept the License agreement



21. Pre-installation Checks for Cacti installation

(please correct the suggested settings in your /etc/php.ini file as shown and restart Apache after making changes)

memory_limit = 800M
max_execution_time = 60
date.timezone = Africa/Juba

# timedatectl list-timezones
Africa/Juba

# timedatectl set-timezone Africa/Juba


22. Similarly, you also need to grant access to the MySQL TimeZone database for user Cacti, 
so that the database is populated with global TimeZone information

mysql> use mysql;
mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
mysql> flush privileges;
mysql> show variables like '%time_zone%';


23. To clear this ERROR: Your MySQL TimeZone database is not populated. 
Please populate this database before proceeding.
Run the following command

# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql 

Hit refresh and if the errors have cleared, you are good to proceed to next

24. Installation Type


25. Directory Permission Checks

Potential permission issues (ERROR!  /usr/share/cacti/log/ Not Writable)

Run the following commands to clear the error above

[root@localhost ~]# chown -R apache.apache /usr/share/cacti/log/
[root@localhost ~]# setenforce 0


26. Critical Binary Locations and Versions

27. Confirm Installation




Problem Solved?




You are welcome to ask questions in the comments section

7 comments:

Unknown said...

Hi, i successfully installed cacti but no data graphs are showing. Can you help me with that?

Joshua said...

Hello, can you check to make sure your chrone job is running smoothly. you could try and run the poller script manually.

Unknown said...

Hello, i did run the poller script manually and is running but still no graphs. Real Time grephs are working.

Joshua said...

If real time graphs are working means there is issue with the poller script. when you run it manually, are you running it as user "root"? if so, make sure the chron job is also running with user "root"

Unknown said...

I run poller like this and still no graphs.

[root@graph ~]# /usr/bin/php /usr/share/cacti/poller.php
2021-01-30 10:17:08 - POLLER: Poller[1] WARNING: Cron is out of sync with the Poller Interval! The Poller Interval is '10' seconds, with a maximum of a '60' second Cron, but 126.9 seconds have passed since the last poll!
2021-01-30 10:17:10 - SYSTEM STATS: Time:1.2203 Method:cmd.php Processes:1 Threads:1 Hosts:12 HostsPerProcess:12 DataSources:0 RRDsProcesse d:0
2021-01-30 10:17:20 - SYSTEM STATS: Time:1.2338 Method:cmd.php Processes:1 Threads:1 Hosts:12 HostsPerProcess:12 DataSources:0 RRDsProcesse d:0
2021-01-30 10:17:30 - SYSTEM STATS: Time:1.2145 Method:cmd.php Processes:1 Threads:1 Hosts:12 HostsPerProcess:12 DataSources:0 RRDsProcesse d:0
2021-01-30 10:17:40 - SYSTEM STATS: Time:1.2243 Method:cmd.php Processes:1 Threads:1 Hosts:12 HostsPerProcess:12 DataSources:0 RRDsProcessed:0
2021-01-30 10:17:50 - SYSTEM STATS: Time:1.2307 Method:cmd.php Processes:1 Threads:1 Hosts:12 HostsPerProcess:12 DataSources:0 RRDsProcessed:0
2021-01-30 10:18:00 - SYSTEM STATS: Time:1.2242 Method:cmd.php Processes:1 Threads:1 Hosts:12 HostsPerProcess:12 DataSources:0 RRDsProcessed:0
[root@graph ~]#

Joshua said...

Send me the output of this command:

crontab -l

Knife Hubs said...

Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee
Monitor Bee