Installing Zabbix Server on Centos6

Zabbix as stated on official website is an “enterprise-level software designed for monitoring availability and performance of IT infrastructure components”.
It’s handy if you need to monitor a handful of servers and supports most major linux distributions, Windows, VMware and Java Applications. It’s also fairly easy to setup and understand with a short learning curve offering many built in “scenarios” and fancy graphs. I personally prefer it over other similar solutions like Nagios.
So let’s go through installing and configuring. There are two options, you can either use the official guide where you’ll have to go through all the steps and manually setup things or use a fancy ansible script and do things automagically! We’ll use the ansible script to make our lives easier.
Ansible is an automation tool that is able to deploy and configure software on multiple hosts simultaneously. Comparing it to other similar tools (chef, puppet, etc.) i find it much easier to read, write and maintain, has a big set of premade scripts that are expanding all the time at ansible galaxy and is agentless. All you need is ssh access to your machines. So let’s go through installing ansible and running our playbook.
You can install ansible on any machine you’d like and we’ll run the playbooks from there. On Fedora you can install it through the official repos with

sudo yum install ansible -y

We’ll use a premade playbook that i’ve found on ansible galaxy that installs zabbix server and agent on a Centos 6 system with MySQL and apache. First fetch the playbook.

sudo ansible-galaxy install akamine.c6-zabbix

Then edit the default configuration here /etc/ansible/roles/akamine.c6-zabbix/defaults/main.yml and follow the below steps.

 mkdir zabbix-ansible
cd zabbix-ansible
vi hosts
vi zabbix.yml
ansible-playbook -i hosts zabbix.yml

On the hosts file you’ll put the hosts you wish the playbook to run.
An example is as follows

[zabbix-server]
my.leet.host

And on zabbix.yml

---
- hosts: all
  roles:
  - akamine.c6-zabbix

When playing the book you should see it output what is doing similar to this:

akis@localhost ansible$ ansible-playbook -i zabbix.host zabbix.yml 

PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [my.leet.host]

TASK: [akamine.c6-zabbix | install libselinux-python] ************************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install MySQL-python] ****************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | change selinux mode to permissive] ***************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | disable iptables] ********************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install ntp] *************************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | Start and enable ntp service] ********************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install epel repo rpm key] ************************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | setup epel repo] *********************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install htop] ************************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install tmux] ************************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install mysql server] ****************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | enable mysql server] ******************************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | set innodb_buffer_size in /etc/my.cnf] ************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | enable event_scheduler in /etc/my.cnf] ************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install zabbix rpm key] **************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | setup zabbix repo] ********************************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install zabbix-server-mysql] *********************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install zabbix-web-mysql] ************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | install zabbix-agent] ****************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | create database zabbix] **************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | ensure mysqld is running] ************************** 
ok: [my.leet.host]

TASK: [akamine.c6-zabbix | initialize zabbix database] ************************ 
changed: [my.leet.host] => (item=schema.sql)
changed: [my.leet.host] => (item=images.sql)
changed: [my.leet.host] => (item=data.sql)

TASK: [akamine.c6-zabbix | copy sql scripts for database partitioning] ******** 
changed: [my.leet.host] => (item=alter_table_indexes.sql)
changed: [my.leet.host] => (item=stored_procedures.sql)
changed: [my.leet.host] => (item=event_schedule.sql)

TASK: [akamine.c6-zabbix | alter table indexes] ******************************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | add stored procedures for partitioning] ************ 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | add partitioning event to schedule] **************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | create mysql user] ********************************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | modify /etc/zabbix/zabbix_server.conf] ************* 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | modify /etc/httpd/conf.d/zabbix.conf] ************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | add e-mail sending script to /usr/lib/zabbix/alertscripts] *** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | enable httpd] ************************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | enable zabbix server] ****************************** 
changed: [my.leet.host]

TASK: [akamine.c6-zabbix | enable and start zabbix agent] ********************* 
changed: [my.leet.host]

NOTIFIED: [akamine.c6-zabbix | restart zabbix server] ************************* 
changed: [my.leet.host]

NOTIFIED: [akamine.c6-zabbix | restart httpd] ********************************* 
changed: [my.leet.host]

NOTIFIED: [akamine.c6-zabbix | restart mysqld] ******************************** 
changed: [my.leet.host]

PLAY RECAP ******************************************************************** 
my.leet.host    : ok=37   changed=35   unreachable=0    failed=0

Next all you need to do is login to your new zabbix server instance on http://my.leet.host/zabbix with username Admin and pass zabbix.
Will go through configuring the server and installing agents in a later post.
Happy playing around with zabbix!

PS: Some quick notes..
The ansible playbook installs mysql-server with default options, meaning no root password.
You can go further editing the playbook adding these to zabbix-database-init.yml

- name: Update mysql root password for all root accounts
  mysql_user: name=root host={{ item }} password=huhu
  with_items: [ '{{ ansible_hostname }}', '127.0.0.1', '::1', 'localhost' ]

- name: Delete anonymous mysql user
  mysql_user: user="" host={{ item }} state=absent
  with_items: [ '{{ ansible_hostname }}', 'localhost' ]

- name: Remove test database
  mysql_db: db=test state=absent

This will setup a password for root account and remove test database.
I’ll probably do a fork of the repo and add some bits and pieces to it and update this post but for the time being this should do.

Advertisements

#alternative, #centos, #linux, #monitor, #monitoring, #nagios, #server, #zabbix

Enabling automatic updates on Centos6.

First install package yum-cron.

sudo yum -y install yum-cron

Then edit /etc/sysconfig/yum-cron if needed. The options are self-explanatory.
Finally to start the service and enable it to auto start on boot issue the following commands.

sudo service yum cron-start
sudo chkconfig yum-cron on

Updates will be run daily.
Done!

#centos, #linux, #updates

[Ubuntu] WARNING: gnome-keyring:: couldn’t connect to: /tmp/keyring-*****/pkcs11

Do

sudo gedit /etc/xdg/autostart/gnome-keyring-pkcs11.desktop

replace

OnlyShowIn=GNOME;Unity

with

OnlyShowIn=GNOME;Unity;LXDE;XFCE

#gnome, #keyring, #linux, #openbox, #ubuntu