当前位置: 首页 > 工具软件 > WeatherMap > 使用案例 >

Installing Cacti 0.8.8h and php weathermap 0.98 on CentOS 7

路欣荣
2023-12-01

Installing Cacti 0.8.8h and php weathermap 0.98 on CentOS 7

Overview
Cacti is an open-source, web-based network monitoring and graphing tool used to get a graph data such as CPU usage, memory usage, network bandwidth utilization, and more. It can graph the network traffic by polling a router or switch using SNMP protocol.
In this article will show how to install Cacti on CentOS 7. To use PHP weathermap cacti plugin, the Cacti version that need to download is 0.8.8h.
Prerequisites
In this tutorial, it is supposed that:
a. You have already install RHEL/CentOS 7 Linux server up and running. In case that you don’t, you would probably like to read this link. Minimal RHEL/CentOS 7 Installation With Logical Volume Manager (LVM).
b. You have already done the initial server setup. Please refer to this link Minimal RHEL/CentOS 7 Initial Server Setup.
Install and Configure Database for Cacti Application
In CentOS 7, MySQl is moved to MariaDB, execute the following command to install MariaDB.
yum -y install mariadb-server mariadb-devel
Enable MariaDB service to start it a the system boot and start its service.

systemctl enable mariadb
systemctl start mariadb
Now let do the security hardening of MariaDB by execute the following command.

mysql_secure_installation
We need to create a database and a user for Cacti application and grant it all database privileges.

mysql -u root -p
create database cacti;
create user ‘cacti’@‘localhost’ identified by ‘cacti’;
grant all privileges on cacti.* to cacti@localhost;
flush privileges;

Installing Cacti Application
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php56 [Install PHP 5.6]
yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
To install Cacti web application, we need to install some mandatory packages as the following first.

yum -y install php php-cli php-mysql net-snmp-utils rrdtool php-snmp gcc net-snmp-devel autoconf automake libtool dos2unix wget help2man php-gd php-ldap php-pear php-common php-devel php-mbstring net-snmp-utils net-snmp-libs httpd
Enable Apache service to start it a the system boot and start its service.

systemctl enable httpd
systemctl start httpd
Enable SNMP service to start it a the system boot and start its service.

systemctl enable snmpd
systemctl start snmpd
Let move to the installation directory for Cacti application, /var/www, download and extract it.

cd /opt
mkdir cacti
cd cacti
wget http://www.cacti.net/downloads/cacti-0.8.8h.tar.gz
tar -xzvf cacti-0.8.8h.tar.gz
It is recommended to create a symbolic link to the extracted directory of Cacti application “cacti-1.1.10”. So, it will make us easy to upgrades Cacti to a newer versions.

mv cacti-0.8.8h cacti
Also, we need to create a user for Cacti application and make sure that the permissions on the log and rra directories are set correctly as the following.

adduser -d /opt/cacti -s /sbin/nologin cacti
chown -R apache:apache /opt/cacti
chown -R cacti /opt/cacti/cacti/rra
Now we need to add a cron entry for a 1 minute polling interval of Cacti application using the following command.

vim /etc/cron.d/cacti
*/1 * * * * cacti php /opt/cacti/cacti/poller.php --debug --force &>/dev/null

Or:

su – cacti
$ crontab -e
/bin/php /opt/cacti/cacti/poller.php --debug –force

*/1 * * * * /usr/bin/php /opt/cacti/cacti/poller.php --debug –force > /dev/null 2>&1
Now, let import Cacti application database into the database created using the following command.

mysql -p cacti < /opt/cacti/cacti/cacti.sql
Next, we need to change some settings for database credentials in configuration file of Cacti application.

vim /opt/cacti/cacti/include/config.php
$database_type = ‘mysql’;
$database_default = ‘cacti’;
$database_hostname = ‘localhost’;
$database_username = ‘cacti’;
$database_password = ‘cacti’;
$database_port = ‘3306’;
$database_ssl = false;
Next, we need to open HTTP port 80 on IPTables.

vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

systemctl restart iptables
iptables -L -n -v
Usually, the default PHP installation usually has not configured the correct timezone or php error reporting. While not required to run Cacti, it’s highly recommended to enable error reporting to syslog for troubleshooting issues with plugins or other scripts. Edit file /etc/php.ini as the following.

vim /etc/php.ini
date.timezone = Asia/Shanghai
log_errors = syslog
Then, we need to restart Apache service.

systemctl restart httpd
We also need to disable SELinux.

vim /etc/selinux/config
SELINUX=disabled

reboot
Configure VHost for Cacti Application
To create a VHost for Cacti application, create a *.conf file in directory /etc/httpd/conf.d as the following.
vim /etc/httpd/conf.d/cacti.conf
<VirtualHost *>
DocumentRoot /opt/cacti/
ServerName cacti.domain.com
CustomLog /opt/cacti/logs/access_log combined
ErrorLog /opt/cacti/logs/error_log
<Directory “/opt/cacti/”>
AllowOverride All
Options FollowSymLinks MultiViews
Require all granted


Then, we need to restart Apache service.

systemctl restart httpd
Finally, we are ready to install Cacti application. In your broswer, in the address box type in http://cacti.techspacekh.com and the following windows appears.

Cacti Default Password Default Username and password of Cacti Web Admin in Ubuntu Debian or Windows Default URL : User Name : admin Password : admin
Change the password to cacti
6. Installing weathermap

cd /opt/cacti/
ls
cacti-0.8.8h.tar.gz
php-weathermap-0.98.zip

unzip php-weathermap-0.98.zip
mv weathermap/ /opt/cacti/cacti/plugins/
chown -R apache configs/
chown -R cacti output/
6.1 enable weathermap
登录cacti界面,Console ->Plugin Management,再点击Actions即可

如下图,标识Weathermap安装成功(有weathermap页签,状态是active)

6.2 修改配置文件editor.php
vi editor.php
$ENABLED=true;

 类似资料:

相关阅读

相关文章

相关问答