Add room temperature monitoring and alarm on Zabbix

Source: Internet
Author: User
Tags grafana
This is a creation in Article, where the information may have evolved or changed.

Accessories and Preparation

Raspberry
Pi (Install CENTOS7 system and Zabbix agent) 1
Ds18b20 1

Company self-built engine room, and then air conditioning failure, buckle Our back pot man 500 yuan per person, said very depressed. Enough to eat a lot of big stalls!! The pot man on the back is not satisfied! Because of the company's Zabbix monitoring, there is just a Raspberry Pi (the pot-man's own, has been requisitioned), so think of the temperature into the Zabbix inside. From a treasure bought a DS18B20 board, has been welding resistance and other devices,


Ds18b20

0x01 after several days of waiting, a treasure of the ds18b20 to the next, connected to the Raspberry Pi, wiring as shown:


Wiring diagram

0x02 Modify the boot configuration of the Raspberry Pi, add driver support for DS18B20, otherwise the temperature information cannot be read

echo "dtoverlay=w1-gpio" >> /boot/config.txt

After blue, restart the Raspberry Pi and find the driver information that can be read to Ds18b20

cat /sys/bus/w1/devices/w1_bus_master1/28-0316a281adff/w1_slave 7f 01 4b 46 7f ff 0c 10 ba : crc=ba YES7f 01 4b 46 7f ff 0c 10 ba t=23937

Note: 28-0316A281ADFF is the device number, and each person's device number will be different.
Where t=23937 is the temperature, calculate the actual problem, only need to divide by 1000.

0X03 using code to get the temperature

This is a simple step, and it should be super simple for Linux's small partners. One awk can take care of it.

awk -F= '$0~/t=/{print $2/1000}' /sys/bus/w1/devices/w1_bus_master1/28-0316a281adff/w1_slave24.25

PS: Recently the pot-man in the back of the Golang, so idle bored, with Golang wrote a version

package mainimport (        "fmt"        "io/ioutil"        "strconv"        "strings")func main() {        date, err := ioutil.ReadFile("/sys/bus/w1/devices/28-0316a281adff/w1_slave")        if err != nil {                return        }        tmp := fmt.Sprintf("%s", date)        buffer := strings.Split(tmp, "=")        buffer1 := strings.Split(buffer[2], "\n")        temp, err := strconv.Atoi(buffer1[0])        if err != nil {                fmt.Println(err)        }        fmt.Println(float64(temp) / 1000.0)}

0x03 Access Zabbix

Modify the Zabbix_agentd configuration file, add key and corresponding program path (this back pot with Golang written, so directly compiled into binary)

UserParameter=get_temp,/opt/zabbix_agent/script/get_temp

0x04 Zabbix Server Adding monitoring items, triggers, and graphics

The monitoring items are configured as follows: Information to select floating point numbers


Monitoring items

The triggers are configured as follows:


Trigger

The graphical configuration is as follows: Select the above configured temperature monitoring item in the Monitoring item


Graphics

0x04 Zabbix and Grafana.

Zabbix


Zabbix effect

Grafana


Grafana effect
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.