ProcessProbe Class
Probe for attaining process and O/S information
Constructor
ProcessProbe
-
[initParams]
-
model
Parameters:
-
[initParams]
Object optionalProbe initialization parameters (from PollingProbe)
-
[pollInterval]
Integer optionalPolling interval in milliseconds. Default: null
-
[cronPattern]
String optionalCrontab syle polling pattern. Default once per second: "* * * * * *"
-
-
model
ObjectMonitor data model elements
-
platform
StringO/S Platform
-
version
StringNode.js compiled-in version
-
installPrefix
StringNode.js installation directory
-
title
StringThe current process title (as reported in ps)
-
execPath
StringThe path to the current node.js executable
-
argv
Array(String)Arguments passed on the command line to this process
-
env
ObjectCurrent environment (inherited)
-
cwd
StringCurrent working directory
-
uptime
IntegerNumber of seconds the process has been up (if available)
-
versions
StringVersions of V8 and dependent libraries (if available)
-
arch
StringProcessor architecture (if available)
-
gid
IntegerProcess group ID
-
uid
IntegerProcess user ID
-
pid
IntegerUnique process ID
-
umask
IntegerThe process file mode creation mask
-
memoryUsage
ObjectAn object describing memory usage of the node.js process
-
rss
IntegerAs defined by process.memoryUsage -
vsize
IntegerAs defined by process.memoryUsage -
heapTotal
IntegerAs defined by process.memoryUsage -
heapUsed
IntegerAs defined by process.memoryUsage
-
-
os
ObjectAn object containing O/S information
-
hostname
StringName of the host operating system -
type
StringOperating system type -
release
StringO/S Release version -
uptime
StringO/S Uptime in seconds -
loadavg
Array(Number)An array containing the 1, 5, and 15 minute load averages -
freemem
IntegerFree O/S memory (in bytes) -
totalmem
IntegerTotal O/S memory capacity (in bytes) -
cpus
Array(Object)An array of objects containing information about each CPU/core installed
-
-
Item Index
Methods
Methods
initialize
-
attributes
-
options
Initialize the probe
This is called on the probe during construction. It contains the probe initialization attributes and an option to make probe construction asynchronous.
Probe implementations can defer the initial response to the monitor until
the initial state is loaded. This allows the callback on
Monitor.connect()
to have the complete initial state of the probe when called.
If the initial probe state cannot be determined in initialize
, it should
set the options.asyncInit
option to true
, and call the
options.callback(error)
once the initial state is determined.
// Asynchronous initialization
options.asyncInit = true;
var callback = options.callback
If asyncInit
is set to true, the callback
must be called once
the initial state of the probe is known (or in an error condition).
// Set the initial state, and call the callback
this.set(...);
callback(null);
See the initialize
method of the FileProbe probe for an example. It defers
returning the probe to the monitor until the initial file contents are loaded.
Parameters:
-
attributes
ObjectInitial probe attributes sent in from the Monitor
-
options
ObjectInitialization options
-
asyncInit
BooleanSet this to TRUE if the initial probe state can't be known immediately.
-
callback
Function(error)The callback to call if asyncInit is set to true. If an error is passed, the probe will not be used.
-
onControl
-
name
-
[params]
-
[callback]
Dispatch a control message to the appropriate control function.
This is called when the
control()
method of a monitor is called.
The name determines the method name called on the probe.
The probe must implement a method with the name {name}_control()
,
and that method must accept two parameters - an input params and a callback.
The callback must be called, passing an optional error and response object.
For example, if the probe supports a control with the name go
, then
all it needs to do is implement the go_control()
method with the
proper signature. See ping_control()
for an example.
Parameters:
-
name
StringName of the control message.
-
[params]
Any optionalInput parameters specific to the control message.
-
[callback]
Function(error, response) optionalCalled to send the message (or error) response.
- error (Any) An object describing an error (null if no errors)
- response (Any) Response parameters specific to the control message.
ping_control
-
params
-
callback
Respond to a ping control sent from a monitor
Parameters:
-
params
ObjectInput parameters (not used)
-
callback
Function(error, response)Called to send the message (or error) response.
- error (Any) An object describing an error
- response (String) The string 'pong' is returned as the response
poll
()
Poll the probe for changes
This method is called by the parent PollingProbe on the interval specified by the client Monitor.
It polls for process information, and updates the data model with any changes.
release
()
Release any resources consumed by this probe.
This can be implemented by derived classes that need to be informed when they are to be shut down.
Probes that listen to events should use this method to remove their event listeners.