One Unified Global Perspective
Communications with a Global Perspective
Home
Intro
Contact Us
Voice over IP
PBX Solutions
Services
Support
Glossary
Open Source
Blog
Forum

WebMail





2007 May 04 - Fri

Configuring eSensors with Nagios

The EM01B WebSensor from Esensor (http://www.eesensors.com/websensor.html) provides Temperature, Humidity, and Illumination values to Nagios.

Download the source code for the Nagios plugin from http://www.nagiosexchange.org/Environmental.60.0.html?&tx_netnagext_pi1[p_view]=13 and place it into the /usr/src directory. Unzip it to a directory called esensors. Change into /usr/src/esensors/c and run:

gcc check_em01.c -o check_em01
cp check_em01 /usr/local/nagios/libexec/

Ignore the warnings.

Add the following llnes to /usr/local/nagios/etc/checkcommands.cfg:

# 'check_temp' command definition
define command{
            command_name check_temp
            command_line $USER1$/check_em01 $HOSTADDRESS$ T $ARG1$ $ARG2$ $ARG3$ $ARG4$
            }
# 'check_humidity' command definition
define command{
            command_name check_humidity
            command_line $USER1$/check_em01 $HOSTADDRESS$ H $ARG1$ $ARG2$ $ARG3$ $ARG4$
            }
# 'check_light command definition
define command{
            command_name check_light
            command_line $USER1$/check_em01 $HOSTADDRESS$ I $ARG1$ $ARG2$ $ARG3$ $ARG4$
            }

Create a file named /usr/local/nagios/etc/srvc_esensor.cfg with the following content:

###############################################################################
#
# Configuration file for eSensor Devices
#
# Last Modified: 2006-06-08
#
################################################################################

################################################################################
# SERVICE DEFINITIONS
################################################################################
# Generic service definition template
define service{
        name                            generic-esensor ;  Referenced in other service definitions
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    0       ; Retain non-status information across program restarts
        register                        0       ; DONT REGISTER THIS DEFINITION
        is_volatile 0
        check_period 24x7
        max_check_attempts 3
        normal_check_interval 5
        retry_check_interval 1
        contact_groups sensor-admins
        notification_interval 30
        notification_period 24x7
        notification_options d,u,r
        }
# check temp service definition template
define service{
        use                             generic-esensor
        name                            etemp-service   ; Referenced in other service definitions
        register                        0       ; DONT REGISTER THIS DEFINITION
        service_description Temperature
        check_command check_temp!2!110!1!120
        }
# check humidity service definition template
define service{
        use                             generic-esensor
        name                            ehum-service    ; Referenced in other service definitions
        register                        0       ; DONT REGISTER THIS DEFINITION
        service_description Humidity
        check_command check_humidity!2!90!1!99
        }
# check light service definition template
define service{
        use                             generic-esensor
        name                            eillum-service  ; Referenced in other service definitions
        register                        0       ; DONT REGISTER THIS DEFINITION
        service_description Illumination
        check_command check_light!2!600!1!700
        }

Add the following line to /usr/local/nagios/etc/nagios.cfg:

cfg_file=/usr/local/nagios/etc/srvc_esensor.cfg

Create a file called /usr/local/nagios/etc/examplecom/em01.cfg with the following content:

define host{
        use                             generic-host
        host_name                       em01
        alias                           Heat, Humidity and Illumination tests
        address                         10.1.6.30
        }

define hostgroup{
        hostgroup_name  	Esensors
        alias          		Esensors HVAC sensor
        members         	em01
        }

define servicegroup{
        servicegroup_name       esensors
        alias                   Enviromental Monitoring
        members                 em01,Temperature
        members                 em01,Humidity
        members                 em01,Illumination
        }

define service {
        use                     etemperature-service
        host                    em01
        check_command           check_temp!60!80!50!85
        }

define service {
        use                     ehumidity-service
        host                    em01
        }

define service {
        use                     eillumination-service
        host                    em01
        }

As a side note, I think I'm going to process esensor output with something else. Here is a brief regular expression in a perl file called 'em.pl' to handle the output:

use strict;

my $a = <STDIN>;
$a =~ m/TF:[ ]*(\d+\.\d+).*HU:[ ]*(\d+\.\d+).+IL[ ]*(\d+\.\d+)/;
print "$1, $2, $3\n";

The following command line generates three values (using the tool 'curl' to obtain the current values):

echo `curl -s http://bmem01/index.html?em123456` | perl em.pl

[/OpenSource/Debian/Monitoring] permanent link



Blog Content ©2008
Ray Burkholder
All Rights Reserved
ray@oneunified.net
(441) 505 7293
Available for Contract Work
Resume

RSS: Click to see the XML version of this web page.

View Ray 
Burkholder's profile on LinkedIn
technorati
Add to Technorati Favorites



May
Su Mo Tu We Th Fr Sa
    4
   


Main Links:
Monitoring Server
SSH Tools
QuantDeveloper Code

Special Links:
Frink

Blog Links:
Sergey Solyanik
Marc Andreessen
HotGigs
Micro Persuasion
... Reasonable ...
Chris Donnan
BeyondVC
lifehacker
Trader Mike
Ticker Sense
HeadRush
TraderFeed
Stock Bandit
The Daily WTF
Guy Kawaski
J. Brant Arseneau
Steve Pavlina
Matt Cutts
Kevin Scaldeferri
Joel On Software
Quant Recruiter
Blosxom User Group
Wesner Moise
Julian Dunn
Steve Yegge

2007
Months
May




Mason HQ

Disclaimer: This site may include market analysis. All ideas, opinions, and/or forecasts, expressed or implied herein, are for informational purposes only and should not be construed as a recommendation to invest, trade, and/or speculate in the markets. Any investments, trades, and/or speculations made in light of the ideas, opinions, and/or forecasts, expressed or implied herein, are committed at your own risk, financial or otherwise.