Skip to content

Add a --human-readable option to check_disk [sf#2924632] #924

@monitoring-user

Description

@monitoring-user

Submitted by None on 2010-01-01 20:53:12

I recently switched all our machines to use '-u GB' with check_disk
which was a vast improvement for most machines. However it's turns
out to be less useful for small drives, e.g.

| $ /usr/lib/nagios/plugins/check_disk -u GB -w 40% -c 20% -p /
| DISK WARNING - free space: / 0 GB (35% inode=74%);| /=1GB;0;0;0;1

To try and work around this, I added a --human-readable option, a la
GNU df(1), e.g.

| $ ./check_disk --human-readable -w 40% -c 20% -p /
| DISK WARNING - free space: / 632M (35% inode=74%);| /=1163MB;1134;1512;0;1891

I've attached the patch I used to do this; would it be possible to
include it (or something like it) in future releases of
nagios-plugins?

A few notes:

  1. It requires importing the 'human' module from gnulib into 'gl'. I
    didn't attach a patch to do this, since the resulting patch is
    messy and very dependent on the versions of auto* and gnulib on my
    local system. If you want such a patch anyway, I'll be happy to
    provide one.

  2. It's based on 1.4.13+git200906171200 because that's the version in
    Ubuntu right now; if you want a patch rebased against current git,
    please let me know.

  3. I chose to avoid altering the performance data and separated the
    new option from -u/--units as that seemed to make the most sense
    to me but if you want it done differently, I'm happy to do that
    too.

  4. I used --human-readable and 'Z' (internally only) as the options;
    this is different from df(1) which dedicates -h to the option, but
    I assumed consistency with other plugins would trump consistency
    with df(1)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions