mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-23 07:07:00 -04:00
Merge branch 'master' into compiler_warning_part_6
This commit is contained in:
commit
e4b6e83264
15 changed files with 1234 additions and 1103 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -74,6 +74,10 @@ jobs:
|
|||
/bin/sh -c '${{ matrix.prepare }} && \
|
||||
tools/setup && \
|
||||
./configure --enable-libtap --with-ipv6=no && \
|
||||
set -x && \
|
||||
tmp_dir=$(mktemp -d -t test-XXXX) && cp -a po/ $tmp_dir/ && \
|
||||
cd po && make update-po && cd .. && \
|
||||
diff -Nur $tmp_dir/po/*.po po/*.po | tee -a /tmp/po.diff && diff -Nur $tmp_dir/po/*.pot po/*.pot | tee -a /tmp/po.diff && if [ $(wc -l /tmp/po.diff | cut -f 1 -d" ") -gt 0 ]; then echo "Error: Translations needs to be updated with make update-po!" && exit 1; fi && \
|
||||
make && \
|
||||
make test'
|
||||
docker container prune -f
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ struct in_addr requested_address;
|
|||
|
||||
int process_arguments(int, char **);
|
||||
int call_getopt(int, char **);
|
||||
int validate_arguments(int, int);
|
||||
int validate_arguments(int);
|
||||
void print_usage(void);
|
||||
void print_help(void);
|
||||
|
||||
|
|
@ -1055,8 +1055,8 @@ int process_arguments(int argc, char **argv){
|
|||
return ERROR;
|
||||
|
||||
arg_index = call_getopt(argc,argv);
|
||||
return validate_arguments(argc,arg_index);
|
||||
}
|
||||
return validate_arguments(argc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1154,13 +1154,13 @@ int call_getopt(int argc, char **argv){
|
|||
}
|
||||
|
||||
|
||||
int validate_arguments(int argc, int arg_index){
|
||||
int validate_arguments(int argc){
|
||||
|
||||
if(argc-optind > 0)
|
||||
if(argc - optind > 0)
|
||||
usage(_("Got unexpected non-option argument"));
|
||||
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(__sun__) || defined(__solaris__) || defined(__hpux__)
|
||||
|
|
|
|||
|
|
@ -1432,15 +1432,20 @@ get_ip_address(const char *ifname)
|
|||
{
|
||||
// TODO: Rewrite this so the function return an error and we exit somewhere else
|
||||
struct sockaddr_in ip;
|
||||
ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy
|
||||
#if defined(SIOCGIFADDR)
|
||||
struct ifreq ifr;
|
||||
|
||||
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
|
||||
|
||||
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
|
||||
|
||||
if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1)
|
||||
crash("Cannot determine IP address of interface %s", ifname);
|
||||
|
||||
memcpy(&ip, &ifr.ifr_addr, sizeof(ip));
|
||||
#else
|
||||
(void) ifname;
|
||||
errno = 0;
|
||||
crash("Cannot get interface IP address on this platform.");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ void curlhelp_freewritebuffer (curlhelp_write_curlbuf*);
|
|||
int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t);
|
||||
int curlhelp_buffer_read_callback (void *, size_t , size_t , void *);
|
||||
void curlhelp_freereadbuffer (curlhelp_read_curlbuf *);
|
||||
curlhelp_ssl_library curlhelp_get_ssl_library (CURL*);
|
||||
curlhelp_ssl_library curlhelp_get_ssl_library ();
|
||||
const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library);
|
||||
int net_noopenssl_check_certificate (cert_ptr_union*, int, int);
|
||||
|
||||
|
|
@ -297,6 +297,7 @@ main (int argc, char **argv)
|
|||
|
||||
int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
|
||||
{
|
||||
(void) preverify_ok;
|
||||
/* TODO: we get all certificates of the chain, so which ones
|
||||
* should we test?
|
||||
* TODO: is the last certificate always the server certificate?
|
||||
|
|
@ -321,6 +322,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
|
|||
|
||||
CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm)
|
||||
{
|
||||
(void) curl; // ignore unused parameter
|
||||
(void) parm; // ignore unused parameter
|
||||
SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
|
||||
|
||||
return CURLE_OK;
|
||||
|
|
@ -375,8 +378,12 @@ void
|
|||
handle_curl_option_return_code (CURLcode res, const char* option)
|
||||
{
|
||||
if (res != CURLE_OK) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Error while setting cURL option '%s': cURL returned %d - %s"),
|
||||
option, res, curl_easy_strerror(res));
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Error while setting cURL option '%s': cURL returned %d - %s"),
|
||||
option,
|
||||
res,
|
||||
curl_easy_strerror(res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
}
|
||||
|
|
@ -516,9 +523,13 @@ check_http (void)
|
|||
// fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy
|
||||
if(use_ssl && host_name != NULL) {
|
||||
if ( (res=lookup_host (server_address, addrstr, DEFAULT_BUFFER_SIZE/2)) != 0) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
|
||||
server_address, res, gai_strerror (res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
|
||||
server_address,
|
||||
res,
|
||||
gai_strerror (res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, addrstr);
|
||||
host = curl_slist_append(NULL, dnscache);
|
||||
|
|
@ -646,7 +657,7 @@ check_http (void)
|
|||
}
|
||||
|
||||
/* detect SSL library used by libcurl */
|
||||
ssl_library = curlhelp_get_ssl_library (curl);
|
||||
ssl_library = curlhelp_get_ssl_library ();
|
||||
|
||||
/* try hard to get a stack of certificates to verify against */
|
||||
if (check_cert) {
|
||||
|
|
@ -816,9 +827,13 @@ check_http (void)
|
|||
|
||||
/* Curl errors, result in critical Nagios state */
|
||||
if (res != CURLE_OK) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
|
||||
server_port, res, errbuf[0] ? errbuf : curl_easy_strerror(res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
|
||||
server_port,
|
||||
res,
|
||||
errbuf[0] ? errbuf : curl_easy_strerror(res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
|
||||
/* certificate checks */
|
||||
|
|
@ -861,15 +876,19 @@ check_http (void)
|
|||
}
|
||||
GOT_FIRST_CERT:
|
||||
if (!raw_cert) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot retrieve certificates from CERTINFO information - certificate data was empty"));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Cannot retrieve certificates from CERTINFO information - certificate data was empty"));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
BIO* cert_BIO = BIO_new (BIO_s_mem());
|
||||
BIO_write (cert_BIO, raw_cert, strlen(raw_cert));
|
||||
cert = PEM_read_bio_X509 (cert_BIO, NULL, NULL, NULL);
|
||||
if (!cert) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot read certificate from CERTINFO information - BIO error"));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Cannot read certificate from CERTINFO information - BIO error"));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
BIO_free (cert_BIO);
|
||||
result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
|
||||
|
|
@ -886,9 +905,12 @@ GOT_FIRST_CERT:
|
|||
}
|
||||
#endif /* USE_OPENSSL */
|
||||
} else {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot retrieve certificates - cURL returned %d - %s"),
|
||||
res, curl_easy_strerror(res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Cannot retrieve certificates - cURL returned %d - %s"),
|
||||
res,
|
||||
curl_easy_strerror(res));
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -927,8 +949,11 @@ GOT_FIRST_CERT:
|
|||
|
||||
/* get status line of answer, check sanity of HTTP code */
|
||||
if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparsable status line in %.3g seconds response time|%s\n",
|
||||
total_time, perfstring);
|
||||
snprintf (msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
"Unparsable status line in %.3g seconds response time|%s\n",
|
||||
total_time,
|
||||
perfstring);
|
||||
/* we cannot know the major/minor version here for sure as we cannot parse the first line */
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg);
|
||||
}
|
||||
|
|
@ -948,9 +973,16 @@ GOT_FIRST_CERT:
|
|||
/* make sure the status line matches the response we are looking for */
|
||||
if (!expected_statuscode(status_line.first_line, server_expect)) {
|
||||
if (server_port == HTTP_PORT)
|
||||
snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host: %s\n"), status_line.first_line);
|
||||
snprintf(msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Invalid HTTP response received from host: %s\n"),
|
||||
status_line.first_line);
|
||||
else
|
||||
snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: %s\n"), server_port, status_line.first_line);
|
||||
snprintf(msg,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("Invalid HTTP response received from host on port %d: %s\n"),
|
||||
server_port,
|
||||
status_line.first_line);
|
||||
die (STATE_CRITICAL, "HTTP CRITICAL - %s%s%s", msg,
|
||||
show_body ? "\n" : "",
|
||||
show_body ? body_buf.buf : "");
|
||||
|
|
@ -1023,23 +1055,55 @@ GOT_FIRST_CERT:
|
|||
|
||||
if (strlen (header_expect)) {
|
||||
if (!strstr (header_buf.buf, header_expect)) {
|
||||
|
||||
strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
|
||||
|
||||
if(output_header_search[sizeof(output_header_search)-1]!='\0') {
|
||||
bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
|
||||
}
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
|
||||
result = STATE_CRITICAL;
|
||||
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("%sheader '%s' not found on '%s://%s:%d%s', "),
|
||||
msg,
|
||||
output_header_search,
|
||||
use_ssl ? "https" : "http",
|
||||
host_name ? host_name : server_address,
|
||||
server_port,
|
||||
server_url);
|
||||
|
||||
strcpy(msg, tmp);
|
||||
|
||||
result = STATE_CRITICAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen (string_expect)) {
|
||||
if (!strstr (body_buf.buf, string_expect)) {
|
||||
|
||||
strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
|
||||
|
||||
if(output_string_search[sizeof(output_string_search)-1]!='\0') {
|
||||
bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
|
||||
}
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
|
||||
result = STATE_CRITICAL;
|
||||
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp,
|
||||
DEFAULT_BUFFER_SIZE,
|
||||
_("%sstring '%s' not found on '%s://%s:%d%s', "),
|
||||
msg,
|
||||
output_string_search,
|
||||
use_ssl ? "https" : "http",
|
||||
host_name ? host_name : server_address,
|
||||
server_port,
|
||||
server_url);
|
||||
|
||||
strcpy(msg, tmp);
|
||||
|
||||
result = STATE_CRITICAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1050,27 +1114,48 @@ GOT_FIRST_CERT:
|
|||
result = max_state_alt(STATE_OK, result);
|
||||
}
|
||||
else if ((errcode == REG_NOMATCH && !invert_regex) || (errcode == 0 && invert_regex)) {
|
||||
if (!invert_regex)
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
|
||||
else
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
|
||||
result = STATE_CRITICAL;
|
||||
}
|
||||
else {
|
||||
regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf);
|
||||
result = STATE_UNKNOWN;
|
||||
}
|
||||
if (!invert_regex) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
|
||||
strcpy(msg, tmp);
|
||||
|
||||
} else {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
|
||||
strcpy(msg, tmp);
|
||||
|
||||
}
|
||||
result = STATE_CRITICAL;
|
||||
} else {
|
||||
regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
|
||||
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf);
|
||||
strcpy(msg, tmp);
|
||||
result = STATE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/* make sure the page is of an appropriate size */
|
||||
if ((max_page_len > 0) && (page_len > max_page_len)) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len);
|
||||
result = max_state_alt(STATE_WARNING, result);
|
||||
} else if ((min_page_len > 0) && (page_len < min_page_len)) {
|
||||
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len);
|
||||
result = max_state_alt(STATE_WARNING, result);
|
||||
}
|
||||
if ((max_page_len > 0) && (page_len > max_page_len)) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len);
|
||||
|
||||
strcpy(msg, tmp);
|
||||
|
||||
result = max_state_alt(STATE_WARNING, result);
|
||||
|
||||
} else if ((min_page_len > 0) && (page_len < min_page_len)) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len);
|
||||
strcpy(msg, tmp);
|
||||
result = max_state_alt(STATE_WARNING, result);
|
||||
}
|
||||
|
||||
/* -w, -c: check warning and critical level */
|
||||
result = max_state_alt(get_status(total_time, thlds), result);
|
||||
|
|
@ -1654,6 +1739,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'R': /* regex */
|
||||
cflags |= REG_ICASE;
|
||||
// fall through
|
||||
case 'r': /* regex */
|
||||
strncpy (regexp, optarg, MAX_RE_SIZE - 1);
|
||||
regexp[MAX_RE_SIZE - 1] = 0;
|
||||
|
|
@ -2307,37 +2393,67 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
|
|||
server_date = get_header_value (headers, nof_headers, "date");
|
||||
document_date = get_header_value (headers, nof_headers, "last-modified");
|
||||
|
||||
if (!server_date || !*server_date) {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg);
|
||||
date_result = max_state_alt(STATE_UNKNOWN, date_result);
|
||||
} else if (!document_date || !*document_date) {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg);
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
if (!server_date || !*server_date) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg);
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_UNKNOWN, date_result);
|
||||
|
||||
} else if (!document_date || !*document_date) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg);
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
|
||||
} else {
|
||||
time_t srv_data = curl_getdate (server_date, NULL);
|
||||
time_t doc_data = curl_getdate (document_date, NULL);
|
||||
if (verbose >= 2)
|
||||
printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data);
|
||||
if (srv_data <= 0) {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else if (doc_data <= 0) {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else if (doc_data > srv_data + 30) {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else if (doc_data < srv_data - maximum_age) {
|
||||
int n = (srv_data - doc_data);
|
||||
if (n > (60 * 60 * 24 * 2)) {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else {
|
||||
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (srv_data <= 0) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else if (doc_data <= 0) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else if (doc_data > srv_data + 30) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else if (doc_data < srv_data - maximum_age) {
|
||||
int n = (srv_data - doc_data);
|
||||
if (n > (60 * 60 * 24 * 2)) {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
} else {
|
||||
char tmp[DEFAULT_BUFFER_SIZE];
|
||||
|
||||
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
|
||||
strcpy(*msg, tmp);
|
||||
|
||||
date_result = max_state_alt(STATE_CRITICAL, date_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (server_date) free (server_date);
|
||||
if (document_date) free (document_date);
|
||||
|
|
@ -2379,7 +2495,7 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
|
|||
|
||||
/* TODO: is there a better way in libcurl to check for the SSL library? */
|
||||
curlhelp_ssl_library
|
||||
curlhelp_get_ssl_library (CURL* curl)
|
||||
curlhelp_get_ssl_library ()
|
||||
{
|
||||
curl_version_info_data* version_data;
|
||||
char *ssl_version;
|
||||
|
|
|
|||
|
|
@ -433,6 +433,7 @@ process_arguments (int argc, char **argv)
|
|||
else
|
||||
timeout_interval = atoi (optarg);
|
||||
|
||||
break;
|
||||
case 'H': /* host */
|
||||
if (!is_host (optarg))
|
||||
usage2 (_("Invalid hostname/address"), optarg);
|
||||
|
|
|
|||
|
|
@ -354,6 +354,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'I': /* sourceip */
|
||||
sourceif = strscpy (sourceif, optarg);
|
||||
break;
|
||||
case '4': /* IPv4 only */
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -353,6 +353,7 @@ process_arguments (int argc, char **argv)
|
|||
usage2 (_("Port must be a positive short integer"), optarg);
|
||||
else
|
||||
port = atoi(optarg);
|
||||
break;
|
||||
case 'D': /* disable paper out check*/
|
||||
check_paper_out = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -498,6 +498,7 @@ bool process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'R': /* regex */
|
||||
cflags |= REG_ICASE;
|
||||
// fall through
|
||||
case 'r': /* regex */
|
||||
strncpy (regexp, optarg, MAX_RE_SIZE - 1);
|
||||
regexp[MAX_RE_SIZE - 1] = 0;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
|
|||
* status is pretty much useless as syncsource_found is a global variable
|
||||
* used later in main to check is the server was synchronized. It works
|
||||
* so I left it alone */
|
||||
int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){
|
||||
int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){
|
||||
int conn=-1, i, npeers=0, num_candidates=0;
|
||||
double tmp_offset = 0;
|
||||
int min_peer_sel=PEER_INCLUDED;
|
||||
|
|
@ -585,8 +585,8 @@ int main(int argc, char *argv[]){
|
|||
/* set socket timeout */
|
||||
alarm (socket_timeout);
|
||||
|
||||
/* This returns either OK or WARNING (See comment proceeding ntp_request) */
|
||||
result = ntp_request(server_address, &offset, &offset_result, &jitter, &stratum, &num_truechimers);
|
||||
/* This returns either OK or WARNING (See comment preceding ntp_request) */
|
||||
result = ntp_request(&offset, &offset_result, &jitter, &stratum, &num_truechimers);
|
||||
|
||||
if(offset_result == STATE_UNKNOWN) {
|
||||
/* if there's no sync peer (this overrides ntp_request output): */
|
||||
|
|
|
|||
|
|
@ -632,6 +632,7 @@ process_arguments (int argc, char **argv)
|
|||
#else
|
||||
usage (_("SSL support not available - install OpenSSL and recompile"));
|
||||
#endif
|
||||
// fall through
|
||||
case 'S':
|
||||
/* starttls */
|
||||
use_ssl = TRUE;
|
||||
|
|
|
|||
|
|
@ -855,6 +855,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'R': /* regex */
|
||||
cflags = REG_ICASE;
|
||||
// fall through
|
||||
case 'r': /* regex */
|
||||
cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
|
||||
strncpy (regex_expect, optarg, sizeof (regex_expect) - 1);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ char *ups_status;
|
|||
int temp_output_c = 0;
|
||||
|
||||
int determine_status (void);
|
||||
int get_ups_variable (const char *, char *, size_t);
|
||||
int get_ups_variable (const char *, char *);
|
||||
|
||||
int process_arguments (int, char **);
|
||||
int validate_arguments (void);
|
||||
|
|
@ -189,7 +189,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* get the ups utility voltage if possible */
|
||||
res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer));
|
||||
res=get_ups_variable ("input.voltage", temp_buffer);
|
||||
if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
|
||||
else if (res != OK)
|
||||
return STATE_CRITICAL;
|
||||
|
|
@ -224,7 +224,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* get the ups battery percent if possible */
|
||||
res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer));
|
||||
res=get_ups_variable ("battery.charge", temp_buffer);
|
||||
if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
|
||||
else if ( res != OK)
|
||||
return STATE_CRITICAL;
|
||||
|
|
@ -253,7 +253,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* get the ups load percent if possible */
|
||||
res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer));
|
||||
res=get_ups_variable ("ups.load", temp_buffer);
|
||||
if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
|
||||
else if ( res != OK)
|
||||
return STATE_CRITICAL;
|
||||
|
|
@ -282,7 +282,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
/* get the ups temperature if possible */
|
||||
res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer));
|
||||
res=get_ups_variable ("ups.temperature", temp_buffer);
|
||||
if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
|
||||
else if ( res != OK)
|
||||
return STATE_CRITICAL;
|
||||
|
|
@ -342,7 +342,7 @@ determine_status (void)
|
|||
char *ptr;
|
||||
int res;
|
||||
|
||||
res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
|
||||
res=get_ups_variable ("ups.status", recv_buffer);
|
||||
if (res == NOSUCHVAR) return OK;
|
||||
if (res != STATE_OK) {
|
||||
printf ("%s\n", _("Invalid response received from host"));
|
||||
|
|
@ -388,7 +388,7 @@ determine_status (void)
|
|||
|
||||
/* gets a variable value for a specific UPS */
|
||||
int
|
||||
get_ups_variable (const char *varname, char *buf, size_t buflen)
|
||||
get_ups_variable (const char *varname, char *buf)
|
||||
{
|
||||
/* char command[MAX_INPUT_BUFFER]; */
|
||||
char temp_buffer[MAX_INPUT_BUFFER];
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue