Simple Command Line Probe using Perl

InterMapper allows you to create probes (plugins) that test a device and display the results of that test. A command-line probe runs a program or script (as if you had typed it on the command line) and displays the results of that script in the Status Window on the map.

The example probe below demonstrates how to write a command line probe with a short Perl program embedded within the probe file itself. For more information, read the Command Line Probe section of the Developer Guide or contact support.intermapper@helpsystems.com

You can download the file 
  

Code:
<!--
Command Line Probe in Perl (com.dartware.commandline.perl.txt)
Demonstrates the <tool:xxx> section
Please feel free to use this as a base for further development.
-->

<header>
    type            =    "cmd-line"
    package         =    "com.dartware"
    probe_name      =    "commandline.perl"
    human_name      =    "Command Line-Perl"
    version         =    "1.1"
    address_type    =    "IP"
    display_name    =    "Miscellaneous/Test/Command Line-Perl"
</header>

<description>
\GB\Companion Script Example in perl - Using the "tool" Section of a Probe\p\

This probe launches a trivial Companion Script -- a two-line Perl script that's embedded within the probe.

The script sets and returns two values ($val1 and $val2), and also shows how to set the probe's condition string.

In addition, the exit status (set to "1" in this example) sets the severity of the device.
</description>

<parameters>
</parameters>

<command-line>
   -- "path" must be the directory that contains the perl executable binary
   -- This varies by operating system and installations
   path  = "/usr/bin"         
   cmd   = "perl test.pl"
   arg   = ""
</command-line>

<command-exit>
-- The full range of InterMapper status/exit codes
       down:   ${EXIT_CODE}=4
   critical:   ${EXIT_CODE}=3
      alarm:   ${EXIT_CODE}=2
       warn:   ${EXIT_CODE}=1
       okay:   ${EXIT_CODE}=0
</command-exit>

<command-display>
\b5\Companion Script Return Values\p0\
\4\  Value1:\0\ $val1
\4\  Value2:\0\ $val2
</command-display>

<tool:test.pl>
# Trivial example to return two values and a text condition string
# Note that the returned string must escape the "\" and "$"

print "\\{ \$val1 := 1, \$val2 := 'abcdef' }Condition string - device should be yellow";
exit 1;                  # Return code sets device status (Warn = 1)

</tool:test.pl>