Here is a list of built-in variables available in custom-probes and notifiers. Note that certain variables are available only in certain contexts. The variables are listed by context.
The following variables are available in the specified sections of Command-line probes. (probe-type=cmd-line)
The following variables are available in <command-line> and <command-exit> sections of command line probes
| Variable Name | Variable Description |
|---|---|
| ${address} | The network address of the device. |
| ${devicename} | The device name of the device. Note: In some cases, the device name may resolve to the device's IP address. |
| ${port} | The network port number that is being monitored. |
| ${exit_code} | The exit code of the command-line probe. Note: The ${exit_code} variable is used in <command-exit> only. |
| ${cscript} | Evaluates to the full path to the Windows cscript.exe utility; it also automatically adds /nologo as a command-line option. Note: This variable is only available in Windows. |
| ${python} | Evaluates to the full path to the python interpreter installed as part of InterMapper DataCenter; it also automatically adds any necessary command-line options for normal operation. |
The following variables are available in the <command-display> section of command line probes. (probe-type=cmd-line)
| Variable Name | Variable Description |
|---|---|
| ${devicename} | The device's name taken from first line of the label. |
| ${deviceaddress} | The network address of the device. |
| ${eval:} | The eval macro. |
| ${chartable[:fmt]:expr} | Evaluate expr and format the result as a chartable value |
| ${scalable2:fmt:expr} ${scalable10:fmt:expr} |
Scales large numbers into smaller units for better readability. The values are chartable. |
| ${^stdout} | Any output written to the standard output of a command-line script. See below for additional information about the effect of ${^stdout} on the reason string. |
| ${nagios_output} | Parses a Nagios plugin's output for display. |
These variables are available in SNMP Probes. (probe-type = customsnmp)
| Variable Name | Variable Description |
|---|---|
| ${devicename} | The device's name taken from first line of the label. |
| ${deviceaddress} | The network address of the device. |
| ${imserveraddress} | The network address of the InterMapper Server. |
| ${alarmpointlist} | alarm point list. |
| ${eval:expr} | The eval macro. |
| ${chartable[:fmt]:expr} | The chartable macro. |
| ${scalable2:fmt:expr} ${scalable10:fmt:expr} |
Scales large numbers into smaller units for better readability. The values are chartable. |
| ${[variablename]:legend} | The variable's legend as specified in the <snmp-device-variables> section For more information, see SNMP Probe Variables. |
| Variable Name | Variable Description |
|---|---|
| ${ifIndex} | The interface index. |
| ${ifType} | The interface type. |
| ${ifDescr} | The interface description. |
| ${ifAlias} | The interface's alias |
| Variable Name | Variable Description |
|---|---|
| ${SpecificTrap} | Trap Field: specific-trap (SNMP v1; generic-trap is enterpriseSpecific) |
| ${GenericTrap} | Trap Field: generic-trap (SNMP v1) |
| ${TimeStamp} | Trap Field: trap timestamp (SNMP v1, v2c) |
| ${Enterprise} | Trap Field: enterprise (SNMP v1) |
| ${CommunityString} | Trap Field: community (SNMP v1, v2c) |
| ${TrapOID} | Trap Field: trap OID (SNMPv2c, v3) |
| ${SnmpVersion} | Trap Field: trap version |
| ${SenderAddress} | Trap Field: trap sender's address |
| ${AgentAddress} | Trap Field: trap agent's address (if different from sender) |
| ${VarbindCount} | Trap Field: count of varbind variables Note: the next three macros do not use a colon ${VarbindValue8} returns the value of the eigth Varbind item. |
| ${VarbindOID<num>} | Trap Field: nth varbind OID |
| ${VarbindValue<num>} | Trap Field: nth varbind Value |
| ${VarbindType<num>} | Trap Field: nth varbind Type |
These variables are available in TCP probes. (probe-type = tcp-script)
| Variable Name | Variable Description |
|---|---|
| ${_remoteaddress} | The network address of the remote end of the connection. |
| ${_remoteport} | The network port number of the remote end of the connection. |
| ${_localaddress} | The network address of the local end of the connection. |
| ${_localport} | The network port number of the local end of the connection. |
| ${_gmttime} | The current time in RFC 822 format. |
| ${_version} | The version number of the InterMapper program. |
| ${_line:len} | The text of the last line received, truncated to the given length. |
| ${_idletimeout} | The idle timeout for the probe in seconds. |
| ${_stringtomatch} | The string we attempted to match in the last EXPT or MTCH command. |
| ${_base64:str} | Encode the given argument into base64. |
| ${_cvspassword:str} | Encode the given argument using the cvs password algorithm. |
| ${_md5:str} | The MD5 hash of the given argument, in hexadecimal. |
| ${_idleline} | The line number of the script where we were before the idle handler was invoked. |
| ${_secsconnected} | The number of seconds the probe spent connected to the other end. May be 0 if we were disconnected immediately or connection failed. |
| ${_length:str} | The length of the given argument in bytes. |
| ${_float:num} | The argument "pretty-printed" as a floating point number via printf %g. |
| ${_hmac:key:msg} | The HMAC-MD5 of the message, using the given key. |
| ${_xor} | |
| ${_urlencode:str} | Encodes the specified string for use in URLs. |
| Variable Name | Variable Description |
|---|---|
| ${devicename} | The device's name taken from first line of the label. |
| ${deviceaddress} | The network address of the device. |
| ${eval:} | The eval macro. |
| ${scalable2:fmt:expr} ${scalable10:fmt:expr} |
Scales large numbers into smaller units for better readability. The values are chartable. |
The following variables are available for passing to a command line notifier. These values allow you to pass messages or URLs as command-line arguments in formats that are platform-friendly.
| Variable Name | Variable Description |
|---|---|
| ${message} | The notifier's message text. (On Windows, each double-quote " is escaped by \".) |
| ${stripped_message} | The notifier's message text with quotes (' and ") removed and newlines (\r and \n) replaced by space. |
| ${escaped_message$} | The notifier's message text escaped for url syntax (e.g. %20 for space, etc.) |
| ${urlescape:str} | The urlescape macro. |
Use the ${chartable} macro to evaluate expr and to format the result as a chartable value.
${chartable[:fmt]:expr}
A SNMP device might return a temperature as "723", where the temperature is 72 degrees Fahrenheit. Although this value is useful in charting the value, you might want to format the output in the status window as follows:
\4\Temperature (F):\0\ ${chartable: ##.#: ${temp}}
<!-- result is 72.3 -->
Use the ${eval} macro to compute a value in the output of a script. It is available in the following contexts:
The syntax for the ${eval} macro is as follows:
${eval:[expr]}
The expression can use any operators or functions defined in Probe Calculations, allowing you to perform variable assignments, arithmetic calculations, relational and logical comparisons, as well as use built-in functions to perform bitwise, rounding and mathematical operations. You can also perform operations on strings using sprintf formatting and regular expressions.
Here are some examples that use the Eval macro:
Arithmetic: ${eval:${test} := (4-1)*(2+1)/(9/3)}
<!-- result = 3, also assigns result to ${test} -->
Modulo: ${eval:${test}%2}
<!-- result = 1, uses the ${test} variable -->
String assign: ${eval:${yes}:="Yes"} ${eval:${no}:="No"}
Numeric assign: ${eval:${test}:=5} (
Conditional: ${eval: $test==5 ? ($response := "Yes") : ($response := "No") }
<!-- result="Yes", because ${test} variable = 5
result also assigned to ${response} variable, output on the next line -->
${response}
subid(): ${eval:subid("1.3.6.1.2.1.4.20.1.1.10.10.2.20", -4, 4)}
<!-- result="10.10.2.20" -->
Regular Expression: ${eval: "test123" =~ "^te([st]*)([0-9]*)"; "${1} ${2}"}
<!-- result = "st 123"-->
Use the ${scalable10} and ${scalable2} macros to display numbers in the appropriate scaled units. The values are always between 1.0 and 1000, are chartable, and are scaled by a factor of 1000 or 1024:
Both macros display the appropriate scale. They use the same syntax as the ${chartable} macro.
${scalable10[:fmt]:expr}
${scalable2[:fmt]:expr}
${scalable10: #.## : 12304 }bytes => 12.30 kbytes
${scalable10:"%3.2d" : 12304 }bytes => 12.30 kbytes
${scalable2: #.## : 12304 }bytes => 12.02 kbytes
${scalable2: "%3.2d" : 12304 }bytes => 12.02 kbytes
The following examples use the scalable10 macro.
char scale factor short for example val units example output
---- ------------ --------- ----------- ----- --------------
k * 1000 kilo 12304 bytes 12.30 kbytes
M * 1e6 Mega 3421814 bytes 3.42 Mbytes
G * 1e9 Giga 125032100300 bytes 125.03 Gbytes
T * 1e12 Tera 1.23 x 10^12 bytes 1.23 Tbytes
none * 1 nothing 123 bytes 123.00 bytes
m / 1000 milli 0.02835 sec 28.35 msec
u / 1e-6 micro 0.00047658 sec 476.58 usec
n / 1e-9 nano 0.0000000032 sec 3.20 nsec
p / 1e-12 pico 1.0 x 10^-10 sec 100.00 psec
In command-line probes, a specially formatted output string is used to define variables and their values. Normally, anything else written to standard output is used as the reason string for the probe.
If ${^stdout} exists in the command-display section of a command-line probe, then anything written to standard output by the probe script is assigned as the value of the ${^stdout} variable. This allows the script to programmatically define all or part of the contents of the lower part of the status window.
Using ${^stdout} means that the reason string does not get defined. To compensate, and to allow the definition of a meaningful reason string, a convention was defined. If the specially-formatted output string mentioned above defines a variable named reason, then its value is assigned to the reason string used in the status window.
For example, output from the WMI Top Processes probe might look like this:
\{ProcessTime0:=100.0,CPU:=1.0,reason:="CPU utilization is below 60%"}
\B5\WMI Top Processes\0P\
\B4\CPU Utilization:\P0\ $CPU %
\B4\wmiprvse(3924)\P0\ $ProcessTime0 %