Monitor Plugin
Version: 1.0
Status:
Monitor plugin for Thunder framework.
Table of Contents
Introduction
Scope
This document describes purpose and functionality of the Monitor plugin. It includes detailed specification about its configuration, methods and properties as well as sent notifications.
Case Sensitivity
All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.
Acronyms, Abbreviations and Terms
The table below provides and overview of acronyms used in this document and their definitions.
Acronym | Description |
---|---|
API | Application Programming Interface |
HTTP | Hypertext Transfer Protocol |
JSON | JavaScript Object Notation; a data interchange format |
JSON-RPC | A remote procedure call protocol encoded in JSON |
The table below provides and overview of terms and abbreviations used in this document and their definitions.
Term | Description |
---|---|
callsign | The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique. |
References
Ref ID | Description |
---|---|
HTTP | HTTP specification |
JSON-RPC | JSON-RPC 2.0 specification |
JSON | JSON specification |
Thunder | Thunder API Reference |
Description
The Monitor plugin provides a watchdog-like functionality for framework processes.
The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].
Configuration
The table below lists configuration options of the plugin.
Name | Type | M/O | Description |
---|---|---|---|
callsign | string | mandatory | Plugin instance name (default: Monitor) |
classname | string | mandatory | Class name: Monitor |
locator | string | mandatory | Library name: libThunderMonitor.so |
startmode | string | mandatory | Determines in which state the plugin should be moved to at startup of the framework |
configuration | object | optional | ... |
configuration?.observables | array | optional | List of observable plugin details |
configuration?.observables[#] | object | mandatory | ... |
configuration?.observables[#]?.callsign | string | optional | Callsign of the plugin to be monitored |
configuration?.observables[#]?.memory | integer | optional | Interval(in seconds) for a memory measurement |
configuration?.observables[#]?.memorylimit | integer | optional | Memory threshold in bytes |
configuration?.observables[#]?.operational | integer | optional | Interval(in seconds) to check the monitored processes |
configuration?.observables[#]?.restart | object | optional | Restart limits for failures applying to the plugin |
configuration?.observables[#]?.restart?.window | integer | optional | Time period(in seconds) within which failures must happen for the limit to be considered crossed |
configuration?.observables[#]?.restart?.limit | integer | optional | Maximum number or restarts to be attempted |
Interfaces
This plugin implements the following interfaces:
- Monitor.json (version 1.0.0) (compliant format)
- IMemoryMonitor (IMemoryMonitor.h) (version 1.0.0) (compliant format)
This interface uses legacy
lowercase
naming convention. With the next major release the naming convention will change tocamelCase
.
Methods
The following methods are provided by the Monitor plugin:
Monitor interface methods:
Method | Description |
---|---|
restartlimits | Sets new restart limits for a service |
resetstats | Resets memory and process statistics for a single service watched by the Monitor |
MemoryMonitor interface methods:
Method | Description |
---|---|
resetstatistics | Resets memory statistics for a given service |
restartlimits method
Sets new restart limits for a service.
Parameters
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.callsign | string | mandatory | The callsign of a service to reset measurements snapshot of |
params.restart | object | mandatory | Restart limits for failures applying to the service |
params.restart.limit | integer | mandatory | Maximum number or restarts to be attempted |
params.restart.window | integer | mandatory | Time period (in seconds) within which failures must happen for the limit to be considered crossed |
Result
Name | Type | M/O | Description |
---|---|---|---|
result | null | mandatory | Always null (default: None) |
Example
Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.restartlimits",
"params": {
"callsign": "WebServer",
"restart": {
"limit": 3,
"window": 60
}
}
}
Response
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
resetstats method
Resets memory and process statistics for a single service watched by the Monitor.
Parameters
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.callsign | string | mandatory | The callsign of a service to reset statistics of |
Result
Name | Type | M/O | Description |
---|---|---|---|
result | object | mandatory | Measurements for the service before reset |
result.measurements | object | mandatory | Measurements for the service |
result.measurements.resident | object | mandatory | Resident memory measurement |
result.measurements.resident.min | integer | mandatory | Minimal value measured |
result.measurements.resident.max | integer | mandatory | Maximal value measured |
result.measurements.resident.average | integer | mandatory | Average of all measurements |
result.measurements.resident.last | integer | mandatory | Last measured value |
result.measurements.allocated | object | mandatory | Allocated memory measurement |
result.measurements.allocated.min | integer | mandatory | Minimal value measured |
result.measurements.allocated.max | integer | mandatory | Maximal value measured |
result.measurements.allocated.average | integer | mandatory | Average of all measurements |
result.measurements.allocated.last | integer | mandatory | Last measured value |
result.measurements.shared | object | mandatory | Shared memory measurement |
result.measurements.shared.min | integer | mandatory | Minimal value measured |
result.measurements.shared.max | integer | mandatory | Maximal value measured |
result.measurements.shared.average | integer | mandatory | Average of all measurements |
result.measurements.shared.last | integer | mandatory | Last measured value |
result.measurements.process | object | mandatory | Processes measurement |
result.measurements.process.min | integer | mandatory | Minimal value measured |
result.measurements.process.max | integer | mandatory | Maximal value measured |
result.measurements.process.average | integer | mandatory | Average of all measurements |
result.measurements.process.last | integer | mandatory | Last measured value |
result.measurements.operational | boolean | mandatory | Whether the service is up and running |
result.measurements.count | integer | mandatory | Number of measurements |
result.observable | string | mandatory | A callsign of the watched service |
result.restart | object | mandatory | Restart limits for failures applying to the service |
result.restart.limit | integer | mandatory | Maximum number or restarts to be attempted |
result.restart.window | integer | mandatory | Time period (in seconds) within which failures must happen for the limit to be considered crossed |
Example
Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.resetstats",
"params": {
"callsign": "WebServer"
}
}
Response
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"measurements": {
"resident": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"allocated": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"shared": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"process": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"operational": true,
"count": 100
},
"observable": "callsign",
"restart": {
"limit": 3,
"window": 60
}
}
}
resetstatistics method
Resets memory statistics for a given service.
Parameters
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.callsign | string | mandatory | Callsign of the service |
Result
Name | Type | M/O | Description |
---|---|---|---|
result | null | mandatory | Always null |
Example
Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.resetstatistics",
"params": {
"callsign": "WebServer"
}
}
Response
{
"jsonrpc": "2.0",
"id": 42,
"result": null
}
Properties
The following properties are provided by the Monitor plugin:
Monitor interface properties:
Property | R/W | Description |
---|---|---|
status | read-only | Service statistics |
MemoryMonitor interface properties:
Property | R/W | Description |
---|---|---|
restartinglimits | read/write | Limits of restarting of a service |
observables | read-only | List of services watched by the Monitor |
measurementdata | read-only | Memory statistics for a given service |
status property
Provides access to the service statistics.
This property is read-only.
The callsign parameter shall be passed as the index to the property, i.e.
status@<callsign>
.
Index
Name | Type | M/O | Description |
---|---|---|---|
callsign | string | mandatory | If omitted then all observed objects will be returned on read |
Value
Name | Type | M/O | Description |
---|---|---|---|
(property) | array | mandatory | Service statistics |
(property)[#] | object | mandatory | ... |
(property)[#].measurements | object | mandatory | Measurements for the service |
(property)[#].measurements.resident | object | mandatory | Resident memory measurement |
(property)[#].measurements.resident.min | integer | mandatory | Minimal value measured |
(property)[#].measurements.resident.max | integer | mandatory | Maximal value measured |
(property)[#].measurements.resident.average | integer | mandatory | Average of all measurements |
(property)[#].measurements.resident.last | integer | mandatory | Last measured value |
(property)[#].measurements.allocated | object | mandatory | Allocated memory measurement |
(property)[#].measurements.allocated.min | integer | mandatory | Minimal value measured |
(property)[#].measurements.allocated.max | integer | mandatory | Maximal value measured |
(property)[#].measurements.allocated.average | integer | mandatory | Average of all measurements |
(property)[#].measurements.allocated.last | integer | mandatory | Last measured value |
(property)[#].measurements.shared | object | mandatory | Shared memory measurement |
(property)[#].measurements.shared.min | integer | mandatory | Minimal value measured |
(property)[#].measurements.shared.max | integer | mandatory | Maximal value measured |
(property)[#].measurements.shared.average | integer | mandatory | Average of all measurements |
(property)[#].measurements.shared.last | integer | mandatory | Last measured value |
(property)[#].measurements.process | object | mandatory | Processes measurement |
(property)[#].measurements.process.min | integer | mandatory | Minimal value measured |
(property)[#].measurements.process.max | integer | mandatory | Maximal value measured |
(property)[#].measurements.process.average | integer | mandatory | Average of all measurements |
(property)[#].measurements.process.last | integer | mandatory | Last measured value |
(property)[#].measurements.operational | boolean | mandatory | Whether the service is up and running |
(property)[#].measurements.count | integer | mandatory | Number of measurements |
(property)[#].observable | string | mandatory | A callsign of the watched service |
(property)[#].restart | object | mandatory | Restart limits for failures applying to the service |
(property)[#].restart.limit | integer | mandatory | Maximum number or restarts to be attempted |
(property)[#].restart.window | integer | mandatory | Time period (in seconds) within which failures must happen for the limit to be considered crossed |
Example
Get Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.status@WebServer"
}
Get Response
{
"jsonrpc": "2.0",
"id": 42,
"result": [
{
"measurements": {
"resident": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"allocated": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"shared": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"process": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"operational": true,
"count": 100
},
"observable": "callsign",
"restart": {
"limit": 3,
"window": 60
}
}
]
}
restartinglimits property
Provides access to the limits of restarting of a service.
The callsign parameter shall be passed as the index to the property, i.e.
restartinglimits@<callsign>
.
Index (Get)
Name | Type | M/O | Description |
---|---|---|---|
callsign | string | mandatory | Callsign of the service |
Index (Set)
Name | Type | M/O | Description |
---|---|---|---|
callsign | string | mandatory | Callsign of the service |
Value
Name | Type | M/O | Description |
---|---|---|---|
(property) | object | mandatory | Limits of restarting of a service |
(property).value | object | mandatory | Limits of restarts applying to a given service |
(property).value.limit | integer | mandatory | Maximum number or restarts to be attempted |
(property).value.window | integer | mandatory | Time period (in seconds) within which failures must happen for the limit to be considered crossed |
Name | Type | M/O | Description |
---|---|---|---|
(property) | object | mandatory | Limits of restarting of a service |
(property).limit | integer | mandatory | Maximum number or restarts to be attempted |
(property).window | integer | mandatory | Time period (in seconds) within which failures must happen for the limit to be considered crossed |
Example
Get Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.restartinglimits@WebServer"
}
Get Response
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"limit": 3,
"window": 60
}
}
Set Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.restartinglimits@WebServer",
"params": {
"value": {
"limit": 3,
"window": 60
}
}
}
Set Response
{
"jsonrpc": "2.0",
"id": 42,
"result": "null"
}
observables property
Provides access to the list of services watched by the Monitor.
This property is read-only.
Value
Name | Type | M/O | Description |
---|---|---|---|
(property) | array | mandatory | List of monitored services |
(property)[#] | string | mandatory | ... |
Example
Get Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.observables"
}
Get Response
{
"jsonrpc": "2.0",
"id": 42,
"result": [
"..."
]
}
measurementdata property
Provides access to the memory statistics for a given service.
This property is read-only.
The callsign parameter shall be passed as the index to the property, i.e.
measurementdata@<callsign>
.
Index
Name | Type | M/O | Description |
---|---|---|---|
callsign | string | mandatory | Callsign of the service |
Value
Name | Type | M/O | Description |
---|---|---|---|
(property) | object | mandatory | Statistics for the requested callsign |
(property).resident | object | mandatory | Resident memory measurement |
(property).resident.min | integer | mandatory | Minimal value measured |
(property).resident.max | integer | mandatory | Maximal value measured |
(property).resident.average | integer | mandatory | Average of all measurements |
(property).resident.last | integer | mandatory | Last measured value |
(property).allocated | object | mandatory | Allocated memory measurement |
(property).allocated.min | integer | mandatory | Minimal value measured |
(property).allocated.max | integer | mandatory | Maximal value measured |
(property).allocated.average | integer | mandatory | Average of all measurements |
(property).allocated.last | integer | mandatory | Last measured value |
(property).shared | object | mandatory | Shared memory measurement |
(property).shared.min | integer | mandatory | Minimal value measured |
(property).shared.max | integer | mandatory | Maximal value measured |
(property).shared.average | integer | mandatory | Average of all measurements |
(property).shared.last | integer | mandatory | Last measured value |
(property).process | object | mandatory | Processes measurement |
(property).process.min | integer | mandatory | Minimal value measured |
(property).process.max | integer | mandatory | Maximal value measured |
(property).process.average | integer | mandatory | Average of all measurements |
(property).process.last | integer | mandatory | Last measured value |
(property).operational | boolean | mandatory | Whether the service is up and running |
(property).count | integer | mandatory | Number of measurements |
Example
Get Request
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.measurementdata@WebServer"
}
Get Response
{
"jsonrpc": "2.0",
"id": 42,
"result": {
"resident": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"allocated": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"shared": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"process": {
"min": 0,
"max": 100,
"average": 50,
"last": 100
},
"operational": true,
"count": 100
}
}
Notifications
Notifications are autonomous events triggered by the internals of the implementation and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.
The following events are provided by the Monitor plugin:
Monitor interface events:
Notification | Description |
---|---|
action | Signals an action taken by the Monitor |
MemoryMonitor interface events:
Notification | Description |
---|---|
statuschanged | Signals an action taken by the Monitor |
action notification
Signals an action taken by the Monitor.
Notification Parameters
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.callsign | string | mandatory | Callsign of the service the Monitor acted upon |
params.action | string | mandatory | The action executed by the Monitor on a service. One of: "Activate", "Deactivate", "StoppedRestarting" |
params.reason | string | mandatory | A message describing the reason the action was taken |
Example
Registration
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.register",
"params": {
"event": "action",
"id": "myid"
}
}
Notification
{
"jsonrpc": "2.0",
"method": "myid.action",
"params": {
"callsign": "WebServer",
"action": "Deactivate",
"reason": "EXCEEDED_MEMORY"
}
}
The client ID parameter is passed within the notification designator, i.e.
<client-id>.action
.
statuschanged notification
Signals an action taken by the Monitor.
Notification Parameters
Name | Type | M/O | Description |
---|---|---|---|
params | object | mandatory | ... |
params.callsign | string | mandatory | Callsign of the service the Monitor acted upon |
params.action | string | mandatory | Ation executed by the Monitor on a service (must be one of the following: Activated, Deactivated, RestartingStopped) |
params?.reason | string | optional | Mssage describing the reason the action was taken (must be one of the following: ExceededMemory, NotOperational) |
Example
Registration
{
"jsonrpc": "2.0",
"id": 42,
"method": "Monitor.1.register",
"params": {
"event": "statuschanged",
"id": "myid"
}
}
Notification
{
"jsonrpc": "2.0",
"method": "myid.statuschanged",
"params": {
"callsign": "WebServer",
"action": "Deactivate",
"reason": "EXCEEDED_MEMORY"
}
}
The client ID parameter is passed within the notification designator, i.e.
<client-id>.statuschanged
.