Zabbix Automated Script for Ubuntu


set -x

Add Zabbix 2.0 Repository
echo deb precise main >> /etc/apt/sources.list
echo deb-src precise main >> /etc/apt/sources.list

Install the public key of the repository and update your package index
apt-key adv –keyserver –recv-keys C407E17D5F76A32B

Install System Updates, Zabbix & Components
apt-get update
sleep 5
apt-get install -y zabbix-server-pgsql  zabbix-frontend-php php5-pgsql libapache2-mod-php5 zabbix-agent

sleep 5

Set Access To DataBase
sed -i ‘s/peer/trust/gi’ /etc/postgresql/9.1/main/pg_hba.conf
sed -i ‘s/md5/trust/gi’ /etc/postgresql/9.1/main/pg_hba.conf

service postgresql restart

sleep 5

Create new User & Create new DB ‘zabbix’
su – postgres -c “echo \”create user zabbix with password ‘zabbix’;\” | psql”
su – postgres -c “echo \”create database zabbix owner zabbix;\” | psql”

sleep 5

Add data to Zabbix db
pushd /usr/share/zabbix-server-pgsql/

gunzip *.gz
psql -U zabbix zabbix < schema.sql
psql -U zabbix zabbix < images.sql
psql -U zabbix zabbix < data.sql

sleep 5

Zabbix Server is Set Startup
sed -i ‘s/START=no/START=yes/gi’ /etc/default/zabbix-server

Start Zabbix Service
/etc/init.d/zabbix-server restart

Configure the Zabbix Webinterface
sed -i ‘s/post_max_size = 8M/post_max_size = 16M/gi’ /etc/php5/apache2/php.ini
sed -i ‘s/max_execution_time = 30/max_execution_time = 300/gi’ /etc/php5/apache2/php.ini
sed -i ‘s/max_input_time = 60/max_input_time = 300/gi’ /etc/php5/apache2/php.ini
sed -i ‘s/;date.timezone =/date.timezone = America\/New_York/gi’ /etc/php5/apache2/php.ini

Apache alias module is Enabled & Restart Apache
cp -f /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/conf.d/zabbix.conf
a2enmod alias
/etc/init.d/apache2 restart

Copy the sample php configuration file to the Zabbix folder
cp -f /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php

Pushd /etc/apache2/conf.d/
sed -i -e ‘1 s/^/Listen 8080\n/;’ zabbix.conf

Re-starting Web Service
service apache2 restart

Update your database details in /etc/zabbix/zabbix.conf.php
echo “<?php
// Zabbix GUI configuration file
global \$DB;
\$DB[‘”TYPE”‘]                     = ‘POSTGRESQL’;
\$DB[‘”SERVER”‘]                   = ‘localhost’;
\$DB[‘”PORT”‘]                     = ‘0’;
\$DB[‘”DATABASE”‘]                 = ‘zabbix’;
\$DB[‘”USER”‘]                     = ‘zabbix’;
\$DB[‘”PASSWORD”‘]                 = ‘zabbix’;
// SCHEMA is relevant only for IBM_DB2 database
\$DB[‘”SCHEMA”‘]                   = ”;
\$ZBX_SERVER                       = ‘localhost’;
\$ZBX_SERVER_PORT                = ‘10051’;
\$ZBX_SERVER_NAME                = ”;
?>” > /etc/zabbix/zabbix.conf.php

Re-starting Zabbix Sevice
service zabbix-server restart


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s