-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nelson Roberts
committed
Mar 8, 2013
0 parents
commit 8f01839
Showing
11 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
options: | ||
server-name: | ||
type: string | ||
default: zabbix-server | ||
description: Name of the Zabbix server | ||
node-id: | ||
type: int | ||
default: 0 | ||
description: Node id. Must be unique for all of the servers in the distrubited network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
set -eux # -x for verbose logging to juju debug-log | ||
|
||
juju-log "starting config-changed hook" | ||
|
||
hooksdir="$PWD/hooks" | ||
|
||
user=`relation-get user` | ||
password=`relation-get password` | ||
host=`relation-get private-address` | ||
database=`relation-get database` | ||
server_name=`config-get server-name` | ||
node_id=`config-get node-id` | ||
|
||
if [ -z "$database" ] ; then | ||
exit 0 | ||
fi | ||
|
||
|
||
juju-log "setup zabbix config" | ||
|
||
zabbix_conf_php="/var/www/zabbix/conf/zabbix.conf.php" | ||
zabbix_server_conf="/usr/local/etc/zabbix_server.conf" | ||
|
||
cp src/zabbix.conf.php ${zabbix_conf_php} | ||
|
||
sed -i "s|DB_SERVER|${host}|g" ${zabbix_conf_php} | ||
sed -i "s|DB_NAME|${database}|g" ${zabbix_conf_php} | ||
sed -i "s|DB_USER|${user}|g" ${zabbix_conf_php} | ||
sed -i "s|DB_PASSWORD|${password}|g" ${zabbix_conf_php} | ||
sed -i "s|ZABBIX_SERVER_NAME|${server_name}|g" ${zabbix_conf_php} | ||
|
||
mkdir -p /var/log/zabbix | ||
mkdir -p /var/run/zabbix | ||
|
||
chown zabbix.zabbix /var/log/zabbix | ||
chown zabbix.zabbix /var/run/zabbix | ||
|
||
cp ${zabbix_server_conf} ${zabbix_server_conf}.orig | ||
|
||
sed -i "s|.*NodeID=.*|NodeID=${node_id}|g" ${zabbix_server_conf} | ||
sed -i "s|.*LogFile=.*log|LogFile=/var/log/zabbix/zabbix_server.log|g" ${zabbix_server_conf} | ||
sed -i "s|*.PidFile=.*pid|PidFile=/var/run/zabbix/zabbix_server.pid|g" ${zabbix_server_conf} | ||
sed -i "s|.*DBHost=.*|DBHost=${host}|g" ${zabbix_server_conf} | ||
sed -i "s|.*DBName=zabbix.*|DBName=${database}|g" ${zabbix_server_conf} | ||
sed -i "s|.*DBUser=root.*|DBUser=${user}|g" ${zabbix_server_conf} | ||
sed -i "s|.*DBPassword=.*|DBPassword=${password}|g" ${zabbix_server_conf} | ||
sed -i "s|.*StartTrappers=.*|StartTrappers=5|g" ${zabbix_server_conf} | ||
sed -i "s|.*JavaGateway=.*|JavaGateway=1|g" ${zabbix_server_conf} | ||
sed -i "s|.*StartJavaPollers=.*|StartJavaPollers=5|g" ${zabbix_server_conf} | ||
|
||
|
||
juju-log "restart services" | ||
${hooksdir}/restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
set -eux # -x for verbose logging to juju debug-log | ||
|
||
hooksdir="$PWD/hooks" | ||
|
||
user=`relation-get user` | ||
password=`relation-get password` | ||
host=`relation-get private-address` | ||
database=`relation-get database` | ||
server_name=`config-get server-name` | ||
|
||
if [ -z "$database" ] ; then | ||
exit 0 | ||
fi | ||
|
||
mysql_exec="mysql -h${host} -u${user} -p${password} ${database}" | ||
|
||
if ${mysql_exec} -e "SELECT 1 FROM maintenances LIMIT 0" ; then | ||
juju-log -l INFO "zabbix database already setup. skipping schema setup" | ||
else | ||
juju-log "setup zabbix database" | ||
cd /tmp/zabbix-src/zabbix-2.0.5 | ||
|
||
juju-log "applying database schema" | ||
${mysql_exec} < database/mysql/schema.sql | ||
|
||
juju-log "applying images schema" | ||
${mysql_exec} < database/mysql/images.sql | ||
|
||
juju-log "applying data schema" | ||
${mysql_exec} < database/mysql/data.sql | ||
fi | ||
|
||
${hooksdir}/config-changed | ||
|
||
open-port 80/tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
set -eu # -x for verbose logging to juju debug-log | ||
juju-log "Starting install of Zabbix Server" | ||
|
||
hooksdir=${PWD}/hooks | ||
srcdir=${PWD}/src | ||
|
||
add-apt-repository ppa:charmers/charm-helpers > /dev/null | ||
apt-get -qq update && apt-get -qq -y upgrade > /dev/null | ||
|
||
apt-get -qq -y install php5-memcache mysql-client pwgen php5 php5-fpm php-apc mailutils php-mail sysstat php5-mysql php5-mcrypt php5-memcache charm-helper-sh php5-curl rsync nfs-common git-core mktemp libmysqlclient-dev libcurl4-openssl-dev libsnmp-base libsnmp-dev php5 libiksemel3 libiksemel-dev libssh2-1 libssh2-1-dev libopenipmi-dev default-jdk libsqlite3-dev php5-sqlite php5-mysql php5-gd make apache2 apache2-suexec libapache2-mod-php5 > /dev/null | ||
|
||
juju-log "setup zabbix user and group" | ||
if [ "$(grep -c zabbix /etc/group)" -lt "1" ] ; then | ||
groupadd -f zabbix | ||
fi | ||
|
||
if [ "$(grep -c zabbix /etc/passwd)" -lt "1" ] ; then | ||
useradd -m -g zabbix zabbix | ||
fi | ||
|
||
juju-log "extract zabbix source" | ||
mkdir -p /tmp/zabbix-src | ||
cd /tmp/zabbix-src | ||
|
||
tar zxf ${srcdir}/zabbix-2.0.5.tar.gz | ||
cd zabbix-2.0.5 | ||
|
||
juju-log "configure zabbix source" | ||
./configure --enable-server --enable-proxy --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --enable-java --with-ssh2 --with-openipmi --with-ldap --with-jabber > /dev/null | ||
|
||
juju-log "make zabbix source" | ||
make install > /dev/null | ||
|
||
juju-log "install and configure zabbix frontend" | ||
mkdir -p /var/www/zabbix | ||
cd frontends/php | ||
cp -a . /var/www/zabbix | ||
cp ${srcdir}/zabbix.conf.php /var/www/zabbix/conf | ||
chown -R www-data.www-data /var/www/zabbix | ||
|
||
sed -i 's/post_max_size = .*/post_max_size = 16m/g' /etc/php5/apache2/php.ini | ||
sed -i 's/max_execution_time = .*/max_execution_time = 300/g' /etc/php5/apache2/php.ini | ||
sed -i 's/max_input_time = .*/max_input_time = 300/g' /etc/php5/apache2/php.ini | ||
sed -i 's/;date.timezone.*/date.timezone = America\/New_York/g' /etc/php5/apache2/php.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash -eux | ||
|
||
juju-log "running restart hook" | ||
|
||
hooksdir="$PWD/hooks" | ||
|
||
${hooksdir}/stop | ||
${hooksdir}/start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -eux | ||
juju-log "running start hook" | ||
|
||
database=`relation-get database` | ||
|
||
if [ -z "$database" ] ; then | ||
juju-log "database relation not setup skipping service start" | ||
exit 0 | ||
fi | ||
|
||
service apache2 start | ||
su zabbix -c /usr/local/sbin/zabbix_server | ||
su zabbix -c /usr/local/sbin/zabbix_java/startup.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -x | ||
juju-log "running stop hook" | ||
|
||
service apache2 stop | ||
|
||
/usr/local/sbin/zabbix_java/shutdown | ||
pkill -9 zabbix_server | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: zabbix-server | ||
summary: "Zabbix Server" | ||
maintainer: "Nelson Roberts <[email protected]>" | ||
description: | | ||
Installs Zabbix Server | ||
requires: | ||
db: | ||
interface: mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
14 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
// Zabbix GUI configuration file | ||
global $DB; | ||
|
||
$DB['TYPE'] = 'MYSQL'; | ||
$DB['SERVER'] = 'DB_SERVER'; | ||
$DB['PORT'] = '0'; | ||
$DB['DATABASE'] = 'DB_NAME'; | ||
$DB['USER'] = 'DB_USER'; | ||
$DB['PASSWORD'] = 'DB_PASSWORD'; | ||
|
||
// SCHEMA is relevant only for IBM_DB2 database | ||
$DB['SCHEMA'] = ''; | ||
|
||
$ZBX_SERVER = 'localhost'; | ||
$ZBX_SERVER_PORT = '10051'; | ||
$ZBX_SERVER_NAME = 'ZABBIX_SERVER_NAME'; | ||
|
||
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; | ||
?> |