nginx module for displaying sysinfo as JSON
dynamic module support
linting, tidy up
shell linting

refs

master
browse log

clone

read-only
https://git.sr.ht/~roryrjb/ngx-system-info
read/write
git@git.sr.ht:~roryrjb/ngx-system-info

ngx-system-info

Nginx module for displaying sysinfo as JSON (Linux only).

Installation

Firstly clone this repo somewhere.

Download Nginx source:

$ wget https://nginx.org/download/nginx-VERSION.tar.gz
$ tar -xzf nginx-VERSION.tar.gz
$ cd nginx-VERSION

Build as static module:

$ ./configure --add-module=/path/to/ngx-system-info
$ make
$ sudo make install

Build as a dynamic module:


Compiles with at least the following versions of Nginx:

  • 1.6.3
  • 1.8.1
  • 1.10.3
  • 1.12.2
  • 1.14.0

Usage

Specify a location in your Nginx configuration to display the data, which will be output as JSON (application/json):

location /system_info {
  system_info;
}

Example output:

{
  "uptime": 3618,
  "totalram": 8223174656,
  "freeram": 3047157760,
  "loadavg": [
     1.29,  0.84,  0.81
  ],
  "sharedram": 166408192,
  "bufferram": 102264832,
  "totalswap": 8438935552,
  "freeswap": 8438935552,
  "procs": 857
}

Testing

There's an included Dockerfile that will build this module against various versions of Nginx and do a simple curl test against an endpoint.

$ make test