How to Configure Cacti cacti-0.8.8g using CentOS 7 Linux

After completed all the required packages and configuration in the previous phase of How to install Cacti Network Monitoring you can follow the configuration now from here to finish it.

Step 1: Now we are ready to install the Cacti application using yum

[[email protected] ~]# yum install cacti

cacti_17

then it will confirm if you want to proceed installing the package using the repository that we just use

cacti_18

Step 2: Now import the SQL database tables “cacti.sql” using the command below it will search the path of the file

[[email protected]~]# rpm -ql cacti | grep cacti.sql

[[email protected]~]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8b/cacti.sql
[[email protected] ~]#

cacti_config_02

And then issue the below command to import tables to cactidb and type the password that was set in the previous phase.

[[email protected] ~]# mysql -u root -p cactidb < /usr/share/doc/cacti-0.8.8b/cacti.sql

cacti_config_04

and verify if the table was imported properly by login in mariadb

[[email protected] ~]# mysql -u root -p

cacti_config_05

MariaDB [(none)]> show databases;
MariaDB [(none)]> use cactidb;
MariaDB [cactidb]> show tables;

cacti_config_06

Step 3:  Edit the file in /etc/cacti/db.php and append below lines .

[[email protected] ~]# vim /etc/cacti/db.php

cacti_config_07

and then type your db name, db user and database password

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "abcde12345";
$database_port = "3306";
$database_ssl = false;

cacti_config_08a

Step 4: Open /etc/httpd/conf.d/cacti.conf file put comment in all line that has the word “Deny from all” and there are only 3 of them inside and put a # as show in below. And change the “Order deny,allow” to “Order allow,deny” and also change “Require host localhost” to “Require all granted”

cacti_config_09

 

cacti_config_14

Alias /cacti    /usr/share/cacti

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

<Directory /usr/share/cacti/install>
        # mod_security overrides.
        # Uncomment these if you use mod_security.
        # allow POST of application/x-www-form-urlencoded during install
        #SecRuleRemoveById 960010
        # permit the specification of the rrdtool paths during install
        #SecRuleRemoveById 900011
</Directory>


# These sections marked "Require all denied" (or "Deny from all")
# should not be modified.
# These are in place in order to harden Cacti.
<Directory /usr/share/cacti/log>
        <IfModule mod_authz_core.c>
                Require all denied
        </IfModule>
        <IfModule !mod_authz_core.c>
                Order allow,deny
                allow from all
#               Order deny,allow
#               Deny from all
        </IfModule>
</Directory>
<Directory /usr/share/cacti/rra>
        <IfModule mod_authz_core.c>
                Require all denied
        </IfModule>
        <IfModule !mod_authz_core.c>
                Order allow,deny
                allow from all
#               Order deny,allow
#               Deny from all
        </IfModule>

Step 5: Edit the file “/etc/cron.d/cacti” and uncomment the line / remove the #

cacti_config_10

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

cacti_config_11

and then restart the httpd and crond service by issuing below commands

[[email protected] ~]# systemctl restart httpd.service
[[email protected] ~]# systemctl restart crond.service

cacti_config_12

And then make sure you disabled the firewall (iptables) to enable the port 80 to open so that the client can connect to Cacti

[[email protected]~]# systemctl disable iptables.service

and

[[email protected]~]# iptables –flush

and followed by netstat -natp command to check if the port 80 is open as shown in below image

[[email protected]~]# netstat -natp

cacti_config_13

Step 6: Now open http://serverip/cacti in your browser, and configure the Cacti installation in your browser page

cacti_config_15

Click Next

cacti_config_16

Click Next then Finish (Leave all by default)

cacti_config_17

 

Step 7: Login as default user using below credentials  to continue configuring the Cacti

user: admin
password: admin

cacti_config_18

then after you type the user admin and password as admin the Cacti will ask you one time change password as shown in below screenshot. This time type your own password

cacti_config_19

And that’s it it will show you the management view of the Cacti

cacti_config_20

 

Step 8: Then configure the cacti graph choose – > Devices – > click Localhost in the right side menu and look for

cacti_config_21

Then scroll down and look for “SNMP Options“. select SNMP Version -> “Version 2” and SNMP Community -> public and then click the “save” button at the end bottom.

cacti_config_22

Step 9: Now you can see the SNMP information at the top . Click “Create Graphs for this host” in the upper right

cacti_config_23

and choose  Graph Types > then ALL and select all the check boxes as show below and press “create“. Now choose the color option ( Leave as it is ) and then press “create“.

cacti_config_24

cacti_config_25

After few minutes , you can see the initial stage of graphs for localhost in the Graphs section tab on top . after few hours you can see the graphs like below.

cacti_config_26

 

Step 10: Adding the Linux, Windows and Network devices in Cacti Monitoring

Adding linux machines

a. Now in cacti , “Create devices” and Add description and hostname (or) IP .
b. Choose “Host Template” as “Local linux machine”.
c. Under SNMP Options select SNMP Version -> “Version 2” and SNMP Community -> public and click the “save” button at the bottom.
d. Add the device to the Graph tree.

Adding Windows machines

a. Enable SNMP service in your windows client
b. Make sure you added community name “public” and allowed your Cacti server IP.
c. Now in cacti , “Create devices” and Add description and hostname (or) IP .
d. Choose “Host Template” as “Windows 2000/XP host”.
e. Under SNMP Options select SNMP Version -> “Version 2” and SNMP Community -> public and click the “save” button at the bottom.
f. Add the device to the Graph tree.

Adding Network Switch/Router

a. Go to Management and click on Devices.
b. Click on the Add link in the top right corner.
c. Enter the hostname and description of your Cisco device.
d. Select Cisco Router as the Host Template.

cacti_config_27
e. Select Version 2 for the SNMP Version and enter the community name of your Cisco device.

cacti_config_28
f. Click on Save at the bottom.

 

Step 11: Edit the “/etc/php.ini” file and add the timezone “date.timezone = Asia/Singapore”

[[email protected]~]# vim /etc/php.ini

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Singapore

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

And after that restart the httpd by issuing “systemctl restart httpd.service” command

Step 12: Edit your index.php and append below line inside this will correct the error regarding the UTC Timezone error that will log in /var/log/httpd/*.logs

date_default_timezone_set(‘Asia/Singapore’);

<?php
/*
 +-------------------------------------------------------------------------+
 | Copyright (C) 2004-2013 The Cacti Group                                 |
 |                                                                         |
 | This program is free software; you can redistribute it and/or           |
 | modify it under the terms of the GNU General Public License             |
 | as published by the Free Software Foundation; either version 2          |
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | Cacti: The Complete RRDTool-based Graphing Solution                     |
 +-------------------------------------------------------------------------+
 | This code is designed, written, and maintained by the Cacti Group. See  |
 | about.php and/or the AUTHORS file for specific developer information.   |
 +-------------------------------------------------------------------------+
 | http://www.cacti.net/                                                   |
 +-------------------------------------------------------------------------+
*/

include("./include/auth.php");
include("./include/top_header.php");

api_plugin_hook('console_before');
date_default_timezone_set('Asia/Singapore');

?>

cacti_config_30

Step 13: It is very important that  you change this below line in host.php or else everytime you add device it will show error “Validation error problem. However in latest version 6.2 this was already fix

[[email protected] cacti]# vim /usr/share/cacti/host.php

a. Edit host.php and in line 179 vim /usr/share/cacti/host.php
b. Replace the line 179:
input_validate_input_number(get_request_var_post(‘drp_action’));
with below
input_validate_input_regex(get_request_var_post(‘drp_action’), “^([a-zA-Z0-9_]+)$”);
c. After that restart httpd.service

/* ------------------------
    The "actions" function
   ------------------------ */

function form_actions() {
        global $colors, $device_actions, $fields_host_edit;

        /* ================= input validation ================= */
        /* input_validate_input_number(get_request_var_post('drp_action')); */
        input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)$");
        /* ==================================================== */

        /* if we are to save this form, instead of display it */

 

 

1 Comment on "How to Configure Cacti cacti-0.8.8g using CentOS 7 Linux"

  1. Sweet

Leave a comment

Your email address will not be published.