通过Nagios监测来自传感器的input数据

我正在开发一个项目,我们安装了多个传感器,并以不同的采样率生成数据。

是否可以使用Nagios插件来检查数据是否来自特定的传感器或设备?

如果有可能,那么哪个插件可以用于这样的目的? 我已经通过Nagios插件网站和互联网search,但找不到任何似乎与此有关的东西。

有不同的传感器生成Ascii格式的数据,所以传感器是数据生成的主要来源,然后我们使用rsync将这些数据同步到我们的中央MySQL数据库。 并且每个传感器具有不同的采样率。 例如温度传感器每2分钟产生一次数据,湿度传感器每5分钟产生一次数据。 这些数据通过使用rsync存储在文本文件中。 我想要根据源采样率来监视数据是每2分钟还是5分钟。 所以自定义的nagios脚本将帮助我了解丢失的数据状态。

有人能指出一个关于自定义插件/脚本来处理这种情况的有用教程吗? (我是Nagios的新手,我会很感激任何帮助。)

你需要创build你自己的插件:

如何:使用BASH脚本创buildNagios插件

如果你编辑你的原始问题,关于如何从传感器收集数据的更多细节,我可能可以帮助你bash如果你需要的话。

编辑:最终答案
享受:=)
任何问题你可以告诉我

 #!/bin/bash # How to execute ./sensor.sh tem_sensor HOUR=$(date +%H) MIN=$(date +%M) # Directory where they are sensor directorys DIR=/home/robbin/Desktop/sensor_collection/ # Name of selected sensor SENSOR=$1 # Name of sensor's directoris SENSORS=(tem_sensor tem_sensor2 tem_sensor3) # Loop in every folder for i in ${SENSORS[@]} do # We only want the specified sensor so we will skip until we found it if [[ $SENSOR != $i ]]; then continue ; fi # You take the hour and minute value from last file LHOUR=$(ls -lrt $DIR/$i| tail -n1 | awk '{ print $8}' | awk -F ':' '{ print $1}') LMIN=$(ls -lrt $DIR/$i | tail -n1 | awk '{ print $8}' | awk -F ':' '{ print $2}') # We calculate the diferences let FHOUR=($HOUR - $LHOUR) let FMIN=($MIN - $LMIN) # I normally put echo to "debug if i need" # echo "------------- SENSOR $i ---------------" # echo "LHOUR : $LHOUR LMIN : $LMIN" # echo "HOUR : $HOUR MIN : $MIN" # echo "FHOUR : $FHOUR FMIN : $FMIN" # echo "---------------------------------------" # if the diference is greater than 2 if [[ $FMIN -gt 02 ]]; then echo "WARNING - More than 2 minutes withouth recieving data" exit 1 # We put warning! # Else if it is not more than 2 # We check if we have an hour of diference! elif [[ $FMIN -gt 04 ]]; then echo "CRITICAL - More than 4 minutes withouth recieving data" exit 2 # We put Red alert! else echo "OK - We recieve data" exit 0 # Green alert if we dont have problems fi done echo "UNKNOW - Sensor not found" exit 3 # If we got unkwnow (Grey alert) # with exit 3 it's because you finished the loop # and you shouldn't, that will be because you misspelled the sensor name