XFS, like most other modern filesystems, offers the ability to configure and use disk quotas. Usually those quotas set limits with regard to the amount of allocatable disk space or number of filesystem objects. Those limits are in most filesystems bound to users or groups of users. XFS is one of the few filesystems which offer quota limits on a per directory basis. In the case of XFS directory quotas are implemented via projects. This article introduces a new Check_MK service check to monitor the use of XFS filesystem quotas with a strong focus on directory based quotas.
For the impatient and TL;DR here is the Check_MK package of the XFS filesystem quota monitoring checks:
The sources are to be found in my Check_MK repository on GitHub
The Check_MK service check to monitor XFS filesystem quotas consists of two major parts, an agent plugin and a check plugin.
The Check_MK agent plugin named
xfs_quota is a simple Bash shell script. It calls the XFS quota administration tool
xfs_quota in order to retrieve a report of the current quota usage. The exact call to
/usr/sbin/xfs_quota -x -c 'report -p -b -i -a'
which currently reports only block and inode quotas of projects or directories on all availables XFS filesystems. An example output of the above command is:
Project quota on /srv/xfs (/dev/mapper/vg00-xfs) Blocks Inodes Project ID Used Soft Hard Warn/Grace Used Soft Hard Warn/ Grace ---------- -------------------------------------------------- -------------------------------------------------- test1 0 0 1024 00 [--------] 1 0 0 00 [--------] test2 0 0 2048 00 [--------] 1 0 0 00 [--------] test3 0 0 3072 00 [--------] 1 0 0 00 [--------]
The output of the above command is parsed and reformated by the agent plugin for easier processing in the check plugin. The above example output would thus be transformed into the agent plugin output shown in the following example:
<<<xfs_quota>>> /srv/xfs:/dev/mapper/vg00-xfs:test1:0:0:1024:1:0:0 /srv/xfs:/dev/mapper/vg00-xfs:test2:0:0:2048:1:0:0 /srv/xfs:/dev/mapper/vg00-xfs:test3:0:0:3072:1:0:0
Although a simple Bash shell script, the agent plugin
xfs_quota has several dependencies which need to be installed in order for the agent plugin to work properly. Namely those are the commands
egrep. On Debian based systems, the necessary packages can be installed with the following command:
root@host:~# apt-get install xfsprogs sed grep
The second part, a Check_MK check plugin also named
xfs_quota, provides the necessary inventory and check functions. Upon inventory it creates a service check for each pair of XFS filesystem mountpoint and quota project ID. During normal check execution, the number of used XFS filesystem blocks and inodes are determined for each inventorized item (pair of XFS filesystem mountpoint and quota project ID). If the hard and soft, block and inode quotas for particular item are all set to zero, no further checks are carried out and only performance data is reported by the check. If either one of hard or soft, block or inode quota is set to a non-zero value, the number of remaining free XFS filesystem blocks or inodes is compared to warning and critical threshold values and an alarm is raised accordingly.
With the additional WATO plugin it is possible to configure the warning and critical levels through the WATO WebUI and thus override the default values. The default values for
blocks_soft are zero (0) free blocks for both warning and critical thresholds. The default values for
inodes_soft are zero (0) free inodes for both warning and critical thresholds. The configuration options for the free block or inode levels can be found under:
-> Host & Service Parameters -> Parameters for discovered services -> Storage, Filesystems and Files -> XFS Quota Utilization -> Create Rule in Folder ... -> The levels for the soft/hard block/inode quotas on XFS filesystems [x] The levels for the hard block quotas on XFS filesystems [x] The levels for the soft block quotas on XFS filesystems [x] The levels for the hard inode quotas on XFS filesystems [x] The levels for the soft inode quotas on XFS filesystems
The following image shows a status output example for several
xfs_quota service checks from the WATO WebUI:
This example shows several service check items, which again are pairs of XFS filesystem mountpoints (here:
/backup) and anonymized quota project IDs. For each item the number of blocks and inodes used are shown along with the appropriate hard and soft quota values. The number of blocks and inodes used are also visualized in the perf-o-meter, blocks on a logarithmic scale growing from the middle to the left, inodes on a logarithmic scale growing from the middle to the right.
The following image shows an example of the two PNP4Nagios graphs for a single service check:
The upper graph shows the number of used XFS filesystem blocks for a pair of XFS filesystem mountpoints (here:
/backup) and a - again anonymized - quota project ID. The lower graph shows the number of used inodes for the same pair. Both graphs show warning and critical thresholds values, which are in this example at their default value of zero. If configured - like in the upper graph of the example - block or inode quotas are also shown as blue horizontal lines in the respective graphs.
The described Check_MK service check to monitor XFS filesystem quotas has been verified to work with version 3.2.1 of the
xfsprogs package on Debian
stable (Jessie) on the client side and the Check_MK versions 1.2.6 and 1.2.8 on the server side.
I hope you find the provided new check useful and enjoyed reading this blog post. Please don't hesitate to drop me a note if you have any suggestions or run into any issues with the provided checks.