new MonitorJS(items)
Constructor function for the MonitorJS class. Initializes MonitorJS with provided items, sets default
properties, and creates data structures.
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<ItemSchema> | An array of items conforming to the ItemSchema for configuration. |
Members
alertSchema :AlertSchema
Represents the schema for alerts used in MonitorJS.
Type:
conditions :Object.<string, string>
Represents conditions used for comparison in MonitorJS.
Type:
- Object.<string, string>
Properties:
Name | Type | Description |
---|---|---|
equal |
string | Compares if the current value is equal to a reference value. |
more |
string | Compares if the current value is greater than a reference value. |
less |
string | Compares if the current value is less than a reference value. |
equal_pct |
string | Compares if the current percentage value is equal to a reference value. |
more_pct |
string | Compares if the current percentage value is greater than a reference value. |
less_pct |
string | Compares if the current percentage value is less than a reference value. |
equal_avg |
string | Compares if the current average value is equal to a reference value. |
more_avg |
string | Compares if the current average value is greater than a reference value. |
less_avg |
string | Compares if the current average value is less than a reference value. |
equal_avg_pct |
string | Compares if the current average percentage value is equal to a reference value. |
more_avg_pct |
string | Compares if the current average percentage value is greater than a reference value. |
less_avg_pct |
string | Compares if the current average percentage value is less than a reference value. |
itemSchema :ItemSchema
Represents the schema for items used in MonitorJS.
Type:
timeSchema :string
Represents the schema for time units used in MonitorJS.
Type:
- string
Methods
(async) check(itemName, alertName) → {Promise.<void>}
Checks if an alert condition is met for a specified item in MonitorJS. Evaluates the condition defined for
the alert associated with the item.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
string | The name of the item to check for an alert. |
alertName |
string | The name of the alert to evaluate. |
Returns:
- A promise resolving after evaluating the alert condition.
- Type
- Promise.<void>
get(itemName) → {*}
Retrieves the data associated with a specific item by its name from the MonitorJS database.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
string | The name of the item whose data is to be retrieved. |
Returns:
- The data associated with the specified item, or undefined if the item doesn't exist.
- Type
- *
run(itemName) → {void}
Initiates the monitoring process for a specific item in MonitorJS. Sets intervals for updating item values
and checking associated alerts based on defined times.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
string | The name of the item to monitor. |
Returns:
- Type
- void
(async) set(itemName) → {Promise.<void>}
Updates the data associated with a specific item in the MonitorJS database. Retrieves a new value using the
item's setter function, updates the data, and analyzes it.
Parameters:
Name | Type | Description |
---|---|---|
itemName |
string | The name of the item to update. |
Returns:
- A promise resolving once the data is updated and analyzed.
- Type
- Promise.<void>
start() → {void}
Starts the monitoring process for all configured items in MonitorJS. Initiates the monitoring process for
each item by calling the 'run' method.
Returns:
- Type
- void
timeConverter(time) → {number}
Converts a time string into milliseconds based on the provided format.
Parameters:
Name | Type | Description |
---|---|---|
time |
string | The time string in the format [Number]_[s (seconds) | m (minutes) | h (hours)]. |
Returns:
- The converted time in milliseconds.
- Type
- number