-
Notifications
You must be signed in to change notification settings - Fork 0
Home
The exercise consists in the following steps:
- install a Zabbix Server+Frontend on a test machine (say vm1)
- configure the Zabbix Server+Frontend
- install a Zabbix agent on another test machine (say vm2)
- configure the Zabbix agent to write on the server installed so far (vm2->vm1)
- configure different types of sensors
- configure triggers, actions
- use Zabbix API to get some (very simple) information
Main reference: https://www.zabbix.com/documentation/2.2
Log into the first machine and install the Zabbix server:
# wget http://repo.zabbix.com/zabbix/2.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.2-1+precise_all.deb
# dpkg -i zabbix-release_2.2-1+precise_all.deb
# apt-get update
Then the following command:
# apt-get install zabbix-server-mysql zabbix-frontend-php
will install the Zabbix server and web frontend with mysql database.
You will be asked for the MySQL root password during the MySQL installation: please take note of the MySQL root password for the future. Right after the MySQL installation, the installation of the zabbix-server-mysql
package will ask for the same password.
After that, install the zabbix-get package as well (it will be useful later):
# apt-get install zabbix-get
Reference here.
Uncomment and edit the timezone in /etc/apache2/conf.d/zabbix
:
php_value date.timezone Europe/Rome
then restart Apache:
# service apache2 restart
The frontend is ready for installation at the following URL:
http://vm1/zabbix
where vm1
is the IP of your server. There you will be redirected to the setup.php page: follow the step by step procedure:
- default username/password is Admin/zabbix
- when asked, provide the setup with the MySQL password
- when asked, add the IP of the server in the corresponding field (here we use localhost, but in general it can be different)
- after finishing the procedure, log in and enjoy the Zabbix frontend.
In particular you may want to change the admin password:
- go to Administration>Users then select Users in the dropdown menu
- click on Admin to edit the admin user
- change the password
- (optional) you can play with other interesting features in the Administration/Users page (create new users, create new groups, add user to group, modify privileges for a given user/group)
In principle we should install a Zabbix Agent 2.2 alligned to the 2.2 server just installed in order to exploit all the new features coming with 2.2; this example will install the agent version coming with Ubuntu 12.04 (zabbix-agent 1.8).
To install the agent, log into a second test machine (say vm2):
# apt-get install zabbix-agent
To configure the agent, edit the Zabbix agent configuration file /etc/zabbix/zabbix_agentd.conf
. You need to configure this file for every host with zabbix_agentd installed.
In particular, you must specify the Zabbix server IP address in the file:
Server=10.10.10.231
Connections from other hosts will be denied. The restart the agent:
/etc/init.d/zabbix-agent restart
To test if the agent is well-configured, you can use the zabbix_get
utility from vm1:
vm1# zabbix_get -s vm2 -k system.cpu.load
where vm1 is the server (where we previously installed the zabbix_get) and vm2 is the agent. If a number is returned, everything is OK; if ZBX_NOTSUPPORTED is returned, you have a problem (and have to revise the procedure above).
We will:
- create a host entry for vm2
- create an item for monitoring its CPU
- verify that a graph is created
- (optional) create a trigger which activates if the CPU is too high
- (optional) create an action which sends you an email
On the Frontend:
-
Configuration>Hosts, then "Create host" and provide the parameters in the first tab "Host"
-
then click on the "Templates" tab, write "Linux" in the "Link new templates" field, select "Template OS Linux", then "Add" and "Save"
-
Configuration>Hosts, then click on "Items" for the vm2, then "Create item": add an item named "CPULOAD", "system.cpu.load" as key
In principle, this procedure is correct; but the Frontend will say "Not supported by Zabbix agent": the agent version is too old! We don't want to upgrade to 2.2.
A solution can be using a custom sensor:
- open /etc/zabbix/zabbix_agentd.conf and add:
UserParameter=mycpuload,awk -F '.' '{print }' /proc/loadavg
then restart the agent;
- use zabbix_get to test the new sensor:
# zabbix_get -s 10.10.10.232 -k mycpuload
Then modify the item in the frontend changing the key to "mycpuload".
Finally, use Monitoring>"Latest data" to get the information and the graphs related to the metric just created. If you want the graph to display some meaningful value, open a shell on vm2 (the agent) and run the following (just copy/paste the whole command):
# apt-get -y install stress ; while [ 1 ] ; do (stress --cpu 2 --timeout 10; sleep 10 ) ; done
This will keep the CPU busy for 10 seconds, then stop for 10 seconds, in a never ending cycle. You should be able to see the corresponding graph on the server side.
Try to create a trigger and an action for the CPULOAD item.