tags:

views:

586

answers:

1

What is the simplest code in perl to monitor trap from any devices such as UPS, Rectifier, AirCond etc. In example we want to monitor temperature, server room humidity, aircond level etc. Each devices such as UPS, there are SNMP card inside and then we put out trap server IP address. Currently I am using snmptt open software application.

+9  A: 

Getting rid of mice in the machine room can be very difficult. They can cause serious difficulties if you are unfortunate enough to use a cable they find attractive to gnaw on.

Personally I wouldn't place traps directly on my routers or other gear--but trap placement is something of an art, and mice won't respect our ideas of propriety. Mouse traps can be messy when triggered, so you might want to put some newspaper down under the traps to contain any mess. Of course, you will need to ensure good air-flow in your equipment to avoid overheating.

  1. Build a small PCB with a pressure sensitive switch, a microcontroller, a battery and ethernet module.
  2. Write software to monitor the state of the switch and provide a web based interface to the micro by using one of the many embedded TCP/IP and HTTP stacks available for small projects.
  3. Mount the PCB on the trap so that its jaws will apply pressure to the switch when it is closed.
  4. Set each PCB with a static IP address and cofigure the webserver to display the trap status on the main page.
  5. Now you can use LWP::Simple to monitor the trap.

Sample Perl code:

use strict;
use warnings;

use LWP::Simple;

my @hosts = @_;

while(1) {

    for my $host ( @hosts ) {

        my $content = get( "http://$host" );
        print "Host $host caught a mouse!\n" if $content =~ "TRAP CLOSED";

    }

    sleep 60;
}

Of course this solution assumes that you are using a trap with jaws and that you are catching mice. Different trap types, such as glue traps will require a different sensor on your PCB. Different quarry will require only a change to the Perl code.


If this isn't the answer you were looking for, please describe what you are trying to do in detail, let us know what tools you've tried and any other factors or constraints you are operating under.

If you are unsure what libraries are available and haven't been able to get started, at least let us know what protocols you are planning to use.

daotoad