initial commit of file from CVS for smeserver-zabbix-server on Sat Sep 7 21:19:08 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 21:19:08 +10:00
parent 43379e295c
commit 88f19a11b6
57 changed files with 3069 additions and 2 deletions

View File

@@ -0,0 +1 @@
zabbixdb

View File

@@ -0,0 +1 @@
zabbixuser

View File

@@ -0,0 +1 @@
zabbix

View File

@@ -0,0 +1 @@
secret

View File

@@ -0,0 +1 @@
localhost

View File

@@ -0,0 +1 @@
enabled

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
10051

View File

@@ -0,0 +1 @@
local

View File

@@ -0,0 +1 @@
private

View File

@@ -0,0 +1 @@
enabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1,38 @@
{
my $rec = $DB->get('zabbix-server')
|| $DB->new_record('zabbix-server', {type => 'service'});
my $pw = $rec->prop('DbPassword');
if (not $pw or length($pw) < 57)
{
use MIME::Base64 qw(encode_base64);
$pw = "not set due to error";
if ( open( RANDOM, "/dev/urandom" ) )
{
my $buf;
# 57 bytes is a full line of Base64 coding, and contains
# 456 bits of randomness - given a perfectly random /dev/random
if ( read( RANDOM, $buf, 57 ) != 57 )
{
warn("Short read from /dev/random: $!");
}
else
{
$pw = encode_base64($buf);
chomp $pw;
}
close RANDOM;
}
else
{
warn "Could not open /dev/urandom: $!";
}
$rec->set_prop('DbPassword', $pw);
}
my $AdminPass = $rec->prop('AdminPassword') ||
$rec->set_prop('AdminPassword', `/usr/bin/openssl rand -base64 15 | /usr/bin/tr -c -d '[:graph:]'`);
}

View File

@@ -0,0 +1,3 @@
systemctl daemon-reload
systemsctl preset-all
systemsctl restart zabbix-server

View File

@@ -0,0 +1,7 @@
#!/bin/bash
# restart mysql.init
/usr/bin/systemctl stop zabbix-server 1>/dev/null
/usr/bin/systemctl restart mariadb105-mysql.init 1>/dev/null
/usr/bin/systemctl start zabbix-server 1>/dev/null
exit 0

View File

@@ -0,0 +1 @@
PERMS=0750

View File

@@ -0,0 +1,3 @@
TEMPLATE_PATH="/etc/zabbix/zabbix.conf.php"
OUTPUT_FILENAME="/etc/zabbix/web/zabbix.conf.php"

View File

@@ -0,0 +1,3 @@
PERMS=0600
UID="zabbix"
GID="zabbix"

View File

@@ -0,0 +1,4 @@
PERMS=0750
UID="root"
GID="zabbix"

View File

@@ -0,0 +1,21 @@
#Only non rpm owned files are backupe there
{
use RPM2;
my $rpm_db = RPM2->open_rpm_db();
my @dirs = qw(
/etc/zabbix
/etc/zabbix/zabbix_agentd.conf.d/
/var/lib/zabbix/bin/
);
foreach my $some_dir (@dirs) {
next unless ( -e $some_dir );
opendir(my $dh, $some_dir) || die "Can't open $some_dir: $!";
while ( (my $file = readdir $dh) ) {
next if $file =~ /^\.{1,2}$/;
$OUT .= "$some_dir/$file\n" unless $rpm_db->find_by_file("$some_dir/$file");
}
closedir $dh;
}
}

View File

