Page 1 of 1

How to check for free/used space in GB with NRPE (Linux)

Posted: Mon Jun 06, 2016 3:19 pm
by dlukinski
Hello XI support

How to check for free/used space in GB with NRPE (Linux)
- with check_disk command?

Thank you

Re: How to check for free/used space in GB with NRPE (Linux)

Posted: Mon Jun 06, 2016 3:27 pm
by mcapra
check_disk accepts a "units" argument that should allow you to get the output in terms of kilobytes, megabytes (default), gigabytes, or terabytes.

From ./check_disk -h:

Code: Select all

 -u, --units=STRING
    Choose bytes, kB, MB, GB, TB (default: MB)
Applied like so:

Code: Select all

[root@localhost libexec]# ./check_disk -u kB
DISK OK - free space: / 15482344 kB (84% inode=99%); /dev 1931056 kB (100% inode=99%); /dev/shm 1941232 kB (100% inode=99%); /run 1723688 kB (88% inode=98%); /sys/fs/cgroup 1941232 kB (100% inode=99%); /boot 383132 kB (75% inode=99%); /run/user/0 388248 kB (100% inode=99%); /run/user/1000 388248 kB (100% inode=99%);| /=2824728kB;;;0;18307072 /dev=0kB;;;0;1931056 /dev/shm=0kB;;;0;1941232 /run=217544kB;;;0;1941232 /sys/fs/cgroup=0kB;;;0;1941232 /boot=125456kB;;;0;508588 /run/user/0=0kB;;;0;388248 /run/user/1000=0kB;;;0;388248

....

[root@localhost libexec]# ./check_disk -u GB
DISK OK - free space: / 14 GB (84% inode=99%); /dev 1 GB (100% inode=99%); /dev/shm 1 GB (100% inode=99%); /run 1 GB (88% inode=98%); /sys/fs/cgroup 1 GB (100% inode=99%); /boot 0 GB (75% inode=99%); /run/user/0 0 GB (100% inode=99%); /run/user/1000 0 GB (100% inode=99%);| /=2GB;;;0;17 /dev=0GB;;;0;1 /dev/shm=0GB;;;0;1 /run=0GB;;;0;1 /sys/fs/cgroup=0GB;;;0;1 /boot=0GB;;;0;0 /run/user/0=0GB;;;0;0 /run/user/1000=0GB;;;0;0

In your Nagios XI configuration, you would simply reconfigure the service check adding -u GB to the arguments passed to check_disk.

Re: How to check for free/used space in GB with NRPE (Linux)

Posted: Tue Jun 07, 2016 12:26 pm
by dlukinski
mcapra wrote:check_disk accepts a "units" argument that should allow you to get the output in terms of kilobytes, megabytes (default), gigabytes, or terabytes.

From ./check_disk -h:

Code: Select all

 -u, --units=STRING
    Choose bytes, kB, MB, GB, TB (default: MB)
Applied like so:

Code: Select all

[root@localhost libexec]# ./check_disk -u kB
DISK OK - free space: / 15482344 kB (84% inode=99%); /dev 1931056 kB (100% inode=99%); /dev/shm 1941232 kB (100% inode=99%); /run 1723688 kB (88% inode=98%); /sys/fs/cgroup 1941232 kB (100% inode=99%); /boot 383132 kB (75% inode=99%); /run/user/0 388248 kB (100% inode=99%); /run/user/1000 388248 kB (100% inode=99%);| /=2824728kB;;;0;18307072 /dev=0kB;;;0;1931056 /dev/shm=0kB;;;0;1941232 /run=217544kB;;;0;1941232 /sys/fs/cgroup=0kB;;;0;1941232 /boot=125456kB;;;0;508588 /run/user/0=0kB;;;0;388248 /run/user/1000=0kB;;;0;388248

....

[root@localhost libexec]# ./check_disk -u GB
DISK OK - free space: / 14 GB (84% inode=99%); /dev 1 GB (100% inode=99%); /dev/shm 1 GB (100% inode=99%); /run 1 GB (88% inode=98%); /sys/fs/cgroup 1 GB (100% inode=99%); /boot 0 GB (75% inode=99%); /run/user/0 0 GB (100% inode=99%); /run/user/1000 0 GB (100% inode=99%);| /=2GB;;;0;17 /dev=0GB;;;0;1 /dev/shm=0GB;;;0;1 /run=0GB;;;0;1 /sys/fs/cgroup=0GB;;;0;1 /boot=0GB;;;0;0 /run/user/0=0GB;;;0;0 /run/user/1000=0GB;;;0;0

In your Nagios XI configuration, you would simply reconfigure the service check adding -u GB to the arguments passed to check_disk.
Thank you, how to configure warnings / criticals in this case?

Re: How to check for free/used space in GB with NRPE (Linux)

