diff options
Diffstat (limited to 'plugins/check_disk.d/utils_disk.h')
| -rw-r--r-- | plugins/check_disk.d/utils_disk.h | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/plugins/check_disk.d/utils_disk.h b/plugins/check_disk.d/utils_disk.h new file mode 100644 index 00000000..c96d4296 --- /dev/null +++ b/plugins/check_disk.d/utils_disk.h | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | #pragma once | ||
| 2 | /* Header file for utils_disk */ | ||
| 3 | |||
| 4 | #include "../../config.h" | ||
| 5 | #include "../../gl/mountlist.h" | ||
| 6 | #include "../../lib/utils_base.h" | ||
| 7 | #include "../../lib/output.h" | ||
| 8 | #include "regex.h" | ||
| 9 | #include <stdint.h> | ||
| 10 | |||
| 11 | typedef unsigned long long byte_unit; | ||
| 12 | |||
| 13 | typedef enum { | ||
| 14 | Humanized, | ||
| 15 | Bytes, | ||
| 16 | KibiBytes, | ||
| 17 | MebiBytes, | ||
| 18 | GibiBytes, | ||
| 19 | TebiBytes, | ||
| 20 | PebiBytes, | ||
| 21 | ExbiBytes, | ||
| 22 | KiloBytes, | ||
| 23 | MegaBytes, | ||
| 24 | GigaBytes, | ||
| 25 | TeraBytes, | ||
| 26 | PetaBytes, | ||
| 27 | ExaBytes, | ||
| 28 | } byte_unit_enum; | ||
| 29 | |||
| 30 | typedef struct name_list string_list; | ||
| 31 | struct name_list { | ||
| 32 | char *name; | ||
| 33 | string_list *next; | ||
| 34 | }; | ||
| 35 | |||
| 36 | struct regex_list { | ||
| 37 | regex_t regex; | ||
| 38 | struct regex_list *next; | ||
| 39 | }; | ||
| 40 | |||
| 41 | typedef struct parameter_list parameter_list_elem; | ||
| 42 | struct parameter_list { | ||
| 43 | char *name; | ||
| 44 | char *group; | ||
| 45 | |||
| 46 | mp_thresholds freespace_units; | ||
| 47 | mp_thresholds freespace_percent; | ||
| 48 | mp_thresholds freeinodes_percent; | ||
| 49 | |||
| 50 | struct mount_entry *best_match; | ||
| 51 | |||
| 52 | uintmax_t inodes_free_to_root; | ||
| 53 | uintmax_t inodes_free; | ||
| 54 | uintmax_t inodes_used; | ||
| 55 | uintmax_t inodes_total; | ||
| 56 | |||
| 57 | uint64_t used_bytes; | ||
| 58 | uint64_t free_bytes; | ||
| 59 | uint64_t total_bytes; | ||
| 60 | |||
| 61 | parameter_list_elem *next; | ||
| 62 | parameter_list_elem *prev; | ||
| 63 | }; | ||
| 64 | |||
| 65 | typedef struct { | ||
| 66 | size_t length; | ||
| 67 | parameter_list_elem *first; | ||
| 68 | } filesystem_list; | ||
| 69 | |||
| 70 | filesystem_list filesystem_list_init(); | ||
| 71 | |||
| 72 | typedef struct { | ||
| 73 | char *name; | ||
| 74 | char *filesystem_type; | ||
| 75 | bool is_group; | ||
| 76 | |||
| 77 | mp_thresholds freespace_bytes_thresholds; | ||
| 78 | mp_thresholds freespace_percent_thresholds; | ||
| 79 | mp_thresholds freeinodes_percent_thresholds; | ||
| 80 | |||
| 81 | uintmax_t inodes_free_to_root; | ||
| 82 | uintmax_t inodes_free; | ||
| 83 | uintmax_t inodes_used; | ||
| 84 | uintmax_t inodes_total; | ||
| 85 | |||
| 86 | uintmax_t used_bytes; | ||
| 87 | uintmax_t free_bytes; | ||
| 88 | uintmax_t total_bytes; | ||
| 89 | } measurement_unit; | ||
| 90 | |||
| 91 | typedef struct measurement_unit_list measurement_unit_list; | ||
| 92 | struct measurement_unit_list { | ||
| 93 | measurement_unit unit; | ||
| 94 | measurement_unit_list *next; | ||
| 95 | }; | ||
| 96 | |||
| 97 | typedef struct { | ||
| 98 | // Output options | ||
| 99 | bool erronly; | ||
| 100 | bool display_mntp; | ||
| 101 | /* show only local filesystems. */ | ||
| 102 | bool show_local_fs; | ||
| 103 | /* show only local filesystems but call stat() on remote ones. */ | ||
| 104 | bool stat_remote_fs; | ||
| 105 | bool display_inodes_perfdata; | ||
| 106 | |||
| 107 | bool exact_match; | ||
| 108 | bool freespace_ignore_reserved; | ||
| 109 | |||
| 110 | bool ignore_missing; | ||
| 111 | bool path_ignored; | ||
| 112 | |||
| 113 | /* Linked list of filesystem types to omit. | ||
| 114 | If the list is empty, don't exclude any types. */ | ||
| 115 | struct regex_list *fs_exclude_list; | ||
| 116 | /* Linked list of filesystem types to check. | ||
| 117 | If the list is empty, include all types. */ | ||
| 118 | struct regex_list *fs_include_list; | ||
| 119 | struct name_list *device_path_exclude_list; | ||
| 120 | filesystem_list path_select_list; | ||
| 121 | /* Linked list of mounted filesystems. */ | ||
| 122 | struct mount_entry *mount_list; | ||
| 123 | struct name_list *seen; | ||
| 124 | |||
| 125 | byte_unit_enum display_unit; | ||
| 126 | // byte_unit unit; | ||
| 127 | |||
| 128 | bool output_format_is_set; | ||
| 129 | mp_output_format output_format; | ||
| 130 | } check_disk_config; | ||
| 131 | |||
| 132 | void np_add_name(struct name_list **list, const char *name); | ||
| 133 | bool np_find_name(struct name_list *list, const char *name); | ||
| 134 | bool np_seen_name(struct name_list *list, const char *name); | ||
| 135 | int np_add_regex(struct regex_list **list, const char *regex, int cflags); | ||
| 136 | bool np_find_regmatch(struct regex_list *list, const char *name); | ||
| 137 | |||
| 138 | parameter_list_elem parameter_list_init(const char *); | ||
| 139 | |||
| 140 | parameter_list_elem *mp_int_fs_list_append(filesystem_list *list, const char *name); | ||
| 141 | parameter_list_elem *mp_int_fs_list_find(filesystem_list list, const char *name); | ||
| 142 | parameter_list_elem *mp_int_fs_list_del(filesystem_list *list, parameter_list_elem *item); | ||
| 143 | parameter_list_elem *mp_int_fs_list_get_next(parameter_list_elem *current); | ||
| 144 | void mp_int_fs_list_set_best_match(filesystem_list list, struct mount_entry *mount_list, | ||
| 145 | bool exact); | ||
| 146 | |||
| 147 | measurement_unit measurement_unit_init(); | ||
| 148 | measurement_unit_list *add_measurement_list(measurement_unit_list *list, measurement_unit elem); | ||
| 149 | measurement_unit add_filesystem_to_measurement_unit(measurement_unit unit, | ||
| 150 | parameter_list_elem filesystem); | ||
| 151 | measurement_unit create_measurement_unit_from_filesystem(parameter_list_elem filesystem, | ||
| 152 | bool display_mntp); | ||
| 153 | |||
| 154 | int search_parameter_list(parameter_list_elem *list, const char *name); | ||
| 155 | bool np_regex_match_mount_entry(struct mount_entry *, regex_t *); | ||
| 156 | |||
| 157 | char *get_unit_string(byte_unit_enum); | ||
| 158 | check_disk_config check_disk_config_init(); | ||
| 159 | |||
| 160 | char *humanize_byte_value(unsigned long long value, bool use_si_units); | ||
