A micro server reporting simple information on its (Linux) host machine:
{ "memory_used": 0.81, "disk_used": 0.49, "cpu_used": 0.13 }
Those are fractions of the total resources available.
git clone https://github.com/maxlath/os-health-report.git
cd os-health-report
npm install
- As a normal process
npm start
# Check that everything is fine
curl -k https://localhost:1112
- As a daemon handled by systemd
# Uses sudo so you will be prompt for your password
npm run add-to-systemd
sudo systemctl start os-health-report
# Check that everything is fine
sudo systemctl status os-health-report
curl -k https://localhost:1112
curl -k https://localhost:1112
output:
{ "memory_used": 0.81, "disk_used": 0.49, "cpu_used": 0.13 }
cpu_used
is the 15 minutes CPU average load.
curl -k 'https://localhost:1112?services=couchdb|inventaire|nginx'
output:
{
"memory_used": 0.35,
"disk_used": 0.48,
"cpu_used": 0.04,
"services": {
"couchdb": "active",
"inventaire": "inactive",
"nginx": "active"
}
}
curl -k 'https://localhost:1112?docker=elasticsearch|lyrasis/blazegraph|585c7be23ac3|7ea426b95a78'
output:
{
"memory_used": 0.35,
"disk_used": 0.48,
"cpu_used": 0.04,
"docker": {
"elasticsearch": "active",
"lyrasis/blazegraph": "inactive",
"585c7be23ac3": "active",
"7ea426b95a78": "inactive"
}
}
The server uses self-signed certificates to run with HTTPS, thus the -k
option passed to curl so that it ignores the TLS error it will get.
You can do the same within Node using process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
, or by disabling it per request: for instance with the request lib, it can be done by passing a flag:
request({ method, url, rejectUnauthorized: false })
If for some reason, you prefer using HTTP, override the config by setting a different protocol in ./config/local.js
echo "module.exports = { protocol: 'http' }" > ./config/local.js