Skip to content

Endpoint to expose simple machine statistics for uptime monitoring

License

Notifications You must be signed in to change notification settings

IanKulin/vitals-glimpse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vitals-glimpse

vitals-glimpse is a very simple REST API that exposes a Linux host's memory and disk usage as percentages.

The JSON returned also has status keywords for the memory and disk which makes it a good candidate for simple monitoring tools such as Uptime Kuma which can provide a binary up/down response based on the presence or absence of a keyword.

To access the endpoint in a browser, visit <server name>:10321/vitals

A sample response might be:

{
	"title": "vitals-glimpse",
	"version": 0.1,
	"mem_status": "mem_okay",
	"mem_percent": 37,
	"disk_status": "disk_okay",
	"disk_percent": 15,
	"cpu_status":"cpu_okay",
	"cpu_percent":2
}

or if the thresholds are exceeded:

{
	"title": "vitals-glimpse",
	"version": 0.1,
	"mem_status": "mem_fail",
	"mem_percent": 91,
	"disk_status": "disk_fail",
	"disk_percent": 81,
	"cpu_status":"cpu_fail",
	"cpu_percent":92
}

The thresholds for the status keywords are:

  • mem_okay - below 90% memory usage
  • disk_okay - below 80% disk usage
  • cpu_okay - below 90% cpu usage

The disk usage is based on the / root mount point

Building on M1 MacBook

  • GOARCH=amd64 GOOS=linux go build

Testing on Debian LXC

  • scp vitals-glimpse ian@ct390-test:vitals-glimpse
  • ssh ian@ct390-test 'chmod +x vitals-glimpse'
  • ssh ian@ct390-test 'nohup ./vitals-glimpse > output.log 2>&1 & echo $! > vitals-glimpse.pid'
  • 'http://ct390-test:10321/vitals"
  • ssh ian@ct390-test 'kill $(cat vitals-glimpse.pid)'

About

Endpoint to expose simple machine statistics for uptime monitoring

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages