O'Reilly logo

Nagios, 2nd Edition by Wolfgang Barth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 25. Determining File and Directory Sizes

For a specific example of a Perl plugin, we will look at check_du.pl.[296] It is used to determine the size of specified files or directories and to check whether the total size lies within preset thresholds. To do this, it calls the system program du:

user@linux:~$ du -cs /var/spool/var/log
26524   /var/spool
745640  /var/log
772164  total

When used with the -s option, du does not list all the individual subdirectories but just shows the total size. -c adds up individual values to reach a total size.

At the beginning, the plugin generates a new new Nagios::Plugin object with the new constructor so that it can make use of the functions of the module:

#!/usr/bin/perl -w use strict; use warnings; use FindBin; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required