Measurement Cookbook
This guide provides a list of quick snippets that can be used to report various resource allocations to Nine9s.
To learn more about Measures, see the Measurement Quickstart.
Disk Usage
You can use the df
tool to get the percentage of disk usage for each mounted drive on your server. Then you can use the following command to get the disk usage percentage for a given disk.
$ df -h | grep {disk name} | awk '{print $5}'
Then simply post that data to Nine9s like so:
$ curl -X POST http://nine9s.cloud/{measure url}}
-H "X-Secret: {secret}"
-d `df -h | grep {disk name} | awk '{print (1 - $4/$2) * 100}'`
Add it as a cron-job and you're set! This job runs every minute and sends the current disk usage percentage to Nine9s.
The measure URL and measure secret are both available when you create a measure.
* * * * * curl -X POST http://nine9s.cloud/{measure url} -H "X-Secret: {secret}" -d `df -h | grep {disk name} | awk '{print $5}'`
Once this is done, you just need to configure Nine9s to watch this measure for some limit. Consider setting a criteria like this:
Entire request body
is less than 90
This will ensure that you get notifications when your server's disk usage exceeds 90%.
Memory Usage
Using a simple expression, we can get the current memory usage as a percentage of total memory.
free -m | grep Mem | awk '{print $3/$2 * 100}'
Then simply post that data to Nine9s like so:
$ curl -X POST http://nine9s.cloud/{measure url}
-H "X-Secret: {secret}"
-d `free -m | grep Mem | awk '{print $3/$2 * 100}'`
Add it as a cron-job and you're set! This job runs every minute and sends the current disk usage percentage to Nine9s.
The measure URL and measure secret are both available when you create a measure.
* * * * * curl -X POST http://nine9s.cloud/{measure url} -H "X-Secret: {secret}" -d `free -m | grep Mem | awk '{print $3/$2 * 100}'`