https://github.com/aleasoluciones/gochecks
Library for checking services health and publish events
https://github.com/aleasoluciones/gochecks
golang library
Last synced: 5 months ago
JSON representation
Library for checking services health and publish events
- Host: GitHub
- URL: https://github.com/aleasoluciones/gochecks
- Owner: aleasoluciones
- License: mit
- Created: 2015-02-14T09:34:00.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-05-18T12:16:59.000Z (about 3 years ago)
- Last Synced: 2024-06-19T09:54:11.247Z (about 2 years ago)
- Topics: golang, library
- Language: Go
- Homepage:
- Size: 151 KB
- Stars: 3
- Watchers: 7
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gochecks
[](https://github.com/aleasoluciones/gochecks/actions/workflows/ci.yml)
[](http://godoc.org/github.com/aleasoluciones/gochecks)
[](https://github.com/aleasoluciones/http2amqp/blob/master/LICENSE)
gochecks package provides utilities to check services health and publish events.
It is written fully in Go.
It includes:
* checks scheduler
* add checks results
* various checks:
* Tcp port
* ICMP/Ping
* http
* snmp get
* rabbitmq queue len
* Arris C4 CMTS temp
* JunOS devices cpu usage and temp
* MySQL connectivity
* Jenkins jobs status
* Publishers:
* RabbitMQ / AMQP
## Install
```
go get github.com/aleasoluciones/gochecks
```
## Sample code
Create a Checks Engine with two publisher (rabbit and log)
```
checkEngine := gochecks.NewCheckEngine([]gochecks.CheckPublisher{
gochecks.RabbitMqPublisher("amqp://localhost", "events"),
gochecks.NewLogPublisher(),
})
```
Add a periodic (20 seconds) http check with up to three retries, tagging the result as production and adding some attributes.
```
checkEngine.AddCheck(
gochecks.NewHttpChecker("golang", "http", "http://www.golang.org", 200).
Attributes(map[string]string{"version": "1", "network": "google"}).
Tags("production").
Retry(3, 1*time.Second),
20 * time.Second)
```
## Development
To pass the integration tests you need to execute a MySQL server, a Postgres server and a RabbitMQ Server and export the corresponding vars.
The directory dev/ offers two scripts and an environment file to achieve this easily:
```
source dev/env_develop
dev/start_gochecks_dependencies.sh
go test -tags integration -v ./...
dev/stop_gochecks_dependencies.sh
```
## Todo
* Metric for all the checks