exampleCommand

command
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Example alerter command to echo message to console.

An alerter command is some command or script to be called by alerter on anomalies found.

Command Line Call

This command will be called by alerter with a JSON-formatted argument:

$ ./echo <JSON-string>

JSON Argument

JSON argument example

{
  "project": {"name": "foo"},
  "user": {
     "name": "jack",
     "email": "jack@gmail.com",
     "enableEmail": true,
     "enablePhone": true,
     "phone": "18735121212"
   },
  "metric": {
    "name": "timer.count_ps.api",
    "score": 1.02,
    "stamp": 1452494901,
    "value": 139.1
  }
}

Alerter Command

An alerter command/script should be like this (pseudo code):

// Parse command line arguments#1 json string
s = argv[1]
data = loadJSON(s)

if data['user']['enableEmail'] then
	// Send email.
	sendEmail(data['user']['email'], data['metric'])
endif
if data['user']['enablePhone'] then
	// Send sms.
	sendPhone(data['user']['phone'], data['metric'])
endif

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL