https://github.com/dataman-cloud/health_checker
Common heath check services
https://github.com/dataman-cloud/health_checker
Last synced: 4 months ago
JSON representation
Common heath check services
- Host: GitHub
- URL: https://github.com/dataman-cloud/health_checker
- Owner: Dataman-Cloud
- Created: 2016-06-02T07:29:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-15T06:59:17.000Z (almost 9 years ago)
- Last Synced: 2025-01-07T21:42:57.585Z (5 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 2
- Watchers: 29
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Health Check Services
```
checker := NewHealthChecker()
```
## Redis```
checker.AddCheckPoint("redis", "localhost:6379", nil, nil)
```## MySQL
```
checker.AddCheckPoint("mysql", "root:@/mysql", nil, nil)
```## Mq
```
checker.AddCheckPoint("mq", "amqp://guest:guest@localhost:5672/", nil, nil)
```## HTTP
```
speedChecker := func() (time.Duration, error) {
beginTime := time.Now()
resp, err := http.Get("http://www.douban.com")
if err != nil {
log.Println(err)
return time.Duration(-1), nil
}
defer resp.Body.Close()if resp.StatusCode != http.StatusOK {
log.Println(resp.StatusCode)
return time.Duration(-1), nil
}return time.Now().Sub(beginTime), nil
}
checker.AddCheckPoint("http", "www.douban.com", NoopConnectionChecker, speedChecker)
```## Fire Check
```
checker.Check()
```## Result
```
{"http":{"Status":0,"Time":150404704},"mq":{"Status":0,"Time":850894},"mysql":{"Status":0,"Time":102477},"redis":{"Status":0,"Time":119484}}
```