Cacti

Aus xinux.net
Zur Navigation springen Zur Suche springen

Install

Prerequisites

  • sudo apt update

Install

#Apache & MariaDB
  • sudo apt install -y apache2 mariadb-server mariadb-client php-mysql libapache2-mod-php
#PHP Extensions
  • sudo apt install -y php-xml php-ldap php-mbstring php-gd php-gmp
#snmp
  • sudo apt install -y snmp php-snmp rrdtool librrds-perl

Configuration

Database Tuning

  • vi /etc/mysql/mariadb.conf.d/50-server.cnf
[mysqld]
collation-server = utf8mb4_unicode_ci
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 124M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 1024M
innodb_buffer_pool_instances = 10
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

Restart mariadb

  • systemctl restart mariadb

Set Timezone

  • vi /etc/php/7.2/apache2/php.ini

AND

  • vi /etc/php/7.2/cli/php.ini
date.timezone = Europe/Berlin
memory_limit = 512M
max_execution_time = 60

Restart MariaDB

  • sudo systemctl restart mariadb

Create Database

  • sudo mysql -u root -p
    • create database cacti;
    • GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';
    • flush privileges;
    • exit

Importmysql_test_data_tiemzone

  • sudo mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Grant the permission to cactiuser

  • sudo mysql -u root -p
    • GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
    • flush privileges;
    • exit

Install cacti

Import the default Cacti database

  • sudo mysql -u root -p cacti < /opt/cacti/cacti.sql

Cacti Config

  • vi /opt/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipassword";
$database_port = "3306";
$database_ssl = false;

Edit the crontab file

  • vi /etc/cron.d/cacti
*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1

Apache Config

  • vi /etc/apache2/sites-available/cacti.conf
Alias /cacti /opt/cacti

  <Directory /opt/cacti>
      Options +FollowSymLinks
      AllowOverride None
      <IfVersion >= 2.3>
      Require all granted
      </IfVersion>
      <IfVersion < 2.3>
      Order Allow,Deny
      Allow from all
      </IfVersion>

   AddType application/x-httpd-php .php

<IfModule mod_php.c>
      php_flag magic_quotes_gpc Off
      php_flag short_open_tag On
      php_flag register_globals Off
      php_flag register_argc_argv On
      php_flag track_vars On
      # this setting is necessary for some locales
      php_value mbstring.func_overload 0
      php_value include_path .
 </IfModule>

  DirectoryIndex index.php
</Directory>

Enable and restart Apache2

  • a2ensite cacti
  • systemctl restart apache2

Create a log file and set Rights

  • sudo touch /opt/cacti/log/cacti.log
  • sudo chown -R www-data:www-data /opt/cacti/

Login

Links