Hi,I keep in mind what Mark explain but as I've Nagios runing on my server for other services I've made a Nagios plugin for 1wire.
This script is made from the Peter Andersson's one, "check_1-wiretemp", available here http://www.it-slav.net/blogs/2008/11/17/op5-monitor-or-nagios-plugins-for-1-wire-temperature-measurement/.
Mine don't do the rrd graph and can monitor more than one type of sensor in the same script.
As Mark said, I'don't use the Owfs error files but only check the return state off the connection on the owerver and when reading dir and files. The script is running since 1 week now, when I've unpluged some sensor I received the alerts fron nagios and I didn't have faulse positive since the begining.
You'll find the script as attachement with this mail. Hope it could be useful for some of you. If you find errors or improuvement on the script you're welcome :). Regards, Pascal.
#!/usr/bin/perl -w # # Check owserver, sensor dir and files # Requires use of OWNet # # Licence GPLv2 # Version 0.1 use strict; use Getopt::Std; use OWNet; # Default values my(%ERRORS) = ( OK=>0, WARNING=>1, CRITICAL=>2, UNKNOWN=>3 ); my $status=$ERRORS{OK}; my $message = "OK"; # Default server connexion settings my $server_address = "127.0.0.1"; my $server_port = "4304"; my $server = "$server_address:$server_port"; my ($owserver, $read, $val); # Define device file to monitor and more if needed my %type = ( 'temperature' => { "unit" => '°C', "file" => 'temperature', }, 'humidity' => { "unit" => '%', "file" => 'humidity', }, 'switch' => { "unit" => '', "file" => 'latch.A', }, ); # Debug my $debug_flag=0; # Command line options our($opt_d, $opt_t, $opt_s, $opt_p, $opt_h); getopts("d:t:s:p:h"); # Help sub printhelp () { print "Usage: check_owserver [-h] -d device_id -t device_type [-s server_ip] [-o server_port]\n"; print "-h Help, this text"; print "-s 1wire server ip address to use, default 127.0.0.1\n"; print "-p 1wire server listening port number to connect, default 4304\n"; print "-d 1wire device ID, i.e. 28.00D8B1020000\n"; print "-t 1wire device type, temperature, humidity...\n"; if ($debug_flag) { print "opt_d:$opt_d opt_t:$opt_t opt_s:$opt_s opt_p:$opt_p opt_h:$opt_h\n"; } exit $status; } chomp ($opt_d, $opt_t); # Check command line if (!defined $opt_d || !defined $opt_t || $opt_h) { $status= $ERRORS{UNKNOWN}; &printhelp; } elsif ( $opt_d !~ /^[0-9A-F]{2}\.[0-9A-F]{12}$/) { $status= $ERRORS{UNKNOWN}; print "Bad device ID\n"; print "$opt_d\n"; &printhelp; } elsif ( $opt_t !~ /^(temperature|humidity|switch)$/) { $status= $ERRORS{UNKNOWN}; print "Bad device type\n"; &printhelp; } # Get address and port from comand line if present if (($opt_s) && (! $opt_p)) { $server = "$opt_s:$server_port"; } elsif ((! $opt_s ) && ( $opt_p )) { $server = "$server_address:$opt_p"; } elsif (( $opt_s) && ($opt_p )) { $server = "$opt_s:$opt_p"; } # Connect to owserver $owserver = OWNet->new($server); unless(length($owserver->dir("/settings"))!=0) { $status = $ERRORS{CRITICAL}; $message = "No owserver running at $server\n"; print "$message\n"; exit $status; } # check the device if (!$owserver->dir("/uncached/$opt_d")) { $status = $ERRORS{CRITICAL}; $message = "Device $opt_d not present\n"; print $message; exit $status; } else { # check device type if ($owserver->dir("/uncached/$opt_d/") !~ /$type{$opt_t}{file},/) { $status = $ERRORS{CRITICAL}; $message = "Device $opt_d NOT a $opt_t SENSOR or on ERROR\n"; print $message; exit $status; } else { # check device file $read = $owserver->read("/uncached/$opt_d/$type{$opt_t}{file}"); chomp ($read); # Remove whitespaces $read =~ s/^\s*(.*?)\s*$/$1/; #check that it is an integer or decimal returned if (($read !~ /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/) || ($read !~ /^[+-]?\d+$/) || ($read !~ /^[0-1]$/) || ($read eq 0) || ($read eq 1)) { $val = sprintf("%.2f", $read); $message="OK"; $status=$ERRORS{OK}; } else { $message="Did not got an integer or a decimal from $opt_t probe\n"; $status=$ERRORS{CRITICAL}; } } } if ($debug_flag) { print "opt_d:$opt_d opt_t:$opt_t opt_s:$opt_s opt_p:$opt_p opt_h:$opt_h\n"; } print "$message ($status) - $opt_t $val $type{$opt_t}{'unit'}\|$opt_t=$val;$opt_d;$opt_t\n"; exit $status;
------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
_______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers