Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cliffano/health
Resource health status checking library
https://github.com/cliffano/health
checker cli http nodejs
Last synced: 21 days ago
JSON representation
Resource health status checking library
- Host: GitHub
- URL: https://github.com/cliffano/health
- Owner: cliffano
- License: mit
- Created: 2013-04-19T09:53:28.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T13:08:29.000Z (over 1 year ago)
- Last Synced: 2024-10-10T19:45:31.600Z (about 1 month ago)
- Topics: checker, cli, http, nodejs
- Language: JavaScript
- Homepage:
- Size: 819 KB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://github.com/cliffano/health/workflows/CI/badge.svg)](https://github.com/cliffano/health/actions?query=workflow%3ACI)
[![Dependencies Status](https://img.shields.io/david/cliffano/health.svg)](http://david-dm.org/cliffano/health)
[![Coverage Status](https://img.shields.io/coveralls/cliffano/health.svg)](https://coveralls.io/r/cliffano/health?branch=master)
[![Published Version](https://img.shields.io/npm/v/health.svg)](http://www.npmjs.com/package/health)
[![Vulnerabilities Status](https://snyk.io/test/github/cliffano/health/badge.svg)](https://snyk.io/test/github/cliffano/health)
[![npm Badge](https://nodei.co/npm/health.png)](http://npmjs.org/package/health)Health
------Health is a resource health status checking library.
This is handy when you want to check the status of multiple resources using a simple configuration file. For example, if your application requires a web service and a MongoDB database to be available, Health module can monitor those resources and return status ok/fail against each resource along with the response time.
It also supports result caching via ttl attribute of each resource, which is handy when you want to monitor multiple resources at a different interval or to reduce the load on certain resources.
Installation
------------npm install -g health
Usage
-----// use default formatter
var health = new (require('health'))(
setup: [ { name: 'google', uri: 'http://google.com' } ]
);// use built-in formatter (html, text, or xml)
var health = new (require('health'))(
setup: [ { name: 'google', uri: 'http://google.com' } ],
formatter: 'html'
);// use custom formatter function
var health = new (require('health'))(
setup: [ { name: 'google', uri: 'http://google.com' } ],
formatter: function (results) {
return results.join('|');
}
);// check resources
health.check(function (err, result) {
});From command-line:
health -f html -s health.json check
Configuration
-------------Health setup is just a simple JSON:
[
{ "name": "Google", "uri", "http://google.com", "statusCodes": [ 200 ] },
{ "name": "GMail", "uri", "https://mail.google.com", "timeout": "1000" },
{ "name": "MongoDB", "uri": "mongodb://somehost:27017", "timeout": 200, "ttl": 30000 },
{ "name": "Temp", "uri": "file:///tmp", "mode": "777", "ttl": 360000 }
]
Attribute
Type
Description
Protocol
Usage
Default
Example
uri
string
Resource URI to check
All
Mandatory
mongodb://somehost:27017
name
string
Resource name
All
Optional
someapp
ttl
number
Cache time to live in milliseconds
All
Optional
30000
lenient
boolean
Replace fail or error with warning
All
Optional
false
true, false
group
string
Resource group name, status is set to warning when there's at least one group member having success/warning status, group members status is set to fail/error only when none of the group members has success/warning status
All
Optional
databases, apps, datacenter1
timeout
number
Request/connect timeout in milliseconds
http, https, mongodb
Optional
500
statusCode
array
An array of acceptable response HTTP status codes
http, https
Optional
[ 200, 409 ]
text
array
An array of all texts that must exist in response body, any of them does not exist means status FAIL
http, https
Optional
[ 'foo', 'bar' ]
mode
string
3-digit file/directory mode
file
Optional
777, 644
Colophon
--------[Developer's Guide](https://cliffano.github.io/developers_guide.html#nodejs)
Build reports:
* [Code complexity report](https://cliffano.github.io/health/complexity/plato/index.html)
* [Unit tests report](https://cliffano.github.io/health/test/buster.out)
* [Test coverage report](https://cliffano.github.io/health/coverage/buster-istanbul/lcov-report/lib/index.html)
* [API Documentation](https://cliffano.github.io/health/doc/dox-foundation/index.html)