Skip to content

manuelgavidia/alarm-client-node

Repository files navigation

Alarm Manager NodeJS Client

License badge

npm install dojot-clientlib

This library implements an Alarm Manager nodejs client for sending alarms to it through RabbitMQ.

How does it work

The client sends a JSON formatted alarm event to the RabbitMQ instance of Alarm Manager. The alarm is enqueued until a server channel connection is available.

Sending messages to Alarm Manager

Alarms are JSON messages :

{
  "namespace": "test.commons.backtrace",
  "domain": "ApplicationCrash",
  "description": "description to be written",
  "severity": "Minor", [Warning, Minor, Major, Clear]
  "primarySubject": {
    "instance_id": "4",
    "module_name": "My beautiful module"
  },
  "additionalData": {
    "process_id": "1",
    "signal": "1"
  },
  "eventTimestamp": "1"
}

And we send it through :

var clientlib = require('dojot-clientlib');

var ALARM = {
        "namespace": "test.commons.backtrace",
        "domain": "ApplicationCrash",
        "description": "description to be written",
        "severity": "Minor",
        "primarySubject": {
            "instance_id": "4",
            "module_name": "My beautiful module"
        },
        "additionalData": {
            "process_id": "1",
            "signal": "1"
        },
        "eventTimestamp": "1"
    };

var client = new clientlib.AlarmConn();
client.send(ALARM);
client.close();

Other parameters include:

function send(alarm,
  hostname = 'localhost', port = '5672',
  username = 'guest', password = 'guest')

When no more alarms are to be sent, the connection should be closed using:

function close();

About

node.js library for producing dojot alarms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published