Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mirgj/go-service-check
Small utility to check whether or not a given endpoint is up. Supports multiple notification channels
https://github.com/mirgj/go-service-check
go golang service-checker
Last synced: about 1 month ago
JSON representation
Small utility to check whether or not a given endpoint is up. Supports multiple notification channels
- Host: GitHub
- URL: https://github.com/mirgj/go-service-check
- Owner: mirgj
- License: mit
- Created: 2019-12-11T14:08:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-11T14:47:19.000Z (about 5 years ago)
- Last Synced: 2024-10-20T09:28:16.500Z (2 months ago)
- Topics: go, golang, service-checker
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-service-check
Small utility to check whether or not a given endpoint is up. Supports multiple notification channels
- console
- SMTP
- SendGrid## Configuration
Based on the notification channel that you want to use to send notifications you're required to set the following ENV variables to make it work:
### Console
No configuration required
### SMTP
The following ENV are required:
```
SMTP_SERVER=
SMTP_USER=
SMTP_PASSWORD=
SMTP_PORT=25
```### SendGrid
The following ENV are required:
```
SENDGRID_API_KEY=
```### Service to be checked
The utility uses a `db.json` which needs to have the following structure to:
```json
{
"sites": [
{
"url": "https://google.com",
"name": "Google",
"delay": 5,
"notifier": "console"
}
]
}
```The array contains a structure with the following fields:
- `url`: URL and/or API endpoint to check (a GET HTTP request will be performed to verify the service availability)
- `name`: Service name to be used as alias for the given URL
- `delay`: Defines the seconds between one ping and another
- `notifier`: Define the type of notifier to be used (allowed values: `console`, `sendgrid`, `smtp`)In case the **notifier** is `sendgrid` or `smtp` the following options are required on the specific element with the given notifier:
```json
{
"options": {
"from": "[email protected]",
"to": "[email protected]",
"body": "{{name}} ({{url}}) was not reachable the last {{delay}} seconds!",
"subject": "{{name}} is down!"
}
}
```The `body` and `subject` can contain the following placeholder that will be replaced with the actual value:
- `{{url}}`: replaced with the service URL
- `{{delay}}`: replaced with the configured delay
- `{{name}}`: replaced with the service name### Full configuration file
Example of a configuration file with all the given options:
```json
{
"sites": [
{
"url": "https://google.com",
"name": "Google",
"delay": 5,
"notifier": "console"
},
{
"url": "https://facebook.com",
"name": "Facebook",
"delay": 5,
"notifier": "sendgrid",
"options": {
"from": "[email protected]",
"to": "[email protected]",
"body": "{{name}} ({{url}}) was not reachable the last {{delay}} seconds!",
"subject": "{{name}} is down!"
}
},
{
"url": "https://stackoverflow.com",
"name": "Stackoverflow",
"delay": 5,
"notifier": "smtp",
"options": {
"from": "[email protected]",
"to": "[email protected]",
"body": "{{name}} ({{url}}) was not reachable the last {{delay}} seconds!",
"subject": "{{name}} is down!"
}
}
]
}
```