PI with Zabbix for monitoring and graphing


Install Zabbix

sudo apt-get install  mysql-server  php5 apache2 php5-gd php5-mysql  php5-ldap  snmpd  libiksemel3  libodbc1  libopenipmi0  fping   ttf-dejavu-core ttf-japanese-gothic

wget https://github.com/imkebe/zabbix3-rpi/archive/master.zip

unzip master.zip
cd zabbix3-rpi-master
sudo dpkg -i zabbix-server-mysql_3.0.*+jessie_armhf.deb
sudo dpkg -i zabbix-frontend-php_3.0.*+jessie_all.deb
sudo dpkg -i zabbix-agent_3.0.*+jessie_armhf.deb
sudo service apache2 reload

Create mysql zabbix database:

mysql -uroot -p123sqwert -e “create database zabbix character set utf8 collate utf8_bin;”
mysql -uroot -p123sqwert -e “grant all privileges on zabbix.* to zabbix@localhost identified by ‘123sqwert’;”
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p123sqwert zabbix

this will take long, just wait until all data injected.

change zabbix server config to use db password:

sudo vi /etc/zabbix/zabbix_server.conf, and modify DBPassword=.

change timezone for php:

sudo vi /etc/apache2/conf-enabled/zabbix.conf

php_value date.timezone America/Toronto

Using snmp to pull data:

change snmpd for access control to allow all access.

create gettemp.sh to pull data from sensor

#!/bin/bash
#
# Usage: gettemp.sh
# e.g. gettemp.sh 28-0215012018ff
SENSOR=$1
SLAVE=”/sys/devices/w1_bus_master1/$SENSOR/w1_slave”
OUTPUT=$(/bin/cat $SLAVE | /usr/bin/awk -F ‘t=’ ‘{ printf $2 }’)
echo $OUTPUT

“gettemp.sh 28-0215012018ff” will show you temperature output.

add “extend .1.3.6.1.3.1.1 temp1 /bin/bash /opt/scripts/gettemp.sh 28-021500ce50ff” at the end of snmpd.conf then run “snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.3.1.1” will show your what snmp trap can get. and this will later be the input data for Zabbix to draw.

So now go to zabbix server, run through installation page and login with default account: admin/zabbix.

enable PI as a host and add snmp interface.

create an new item called “temp_28-0315909092ff”, use SNMPv2, choose snmp interface, give it a key name “temp.28-0315909092ff”(sth that unique), SNMP OID”.1.3.6.1.3.1.1.4.1.2.5.116.101.109.112.49.1″(one that you’d get from snmpwalk script, any of those with correct input will work), community “public”, type of info “float”, unit “‘C”(easier identifier for C degree), custom multiplier”0.001″(because output of temp is like 21437, so this make it easier to read), then save.

then go to graph to create a new look, add this new item and you can see the graph in monitoring tab now!

Monitoring by zabbix Agent

Another way to monitor this is simply by adding UserParameter option under zabbix-agentd.conf.

UserParameter=temp.room.0,/home/pi/gettemp.sh 28-0315909092ff

So in this way, a new KEY temp.room.0 will be added into zabbix database with a value of the output of “gettemp.sh 28-0315909092ff”.

you can also test with this key by “zabbix_agentd -t temp.room.0”

reboot zabbix-agent and load this new key under host items, along with other options to create a new graph.

Advertisements
By Ctrl | Alt | Del Posted in IoT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s