metrics.sh is a lightweight metrics collection and fowarding utility implemented in portable POSIX compliant shell scripts. A transparent interface based on hooks enables writing custom collectors and reporters in an elegant way.
metrics.sh has been tested on Ubuntu 14.04 and Mac OS X but is supposed to run on most Unix-like operating systems. Some of the provided metrics require [procfs](http://en.wikipedia.org/wiki/Procfs) to be available when running on *nix. POSIX compliancy means that metrics.sh works with minimalistic command interpreters such as [dash](http://manpages.ubuntu.com/manpages/trusty/en/man1/dash.1.html). Built-in metrics do __not__ require root privileges.
As an example, the `disk_usage` metric has a configuration variable `DISK_USAGE_MOUNTPOINT` which is set to a default value depending on the operating system metrics.sh is running on. Setting the variable before starting will overwrite it:
$ ./metrics.sh -C > metrics.ini # write configuration to metrics.ini
$ ./metrics.sh -c metrics.ini # load configuration from metrics.ini
```
By default most lines in the configuration are commented out:
```ini
;[metric network_io]
;Network traffic in kB/s.
;NETWORK_IO_INTERFACE=eth0
```
To enable a metric, simply remove the comments and modify values where needed:
```ini
[metric network_io]
;Network traffic in kB/s.
NETWORK_IO_INTERFACE=eth1
```
### Multiple metrics of the same type
Configuring and reporting multiple metrics of the same type is possible through the use of aliases:
```ini
[metric network_io:network_eth0]
NETWORK_IO_INTERFACE=eth0
[metric network_io:network_eth1]
NETWORK_IO_INTERFACE=eth1
```
`network_eth0` and `network_eth1` are aliases of the `network_io` metric with specific configurations. Data of both network interfaces will now be collected and reported independently: