Update documentation

This commit is contained in:
Matej Kramny
2016-05-19 19:18:02 +01:00
parent 0ceccccd45
commit 6e9f5440ba
3 changed files with 35 additions and 19 deletions

View File

@@ -36,8 +36,8 @@ func (monitor *CachetMonitor) makeRequest(requestType string, url string, reqBod
} }
// SendMetric sends lag metric point // SendMetric sends lag metric point
func (monitor *CachetMonitor) SendMetric(metricID int, delay int64) error { func (monitor *Monitor) SendMetric(delay int64) error {
if metricID <= 0 { if monitor.MetricID == 0 {
return nil return nil
} }
@@ -45,7 +45,7 @@ func (monitor *CachetMonitor) SendMetric(metricID int, delay int64) error {
"value": delay, "value": delay,
}) })
resp, _, err := monitor.makeRequest("POST", "/metrics/"+strconv.Itoa(metricID)+"/points", jsonBytes) resp, _, err := monitor.config.makeRequest("POST", "/metrics/"+strconv.Itoa(monitor.MetricID)+"/points", jsonBytes)
if err != nil || resp.StatusCode != 200 { if err != nil || resp.StatusCode != 200 {
return fmt.Errorf("Could not log data point!\n%v\n", err) return fmt.Errorf("Could not log data point!\n%v\n", err)
} }

View File

@@ -112,7 +112,7 @@ func (monitor *Monitor) Tick() {
monitor.AnalyseData() monitor.AnalyseData()
if isUp == true && monitor.MetricID > 0 { if isUp == true && monitor.MetricID > 0 {
monitor.config.SendMetric(monitor.MetricID, lag) monitor.SendMetric(lag)
} }
} }

View File

@@ -14,34 +14,50 @@ Configuration
``` ```
{ {
// URL for the API. Note: Must end with /api/v1
"api_url": "https://<cachet domain>/api/v1", "api_url": "https://<cachet domain>/api/v1",
// Your API token for Cachet
"api_token": "<cachet api token>", "api_token": "<cachet api token>",
"insecure_api": false, // optional, false default, set if your certificate is self-signed/untrusted // optional, false default, set if your certificate is self-signed/untrusted
"insecure_api": false,
"monitors": [{ "monitors": [{
"name": "Name of your monitor", // required, friendly name for your monitor // required, friendly name for your monitor
"url": "Ping URL", // required, url to probe "name": "Name of your monitor",
"method": "get", // optional, http method (defaults GET) // required, url to probe
"strict_tls": true, // self-signed ssl certificate "url": "Ping URL",
"interval": 10, // seconds between checks // optional, http method (defaults GET)
"metric_id": <metric id>, // post lag to cachet metric (graph) "method": "get",
"component_id": <component id>, // post incidents to this component // self-signed ssl certificate
"threshold": 80, // If % of downtime is over this threshold, open an incident "strict_tls": true,
"expected_status_code": 200, // optional, expected status code (either status code or body must be supplied) // seconds between checks
"expected_body": "P.*NG" // optional, regular expression "interval": 10,
// 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"
}], }],
"system_name": "", // optional, system name to identify bot // optional, system name to identify bot (uses hostname by default)
"log_path": "" // optional, defaults to stdout "system_name": "",
// optional, defaults to stdout
"log_path": ""
} }
``` ```
Installation Installation
------------ ------------
1. Download binary from release page 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)) 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` 3. `cachet-monitor -c /etc/cachet-monitor.config.json`
tip: run in background using `nohup cachet-monitor 2>&1 > /var/log/cachet-monitor.log &` pro tip: run in background using `nohup cachet-monitor 2>&1 > /var/log/cachet-monitor.log &`
``` ```
Usage of cachet-monitor: Usage of cachet-monitor: