Commit 89603a9f authored by Alain Takoudjou's avatar Alain Takoudjou

Zabbix server software release

parent 1c68e161
# Apache static configuration
# Automatically generated
# Basic server configuration
PidFile "${:pid_file}"
Listen ${:ipv6}:${:port}
PHPINIDir ${:php_ini_dir}
ServerAdmin someone@email
DefaultType text/plain
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml .php5 .php4
AddType application/x-httpd-php-source .phps
# Log configuration
ErrorLog "${:error_log}"
LogLevel warn
LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b" common
CustomLog "${:access_log}" common
# Directory protection
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory ${:document_root}>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DocumentRoot ${:document_root}
DirectoryIndex index.html index.php
#Update PHP.INI
php_value include_path ".:${:php_lib_path}"
php_value upload_max_filesize 16M
php_value post_max_size 16M
php_value max_execution_time 300
php_value max_input_time 300
php_value output_buffering none
# List of modules
LoadModule unixd_module modules/mod_unixd.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule headers_module modules/mod_headers.so
LoadModule dir_module modules/mod_dir.so
LoadModule php5_module modules/libphp5.so
LoadModule alias_module modules/mod_alias.so
\ No newline at end of file
#!/bin/sh
if [ -f "${:installed_file}" ]
then
echo "Database is configured. Exiting...";
exit 0;
fi
sleep 60
echo "Installing file schema.sql..."
cat ${:mysql_schema} | ${:mysql_bin} -h${:mysql_host} -P${:mysql_port} -u${:mysql_user} -p${:mysql_pwd} ${:mysql_db}
echo "Installing file images.sql..."
cat ${:mysql_images} | ${:mysql_bin} -h${:mysql_host} -P${:mysql_port} -u${:mysql_user} -p${:mysql_pwd} ${:mysql_db}
echo "Installing file data.sql..."
cat ${:mysql_data} | ${:mysql_bin} -h${:mysql_host} -P${:mysql_port} -u${:mysql_user} -p${:mysql_pwd} ${:mysql_db}
echo "installed" > ${:installed_file}
exit 0
\ No newline at end of file
[buildout]
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[httpd-conf]
recipe = slapos.recipe.template
url = ${template-httpd-conf:location}/${template-httpd-conf:filename}
output = $${rootdirectory:etc}/apache.conf
mode = 0600
document_root = $${directory:www}
pid_file = $${basedirectory:run}/apache.pid
lock_file = $${basedirectory:run}/apache.lock
ipv6 = $${apache-network-configuration:listening-ip}
port = $${apache-network-configuration:listening-port}
error_log = $${directory:httpd-log}/error.log
access_log = $${directory:httpd-log}/access.log
php_ini_dir = $${directory:php-ini-dir}
php_lib_path = ${apache-php:location}/lib/php
[zabbix-conf]
recipe = slapos.recipe.template
url = ${template-zabbix-conf:location}/${template-zabbix-conf:filename}
output = $${rootdirectory:etc}/zabbix_server.conf
mode = 0600
log_file = $${basedirectory:log}/zabbix_server.log
pid_file = $${basedirectory:run}/zabbix_server.pid
ip = $${slap-network-information:global-ipv6}
port = 10051
mysql_user = $${apache-php:mysql-username}
mysql_password = $${apache-php:mysql-password}
mysql_db = $${apache-php:mysql-database}
mysql_host = $${apache-php:mysql-host}
mysql_port = $${apache-php:mysql-port}
[install-zabbix-db]
recipe = slapos.recipe.template
url = ${template-zabbix-database:location}/${template-zabbix-database:filename}
output = $${basedirectory:scripts}/prepare-database
mode = 0700
installed_file = $${buildout:directory}/.zabbix.db.installed
mysql_bin = ${mariadb:location}/bin/mysql
mysql_host = $${apache-php:mysql-host}
mysql_db = $${apache-php:mysql-database}
mysql_port = $${apache-php:mysql-port}
mysql_user = $${apache-php:mysql-username}
mysql_pwd = $${apache-php:mysql-password}
mysql_schema = ${zabbix-server:compile-directory}/zabbix-${zabbix-server:version}/database/mysql/schema.sql
mysql_data = ${zabbix-server:compile-directory}/zabbix-${zabbix-server:version}/database/mysql/data.sql
mysql_images = ${zabbix-server:compile-directory}/zabbix-${zabbix-server:version}/database/mysql/images.sql
#force to install other parts
httpd-conf = $${httpd-conf:output}
logrotate = $${logrotate-entry-zabbix:name}
wrapper = $${zabbix:wrapper-path}
[zabbix-wrapper]
recipe = slapos.cookbook:wrapper
zabbix-server = ${zabbix-server:location}/sbin/zabbix_server
zabbix-conf = $${zabbix-conf:output}
command-line = $${:zabbix-server} -c $${:zabbix-conf}
wrapper-path = $${rootdirectory:bin}/zabbix_server_raw
[zabbix]
recipe = slapos.cookbook:wrapper
script-file = ${zabbix-svcdeamon:location}/${zabbix-svcdeamon:filename}
command-line = ${buildout:executable} $${:script-file} $${zabbix-wrapper:wrapper-path} $${zabbix-conf:pid_file} 10
wrapper-path = $${basedirectory:services}/zabbix_server
[logrotate-entry-zabbix]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = zabbix_server
log = $${zabbix-conf:log_file}
frequency = daily
rotate-num = 30
sharedscripts = true
notifempty = true
create = true
import os
import subprocess
import time
import signal
import sys
def get_pid(filename):
pid = None
if os.path.exists(filename):
data = open(pid_file).read()
try:
pid = int(data)
except ValueError:
pass
return pid
pid_file = None
def sig_handler(s, frame):
print "Killing on signal %s:" % s,
global pid_file
if pid_file is not None:
pid = get_pid(pid_file)
if pid is not None:
os.kill(pid, signal.SIGTERM)
try:
os.kill(pid, 0)
except Exception:
pass
else:
time.sleep(5)
try:
os.kill(pid, 0)
except Exception:
pass
else:
print 'with SIGKILL...',
os.kill(pid, signal.SIGKILL)
else:
raise ValueError('Pid is none.')
print 'done.'
sys.exit(0)
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGQUIT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
def svcdaemon(args):
"""Utility script to run daemons in supervisord"""
real_binary = args[0]
global pid_file
pid_file = args[1]
subprocess.check_call(real_binary)
print 'Started %r' % real_binary
while True:
time.sleep(5)
pid = get_pid(pid_file)
if pid is None:
raise ValueError('Pid is none')
os.kill(pid, 0)
if __name__ == '__main__':
args = []
args.append(sys.argv[1])
args.append(sys.argv[2])
if len(sys.argv) > 3:
time.sleep(int(sys.argv[3]))
svcdaemon(args)
exit(0)
[buildout]
extends =
../../component/zabbix/buildout.cfg
../../stack/slapos.cfg
../../stack/lamp/buildout.cfg
parts +=
slapos-cookbook
zabbix-server
apache-php
instance-apache-php
[zabbix-instances]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-zabbix.cfg.in
output = ${buildout:directory}/custom-apache-php.cfg
#md5sum = 3e2d71d3684aac3e52d2f55794df96bf
mode = 0644
[custom-application-deployment]
path = ${zabbix-instances:output}
part-list = install-zabbix-db
[application]
recipe = plone.recipe.command
command = echo "I've already downloaded package"
update-command =
location = ${zabbix-server:compile-directory}/zabbix-${zabbix-server:version}/frontends/php
[download-base]
recipe = slapos.recipe.download
location = ${buildout:parts-directory}/${:_buildout_section_name_}
mode = 0644
url = ${:_profile_base_location_}/${:filename}
[application-template]
<= download-base
#md5sum = Student may put here md5sum of this file, this is good idea
filename = zabbix.conf.php.in
[template-zabbix-conf]
<= download-base
#md5sum = Student may put here md5sum of this file, this is good idea
filename = zabbix_server.conf.in
[template-httpd-conf]
<= download-base
#md5sum = Student may put here md5sum of this file, this is good idea
filename = apache.conf.in
[template-zabbix-database]
<= download-base
#md5sum = Student may put here md5sum of this file, this is good idea
filename = database.sh.in
[zabbix-svcdeamon]
<= download-base
#md5sum = Student may put here md5sum of this file, this is good idea
url = ${:_profile_base_location_}/scripts/${:filename}
filename = svcdaemon.py
[application-configuration]
location = conf/zabbix.conf.php
<?php
// Zabbix GUI configuration file
global $DB;
$DB["TYPE"] = 'MYSQL';
$DB["SERVER"] = '%(mysql_host)s';
$DB["PORT"] = '0';
$DB["DATABASE"] = '%(mysql_database)s';
$DB["USER"] = '%(mysql_user)s';
$DB["PASSWORD"] = '%(mysql_password)s';
// SCHEMA is relevant only for IBM_DB2 database
$DB["SCHEMA"] = '';
$ZBX_SERVER = '%(ip)s';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment