Added temperature monitoring

This commit is contained in:
Lukas Macura 2022-04-22 12:14:34 +02:00
parent dcd5121571
commit 60bbd28bfb
2 changed files with 70 additions and 2 deletions

View File

@ -564,7 +564,6 @@ function pfz_ipsec_discovery_ph1(){
}
function pfz_ipsec_ph1($ikeid,$valuekey){
// Get Value from IPsec Phase 1 Configuration
// If Getting "disabled" value only check item presence in config array
@ -740,6 +739,42 @@ function pfz_ipsec_status($ikeid,$reqid=-1,$valuekey='state'){
return $value;
}
// Temperature sensors Discovery
function pfz_temperature_sensors_discovery(){
$json_string = '{"data":[';
$sensors = [];
exec("sysctl -a | grep temperature | cut -d ':' -f 1", $sensors, $code);
if ($code != 0) {
echo "";
return;
} else {
foreach ($sensors as $sensor) {
$json_string .= '{"{#SENSORID}":"' . $sensor . '"';
$json_string .= '},';
}
}
$json_string = rtrim($json_string,",");
$json_string .= "]}";
echo $json_string;
}
// Temperature sensor get value
function pfz_get_temperature($sensorid){
exec("sysctl '$sensorid' | cut -d ':' -f 2", $value, $code);
if ($code != 0 or count($value)!=1) {
echo "";
return;
} else {
echo trim($value[0]);
}
}
function pfz_carp_status($echo = true){
@ -1232,6 +1267,9 @@ function pfz_discovery($section){
case "dhcpfailover":
pfz_dhcpfailover_discovery();
break;
case "temperature_sensors":
pfz_temperature_sensors_discovery();
break;
}
}
@ -1299,6 +1337,9 @@ switch (strtolower($argv[1])){
case "cert_date":
pfz_get_cert_date($argv[2]);
break;
case "temperature":
pfz_get_temperature($argv[2]);
break;
default:
pfz_test();
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>6.0</version>
<date>2022-04-21T09:38:15Z</date>
<date>2022-04-22T10:13:54Z</date>
<groups>
<group>
<uuid>4918b88734c54bd094cff7585b5d71fc</uuid>
@ -1587,6 +1587,33 @@ Alternatively you can also set the macro to 1 or 0.
</trigger_prototype>
</trigger_prototypes>
</discovery_rule>
<discovery_rule>
<uuid>a941879bad06412eba60e9a979664453</uuid>
<name>Temperature sensors Discovery</name>
<type>ZABBIX_ACTIVE</type>
<key>pfsense.discovery[temperature_sensors]</key>
<delay>1d</delay>
<item_prototypes>
<item_prototype>
<uuid>3465a9c666e24da6a66f860d7653b4d2</uuid>
<name>Temperature of sensor {#SENSORID}</name>
<type>ZABBIX_ACTIVE</type>
<key>pfsense.value[temperature,{#SENSORID}]</key>
<delay>10m</delay>
<value_type>FLOAT</value_type>
<units>C</units>
<trigger_prototypes>
<trigger_prototype>
<uuid>e1fe601011654b298092ecca32f70137</uuid>
<expression>last(/Template pfSense Active/pfsense.value[temperature,{#SENSORID}])&gt;70</expression>
<name>Temperature of device is over 70C</name>
<priority>AVERAGE</priority>
<description>There is some problem with cooling.</description>
</trigger_prototype>
</trigger_prototypes>
</item_prototype>
</item_prototypes>
</discovery_rule>
<discovery_rule>
<uuid>06f42546705d4a7b89178d8f024f4a03</uuid>
<name>Mounted filesystem discovery</name>