TrapSnap
Configuration Editing
Editing TrapSnap.cfg.
The work TrapSnap performs is defined in the file "TrapSnap.cfg".
TrapSnap.cfg is stored in the same directory as TrapSnap which you chose at installation.
TrapSnap.cfg is a simple text file.
Each line of the file is either a comment that TrapSnap ignores OR a configuration line.
Comments lines start with a '#' character. TrapSnap ignores these lines.
A configuration line is constructed from fields that a seperated by commas ','.
Each configuration line has the following fields in this order:
1) The IP address of the device that sent the trap.
2) The SNMP Enterprize number of the trap.
3) The SNMP Generic Trap number of the trap. (Can be 0 through 6)
4) The SNMP Specific Trap number of the trap.
5) A condition test that needs to be satisfied.
6) A repetition factor of how many times this task should be done.
7) A delay in milliseconds between each repetition (1000 = 1 second).
8) The protocol to be used is 'ftp', 'veo', 'http' or 'cmd'
9) The action to perform - see below.
TrapSnap ignores invalid configuration lines!
If your run 'TrapSnap -check' TrapSnap will show you any invalid lines.
This way you can perfect your handling of new traps without affecting your existing configuration.
Condition test.
The condition test, if used, compares a value in the actual trap variable bindings with a user supplied value.
Only if the test returns a true result will the action be performed.
The trap variable is specified first, then the comparison and then the value.
There should be no spaces between the test symbol/s and the value!
The numerical comparisons of '=', '!=', '<', '<=', '>', '>=' can be used as well as the string comparison of 'eq' and 'neq'.
Looking at this configuration line:
10.1.1.8,*,6,301,%2=1,2,250,ftp,root:pass@10.1.1.44/tmp/jpg/image.jpg,/inetpub/wwwroot/snaps/%6-%m%d%_-%?.jpg
The comaprison test is '%2=1' which means:
| Field Value | Field Description |
|---|---|
| %2 | the value of the second trap variable binding |
| = | numerically compared for equality to |
| 1 | the value 1 |
Capturing Web Cam Images.
To explain this in more detail, let's look at a configuration that will instruct TrapSnap
to collect an FTP'd image from an Axis camera when a particular switch on a sensor probe opens.
Here is the configuration line:
10.1.1.8,*,6,301,%2=1,2,250,ftp,root:pass@10.1.1.44/tmp/jpg/image.jpg,/inetpub/wwwroot/snaps/%6-%m%d%_-%?.jpg
The fields between the commas are:
| Field Value | Field Description |
|---|---|
| 10.1.1.8 | IP of the sensor probe that sent the trap |
| * | Accept any Enterprize number |
| 6 | This is a specific trap |
| 301 | Specific Trap Number for switch 1 |
| %2=1 | The second Trap variable must be a '1' (this indicates the door is opening) |
| 2 | Repetition factor - Take 2 images |
| 250 | Delay - Wait at least 250 milliseconds (1/4 second) between images. |
| ftp | Protocol to use ('ftp' for Axis, 'veo' for Veo, 'cmd' for commands and 'http' for URLs) |
| root:pass@10.1.1.44/tmp/jpg/images.jpg | User name, password and IP address of the Axis camera and where to find the image on the camera |
| /inetpub/wwwroot/snaps/%6-%m%d%_-%?.jpg | Directory on this PC to store the images and a generated name for the image. %6 use the door name supplied as the 6th value in the sensor probe trap. %m the current month %d the current day of the month %_ the current time of day in the format HH_MM_SS %? the repetition ( 1 and then 2 in this case). |
Logging Traps with TrapSnap.
Here is an example of using TrapSnap to run an application when a specific trap is received.
The 'application' here is the 'echo' command which is part of the command interpreter.
NOTE: Directory names with blanks need surround quotation marks as shown below:
For Unix hosts, you could substitue 'cat' instead of 'echo'.
TrapSnap can be used to log any or all traps it receives this way giving you a simple debugging tool.
Here is the configuration line:
*,*,*,*,*,1,0,cmd,echo %@ %s %n %e %* >>"D:\My Temp\TS%Y%m.log"
The fields between the commas are:
| Field Value | Field Description |
|---|---|
| * | Accept traps from all IP addresses |
| * | Accept any Enterprize number |
| * | Accept any Generic Trap Number |
| * | Accept any Specific Trap Number |
| * | Accept all - condition is always true. |
| 1 | Repetition factor |
| 0 | Delay - No delay (not relevant when repetition = 1) |
| cmd | Protocol to use - run a command |
| echo %s %n %E %* >>"D:\My Temp\TS%Y%m.log" | Print out current values and append them to a file in D:\My Temp\. %s The source IP address. %n Specific Trap Number of the Trap. %E Enterprize Number of Trap Source. %* print all the trap values preceeded by the index number [n] value ... %Y the current year (2XXX). %m the current month |
TrapSnap can handle several switch/arrays combinations.
The limitations will be the speed of transfer from the camera to
the TrapSnap host machine and the frequency of traps.
On Windows machines, when you installed TrapSnap, it will have been configured to run as
a system service. You can start and stop TrapSnap via the services control panel if needed.
On Unix machines, when you installed TrapSnap, it will have been configured to run as
a system daemon. You can start and stop TrapSnap as you would any other daemon.
To change the actions TrapSnap performs, edit its configuration file "TrapSnap.cfg"
using your favourite text editor and save your changes. After receiving the next trap,
TrapSnap will notice that you have modified the configuration and will re-read its configuration file.
Find out about the %substitutes of TrapSnap.cfg in "Substitutes in TrapSnap.cfg".