@@ -0,0 +1,73 @@
{
my $db = ${'zabbix-server'}{'DbName'} || 'zabbixdb';
my $user = ${'zabbix-server'}{'DbUser'} || 'zabbixuser';
my $pass = ${'zabbix-server'}{'DbPassword'} || 'secret';
my $schema = `rpm -qd zabbix-server-mysql | grep create`;
chomp $schema;
my $curcharset= ( -d "/var/lib/mysql/$db" ) ? `echo 'show variables like "character_set_database";'|mysql $db|grep character_set_database|sed -r 's/^character_set_database\\s*([a-zA-Z0-9_-]+)/\\1/'` : "utf8";
chomp $curcharset;
my $adminpass= ${'zabbix-server'}{'AdminPassword'} || 'zabbix';
$hashpass=`/usr/bin/htpasswd -bnBC 10 '' $adminpass | tr -d ':'`;
$hashpass =~ tr/\r\n//d;
$version = `/bin/ls -d /usr/share/doc/zabbix-web*|grep -Eo '[0-9.]+\$'|cut -d. -f1 || echo 4 `;
$modpass=($version > 4)? "update users set passwd='$hashpass' where alias='Admin';": "#$version";
$OUT .= <<"END";
#! /bin/sh
if [ -d /var/opt/rh/rh-mariadb105/lib/mysql/$db ]; then
# check if utf8
if [[ "$curcharset" != "utf8" ]] ;then
echo "ALTER DATABASE $db CHARACTER SET utf8 COLLATE utf8_bin;" |/usr/bin/mysql105
echo 'ALTER TABLE `$db`.`problem_tag` DROP INDEX `problem_tag_1`, ADD INDEX `problem_tag_1` (`eventid`, `tag` (100), `value`(100));' |/usr/bin/mysql105
mysql --batch --skip-column-names --execute 'select concat("alter table ",TABLE_SCHEMA,".",TABLE_NAME," CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;") from information_schema.TABLES where TABLE_SCHEMA="$db"' | /usr/bin/mysql105
fi
for P in \$(rpm -qd zabbix-server-mysql | grep dbpatch | grep mysql); do
/usr/bin/mysql105 $db < \$P
done
else
echo "CREATE DATABASE $db CHARACTER SET utf8 COLLATE utf8_bin;" | /usr/bin/mysql105
/usr/bin/gunzip < $schema | /usr/bin/mysql105 $db
fi
/usr/bin/mysql105 <<EOF
USE $db;
update users set passwd=md5('$adminpass') where alias='Admin' and passwd=md5('zabbix');
$modpass
EOF
/usr/bin/mysql105 <<EOF
USE mysql;
grant all on $db.* to '${'zabbix-server'}{DbUser}'\@'localhost' identified by '${'zabbix-server'}{DbPassword}';
FLUSH PRIVILEGES;
USE ${'zabbix-server'}{DbName};
INSERT IGNORE INTO media_type (
mediatypeid,
type, description,
smtp_server,
smtp_helo,
smtp_email,
exec_path,
gsm_modem,
username,
passwd)
VALUES(
4,
1,
'xmpp',
'',
'',
'',
'sendxmpp',
'',
'',
'');
EOF
END
}

View File

@@ -0,0 +1,45 @@
{
if (
((${'zabbix-server'}{'status'} || 'disabled') eq 'enabled') &&
((${'zabbix-server'}{'WebAccess'} || 'local') ne 'disabled')){
my $access = (${'zabbix-server'}{'WebAccess'} || 'local') eq 'public' ?
'all granted':"ip $localAccess $externalSSLAccess";
my $tz = ${'TimeZone'} || 'Europe/Paris';
$OUT .=<<"HERE";
#-------------------------------------------#
# Zabbix monitoring system php web frontend #
#-------------------------------------------#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
SSLRequireSSL on
Options FollowSymLinks
AllowOverride None
#AddType application/x-httpd-php .php
<FilesMatch .php>
SetHandler "proxy:unix:/var/run/php-fpm/php74-zabbix-server.sock|fcgi://localhost"
</FilesMatch>
Require $access
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
<files *.php>
Require all denied
</files>
</Directory>
<Directory "/usr/share/zabbix/include/classes">
Require all denied
<files *.php>
Require all denied
</files>
</Directory>
HERE
}
}

View File

@@ -0,0 +1,7 @@
{
if ($port ne ${modSSL}{'TCPPort'}){
$OUT = ' RewriteRule ^/zabbix(/.*|$) https://%{HTTP_HOST}/zabbix$1 [L,R]';
}
}

View File

