/alarmtrap

Propietary 🐷 tool generating alarms via SNMP traps

Primary LanguageJava

alarmtrap

This tool provides simple CLI application (built using picocli) that can send proprietary SNMP traps based on provided so called mapping files.

Build CLI

Fat JAR

In order to build runnable fat-jar run:

$ mvn clean install

After successful build, fat-jar alarmtrap.jar is present in target/ folder. It can be run using java, like so:

$ java -jar alarm.jar --help

Native image

In order to build runnable native-image using GraalVM

$ mvn clean install -Pnative-image

As native image is built in install maven step be sure maven is using GraalVM instead of JRE.

After successful build, native image alarmtrap is present in target/ folder. It can be run just like any other ordinary executable program:

$ ./alarmtrap --help

Predefined mapping files

Mapping files put into resources/mappings/ folder are pre-loaded in compile time and available together with files defined by -m option.

Running CLI

For help run:

$ alarmtrap --help

Parameters

<alarmName>

Name of the alarm. Must be present in provided mappings.

<address>

Host address, where resulting SNMP trap is sent.

Must be in form of "<IP_ADDRESS>:<PORT>" or "<IP_ADDRESS>". If is omitted, the 162 is used by default.

Options

-m or --mappings

Path to mapping file or directory containing mapping files in JSON format.

Default path is working directory.

-c or --component (multiple)

Values to be used for random component generated based on regexes and OIDs found in mappings.

In case of component is consisted of more than one regex e.g.:

"Component": "... %%(1\\.3\\.6\\.1\\.4\\.1.*)%% ... %%1.3.6.1.4.1%%"

you can specify list of values an each component OID will be replace by the value as found in list in order e.g.:

$ alarmtrap ... -c "hello" -c "world" ...

first regex OID will be generated randomly and its value will be "hello" and second OID will have value "world".

-s or --severity

Specify alarm's severity. Must be one of:

  • CLEARED (default),
  • INDETERMINATE,
  • WARNING,
  • MINOR,
  • MAJOR,
  • CRITICAL.

Default is CLEARED.

Severity is case insensitive. E.g. severity MINOR can be specified as Minor, minor, MInOr, ... .

-t or --snmptrap

If specified, then alarm is not really send to provided address, but "copy & paste"-ready string snmptrap is printed out instead.

Example:

$ alarmtrap --mapings "/path/to/mappings" --component "hello" --severity Minor SomeAlarm 127.0.0.1 -t

snmptrap -v2c -c public 127.0.0.1:162 '' 1.3.6.1.4.1.X.X.X.X 1.3.6.1.4.1.X.Y.Y.Y s hello

TODOs:

  • separate com.hradecek.alarms.cli to its own maven sub-module
  • implements <TAB> completion
  • multiple alarms with same name
  • additional information replacements - like component