diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7f5c00963116b7942ccb88ce191dac694a785b1e..98a061fbe614e63a93e5d28a12b41467cb8cda9a 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
* License: GPL
* Copyright (c) 1999-2008 Nagios Plugins Development Team
*
-* Last Modified: $Date$
-*
* Description:
*
* This file contains the check_disk plugin
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
-* $Id$
*
*****************************************************************************/
const char *progname = "check_disk";
const char *program_name = "check_disk"; /* Required for coreutils libs */
-const char *revision = "$Revision$";
const char *copyright = "1999-2008";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#pragma alloca
#endif
-/* Linked list of mounted filesystems. */
-static struct mount_entry *mount_list;
-
int process_arguments (int, char **);
void print_path (const char *mypath);
void set_all_thresholds (struct parameter_list *path);
/* If a list of paths has not been selected, find entire
mount list and create list of paths
*/
- if (path_selected == FALSE) {
+ if (path_selected == FALSE) {
for (me = mount_list; me; me = me->me_next) {
if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) {
path = np_add_parameter(&path_select_list, me->me_mountdir);
/* Skip excluded fstypes */
} else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) {
continue;
- /* Skip excluded fs's */
- } else if (dp_exclude_list &&
+ /* Skip excluded fs's */
+ } else if (dp_exclude_list &&
(np_find_name (dp_exclude_list, me->me_devname) ||
np_find_name (dp_exclude_list, me->me_mountdir))) {
continue;
dfree_inodes_percent = 100 - dused_inodes_percent;
if (verbose >= 3) {
- printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n",
+ printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n",
me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult);
}
double pct = -1;
/* I don't understand the below, but it is taken from coreutils' df */
/* Seems to be calculating pct, in the best possible way */
- if (value <= TYPE_MAXIMUM(uintmax_t) / 100
+ if (value <= TYPE_MAXIMUM(uintmax_t) / 100
&& total != 0) {
uintmax_t u100 = value * 100;
pct = u100 / total + (u100 % total != 0);
{"iwarning", required_argument, 0, 'W'},
/* Dang, -C is taken. We might want to reshuffle this. */
{"icritical", required_argument, 0, 'K'},
- {"kilobytes", required_argument, 0, 'k'},
- {"megabytes", required_argument, 0, 'm'},
+ {"kilobytes", no_argument, 0, 'k'},
+ {"megabytes", no_argument, 0, 'm'},
{"units", required_argument, 0, 'u'},
{"path", required_argument, 0, 'p'},
{"partition", required_argument, 0, 'p'},
}
break;
- /* Awful mistake where the range values do not make sense. Normally,
+ /* Awful mistake where the range values do not make sense. Normally,
you alert if the value is within the range, but since we are using
freespace, we have to alert if outside the range. Thus we artifically
force @ at the beginning of the range, so that it is backwards compatible
case 'L':
stat_remote_fs = 1;
case 'l':
- show_local_fs = 1;
+ show_local_fs = 1;
break;
case 'p': /* select path */
- if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
+ if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
warn_usedspace_percent || crit_usedspace_percent || warn_usedinodes_percent ||
crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) {
}
se->group = group;
set_all_thresholds(se);
- np_set_best_match(se, mount_list, exact_match);
+
+ /* With autofs, it is required to stat() the path before re-populating the mount_list */
stat_path(se);
+ /* NB: We can't free the old mount_list "just like that": both list pointers and struct
+ * pointers are copied around. One of the reason it wasn't done yet is that other parts
+ * of check_disk need the same kind of cleanup so it'd better be done as a whole */
+ mount_list = read_file_system_list (0);
+ np_set_best_match(se, mount_list, exact_match);
+
path_selected = TRUE;
break;
case 'x': /* exclude path or partition */
case 'R':
cflags |= REG_ICASE;
case 'r':
- if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
+ if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
warn_usedspace_percent || crit_usedspace_percent || warn_usedinodes_percent ||
crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) {
case 'C':
/* add all mount entries to path_select list if no partitions have been explicitly defined using -p */
if (path_selected == FALSE) {
- struct mount_entry *me;
struct parameter_list *path;
for (me = mount_list; me; me = me->me_next) {
- if (! (path = np_find_parameter(path_select_list, me->me_mountdir)))
+ if (! (path = np_find_parameter(path_select_list, me->me_mountdir)))
path = np_add_parameter(&path_select_list, me->me_mountdir);
path->best_match = me;
path->group = group;
group = NULL;
break;
case 'V': /* version */
- print_revision (progname, revision);
+ print_revision (progname, NP_VERSION);
exit (STATE_OK);
case 'h': /* help */
print_help ();
void
-print_path (const char *mypath)
+print_path (const char *mypath)
{
if (mypath == NULL)
printf ("\n");
void
-set_all_thresholds (struct parameter_list *path)
+set_all_thresholds (struct parameter_list *path)
{
if (path->freespace_units != NULL) free(path->freespace_units);
set_thresholds(&path->freespace_units, warn_freespace_units, crit_freespace_units);
@@ -893,7 +892,7 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
void
print_help (void)
{
- print_revision (progname, revision);
+ print_revision (progname, NP_VERSION);
printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
printf (COPYRIGHT, copyright, email);