A nice small tool to indicate OpenNMS alarms on a blink(1) mk2 USB LED or trigger IFTTT applets.
In order to compile or execute this tool you need to build the libraries blink1.jar
and libBlink1.jnilib
in the blink1
directory.
-
Oracle Java 8 JDK with
java
andjavac
in path environment -
Apache Maven with
mvn
in path environment -
the great blink(1) mk2
apt install libusb-1.0-0-dev -y
git clone https://github.com/opennms-forge/onmsblink.git
cd onmsblink
blink1.jar
and libBlink1.jnilib
git submodule init
git submodule update
cd blink1-java
make jar
If you are building on Mac and have problems like fatal error: 'jni.h' file not found
, try to set the include paths by invoking:
export CFLAGS="-I `/usr/libexec/java_home`/include -I `/usr/libexec/java_home`/include/darwin"
Run the tool by invoking onmsblink.sh
:
./onmsblink.sh --help
The following options are available:
Option | Default | Description |
---|---|---|
|
OpenNMS url |
|
|
|
poll delay in seconds |
|
username, if not given the tool will prompt for the username |
|
|
password, if not given the tool will prompt for the password |
|
|
execute program on status change (placeholders are |
|
|
|
display help and exit |
|
|
test and exit |
|
|
constant glow, no flashing |
|
|
no output except errors |
|
|
send IFTTT events defined in ifttt-config.xml |
|
category filter (Java regular-expression) |
|
|
|
do not validate SSL certificates |
./onmsblink.sh --quiet --delay 5 --username admin --password secret --url http://opennms.yourdomain.com:8980/opennms
In general alarms are associated with nodes and these are organized in categories. You can use the --category
option to
filter for category names by using a Java regular-expression. Severity and alarm count will be computed based on these
alarms.
./onmsblink.sh --username admin --password secret --url http://opennms.yourdomain.com:8980/opennms --category 'Routers|Notification.*'
The given example will filter for alarms based on nodes in the category Routers
and categories starting with Notification
.
You can use OnmsBlink to trigger actions in IFTTT. Create your applets and use the Maker Service trigger by defining
a event name for the web request. The configuration file ifttt-config.xml
contains so called trigger-sets. These named
trigger-sets contain one or more triggers to be executed by OnmsBlink at the given event. Each trigger inside a trigger-set
defines the event name to be triggered at IFTTT Maker Service and three values. These values can be used to set additional
attributes of the defined IFTTT applet action. The following trigger-sets can be defined:
Name | Execution |
---|---|
ON |
on start of the OnmsBlink program to switch on a device |
OFF |
on exit of the OnmsBlink program to switch off a device |
NORMAL |
if severity is NORMAL |
WARNING |
if severity is WARNING |
MINOR |
if severity is MINOR |
MAJOR |
if severity is MAJOR |
CRITICAL |
if severity is CRITICAL |
./onmsblink.sh --quiet --delay 5 --username admin --password secret --url http://opennms.yourdomain.com:8980/opennms --ifttt
The following example shows the configuration file for a WiFi light bulb controlled via IFTTT. The defined applets use
value1
for setting the color and value2
for setting the brightness. You need the key of the IFTTT Maker Service. This
key can be found in your IFTTT service settings.
Note
|
For the severity-based trigger the following placeholders can be used in the three value fields:
%os% for old severity, %ns% for new severity, %oc% for old alarm count and %nc% for new alarm count
|
<ifttt-config key="your-key-here">
<trigger-set name="ON">
<trigger eventName="on" delay="0">
<value1></value1>
<value2></value2>
<value3></value3>
</trigger>
</trigger-set>
<trigger-set name="OFF">
<trigger eventName="off" delay="0">
<value1></value1>
<value2></value2>
<value3></value3>
</trigger>
</trigger-set>
<trigger-set name="NORMAL">
<trigger eventName="color" delay="0">
<value1>#336600</value1>
<value2>0.40</value2>
<value3>%os%,%ns%,%oc%,%nc%</value3>
</trigger>
</trigger-set>
<trigger-set name="WARNING">
<trigger eventName="color" delay="0">
<value1>#FFCC00</value1>
<value2>0.50</value2>
<value3>%os%,%ns%,%oc%,%nc%</value3>
</trigger>
</trigger-set>
<trigger-set name="MINOR">
<trigger eventName="color" delay="0">
<value1>#FF9900</value1>
<value2>0.60</value2>
<value3>%os%,%ns%,%oc%,%nc%</value3>
</trigger>
</trigger-set>
<trigger-set name="MAJOR">
<trigger eventName="color" delay="0">
<value1>#CC3300</value1>
<value2>0.70</value2>
<value3>%os%,%ns%,%oc%,%nc%</value3>
</trigger>
</trigger-set>
<trigger-set name="CRITICAL">
<trigger eventName="flash" delay="0">
<value1>#FF0000</value1>
<value2>0.80</value2>
<value3>%os%,%ns%,%oc%,%nc%</value3>
</trigger>
</trigger-set>
</ifttt-config>