@@ -0,0 +1,60 @@
{
if ($PHP_VERSION eq '74'){
if ((${'zabbix-server'}{status} || 'disabled') eq 'enabled'){
my $id = 'zabbix-server';
my $openbasedir = '/usr/share/zabbix:/var/cache/zabbix/:/var/run/php-fpm/:/var/lib/php/zabbix/' .
':/var/lock/zabbix/:/etc/zabbix/:/usr/share/php/:/usr/share/pear/:/opt/remi/php74/root/usr/share/pear/' .
':/opt/remi/php74/root/usr/share/php/';
$disablefunctions = 'system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, ' .
'escapeshellarg, escapeshellcmd';
$socket = ( -d "/var/lib/mysql/zabbixdb") ? "/var/lib/mysql/mysql.sock" : "/var/lib/mysql/mariadb105.sock";
$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 = 15
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 4
pm.max_requests = 1000
request_terminate_timeout = 30
php_admin_value[session.save_path] = /var/lib/php/zabbix/session
php_admin_value[opcache.file_cache] = /var/lib/php/zabbix/opcache
php_admin_value[upload_tmp_dir] = /var/lib/php/zabbix/tmp
php_admin_value[error_log] = /var/log/php/zabbix/error.log
slowlog = /var/log/php/zabbix/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] = 256M
php_admin_value[max_execution_time] = 600
php_admin_value[max_input_time] = 600
php_admin_value[post_max_size] = 32M
php_admin_value[upload_max_filesize] = 16M
php_admin_value[disable_functions] = $disablefunctions
php_admin_value[open_basedir] = $openbasedir
php_admin_flag[allow_url_fopen] = on
php_admin_flag[file_upload] = off
php_admin_flag[session.cookie_httponly] = on
php_admin_flag[allow_url_include] = off
php_admin_value[session.save_handler] = files
php_admin_value[always_populate_raw_post_data] = -1
php_value[mysqli.default_socket] = $socket
php_value[mysql.default_socket] = $socket
_EOF
}
else{
$OUT .= '; Zabbix Server is disabled';
}
}
}

View File

@@ -0,0 +1 @@
Cmnd_Alias ZABBIX = /usr/sbin/fping,/usr/sbin/fping6

View File

@@ -0,0 +1 @@
zabbix ALL=(root) NOPASSWD: ZABBIX

View File

