This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
cachet-monitor/README.md

77 lines
2.4 KiB
Markdown
Raw Normal View History

2020-02-27 20:25:42 +00:00
# [cachet-monitor](https://git.sp-codes.de/samuel-p/cachet-monitor)
[![Build Status](https://ci.sp-codes.de/api/badges/samuel-p/cachet-monitor/status.svg)](https://ci.sp-codes.de/samuel-p/cachet-monitor) ![Docker Pulls](https://img.shields.io/docker/pulls/samuelph/cachet-monitor)
2020-02-26 22:56:42 +00:00
2020-02-27 21:39:51 +00:00
Simple monitor to watch URLs (`HTTP`) or ports (`TCP`, `UDP`) and update [Cachet](https://cachethq.io/) status.
2020-02-26 22:56:42 +00:00
## Configuration
cachet-monitor can monitor a list of services. Therefore it requires to setup all services in `./data/config.json`. __The id of each service has to match the cachet component id you want to update!__ You also can specify a custom timeout in seconds for each service. If the service timeout is passed the status will be `SLOW` (Cachet `Performance Issues`).
2020-02-27 20:25:42 +00:00
You also need to specify the interval (`cron`) your services should be checked. You can use the cron syntax from [`node-cron`](https://www.npmjs.com/package/node-cron). You also have to set `offlineTimeUntilMajor` which is the offline time in seconds until the state of an offline service turns from partial to major outage. Finally you need to provide the information to your cachet instance (`api` and `token`). The "global" `timeout` value will be used as a final request timeout for each service. If the check request does not complete in this time the service will be marked as offline.
2020-02-27 20:25:42 +00:00
2020-02-26 22:56:42 +00:00
Example:
```json
{
"services": [
{
"id": 1,
"type": "HTTP",
"url": "https://sp-codes.de",
"timeout": 60
},
{
"id": 2,
"type": "TCP",
"host": "sp-codes.de",
"port": 443,
"timeout": 60
}
],
"cron": "0 * * * * *",
"timeout": 30,
2020-02-26 22:56:42 +00:00
"offlineTimeUntilMajor": 300,
"api": "https://<cachet-url>/api/v1",
"token": "<user-token>"
}
```
2020-02-27 20:25:42 +00:00
## Run with docker
You can use the docker image [`samuelph/cachet-monitor`](https://hub.docker.com/r/samuelph/cachet-monitor) and mount a volume to `/monitor/data` to persist cache and config:
```bash
2020-02-27 21:54:05 +00:00
docker run -v /your/path/monitor/data:/monitor/data samuelph/cachet-monitor
2020-02-27 20:25:42 +00:00
```
You also can use it in `docker-compose.yml`:
```yaml
services:
monitor:
image: samuelph/cachet-monitor
restart: always
volumes:
2020-02-27 21:54:05 +00:00
- /your/path/monitor:/monitor/data
2020-02-27 20:25:42 +00:00
```
## Run from source
1. clone the repo
```bash
git clone https://git.sp-codes.de/samuel-p/cachet-monitor.git
```
2. install dependencies
```bash
npm install
```
3. run
```bash
npm run start
```