Skip to content

Commit

Permalink
code clean up to help fix relation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson Roberts committed Apr 12, 2013
1 parent 34b9792 commit 63e2125
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 29 deletions.
6 changes: 1 addition & 5 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ 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
description: Name of the Zabbix server as it appears in the Web UI
10 changes: 5 additions & 5 deletions hooks/config-changed
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ 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
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"

if [ -z "${server_name}" ] ; then
server_name=$(hostname)
fi

cp ${charmdir}/src/zabbix.conf.php ${zabbix_conf_php}

sed -i "s|DB_SERVER|${host}|g" ${zabbix_conf_php}
Expand All @@ -39,7 +41,6 @@ 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}
Expand All @@ -50,6 +51,5 @@ 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
6 changes: 0 additions & 6 deletions hooks/db-relation-changed
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -33,8 +32,3 @@ else
fi

${hooksdir}/config-changed

open-port 80/tcp
open-port 10050/tcp
open-port 10051/tcp
open-port 10052/tcp
3 changes: 2 additions & 1 deletion hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ 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
#./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
./configure --enable-server --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
Expand Down
14 changes: 7 additions & 7 deletions hooks/start
Original file line number Diff line number Diff line change
@@ -1,13 +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

open-port 80/tcp
open-port 10051/tcp
open-port 10051/udp
open-port 10052/tcp
open-port 10052/udp

7 changes: 6 additions & 1 deletion hooks/stop
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash -x
juju-log "running stop hook"

close-port 80/tcp
close-port 10051/tcp
close-port 10051/udp
close-port 10052/tcp
close-port 10052/udp

service apache2 stop

#/usr/local/sbin/zabbix_java/shutdown.sh
pkill -9 com.zabbix.gateway.JavaGateway
rm -f /tmp/zabbix_java.pid

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eux # -x for verbose logging to juju debug-log

juju-log "starting hook monitoring-relation-joined"
juju-log "starting hook zabbix-relation-joined"

4 changes: 2 additions & 2 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ maintainer: "Nelson Roberts <[email protected]>"
description: |
Installs Zabbix Server
provides:
monitoring:
interface: zabbix-server
zabbix-server:
interface: server
requires:
db:
interface: mysql
Expand Down
2 changes: 1 addition & 1 deletion revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24
2

0 comments on commit 63e2125

Please sign in to comment.