oneuptime
Version:
OneUptime is a JS package that tracks error event and send logs from your applications to your oneuptime dashboard.
293 lines (252 loc) • 11.5 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><p><a href="https://github.com/OneUptime/js-sdk/blob/master/docs/server-monitor/README.md"><img src="https://img.shields.io/npm/v/oneuptime-server-monitor" alt="npm"></a></p>
<h1>OneUptime Server Monitor</h1>
<p>A oneuptime shell package that monitor's server resources - disk, memory and CPU percentage - used.</p>
<h2>Installation</h2>
<p>You can install to use on the CLI:</p>
<pre class="prettyprint source lang-bash"><code>$ npm install -g oneuptime-server-monitor
</code></pre>
<p>You can install to use in your project:</p>
<pre class="prettyprint source lang-bash"><code>$ cd project
$ npm install oneuptime-server-monitor
</code></pre>
<h2>CLI Usage</h2>
<p>You can use on the CLI:</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor
</code></pre>
<ul>
<li>Run <code>oneuptime-server-monitor</code>.</li>
<li>Enter your Project ID, API URL, and API key - Get these from your OneUptime Dashboard.</li>
<li>Select Server Monitor from the list of Server Monitors.</li>
<li>Server will be pinged every minute and the data stored in your project.</li>
</ul>
<p>You can also use it like this:</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --project-id 5d64d59cae46131619708309 --api-url https://oneuptime.com/api --api-key b02798c0-c898-11e9-9f14-4963dc67e2ab --monitor-id 5d7775e9f14a531364ba6917
</code></pre>
<p>Or run as a daemon (requires <code>sudo</code> or admin privileges):</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --daemon --project-id 5d64d59cae46131619708309 --api-url https://oneuptime.com/api --api-key b02798c0-c898-11e9-9f14-4963dc67e2ab --monitor-id 5d7775e9f14a531364ba6917
</code></pre>
<p>You can use the following commands with the daemon: <code>start</code>, <code>restart</code>, <code>stop</code>, and <code>uninstall</code>.</p>
<p>Run to start the stopped daemon (requires <code>sudo</code> or admin privileges):</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --daemon start
</code></pre>
<p>Run to restart the running daemon (requires <code>sudo</code> or admin privileges):</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --daemon restart
</code></pre>
<p>Run to stop the running daemon (requires <code>sudo</code> or admin privileges):</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --daemon stop
</code></pre>
<p>Run to stop and uninstall the running daemon (requires <code>sudo</code> or admin privileges):</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --daemon uninstall
</code></pre>
<p>Run to check for logs and errors:</p>
<pre class="prettyprint source lang-bash"><code>$ oneuptime-server-monitor --daemon logs
$ oneuptime-server-monitor --daemon errors
</code></pre>
<p>A complete log of the daemon can be found in these directories:</p>
<pre class="prettyprint source lang-bash"><code># linux logs
/var/log/OneUptime Server Monitor/oneuptimeservermonitor.log
/var/log/OneUptime Server Monitor/oneuptimeservermonitor_error.log
# mac logs
/Library/Logs/OneUptime Server Monitor/oneuptimeservermonitor.log
/Library/Logs/OneUptime Server Monitor/oneuptimeservermonitor_error.log
# windows logs
<service_path>/oneuptimeservermonitor.out.log
<service_path>/oneuptimeservermonitor.err.log
</code></pre>
<p>NB:- In most cases, <code>sudo</code> or admin privileges are required to run the shell as a daemon.</p>
<h3>Services</h3>
<h4>Linux</h4>
<p>Services created by the daemon are like other services running on Linux. It can be started/stopped using <code>service oneuptimeservermonitor start</code> or <code>service oneuptimeservermonitor stop</code> and logs are available. This file is created in /etc/init.d by default. Additionally, log files are generated in /var/log/OneUptime Server Monitor/ for general output and error logging.</p>
<h4>Mac</h4>
<p>Services created by the daemon are similar to most other services running on OSX. It can be stopped from the Activity Monitor and make logs available in the Console app. A plist file is created in /Library/LaunchDaemons by default. Additionally, two log files are generated in /Library/Logs/OneUptime Server Monitor/ for general output and error logging.</p>
<h4>Windows</h4>
<p>Services created by the daemon are similar to most other services running on Windows. It can be started/stopped from the windows service utility, via NET START or NET STOP commands, or even managed using the sc utility. A directory called daemon is created and populated with oneuptimeservermonitor.exe and oneuptimeservermonitor.xml. The XML file is a configuration for the executable. Additionally, logs are created in this directory (which are viewable in the Event log).</p>
<p><a name="module_api"></a></p>
<h2>Programmatic Usage</h2>
<pre class="prettyprint source lang-javascript"><code>const serverMonitor = require('oneuptime-server-monitor');
const monitor = serverMonitor({
projectId: '5d64d59cae46131619708309',
// (optional) If you have installed OneUptime Platform on your server,
// this should be your API URL
apiUrl: 'https://oneuptime.com/api',
apiKey: 'b02798c0-c898-11e9-9f14-4963dc67e2ab',
monitorId: '5d7775e9f14a531364ba6917',
interval: '*/5 * * * * *', // cron job interval
timeout: 10000, // milliseconds
});
monitor.start();
</code></pre>
<h2>Known Issues</h2>
<h4>Windows Temperature</h4>
<p><code>wmic</code> - is used to determine temperature and sometimes needs to be run with admin privileges. So if you do not get any values, try to run it again with according privileges. If you still do not get any values, your system might not support this feature.</p>
<h4>Linux Temperature</h4>
<p>In some cases you may need to install the linux <code>sensors</code> package to be able to measure temperature e.g. on DEBIAN based systems run <code>sudo apt-get install lm-sensors</code>.</p>
<p>See <a href="https://www.npmjs.com/package/systeminformation#known-issues">system information</a> to learn more.</p>
<h2>API Documentation</h2>
<p>Main API to authenticate user, start and stop server monitoring.</p>
<p><strong>See</strong></p>
<ul>
<li>module:helpers</li>
<li>module:logger</li>
</ul>
<p><strong>Author</strong>: HackerBay, Inc.</p>
<ul>
<li><a href="#oneuptime-server-monitor">OneUptime Server Monitor</a>
<ul>
<li><a href="#installation">Installation</a></li>
<li><a href="#cli-usage">CLI Usage</a></li>
<li><a href="#basic-usage">Basic Usage</a></li>
<li><a href="#api-documentation">API Documentation</a>
<ul>
<li><a href="#moduleexportsconfig-apiurl-apikey-monitorid--object-">module.exports(config, apiUrl, apiKey, monitorId) ⇒ <code>Object</code> ⏏</a>
<ul>
<li><a href="#moduleexportspingprojectid-monitorid-apiurl-apikey-interval--object">module.exports~ping(projectId, monitorId, apiUrl, apiKey, interval) ⇒ <code>Object</code></a></li>
<li><a href="#moduleexportsstartid--object--number">module.exports~start(id) ⇒ <code>Object</code> | <code>number</code></a></li>
<li><a href="#moduleexportsstop--object">module.exports~stop() ⇒ <code>Object</code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p><a name="exp_module_api--module.exports"></a></p>
<h3>module.exports(config, apiUrl, apiKey, monitorId) ⇒ <code>Object</code> ⏏</h3>
<p>Authenticate user and get list of server monitors if monitor id not provided.</p>
<p><strong>Kind</strong>: Exported function
<strong>Returns</strong>: <code>Object</code> - The server monitor handlers.</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>config</td>
<td><code>string</code> | <code>Object</code></td>
<td>The project id or config of the project.</td>
</tr>
<tr>
<td>apiUrl</td>
<td><code>string</code></td>
<td>The url of the api.</td>
</tr>
<tr>
<td>apiKey</td>
<td><code>string</code></td>
<td>The api key of the project.</td>
</tr>
<tr>
<td>monitorId</td>
<td><code>string</code> | <code>function</code></td>
<td>The monitor id or function to resolve monitor id of the server monitor.</td>
</tr>
</tbody>
</table>
<p><a name="module_api--module.exports..ping"></a></p>
<h4>module.exports~ping(projectId, monitorId, apiUrl, apiKey, interval) ⇒ <code>Object</code></h4>
<p>Get system information at interval and upload to server.</p>
<p><strong>Kind</strong>: inner method of <a href="#exp_module_api--module.exports"><code>module.exports</code></a>
<strong>Returns</strong>: <code>Object</code> - The ping server cron job.</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>projectId</td>
<td><code>string</code></td>
<td></td>
<td>The project id of the project.</td>
</tr>
<tr>
<td>monitorId</td>
<td><code>string</code></td>
<td></td>
<td>The monitor id of the server monitor.</td>
</tr>
<tr>
<td>apiUrl</td>
<td><code>string</code></td>
<td></td>
<td>The url of the api.</td>
</tr>
<tr>
<td>apiKey</td>
<td><code>string</code></td>
<td></td>
<td>The api key of the project.</td>
</tr>
<tr>
<td>interval</td>
<td><code>string</code></td>
<td><code>"* * * * *"</code></td>
<td>The interval of the cron job, must ba a valid cron format.</td>
</tr>
</tbody>
</table>
<p><a name="module_api--module.exports..start"></a></p>
<h4>module.exports~start(id) ⇒ <code>Object</code> | <code>number</code></h4>
<p>Start server monitor.</p>
<p><strong>Kind</strong>: inner method of <a href="#exp_module_api--module.exports"><code>module.exports</code></a>
<strong>Returns</strong>: <code>Object</code> | <code>number</code> - The ping server cron job or the error code.</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td><code>string</code></td>
<td>The monitor id of the server monitor.</td>
</tr>
</tbody>
</table>
<p><a name="module_api--module.exports..stop"></a></p>
<h4>module.exports~stop() ⇒ <code>Object</code></h4>
<p>Stop server monitor.</p>
<p><strong>Kind</strong>: inner method of <a href="#exp_module_api--module.exports"><code>module.exports</code></a>
<strong>Returns</strong>: <code>Object</code> - The ping server cron job.</p></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-api.html">api</a></li><li><a href="module-config.html">config</a></li><li><a href="module-helpers.html">helpers</a></li><li><a href="module-logger.html">logger</a></li><li><a href="module-server-monitor.html">server-monitor</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Jan 08 2021 00:53:57 GMT+0100 (West Africa Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>