Skip to content

razzzila-dev/golang-server-metrix-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple metrics HTTP client for Linux

GitHub license Ask Me Anything ! contributions welcome

HTTP server for Linux machines which returns the base metrics:

  • CPU
  • RAM
  • Disk

A simple proxy that makes basic authentication and returns results of execution sh calls.

Installation

Requirements:

  • Unix machine with df, free, tr, awk, grep packages and /proc/stat file
  • GoLang 1.3

Package install

Download archive and unzip it or clone this repository using git clone. Change working directory to the package root folder and run:

go mod vendor
go build

Configure

In config.yml file stored basic configurations:

  • url_prefix
  • port
  • key
Param name Description Default Examples
key API key. Currently used as an authentication mechanism. String value. Recommended length 16+. !!!SHOULD BE URI ENCODED!!! N2XMMQrt99Kk8JrT uXA4UM2EAmrY9aMp69vlfNaB69fuRjr 6VrrTePmhnDztsh W6vlfNaB
port PORT which will be listened. 32642 4034 3333 58232
url_prefix A part of URI which goes right after host and in front of API key. !!!SHOULD BE URI ENCODED!!! droplet-metrics/raz-client hidden/path

Usage

Just run built file ./golang-server-metrics-client.

Or run as service. To doing so, first change settings in the ./systemd-config.sample. Most important here is ExecStart field which points to the built file. Also you can change User field.

In main.go file on 91 line change "config.yml" to the path of the config file ("/path/to/package/root/folder/config.yml" for example). It's a hotfix for usage as service with the bug of the absolute path of the config file.

sudo cp ./systemd-config.sample /etc/systemd/system/metrics-http-client.service
sudo service metrics-http-client status
sudo service metrics-http-client restart
sudo service metrics-http-client status

TO-DO

In plans to refactor a little bit and add next functionality:

CPU

  • getFullCPUMetrics(Time) /* return all from below */
  • getAverageCPUMetric(Time)
  • getLowestCPUMetric(Time)
  • getHighestCPUMetric(Time)

CPU Each Core

  • getFullEachCoreMetrics() /* return all from below */
  • getEachCoreMetrics()
  • getEachCoreAverateMetrics(Time)
  • getEachCoreLowestMetrics(Time)
  • getEachCoreHighestMetrics(Time)

RAM

  • getAverageRAM(Time)
  • getLowestRAM(Time)
  • getHighestRAM(Time)

Add SSL.

License

MIT