update readme, remove tcp/icmp
This commit is contained in:
@@ -179,14 +179,6 @@ func getConfiguration(path string) (*cachet.CachetMonitor, error) {
|
||||
var s cachet.DNSMonitor
|
||||
err = mapstructure.Decode(rawMonitor, &s)
|
||||
t = &s
|
||||
case "icmp":
|
||||
var s cachet.ICMPMonitor
|
||||
err = mapstructure.Decode(rawMonitor, &s)
|
||||
t = &s
|
||||
case "tcp":
|
||||
var s cachet.TCPMonitor
|
||||
err = mapstructure.Decode(rawMonitor, &s)
|
||||
t = &s
|
||||
default:
|
||||
logrus.Errorf("Invalid monitor type (index: %d) %v", index, monType)
|
||||
continue
|
||||
|
||||
@@ -1,14 +1,65 @@
|
||||
api:
|
||||
# cachet url
|
||||
url: https://demo.cachethq.io/api/v1
|
||||
# cachet api token
|
||||
token: 9yMHsdioQosnyVK4iCVR
|
||||
insecure: false
|
||||
# https://golang.org/src/time/format.go#L57
|
||||
date_format: 02/01/2006 15:04:05 MST
|
||||
monitors:
|
||||
# http monitor example
|
||||
- name: google
|
||||
target: https://google.com
|
||||
threshold: 80
|
||||
# test url
|
||||
target: http://localhost:2000/ping
|
||||
# strict certificate checking for https
|
||||
strict: true
|
||||
# HTTP method
|
||||
method: POST
|
||||
|
||||
# set to update component (either component_id or metric_id are required)
|
||||
component_id: 1
|
||||
interval: 10
|
||||
timeout: 5
|
||||
# set to post lag to cachet metric (graph)
|
||||
metric_id: 4
|
||||
|
||||
# custom templates (see readme for details)
|
||||
template:
|
||||
investigating:
|
||||
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
|
||||
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
|
||||
fixed:
|
||||
subject: "I HAVE BEEN FIXED"
|
||||
|
||||
# seconds between checks
|
||||
interval: 1
|
||||
# seconds for timeout
|
||||
timeout: 1
|
||||
# If % of downtime is over this threshold, open an incident
|
||||
threshold: 80
|
||||
|
||||
# custom HTTP headers
|
||||
headers:
|
||||
Authorization: Basic <hash>
|
||||
# expected status code (either status code or body must be supplied)
|
||||
expected_status_code: 200
|
||||
strict: true
|
||||
# regex to match body
|
||||
expected_body: "P.*NG"
|
||||
# dns monitor example
|
||||
- name: dns
|
||||
# fqdn
|
||||
target: matej.me.
|
||||
# question type (A/AAAA/CNAME/...)
|
||||
question: mx
|
||||
type: dns
|
||||
# set component_id/metric_id
|
||||
component_id: 2
|
||||
# poll every 1s
|
||||
interval: 1
|
||||
timeout: 1
|
||||
# custom DNS server (defaults to system)
|
||||
dns: 8.8.4.4:53
|
||||
answers:
|
||||
# exact/regex check
|
||||
- regex: [1-9] alt[1-9].aspmx.l.google.com.
|
||||
- exact: 10 aspmx2.googlemail.com.
|
||||
- exact: 1 aspmx.l.google.com.
|
||||
- exact: 10 aspmx3.googlemail.com.
|
||||
5
icmp.go
5
icmp.go
@@ -1,5 +0,0 @@
|
||||
package cachet
|
||||
|
||||
type ICMPMonitor struct {
|
||||
AbstractMonitor `mapstructure:",squash"`
|
||||
}
|
||||
@@ -28,7 +28,7 @@ type AbstractMonitor struct {
|
||||
Name string
|
||||
Target string
|
||||
|
||||
// (default)http, tcp, dns, icmp
|
||||
// (default)http / dns
|
||||
Type string
|
||||
Strict bool
|
||||
|
||||
|
||||
7
monitor_test.go
Normal file
7
monitor_test.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package cachet
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAnalyseData(t *testing.T) {}
|
||||
193
readme.md
193
readme.md
@@ -1,100 +1,155 @@
|
||||

|
||||
|
||||
Features
|
||||
--------
|
||||
## Features
|
||||
|
||||
- [x] Creates & Resolves Incidents
|
||||
- [x] Check URLs by response code and/or body contents
|
||||
- [x] Posts monitor lag to cachet graphs
|
||||
- [x] HTTP Checks (body/status code)
|
||||
- [x] DNS Checks
|
||||
- [x] Updates Component to Partial Outage
|
||||
- [x] Updates Component to Major Outage if already in Partial Outage (works well with distributed monitoring)
|
||||
- [x] Updates Component to Major Outage if already in Partial Outage (works with distributed monitors)
|
||||
- [x] Can be run on multiple servers and geo regions
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
## Example Configuration
|
||||
|
||||
```
|
||||
{
|
||||
// URL for the API. Note: Must end with /api/v1
|
||||
"api_url": "https://<cachet domain>/api/v1",
|
||||
// Your API token for Cachet
|
||||
"api_token": "<cachet api token>",
|
||||
// optional, false default, set if your certificate is self-signed/untrusted
|
||||
"insecure_api": false,
|
||||
"monitors": [{
|
||||
// required, friendly name for your monitor
|
||||
"name": "Name of your monitor",
|
||||
// required, url to probe
|
||||
"url": "Ping URL",
|
||||
// optional, http method (defaults GET)
|
||||
"method": "get",
|
||||
// optional, http Headers to add (default none)
|
||||
"headers": [
|
||||
// specify Name and Value of Http-Header, eg. Authorization
|
||||
{ "name": "Authorization", "value": "Basic <hash>" }
|
||||
],
|
||||
// self-signed ssl certificate
|
||||
"strict_tls": true,
|
||||
// seconds between checks
|
||||
"interval": 10,
|
||||
// seconds for http timeout
|
||||
"timeout": 5,
|
||||
// post lag to cachet metric (graph)
|
||||
// note either metric ID or component ID are required
|
||||
"metric_id": <metric id>,
|
||||
// post incidents to this component
|
||||
"component_id": <component id>,
|
||||
// If % of downtime is over this threshold, open an incident
|
||||
"threshold": 80,
|
||||
// optional, expected status code (either status code or body must be supplied)
|
||||
"expected_status_code": 200,
|
||||
// optional, regular expression to match body content
|
||||
"expected_body": "P.*NG"
|
||||
}],
|
||||
// optional, system name to identify bot (uses hostname by default)
|
||||
"system_name": "",
|
||||
// optional, defaults to stdout
|
||||
"log_path": ""
|
||||
}
|
||||
```yaml
|
||||
api:
|
||||
# cachet url
|
||||
url: https://demo.cachethq.io/api/v1
|
||||
# cachet api token
|
||||
token: 9yMHsdioQosnyVK4iCVR
|
||||
insecure: false
|
||||
# https://golang.org/src/time/format.go#L57
|
||||
date_format: 02/01/2006 15:04:05 MST
|
||||
monitors:
|
||||
# http monitor example
|
||||
- name: google
|
||||
# test url
|
||||
target: http://localhost:2000/ping
|
||||
# strict certificate checking for https
|
||||
strict: true
|
||||
# HTTP method
|
||||
method: POST
|
||||
|
||||
# set to update component (either component_id or metric_id are required)
|
||||
component_id: 1
|
||||
# set to post lag to cachet metric (graph)
|
||||
metric_id: 4
|
||||
|
||||
# custom templates (see readme for details)
|
||||
template:
|
||||
investigating:
|
||||
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
|
||||
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
|
||||
fixed:
|
||||
subject: "I HAVE BEEN FIXED"
|
||||
|
||||
# seconds between checks
|
||||
interval: 1
|
||||
# seconds for timeout
|
||||
timeout: 1
|
||||
# If % of downtime is over this threshold, open an incident
|
||||
threshold: 80
|
||||
|
||||
# custom HTTP headers
|
||||
headers:
|
||||
Authorization: Basic <hash>
|
||||
# expected status code (either status code or body must be supplied)
|
||||
expected_status_code: 200
|
||||
# regex to match body
|
||||
expected_body: "P.*NG"
|
||||
# dns monitor example
|
||||
- name: dns
|
||||
# fqdn
|
||||
target: matej.me.
|
||||
# question type (A/AAAA/CNAME/...)
|
||||
question: mx
|
||||
type: dns
|
||||
# set component_id/metric_id
|
||||
component_id: 2
|
||||
# poll every 1s
|
||||
interval: 1
|
||||
timeout: 1
|
||||
# custom DNS server (defaults to system)
|
||||
dns: 8.8.4.4:53
|
||||
answers:
|
||||
# exact/regex check
|
||||
- regex: [1-9] alt[1-9].aspmx.l.google.com.
|
||||
- exact: 10 aspmx2.googlemail.com.
|
||||
- exact: 1 aspmx.l.google.com.
|
||||
- exact: 10 aspmx3.googlemail.com.
|
||||
```
|
||||
|
||||
Installation
|
||||
------------
|
||||
## Installation
|
||||
|
||||
1. Download binary from [release page](https://github.com/CastawayLabs/cachet-monitor/releases)
|
||||
2. Create your configuration ([example](https://raw.githubusercontent.com/CastawayLabs/cachet-monitor/master/example.config.json))
|
||||
3. `cachet-monitor -c /etc/cachet-monitor.config.json`
|
||||
2. Create a configuration
|
||||
3. `cachet-monitor -c /etc/cachet-monitor.yaml`
|
||||
|
||||
pro tip: run in background using `nohup cachet-monitor 2>&1 > /var/log/cachet-monitor.log &`
|
||||
|
||||
```
|
||||
Usage of cachet-monitor:
|
||||
-c="/etc/cachet-monitor.config.json": Config path
|
||||
-log="": Log path
|
||||
-name="": System Name
|
||||
Usage:
|
||||
cachet-monitor (-c PATH | --config PATH) [--log=LOGPATH] [--name=NAME] [--immediate]
|
||||
cachet-monitor -h | --help | --version
|
||||
cachet-monitor print-config
|
||||
|
||||
Arguments:
|
||||
PATH path to config.json
|
||||
LOGPATH path to log output (defaults to STDOUT)
|
||||
NAME name of this logger
|
||||
|
||||
Examples:
|
||||
cachet-monitor -c /root/cachet-monitor.json
|
||||
cachet-monitor -c /root/cachet-monitor.json --log=/var/log/cachet-monitor.log --name="development machine"
|
||||
|
||||
Options:
|
||||
-c PATH.json --config PATH Path to configuration file
|
||||
-h --help Show this screen.
|
||||
--version Show version
|
||||
--immediate Tick immediately (by default waits for first defined interval)
|
||||
print-config Print example configuration
|
||||
|
||||
Environment varaibles:
|
||||
CACHET_API override API url from configuration
|
||||
CACHET_TOKEN override API token from configuration
|
||||
CACHET_DEV set to enable dev logging
|
||||
```
|
||||
|
||||
Environment variables
|
||||
---------------------
|
||||
## Templates
|
||||
|
||||
| Name | Example Value | Description |
|
||||
| ------------ | ------------------------------ | --------------------------- |
|
||||
| CACHET_API | http://demo.cachethq.io/api/v1 | URL endpoint for cachet api |
|
||||
| CACHET_TOKEN | APIToken123 | API Authentication token |
|
||||
| CACHET_DEV | 1 | Strips logging |
|
||||
This package makes use of [`text/template`](https://godoc.org/text/template).
|
||||
|
||||
Vision and goals
|
||||
----------------
|
||||
The following variables are available:
|
||||
|
||||
| Root objects |
|
||||
| ------------- | -----------------
|
||||
| `.SystemName` | system name
|
||||
| `.API` | `api` object from configuration
|
||||
| `.Monitor` | `monitor` object from configuration
|
||||
| `.now` | formatted date string
|
||||
|
||||
| Monitor variables |
|
||||
| ------------------ |
|
||||
| `.Name` |
|
||||
| `.Target` |
|
||||
| `.Type` |
|
||||
| `.Strict` |
|
||||
| `.MetricID` |
|
||||
| ... |
|
||||
|
||||
All monitor variables are available from `monitor.go`
|
||||
|
||||
## Vision and goals
|
||||
|
||||
We made this tool because we felt the need to have our own monitoring software (leveraging on Cachet).
|
||||
The idea is a stateless program which collects data and pushes it to a central cachet instance.
|
||||
|
||||
This gives us power to have an army of geographically distributed loggers and reveal issues in both latency & downtime on client websites.
|
||||
|
||||
Package usage
|
||||
-------------
|
||||
## Package usage
|
||||
|
||||
When using `cachet-monitor` as a package in another program, you should follow what `cli/main.go` does. It is important to call `ValidateConfiguration` on `CachetMonitor` and all the monitors inside.
|
||||
When using `cachet-monitor` as a package in another program, you should follow what `cli/main.go` does. It is important to call `Validate` on `CachetMonitor` and all the monitors inside.
|
||||
|
||||
[API Documentation](https://godoc.org/github.com/CastawayLabs/cachet-monitor)
|
||||
|
||||
|
||||
15
tcp.go
15
tcp.go
@@ -1,15 +0,0 @@
|
||||
package cachet
|
||||
|
||||
type TCPMonitor struct {
|
||||
AbstractMonitor `mapstructure:",squash"`
|
||||
|
||||
// same as output from net.JoinHostPort
|
||||
// defaults to parsed config from /etc/resolv.conf when empty
|
||||
DNSServer string
|
||||
|
||||
// Will be converted to FQDN
|
||||
Domain string
|
||||
Type string
|
||||
// expected answers (regex)
|
||||
Expect []string
|
||||
}
|
||||
Reference in New Issue
Block a user