A few months ago I wrote about temperatures way above the mean temperature in Zurich, Switzerland. These temperatures were all measured with temperature sensors and the Nagios plugin check_pcmeasure2.pl by www.messpc.de.
Now its winter in Switzerland and temperatures dropped significantly:
On November 28th, the temperature dropped below 0° Celcius and the plugin turned CRITICAL, although the thresholds were set to 37 and 40 degrees:
./check_pcmeasure2.pl -H outsidesensor -p 4000 -S com1.2 -w 37 -c 40 -l temperature -F "%.1fC"
T CRITICAL - -0.1C | temperature=-0.1;37;40
Of course it doesn't make sense that the plugin now is in a CRITICAL status only because the temperature value became negative.
To fix this, I have modified check_pcmeasure2.pl to not pass the current temperature ($value) to the Nagios::Plugin (perl plugin):
# -----------------------------------------------
# finish: return to caller
# -----------------------------------------------
#my $result = $np->check_threshold($value);
# 2013-11-28 Claudio Kuenzler: fix threshold check when negative values occur
my $result = "";
if ( $value > $crit_threshold ) {
$result = "CRITICAL";
}
elsif ( $value > $warn_threshold ) {
$result = "WARNING";
}
else {
$result = "OK";
}
# -- for future use alarm(0);
my $text_output = sprintf "$format_string", $value;
$np->nagios_exit($result, $text_output);
Another possible fix, which I haven't tested though, is to define the thresholds according to the Nagios Plugin Development Guidelines:
# -- thresholds
$np->set_thresholds(
warning => ~:$warn_threshold,
critical => ~:$crit_threshold,
);
Note the "~:" in front of the threshold variables? This declares a negative infinity. But as written above, I haven't tested this fix.
After my fix, the negative values are now handled correctly:
./check_pcmeasure2.pl -H 212.71.111.200 -p 4000 -S com1.2 -w 37 -c 40 -l temperature -F "%.1fC"
T OK - -0.1C | temperature=-0.1;37;40
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder