Dusan
Guru
- Joined
- Jan 29, 2013
- Messages
- 1,165
There is a nice, but undocumented, script in FreeNAS that can check dataset's available space and email you when it's less than a defined amount: /usr/local/www/freenasUI/tools/check_space.py. It uses the email settings defined in System->Settings->Email.
You need to run it via python as it doesn’t have the executable bit set:
[PANEL]python /usr/local/www/freenasUI/tools/check_space.py -d [dataset] -t [threshold][/PANEL]
The [threshold] must have either a T, G, M, K suffix if you want to define an exact amount, or % if you want to use a percentage.
Example:
check_space.py -d [dataset] -t 100G will notify you if the available space is less than 100 gigabytes.
check_space.py -d [dataset] -t 10% will notify you if the available space is less than 10% of the dataset's capacity.
You can schedule a Cron Job to run the script as often as you want to check the available space.
I have a daily cron job setup to run this simple script to check that all pools have at least 10% of capacity available:
You need to run it via python as it doesn’t have the executable bit set:
[PANEL]python /usr/local/www/freenasUI/tools/check_space.py -d [dataset] -t [threshold][/PANEL]
The [threshold] must have either a T, G, M, K suffix if you want to define an exact amount, or % if you want to use a percentage.
Example:
check_space.py -d [dataset] -t 100G will notify you if the available space is less than 100 gigabytes.
check_space.py -d [dataset] -t 10% will notify you if the available space is less than 10% of the dataset's capacity.
You can schedule a Cron Job to run the script as often as you want to check the available space.
I have a daily cron job setup to run this simple script to check that all pools have at least 10% of capacity available:
Code:
#!/bin/sh for pool in `zpool list -Ho name` do python /usr/local/www/freenasUI/tools/check_space.py -d $pool -t 10% done