Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkramny committed May 19, 2016
1 parent 0cecccc commit 6e9f544
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ func (monitor *CachetMonitor) makeRequest(requestType string, url string, reqBod
}

// SendMetric sends lag metric point
func (monitor *CachetMonitor) SendMetric(metricID int, delay int64) error {
if metricID <= 0 {
func (monitor *Monitor) SendMetric(delay int64) error {
if monitor.MetricID == 0 {
return nil
}

jsonBytes, _ := json.Marshal(&map[string]interface{}{
"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 {
return fmt.Errorf("Could not log data point!\n%v\n", err)
}
Expand Down
2 changes: 1 addition & 1 deletion monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (monitor *Monitor) Tick() {
monitor.AnalyseData()

if isUp == true && monitor.MetricID > 0 {
monitor.config.SendMetric(monitor.MetricID, lag)
monitor.SendMetric(lag)
}
}

Expand Down
46 changes: 31 additions & 15 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,50 @@ 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>",
"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": [{
"name": "Name of your monitor", // required, friendly name for your monitor
"url": "Ping URL", // required, url to probe
"method": "get", // optional, http method (defaults GET)
"strict_tls": true, // self-signed ssl certificate
"interval": 10, // seconds between checks
"metric_id": <metric id>, // post lag to cachet metric (graph)
"component_id": <component id>, // post incidents to this component
"threshold": 80, // If % of downtime is over this threshold, open an incident
"expected_status_code": 200, // optional, expected status code (either status code or body must be supplied)
"expected_body": "P.*NG" // optional, regular expression
// 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",
// self-signed ssl certificate
"strict_tls": true,
// seconds between checks
"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
"log_path": "" // optional, defaults to stdout
// optional, system name to identify bot (uses hostname by default)
"system_name": "",
// optional, defaults to stdout
"log_path": ""
}
```

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))
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:
Expand Down

0 comments on commit 6e9f544

Please sign in to comment.