@@ -0,0 +1,19 @@
/*
** ZABBIX
** Copyright (C) 2000-2005 SIA Zabbix
**
** 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.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/

View File

@@ -0,0 +1,20 @@
global $DB;
$DB["TYPE"] = "MYSQL";
$DB["SERVER"] = "localhost";
$DB["PORT"] = "0";
{
my $dbname = ${'zabbix-server'}{'DbName'} || 'zabbix';
my $dbuser = ${'zabbix-server'}{'DbUser'} || 'zabbix';
my $dbpass = ${'zabbix-server'}{'DbPassword'} || 'secret';
$OUT .=<<"HERE";
\$DB["DATABASE"] = "$dbname";
\$DB["USER"] = "$dbuser";
\$DB["PASSWORD"] = "$dbpass";
HERE
}

View File

@@ -0,0 +1,10 @@
{
my $port = ${'zabbix-server'}{'TCPPort'} || '10051';
$OUT .=<<"HERE";
\$ZBX_SERVER = "localhost";
\$ZBX_SERVER_PORT = "$port";
HERE
}

View File

@@ -0,0 +1 @@
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;

View File

@@ -0,0 +1,4 @@
# This is config file for ZABBIX server process
# To get more information about ZABBIX,
# go http://www.zabbix.com

View File

@@ -0,0 +1,11 @@
############ GENERAL PARAMETERS #################
#NodeID dropped since Zabbix 2.40
{
# This defines unique NodeID in distributed setup,
# Default value 0 (standalone server)
# This parameter must be between 0 and 999
#my $nodeID = ${'zabbix-server'}{'NodeID'} || '0';
#$OUT .= "NodeID=$nodeID\n";
}

View File

@@ -0,0 +1,35 @@
# Number of pre-forked instances of pollers
# Default value is 5
# This parameter must be between 0 and 255
StartPollers=5
# Number of pre-forked instances of IPMI pollers
# Default value is 0
# This parameter must be between 0 and 255
#StartIPMIPollers=0
# Number of pre-forked instances of pollers for unreachable hosts
# Default value is 1
# This parameter must be between 0 and 255
#StartPollersUnreachable=1
# Number of pre-forked instances of trappers
# Default value is 5
# This parameter must be between 0 and 255
StartTrappers=5
# Number of pre-forked instances of ICMP pingers
# Default value is 1
# This parameter must be between 0 and 255
StartPingers=1
# Number of pre-forked instances of discoverers
# Default value is 1
# This parameter must be between 0 and 255
StartDiscoverers=1
# Number of pre-forked instances of HTTP pollers
# Default value is 1
# This parameter must be between 0 and 255
#StartHTTPPollers=1

View File

@@ -0,0 +1,16 @@
# Listen port for trapper. Default port number is 10051. This parameter
# must be between 1024 and 32767
{
my $port = ${'zabbix-server'}{'TCPPort'} || '10051';
$OUT .= "ListenPort=$port\n";
}
# Source IP address for outgouing connections
#SourceIP=
# Listen interface for trapper. Trapper will listen all network interfaces
# if this parameter is missing.
#ListenIP=127.0.0.1

View File

@@ -0,0 +1,15 @@
# How often ZABBIX will perform housekeeping procedure
# (in hours)
# Default value is 1 hour
# Housekeeping is removing unnecessary information from
# tables history, alert, and alarms
# This parameter must be between 1 and 24
#HousekeepingFrequency=1
# Uncomment this line to disable housekeeping procedure
#DisableHousekeeping=1
# Frequency of ICMP pings (item keys 'icmpping' and 'icmppingsec'). Defauls is 60 seconds.
#PingerFrequency=60

View File

@@ -0,0 +1,9 @@
# Specifies debug level
# 0 - debug is not created
# 1 - critical information
# 2 - error information
# 3 - warnings (default)
# 4 - for debugging (produces lots of information)
DebugLevel=3

View File

@@ -0,0 +1,13 @@
# Name of PID file
PidFile=/run/zabbix/zabbix_server.pid
# Name of log file
# If not set, syslog is used
LogFile=/var/log/zabbix/zabbix_server.log
# Maximum size of log file in MB. Set to 0 to disable automatic log rotation.
LogFileSize=10

View File

@@ -0,0 +1,17 @@
# Location for custom alert scripts
AlertScriptsPath=/var/lib/zabbix/bin
# Location of external scripts
ExternalScripts=/var/lib/zabbix/bin
# Location of fping. Default is /usr/sbin/fping
# Make sure that fping binary has root permissions and SUID flag set
FpingLocation=/var/lib/zabbix/bin/fping
# Location of fping6. Default is /usr/sbin/fping6
# Make sure that fping binary has root permissions and SUID flag set
Fping6Location=/var/lib/zabbix/bin/fping6
# Temporary directory. Default is /tmp
TmpDir=/var/lib/zabbix/tmp

View File

@@ -0,0 +1,36 @@
# Database host name
# Default is localhost
DBHost=localhost
# Database name
# SQLite3 note: path to database file must be provided. DBUser and DBPassword are ignored.
{
my $dbname = ${'zabbix-server'}{'DbName'} || 'zabbix';
my $dbuser = ${'zabbix-server'}{'DbUser'} || 'zabbix';
my $dbpass = ${'zabbix-server'}{'DbPassword'} || 'secret';
$OUT .=<<"HERE";
DBName=$dbname
# Database user
DBUser=$dbuser
# Database password
# Comment this line if no password used
DBPassword=$dbpass
HERE
}
# Connect to MySQL using Unix socket?
#DBSocket=/var/lib/mysql/mysql.sock
DBSocket=/var/lib/mysql/{$OUT = ( -d "/var/lib/mysql/zabbixdb") ? "mysql" : "mariadb105"}.sock
# Enable database cache module
StartDBSyncers=1

View File

@@ -0,0 +1,12 @@
{
my $tz = ${'TimeZone'} || 'Europe/Paris';
$OUT =<<"HERE";
max_execution_time=600
max_input_time=600
memory_limit=256M
date.timezone=$tz
post_max_size=32M
always_populate_raw_post_data=-1
HERE
}

View File

@@ -0,0 +1,3 @@
# Jabber Account for zabbix alerts
{${'zabbix-server'}{'JabberAccount'}}@{${'zabbix-server'}{'JabberServer'}} {${'zabbix-server'}{'JabberPassword'}}

View File

@@ -0,0 +1,6 @@
echo "$3" | \
sendxmpp -r zabbix -f /var/lib/zabbix/.sendxmpprc \
{(${'zabbix-server'}{'JabberTLS'} || 'enabled') eq 'disabled' ? '':'-t \\';}
-s "$2" "$1"