diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 88a1769..7bd044a 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -121,6 +121,7 @@ static struct mount_entry *mount_list; | |||
121 | 121 | ||
122 | int process_arguments (int, char **); | 122 | int process_arguments (int, char **); |
123 | void print_path (const char *mypath); | 123 | void print_path (const char *mypath); |
124 | void set_all_thresholds (struct parameter_list *path); | ||
124 | int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, char *); | 125 | int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, char *); |
125 | void print_help (void); | 126 | void print_help (void); |
126 | void print_usage (void); | 127 | void print_usage (void); |
@@ -148,6 +149,7 @@ char *warn_usedinodes_percent = NULL; | |||
148 | char *crit_usedinodes_percent = NULL; | 149 | char *crit_usedinodes_percent = NULL; |
149 | char *warn_freeinodes_percent = NULL; | 150 | char *warn_freeinodes_percent = NULL; |
150 | char *crit_freeinodes_percent = NULL; | 151 | char *crit_freeinodes_percent = NULL; |
152 | bool path_selected = false; | ||
151 | 153 | ||
152 | 154 | ||
153 | int | 155 | int |
@@ -190,33 +192,34 @@ main (int argc, char **argv) | |||
190 | /* If a list of paths has not been selected, find entire | 192 | /* If a list of paths has not been selected, find entire |
191 | mount list and create list of paths | 193 | mount list and create list of paths |
192 | */ | 194 | */ |
193 | if (! path_select_list) { | 195 | if (path_selected == false) { |
194 | for (me = mount_list; me; me = me->me_next) { | 196 | for (me = mount_list; me; me = me->me_next) { |
195 | path = np_add_parameter(&path_select_list, me->me_mountdir); | 197 | if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) { |
198 | path = np_add_parameter(&path_select_list, me->me_mountdir); | ||
199 | } | ||
196 | path->best_match = me; | 200 | path->best_match = me; |
197 | set_thresholds(&path->freespace_units, warn_freespace_units, crit_freespace_units); | 201 | set_all_thresholds(path); |
198 | set_thresholds(&path->freespace_percent, warn_freespace_percent, crit_freespace_percent); | ||
199 | set_thresholds(&path->usedspace_units, warn_usedspace_units, crit_usedspace_units); | ||
200 | set_thresholds(&path->usedspace_percent, warn_usedspace_percent, crit_usedspace_percent); | ||
201 | set_thresholds(&path->usedinodes_percent, warn_usedinodes_percent, crit_usedinodes_percent); | ||
202 | set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); | ||
203 | } | 202 | } |
204 | } else { | 203 | } |
205 | np_set_best_match(path_select_list, mount_list, exact_match); | 204 | np_set_best_match(path_select_list, mount_list, exact_match); |
206 | 205 | ||
207 | /* Error if no match found for specified paths */ | 206 | /* Error if no match found for specified paths */ |
208 | temp_list = path_select_list; | 207 | temp_list = path_select_list; |
209 | while (temp_list) { | 208 | while (temp_list) { |
210 | if (! temp_list->best_match) { | 209 | if (! temp_list->best_match) { |
211 | die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); | 210 | die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); |
212 | } | ||
213 | temp_list = temp_list->name_next; | ||
214 | } | 211 | } |
212 | temp_list = temp_list->name_next; | ||
215 | } | 213 | } |
214 | |||
216 | 215 | ||
217 | /* Process for every path in list */ | 216 | /* Process for every path in list */ |
218 | for (path = path_select_list; path; path=path->name_next) { | 217 | for (path = path_select_list; path; path=path->name_next) { |
219 | 218 | ||
219 | if (verbose > 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) | ||
220 | printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end, | ||
221 | path->freespace_percent->critical->end); | ||
222 | |||
220 | /* reset disk result */ | 223 | /* reset disk result */ |
221 | disk_result = STATE_UNKNOWN; | 224 | disk_result = STATE_UNKNOWN; |
222 | 225 | ||
@@ -548,13 +551,14 @@ process_arguments (int argc, char **argv) | |||
548 | crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) { | 551 | crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) { |
549 | die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -p\n")); | 552 | die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -p\n")); |
550 | } | 553 | } |
551 | se = np_add_parameter(&path_select_list, optarg); | 554 | |
552 | set_thresholds(&se->freespace_units, warn_freespace_units, crit_freespace_units); | 555 | /* add parameter if not found. overwrite thresholds if path has already been added */ |
553 | set_thresholds(&se->freespace_percent, warn_freespace_percent, crit_freespace_percent); | 556 | if (! (se = np_find_parameter(path_select_list, optarg))) { |
554 | set_thresholds(&se->usedspace_units, warn_usedspace_units, crit_usedspace_units); | 557 | se = np_add_parameter(&path_select_list, optarg); |
555 | set_thresholds(&se->usedspace_percent, warn_usedspace_percent, crit_usedspace_percent); | 558 | } |
556 | set_thresholds(&se->usedinodes_percent, warn_usedinodes_percent, crit_usedinodes_percent); | 559 | |
557 | set_thresholds(&se->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); | 560 | set_all_thresholds(se); |
561 | path_selected = true; | ||
558 | break; | 562 | break; |
559 | case 'x': /* exclude path or partition */ | 563 | case 'x': /* exclude path or partition */ |
560 | np_add_name(&dp_exclude_list, optarg); | 564 | np_add_name(&dp_exclude_list, optarg); |
@@ -578,6 +582,17 @@ process_arguments (int argc, char **argv) | |||
578 | display_mntp = TRUE; | 582 | display_mntp = TRUE; |
579 | break; | 583 | break; |
580 | case 'C': | 584 | case 'C': |
585 | /* add all mount entries to path_select list if no partitions have been explicitly defined using -p */ | ||
586 | if (path_selected == false) { | ||
587 | struct mount_entry *me; | ||
588 | struct parameter_list *path; | ||
589 | for (me = mount_list; me; me = me->me_next) { | ||
590 | if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) | ||
591 | path = np_add_parameter(&path_select_list, me->me_mountdir); | ||
592 | path->best_match = me; | ||
593 | set_all_thresholds(path); | ||
594 | } | ||
595 | } | ||
581 | warn_freespace_units = NULL; | 596 | warn_freespace_units = NULL; |
582 | crit_freespace_units = NULL; | 597 | crit_freespace_units = NULL; |
583 | warn_usedspace_units = NULL; | 598 | warn_usedspace_units = NULL; |
@@ -590,6 +605,8 @@ process_arguments (int argc, char **argv) | |||
590 | crit_usedinodes_percent = NULL; | 605 | crit_usedinodes_percent = NULL; |
591 | warn_freeinodes_percent = NULL; | 606 | warn_freeinodes_percent = NULL; |
592 | crit_freeinodes_percent = NULL; | 607 | crit_freeinodes_percent = NULL; |
608 | |||
609 | path_selected = false; | ||
593 | break; | 610 | break; |
594 | case 'V': /* version */ | 611 | case 'V': /* version */ |
595 | print_revision (progname, revision); | 612 | print_revision (progname, revision); |
@@ -612,12 +629,7 @@ process_arguments (int argc, char **argv) | |||
612 | 629 | ||
613 | if (argc > c && path == NULL) { | 630 | if (argc > c && path == NULL) { |
614 | se = np_add_parameter(&path_select_list, strdup(argv[c++])); | 631 | se = np_add_parameter(&path_select_list, strdup(argv[c++])); |
615 | set_thresholds(&se->freespace_units, warn_freespace_units, crit_freespace_units); | 632 | set_all_thresholds(se); |
616 | set_thresholds(&se->freespace_percent, warn_freespace_percent, crit_freespace_percent); | ||
617 | set_thresholds(&se->usedspace_units, warn_usedspace_units, crit_usedspace_units); | ||
618 | set_thresholds(&se->usedspace_percent, warn_usedspace_percent, crit_usedspace_percent); | ||
619 | set_thresholds(&se->usedinodes_percent, warn_usedinodes_percent, crit_usedinodes_percent); | ||
620 | set_thresholds(&se->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); | ||
621 | } | 633 | } |
622 | 634 | ||
623 | if (units == NULL) { | 635 | if (units == NULL) { |
@@ -665,6 +677,16 @@ print_path (const char *mypath) | |||
665 | } | 677 | } |
666 | 678 | ||
667 | 679 | ||
680 | void | ||
681 | set_all_thresholds (struct parameter_list *path) | ||
682 | { | ||
683 | set_thresholds(&path->freespace_units, warn_freespace_units, crit_freespace_units); | ||
684 | set_thresholds(&path->freespace_percent, warn_freespace_percent, crit_freespace_percent); | ||
685 | set_thresholds(&path->usedspace_units, warn_usedspace_units, crit_usedspace_units); | ||
686 | set_thresholds(&path->usedspace_percent, warn_usedspace_percent, crit_usedspace_percent); | ||
687 | set_thresholds(&path->usedinodes_percent, warn_usedinodes_percent, crit_usedinodes_percent); | ||
688 | set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); | ||
689 | } | ||
668 | 690 | ||
669 | /* TODO: Remove? | 691 | /* TODO: Remove? |
670 | 692 | ||