Linux


We’ve found that Zabbix has been reliable for our use case so far. This is a how to guide for installing a Zabbix agent on CentOS 6.

zabbix agent config

This asummes you already have MySQL and other web services installed on the target OS.

Install Zabbix Agent

Get required rpm for CentOS 6.

rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm

Install the zabbix agent.

yum install zabbix-agent

Edit the config file for the zabbix agent.

nano /etc/zabbix/zabbix_agentd.conf

Fill variables with the correct values.

Server=<ip of zabbix server>
ServerActive=<ip of zabbix server>
ListenPort=10050
Hostname=hostname.of.server

Configure Agent to Work with MySQL

To make the zabbix agent get the correct values from MySQL, copy .my.cnf to /etc/zabbix

cp /root/.my.cnf /etc/zabbix
chown zabbix:zabbix /etc/zabbix/.my.cnf
chmod 600 /etc/zabbix/.my.cnf

Create a read only mysql user for the zabbix agent.

CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'r34d0nly';
GRANT SELECT ON *.* TO 'zabbix'@'localhost';

Then in /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf, set HOME to /etc/zabbix

nano /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
HOME=/etc/zabbix

Change mysql.ping in /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf to:

UserParameter=mysql.ping,mysqladmin -uzabbix -pr34d0nly ping | grep -c alive

Add a mysql.running variable to userparameter_mysql.conf.

UserParameter=mysql.running,sudo /etc/init.d/mysql status | grep -c SUCCESS

Configure Sudoers

Run visudo to edit the sudoers file.

visudo

Add the following inside the sudoers file. This will allow the zabbix agent to run mysql status command.

zabbix ALL = NOPASSWD: /etc/init.d/mysql status

Place this right after: Defaults requiretty in visudo.

Defaults:zabbix !requiretty

Start zabbix agent and configure to start on boot.

service zabbix-agent start
chkconfig zabbix-agent on

Test the zabbix agent config and variables.

zabbix_agentd -t "mysql.running" -c /etc/zabbix/zabbix_agentd.conf
zabbix_agentd -t "mysql.ping" -c /etc/zabbix/zabbix_agentd.conf
zabbix_agentd --print

The mysql.running variable is a custom zabbix data. To effectively use the status of this data, a little customization is required on the zabbix server.

Note, make sure that the zabbix server ip is allowed through the firewall. If using CSF firewall, run the following command.

csf -a <ip of zabbix server> zabbix server

 

{ 0 comments }

Continue Reading

Find is a very handy tool in Linux when looking for specific files and folders with required conditions. The following are some examples of how you can use find to get the job done. Find all folders named pipot in the current folder. find . -type d -name “pipot” Find all files with names starting [...]

{ 0 comments }

Continue Reading Read More

I had the luck to forget the root MySQL password on one of my servers today (a VPS with CentOS 6.2). So I had no choice but to reset the root password. Just in case you get in the same boat with me, here’s what I did. First off, stop the MySQL server. service mysqld [...]

{ 0 comments }

Continue Reading Read More

When you host a good number of virtual sites on your VPS it’s not a good idea to use the default settings of PHP APC because unless you have a large amount of ram to spare, then chances are APC will gobble all of it. And when PHP APC runs out of memory to use, [...]

{ 0 comments }

Continue Reading Read More

Here’s how I installed nginx + php-fpm + apc + mysql on CentOS 6.2 x64. This will likely work on version 6.3 as well. A big thanks to Remi from famillecollet.com for his stable binaries (repositories) on CentOS and Mell Zamora for creating a kick-ass CentOS guide where I based my installation. Please note that in all [...]

{ 1 comment }

Continue Reading Read More