# Fyipe Server Monitor
A fyipe shell package that monitor's server resources - disk, memory and CPU percentage - used.
## Installation
You can install to use on the CLI:
```
$ npm install -g fyipe-server-monitor
```
You can install to use in your project:
```
$ cd project
$ npm install fyipe-server-monitor
```
## CLI Usage
You can use on the CLI:
- Run `fyipe-server-monitor`.
- Enter your Project ID and API key - Get these from your Fyipe Dashboard.
- Select Server Monitor from the list of Server Monitors.
- Server will be pinged every minute and the data stored in your project.
You can also use like so:
```
$ fyipe-server-monitor -p 5d64d59cae46131619708309 -a b02798c0-c898-11e9-9f14-4963dc67e2ab -m 5d7775e9f14a531364ba6917
```
## Basic Usage
```javascript
const serverMonitor = require('fyipe-server-monitor');
const monitor = serverMonitor({
projectId: '5d64d59cae46131619708309',
apiKey: 'b02798c0-c898-11e9-9f14-4963dc67e2ab',
monitorId: '5d7775e9f14a531364ba6917',
interval: '*/5 * * * * *', // cron job interval
timeout: 10000, // milliseconds
});
monitor.start();
```
## API Documentation
Main API to authenticate user, start and stop server monitoring.
**See**
- module:helpers
- module:logger
**Author**: HackerBay, Inc.
- [api](#module_api)
- [module.exports(config, apiKey, monitorId)](#exp_module_api--module.exports) ⇒ Object
⏏
- [~ping(projectId, monitorId, apiKey, interval)](#module_api--module.exports..ping) ⇒ Object
- [~start(id)](#module_api--module.exports..start) ⇒ Object
\| number
- [~stop()](#module_api--module.exports..stop) ⇒ Object
### module.exports(config, apiKey, monitorId) ⇒ Object
⏏
Authenticate user and get list of server monitors if monitor id not provided.
**Kind**: Exported function
**Returns**: Object
- The server monitor handlers.
| Param | Type | Description |
| --------- | -------------------------------------------- | ----------------------------------------------------------------------- |
| config | string
\| Object
| The project id or config of the project. |
| apiKey | string
| The api key of the project. |
| monitorId | string
\| function
| The monitor id or function to resolve monitor id of the server monitor. |
#### module.exports~ping(projectId, monitorId, apiKey, interval) ⇒ Object
Get system information at interval and upload to server.
**Kind**: inner method of [module.exports
](#exp_module_api--module.exports)
**Returns**: Object
- The ping server cron job.
| Param | Type | Default | Description |
| --------- | ------------------- | --------------------------------------- | ---------------------------------------------------------- |
| projectId | string
| | The project id of the project. |
| monitorId | string
| | The monitor id of the server monitor. |
| apiKey | string
| | The api key of the project. |
| interval | string
| "\* \* \* \* \*"
| The interval of the cron job, must ba a valid cron format. |
#### module.exports~start(id) ⇒ Object
\| number
Start server monitor.
**Kind**: inner method of [module.exports
](#exp_module_api--module.exports)
**Returns**: Object
\| number
- The ping server cron job or the error code.
| Param | Type | Description |
| ----- | ------------------- | ------------------------------------- |
| id | string
| The monitor id of the server monitor. |
#### module.exports~stop() ⇒ Object
Stop server monitor.
**Kind**: inner method of [module.exports
](#exp_module_api--module.exports)
**Returns**: Object
- The ping server cron job.
```
```