initial commit of file from CVS for smeserver-cacti on Sat Sep 7 20:12:27 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:12:27 +10:00
parent 57a57fd2de
commit f07424d1b3
42 changed files with 1080 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004 Ian Berry |
| |
| 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: a php-based graphing solution |
+-------------------------------------------------------------------------+
| Most of this code has been designed, written and is maintained by |
| Ian Berry. See about.php for specific developer credit. Any questions |
| or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "{$cacti{'DbDatabase'}}";
$database_hostname = "localhost";
$database_username = "{$cacti{'DbUser'}}";
$database_password = "{$cacti{'DbPassword'}}";
$database_port = "3306";
/*
* Server is a remote poller, then these entries point to
* the main cacti server. Otherwise, these variables have no use and
* must remain commented out.
*/
#$rdatabase_type = 'myql';
#$rdatabase_default = 'cacti';
#$rdatabase_hostname = 'localhost';
#$rdatabase_username = 'cactiuser';
#$rdatabase_password = 'cactiuser';
#$rdatabase_port = '3306';
#$rdatabase_retries = 5;
#$rdatabase_ssl = false;
#$rdatabase_ssl_key = '';
#$rdatabase_ssl_cert = '';
#$rdatabase_ssl_ca = '';

View File

@@ -0,0 +1,7 @@
/*
* The poller_id of this system. set to `1` for the main cacti web server.
* Otherwise, you this value should be the poller_id for the remote poller.
*/
$poller_id = 1;

View File

@@ -0,0 +1,9 @@
/*
* Set the $url_path to point to the default URL of your cacti install.
* For exmaple if your cacti install as at `https://serverip/cacti/` this
* would be set to `/cacti/`.
*/
$url_path = '/cacti/';

View File

@@ -0,0 +1,19 @@
/*
* Default session name - session name must contain alpha characters
*/
$cacti_session_name = 'Cacti';
/*
* Default Cookie domain - The cookie domain to be used for Cacti
*/
//$cacti_cookie_domain = 'cacti.net';
/*
* Save sessions to a database for load balancing
*/
$cacti_db_session = false;

View File

@@ -0,0 +1,6 @@
/*
* Disable log rotation settings for packagers
*/
$disable_log_rotation = true;

View File

@@ -0,0 +1,18 @@
/*
* Optional parameters to define scripts and resource paths. These
* variables become important when using remote poller installs when the
* scripts and resource files are not in the main Cacti web server path.
*/
//$scripts_path = '/var/www/html/cacti/scripts';
//$resource_path = '/var/www/html/cacti/resource/';
/*
* Optional parameter to define a data input whitelist command string. This
* whitelist file will help protect cacti from unauthorized changes to Cacti
* data input command string.
*/
//$input_whitelist = '/usr/local/etc/cacti/input_whitelist.json';

View File

@@ -0,0 +1,6 @@
/*
* Optional parameter to give explicit path to PHP
*/
$php_path = '/usr/bin/php74';

View File

@@ -0,0 +1,8 @@
/*
* Optional parameter to disable the PHP SNMP extension. If not set, defaults
* to class_exists('SNMP').
*/
//$php_snmp_support = false;

View File

@@ -0,0 +1,8 @@
/*
* Optional parameter to define the path of the csrf_secret.php path. This
* variable is for packagers who wish to specify an alternate location of
* the CRSF secret file.
*/
$path_csrf_secret = '/var/lib/cacti/csrf/csrf-secret.php';

View File

@@ -0,0 +1,30 @@
/*
* The following are optional variables for debugging low level system
* functions that are generally only used by Cacti Developers to help
* identify potential issues in commonly used functions
*
* To use them, uncomment and the equivalent field will be set in the
* $config variable allowing for instant on but still allowing the
* ability to fine turn and turn them off.
*/
/*
* Debug the read_config_option program flow
*/
# define('DEBUG_READ_CONFIG_OPTION', true);
/*
* Automatically suppress the DEBUG_READ_CONFIG_OPTION
*/
# define('DEBUG_READ_CONFIG_OPTION_DB_OPEN', true);
/*
* Always write the SQL command to the cacti log file
*/
# define('DEBUG_SQL_CMD', true);
/*
* Debug the flow of calls to the db_xxx functions that
* are defined in lib/database.php
*/
# define('DEBUG_SQL_FLOW', true);

View File

@@ -0,0 +1 @@
?>

View File

@@ -0,0 +1,11 @@
# cacti poller:
{
if ($cacti{'status'} eq "enabled")
{
$OUT .="*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2> /dev/null &\n";
}
else
{
$OUT .="# cacti disabled";
}
}

View File

@@ -0,0 +1,34 @@
{
my $db = $cacti{DbDatabase} || 'cacti_sme';
my $user = $cacti{DbUser} || 'cacti';
my $pass = $cacti{DbPassword} || 'changeme';
$OUT .= <<END
#!/bin/bash
if [ -d /var/lib/mysql/$db ]; then
/usr/bin/mysql <<EOF
use $db;
use mysql;
ALTER DATABASE $db COLLATE = 'utf8mb4_unicode_ci';
GRANT ALL PRIVILEGES ON $db.* TO $user\@localhost
IDENTIFIED BY '$pass';
GRANT SELECT ON mysql.time_zone_name TO '$user'\@'localhost';
flush privileges;
EOF
exit
fi
/usr/bin/mysql <<EOF
CREATE DATABASE $db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use $db;
use mysql;
GRANT ALL PRIVILEGES ON $db.* TO $user\@localhost
IDENTIFIED BY '$pass';
GRANT SELECT ON mysql.time_zone_name TO '$user'\@'localhost';
flush privileges;
EOF
/usr/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo/ 2>/dev/null |/usr/bin/mysql mysql
/usr/bin/mysql $db < \$(rpm -ql cacti|grep cacti.sql)
#/usr/bin/mysql $db < /etc/e-smith/db/configuration/migrate/80cacti_sme.sql
END
}

View File

@@ -0,0 +1,23 @@
# Cacti template
Alias /cacti /usr/share/cacti
<Directory /usr/share/cacti>
SSLRequireSSL
Options -Indexes
AllowOverride None
Require { (($cacti{'access'} ||"private") eq "public") ? "all granted" : "ip $localAccess $externalSSLAccess"; }
AddType application/x-httpd-php .php
<FilesMatch \.php$ >
SetHandler "proxy:unix:/var/run/php-fpm/php74-cacti.sock|fcgi://localhost"
</FilesMatch>
</Directory>
<Directory /usr/share/cacti/log>
Require all denied
</Directory>
<Directory /usr/share/cacti/rra>
Require all denied
</Directory>

View File

@@ -0,0 +1,9 @@
{
if ($port eq "80")
{
$OUT = ' RewriteRule ^/cacti(/.*|$) https://%{HTTP_HOST}/cacti$1 [L,R]';
} else {
$OUT = ' Alias /cacti /usr/share/cacti';
}
}

View File

@@ -0,0 +1,5 @@
[mariadb-5.5]
#for cacti use
innodb_buffer_pool_size=483M
innodb_additional_mem_pool_size=80M
innodb_flush_log_at_trx_commit=2

View File

@@ -0,0 +1,68 @@
{
if ($PHP_VERSION eq '74'){
if (($cacti{'status'} || 'disabled') eq 'enabled'){
my $max_upload_size = ($cacti{MaxUploadSize} || '4096');
$max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/);
my $memory_limit = ($cacti{MemoryLimit} || '500M');
$memory_limit .= 'M' if ($memory_limit =~ m/^\d+$/);
my $open_basedir= $cacti{PHPBaseDir} || '';
$open_basedir = "/tmp/:/share/:/var/log/cacti:/etc/cacti/db.php:/usr/share/cacti:/var/lib/cacti:/var/log/cacti.log:/var/lib/php/cacti:/home/e-smith/files/cacti:/dev/urandom:/proc/meminfo:$open_basedir";
my $id = 'cacti';
my $max_children = $cacti{'PHPmaxChildren'} || 20;
my $min_spare_servers = $cacti{'PHPminServers'} || 4;
my $start_servers = $cacti{'PHPstartServers'} || 6;
my $max_spare_servers = $cacti{'PHPmaxServers'} || 8;
my $max_requests = $cacti{'PHPmaxRequests'} || 1000;
$min_spare_servers = ( $min_spare_servers > $max_spare_servers ) ? printf("%.0f",$max_spare_servers/2) : $min_spare_servers;
$start_servers = ( $start_servers > $max_spare_servers ) ? printf("%.0f", $max_spare_servers /2 + $min_spare_servers/2 ) : $start_servers;
$OUT .=<<_EOF;
[php$PHP_VERSION-$id]
user = www
group = www
listen.owner = root
listen.group = www
listen.mode = 0660
listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock
pm = dynamic
pm.max_children = $max_children
pm.start_servers = $start_servers
pm.min_spare_servers = $min_spare_servers
pm.max_spare_servers = $max_spare_servers
pm.max_requests = $max_requests
php_admin_value[session.save_path] = /var/lib/php/$id/session
php_admin_value[session.gc_maxlifetime] = 86400
;php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache
php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp
php_admin_value[error_log] = /var/log/php/$id/error.log
slowlog = /var/log/php/cacti/slow.log
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f php@{ $DomainName }
php_admin_flag[display_errors] = off
php_admin_flag[log_errors] = on
php_admin_value[error_log] = syslog
php_admin_value[memory_limit] = $memory_limit
php_admin_value[max_execution_time] = 3600
php_admin_value[post_max_size] = $max_upload_size
php_admin_value[upload_max_filesize] = $max_upload_size
;php_admin_value[disable_functions] = system, show_source, symlink, dl, passthru, phpinfo, escapeshellarg, escapeshellcmd
;php_admin_value[open_basedir] = $open_basedir
php_admin_flag[allow_url_fopen] = on
php_admin_flag[file_upload] = on
;php_admin_flag[session.cookie_httponly] = on
;php_admin_flag[allow_url_include] = off
;php_admin_value[session.save_handler] = files
;php_admin_flag[output_buffering] = off
_EOF
}
else{
$OUT .= '; Cacti is disabled';
}
}
}