diff options
Diffstat (limited to 'plugins/check_time.c')
| -rw-r--r-- | plugins/check_time.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/plugins/check_time.c b/plugins/check_time.c index debf59f3..fc9ba3f9 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c | |||
| @@ -87,7 +87,8 @@ int main(int argc, char **argv) { | |||
| 87 | } else { | 87 | } else { |
| 88 | result = STATE_UNKNOWN; | 88 | result = STATE_UNKNOWN; |
| 89 | } | 89 | } |
| 90 | die(result, _("TIME UNKNOWN - could not connect to server %s, port %d\n"), config.server_address, config.server_port); | 90 | die(result, _("TIME UNKNOWN - could not connect to server %s, port %d\n"), |
| 91 | config.server_address, config.server_port); | ||
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | if (config.use_udp) { | 94 | if (config.use_udp) { |
| @@ -99,7 +100,8 @@ int main(int argc, char **argv) { | |||
| 99 | } else { | 100 | } else { |
| 100 | result = STATE_UNKNOWN; | 101 | result = STATE_UNKNOWN; |
| 101 | } | 102 | } |
| 102 | die(result, _("TIME UNKNOWN - could not send UDP request to server %s, port %d\n"), config.server_address, config.server_port); | 103 | die(result, _("TIME UNKNOWN - could not send UDP request to server %s, port %d\n"), |
| 104 | config.server_address, config.server_port); | ||
| 103 | } | 105 | } |
| 104 | } | 106 | } |
| 105 | 107 | ||
| @@ -123,7 +125,8 @@ int main(int argc, char **argv) { | |||
| 123 | } else { | 125 | } else { |
| 124 | result = STATE_UNKNOWN; | 126 | result = STATE_UNKNOWN; |
| 125 | } | 127 | } |
| 126 | die(result, _("TIME UNKNOWN - no data received from server %s, port %d\n"), config.server_address, config.server_port); | 128 | die(result, _("TIME UNKNOWN - no data received from server %s, port %d\n"), |
| 129 | config.server_address, config.server_port); | ||
| 127 | } | 130 | } |
| 128 | 131 | ||
| 129 | result = STATE_OK; | 132 | result = STATE_OK; |
| @@ -137,7 +140,8 @@ int main(int argc, char **argv) { | |||
| 137 | 140 | ||
| 138 | if (result != STATE_OK) { | 141 | if (result != STATE_OK) { |
| 139 | die(result, _("TIME %s - %d second response time|%s\n"), state_text(result), (int)conntime, | 142 | die(result, _("TIME %s - %d second response time|%s\n"), state_text(result), (int)conntime, |
| 140 | perfdata("time", (long)conntime, "s", config.check_warning_time, (long)config.warning_time, config.check_critical_time, | 143 | perfdata("time", (long)conntime, "s", config.check_warning_time, |
| 144 | (long)config.warning_time, config.check_critical_time, | ||
| 141 | (long)config.critical_time, true, 0, false, 0)); | 145 | (long)config.critical_time, true, 0, false, 0)); |
| 142 | } | 146 | } |
| 143 | 147 | ||
| @@ -157,10 +161,11 @@ int main(int argc, char **argv) { | |||
| 157 | } | 161 | } |
| 158 | 162 | ||
| 159 | printf(_("TIME %s - %lu second time difference|%s %s\n"), state_text(result), diff_time, | 163 | printf(_("TIME %s - %lu second time difference|%s %s\n"), state_text(result), diff_time, |
| 160 | perfdata("time", (long)conntime, "s", config.check_warning_time, (long)config.warning_time, config.check_critical_time, | 164 | perfdata("time", (long)conntime, "s", config.check_warning_time, |
| 165 | (long)config.warning_time, config.check_critical_time, | ||
| 161 | (long)config.critical_time, true, 0, false, 0), | 166 | (long)config.critical_time, true, 0, false, 0), |
| 162 | perfdata("offset", diff_time, "s", config.check_warning_diff, config.warning_diff, config.check_critical_diff, | 167 | perfdata("offset", diff_time, "s", config.check_warning_diff, config.warning_diff, |
| 163 | config.critical_diff, true, 0, false, 0)); | 168 | config.check_critical_diff, config.critical_diff, true, 0, false, 0)); |
| 164 | return result; | 169 | return result; |
| 165 | } | 170 | } |
| 166 | 171 | ||
| @@ -230,7 +235,8 @@ check_time_config_wrapper process_arguments(int argc, char **argv) { | |||
| 230 | result.config.warning_diff = strtoul(optarg, NULL, 10); | 235 | result.config.warning_diff = strtoul(optarg, NULL, 10); |
| 231 | result.config.check_warning_diff = true; | 236 | result.config.check_warning_diff = true; |
| 232 | } else if (strspn(optarg, "0123456789:,") > 0) { | 237 | } else if (strspn(optarg, "0123456789:,") > 0) { |
| 233 | if (sscanf(optarg, "%lu%*[:,]%d", &result.config.warning_diff, &result.config.warning_time) == 2) { | 238 | if (sscanf(optarg, "%lu%*[:,]%d", &result.config.warning_diff, |
| 239 | &result.config.warning_time) == 2) { | ||
| 234 | result.config.check_warning_diff = true; | 240 | result.config.check_warning_diff = true; |
| 235 | result.config.check_warning_time = true; | 241 | result.config.check_warning_time = true; |
| 236 | } else { | 242 | } else { |
| @@ -245,7 +251,8 @@ check_time_config_wrapper process_arguments(int argc, char **argv) { | |||
| 245 | result.config.critical_diff = strtoul(optarg, NULL, 10); | 251 | result.config.critical_diff = strtoul(optarg, NULL, 10); |
| 246 | result.config.check_critical_diff = true; | 252 | result.config.check_critical_diff = true; |
| 247 | } else if (strspn(optarg, "0123456789:,") > 0) { | 253 | } else if (strspn(optarg, "0123456789:,") > 0) { |
| 248 | if (sscanf(optarg, "%lu%*[:,]%d", &result.config.critical_diff, &result.config.critical_time) == 2) { | 254 | if (sscanf(optarg, "%lu%*[:,]%d", &result.config.critical_diff, |
| 255 | &result.config.critical_time) == 2) { | ||
| 249 | result.config.check_critical_diff = true; | 256 | result.config.check_critical_diff = true; |
| 250 | result.config.check_critical_time = true; | 257 | result.config.check_critical_time = true; |
| 251 | } else { | 258 | } else { |
