Skip to content

A micro server reporting simple information on its (Linux) host machine

Notifications You must be signed in to change notification settings

maxlath/os-health-report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

os-health-report

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.

Summary

Installation

git clone https://github.com/maxlath/os-health-report.git
cd os-health-report
npm install

Start

  • As a normal process
npm start
# Check that everything is fine
curl -k https://localhost:1112
# 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

API

Get memory, CPU and disk used fraction

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.

Get systemd services statuses

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"
  }
}

Get docker containers statuses

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"
  }
}

Use HTTP instead of HTTPS

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

Documentation

CPU

See also

About

A micro server reporting simple information on its (Linux) host machine

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published