Posted: Tue Jun 07, 2016 1:13 pm
by mcapra
For check_disk, the warning and critical thresholds adopt the units you define when calling the script.

Warning at 2GB remaining, critical at 1GB remaining:

Code: Select all

[root@localhost libexec]# ./check_disk -u GB -w 2 -c 1
DISK CRITICAL - free space: / 14 GB (84% inode=99%); /dev 1 GB (100% inode=99%); /dev/shm 1 GB (100% inode=99%); /run 1 GB (88% inode=97%); /sys/fs/cgroup 1 GB (100% inode=99%); /boot 0 GB (75% inode=99%); /run/user/0 0 GB (100% inode=99%); /run/user/1000 0 GB (100% inode=99%);| /=2GB;15;16;0;17 /dev=0GB;-1;0;0;1 /dev/shm=0GB;-1;0;0;1 /run=0GB;-1;0;0;1 /sys/fs/cgroup=0GB;-1;0;0;1 /boot=0GB;-2;-1;0;0 /run/user/0=0GB;-2;-1;0;0 /run/user/1000=0GB;-2;-1;0;0
Warning at 2KB remaining, critical at 1KB remaining:

Code: Select all

[root@localhost libexec]# ./check_disk -u kB -w 2 -c 1
DISK OK - free space: / 15471144 kB (84% inode=99%); /dev 1931056 kB (100% inode=99%); /dev/shm 1941232 kB (100% inode=99%); /run 1719664 kB (88% inode=97%); /sys/fs/cgroup 1941232 kB (100% inode=99%); /boot 383132 kB (75% inode=99%); /run/user/0 388248 kB (100% inode=99%); /run/user/1000 388248 kB (100% inode=99%);| /=2835928kB;18307070;18307071;0;18307072 /dev=0kB;1931054;1931055;0;1931056 /dev/shm=0kB;1941230;1941231;0;1941232 /run=221568kB;1941230;1941231;0;1941232 /sys/fs/cgroup=0kB;1941230;1941231;0;1941232 /boot=125456kB;508586;508587;0;508588 /run/user/0=0kB;388246;388247;0;388248 /run/user/1000=0kB;388246;388247;0;388248
You will notice, based on the units we are using, one check generates a CRITICAL status while the other generates an OK status.


The syntax is the same. The only thing that changes is the units. If you use percentages, it doesn't matter what unit is set as far as alerts are concerned.

Code: Select all

[root@localhost libexec]# ./check_disk -u GB -w 75% -c 20%
DISK WARNING - free space: / 14 GB (84% inode=99%); /dev 1 GB (100% inode=99%); /dev/shm 1 GB (100% inode=99%); /run 1 GB (88% inode=97%); /sys/fs/cgroup 1 GB (100% inode=99%); /boot 0 GB (75% inode=99%); /run/user/0 0 GB (100% inode=99%); /run/user/1000 0 GB (100% inode=99%);| /=2GB;4;13;0;17 /dev=0GB;0;0;0;1 /dev/shm=0GB;0;0;0;1 /run=0GB;0;0;0;1 /sys/fs/cgroup=0GB;0;0;0;1 /boot=0GB;0;0;0;0 /run/user/0=0GB;0;0;0;0 /run/user/1000=0GB;0;0;0;0

...

[root@localhost libexec]# ./check_disk -u kB -w 75% -c 20%
DISK WARNING - free space: / 15471092 kB (84% inode=99%); /dev 1931056 kB (100% inode=99%); /dev/shm 1941232 kB (100% inode=99%); /run 1719856 kB (88% inode=97%); /sys/fs/cgroup 1941232 kB (100% inode=99%); /boot 383132 kB (75% inode=99%); /run/user/0 388248 kB (100% inode=99%); /run/user/1000 388248 kB (100% inode=99%);| /=2835980kB;4576768;14645657;0;18307072 /dev=0kB;482764;1544844;0;1931056 /dev/shm=0kB;485308;1552985;0;1941232 /run=221376kB;485308;1552985;0;1941232 /sys/fs/cgroup=0kB;485308;1552985;0;1941232 /boot=125456kB;127147;406870;0;508588 /run/user/0=0kB;97062;310598;0;388248 /run/user/1000=0kB;97062;310598;0;388248

Re: How to check for free/used space in GB with NRPE (Linux)

Posted: Tue Jun 07, 2016 2:25 pm
by dlukinski
mcapra wrote:For check_disk, the warning and critical thresholds adopt the units you define when calling the script.

Warning at 2GB remaining, critical at 1GB remaining:

Code: Select all

[root@localhost libexec]# ./check_disk -u GB -w 2 -c 1
DISK CRITICAL - free space: / 14 GB (84% inode=99%); /dev 1 GB (100% inode=99%); /dev/shm 1 GB (100% inode=99%); /run 1 GB (88% inode=97%); /sys/fs/cgroup 1 GB (100% inode=99%); /boot 0 GB (75% inode=99%); /run/user/0 0 GB (100% inode=99%); /run/user/1000 0 GB (100% inode=99%);| /=2GB;15;16;0;17 /dev=0GB;-1;0;0;1 /dev/shm=0GB;-1;0;0;1 /run=0GB;-1;0;0;1 /sys/fs/cgroup=0GB;-1;0;0;1 /boot=0GB;-2;-1;0;0 /run/user/0=0GB;-2;-1;0;0 /run/user/1000=0GB;-2;-1;0;0
Warning at 2KB remaining, critical at 1KB remaining:

Code: Select all

[root@localhost libexec]# ./check_disk -u kB -w 2 -c 1
DISK OK - free space: / 15471144 kB (84% inode=99%); /dev 1931056 kB (100% inode=99%); /dev/shm 1941232 kB (100% inode=99%); /run 1719664 kB (88% inode=97%); /sys/fs/cgroup 1941232 kB (100% inode=99%); /boot 383132 kB (75% inode=99%); /run/user/0 388248 kB (100% inode=99%); /run/user/1000 388248 kB (100% inode=99%);| /=2835928kB;18307070;18307071;0;18307072 /dev=0kB;1931054;1931055;0;1931056 /dev/shm=0kB;1941230;1941231;0;1941232 /run=221568kB;1941230;1941231;0;1941232 /sys/fs/cgroup=0kB;1941230;1941231;0;1941232 /boot=125456kB;508586;508587;0;508588 /run/user/0=0kB;388246;388247;0;388248 /run/user/1000=0kB;388246;388247;0;388248
You will notice, based on the units we are using, one check generates a CRITICAL status while the other generates an OK status.


The syntax is the same. The only thing that changes is the units. If you use percentages, it doesn't matter what unit is set as far as alerts are concerned.

Code: Select all

[root@localhost libexec]# ./check_disk -u GB -w 75% -c 20%
DISK WARNING - free space: / 14 GB (84% inode=99%); /dev 1 GB (100% inode=99%); /dev/shm 1 GB (100% inode=99%); /run 1 GB (88% inode=97%); /sys/fs/cgroup 1 GB (100% inode=99%); /boot 0 GB (75% inode=99%); /run/user/0 0 GB (100% inode=99%); /run/user/1000 0 GB (100% inode=99%);| /=2GB;4;13;0;17 /dev=0GB;0;0;0;1 /dev/shm=0GB;0;0;0;1 /run=0GB;0;0;0;1 /sys/fs/cgroup=0GB;0;0;0;1 /boot=0GB;0;0;0;0 /run/user/0=0GB;0;0;0;0 /run/user/1000=0GB;0;0;0;0

...

[root@localhost libexec]# ./check_disk -u kB -w 75% -c 20%
DISK WARNING - free space: / 15471092 kB (84% inode=99%); /dev 1931056 kB (100% inode=99%); /dev/shm 1941232 kB (100% inode=99%); /run 1719856 kB (88% inode=97%); /sys/fs/cgroup 1941232 kB (100% inode=99%); /boot 383132 kB (75% inode=99%); /run/user/0 388248 kB (100% inode=99%); /run/user/1000 388248 kB (100% inode=99%);| /=2835980kB;4576768;14645657;0;18307072 /dev=0kB;482764;1544844;0;1931056 /dev/shm=0kB;485308;1552985;0;1941232 /run=221376kB;485308;1552985;0;1941232 /sys/fs/cgroup=0kB;485308;1552985;0;1941232 /boot=125456kB;127147;406870;0;508588 /run/user/0=0kB;97062;310598;0;388248 /run/user/1000=0kB;97062;310598;0;388248
This is not what I meant :-\

How to check for something like 100 MB left : warning / 50 MB left: critical

Re: How to check for free/used space in GB with NRPE (Linux)

Posted: Tue Jun 07, 2016 2:41 pm
by mcapra
dlukinski wrote:How to check for something like 100 MB left : warning / 50 MB left: critical
Locally:

Code: Select all

./check_disk -u MB -w 100 -c 50
With NRPE:

Code: Select all

./check_nrpe -H x.x.x.x -c check_disk -a '-u MB -w 100 -c 50'
Keep in mind that this will check the remaining space of every mount point on the monitored machine.

Re: How to check for free/used space in GB with NRPE (Linux)

Posted: Wed Jun 08, 2016 1:11 pm
by dlukinski
mcapra wrote:
dlukinski wrote:How to check for something like 100 MB left : warning / 50 MB left: critical
Locally:

Code: Select all

./check_disk -u MB -w 100 -c 50
With NRPE:

Code: Select all

./check_nrpe -H x.x.x.x -c check_disk -a '-u MB -w 100 -c 50'
Keep in mind that this will check the remaining space of every mount point on the monitored machine.
This worked, thank you
Please close the case