aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c10
-rw-r--r--plugins/check_dig.c4
-rw-r--r--plugins/check_disk.c24
-rw-r--r--plugins/check_dns.c8
-rw-r--r--plugins/check_fping.c6
-rw-r--r--plugins/check_game.c4
-rw-r--r--plugins/check_hpjd.c2
-rw-r--r--plugins/check_http.c78
-rw-r--r--plugins/check_ldap.c8
-rw-r--r--plugins/check_load.c2
-rw-r--r--plugins/check_mrtgtraf.c2
-rw-r--r--plugins/check_mysql.c2
-rw-r--r--plugins/check_mysql_query.c4
-rw-r--r--plugins/check_nagios.c2
-rw-r--r--plugins/check_nt.c52
-rw-r--r--plugins/check_ntp.c20
-rw-r--r--plugins/check_ntp_peer.c36
-rw-r--r--plugins/check_ntp_time.c16
-rw-r--r--plugins/check_nwstat.c204
-rw-r--r--plugins/check_overcr.c2
-rw-r--r--plugins/check_pgsql.c2
-rw-r--r--plugins/check_ping.c10
-rw-r--r--plugins/check_procs.c34
-rw-r--r--plugins/check_radius.c2
-rw-r--r--plugins/check_real.c2
-rw-r--r--plugins/check_smtp.c30
-rw-r--r--plugins/check_snmp.c34
-rw-r--r--plugins/check_ssh.c4
-rw-r--r--plugins/check_swap.c16
-rw-r--r--plugins/check_tcp.c4
-rw-r--r--plugins/check_time.c2
-rw-r--r--plugins/check_ups.c60
-rw-r--r--plugins/check_users.c2
-rw-r--r--plugins/negate.c2
-rw-r--r--plugins/urlize.c2
-rw-r--r--plugins/utils.c67
-rw-r--r--plugins/utils.h2
37 files changed, 395 insertions, 366 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 87520166..c5f0d529 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -281,8 +281,8 @@ process_arguments (int argc, char **argv)
case 'C': /* Command for remote machine */
commands++;
if (commands > 1)
- asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
- asprintf (&remotecmd, "%s%s", remotecmd, optarg);
+ xasprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
+ xasprintf (&remotecmd, "%s%s", remotecmd, optarg);
break;
case 'S': /* skip n (or all) lines on stdout */
if (optarg == NULL)
@@ -328,13 +328,13 @@ process_arguments (int argc, char **argv)
if (strlen(remotecmd) == 0) {
for (; c < argc; c++)
if (strlen(remotecmd) > 0)
- asprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
+ xasprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
else
- asprintf (&remotecmd, "%s", argv[c]);
+ xasprintf (&remotecmd, "%s", argv[c]);
}
if (commands > 1 || passive)
- asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
+ xasprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
if (remotecmd == NULL || strlen (remotecmd) <= 1)
usage_va(_("No remotecmd"));
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 06f59c80..893e0a14 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -87,7 +87,7 @@ main (int argc, char **argv)
usage_va(_("Could not parse arguments"));
/* get the command to run */
- asprintf (&command_line, "%s @%s -p %d %s -t %s %s",
+ xasprintf (&command_line, "%s @%s -p %d %s -t %s %s",
PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args);
alarm (timeout_interval);
@@ -306,7 +306,7 @@ print_help (void)
{
char *myport;
- asprintf (&myport, "%d", DEFAULT_PORT);
+ xasprintf (&myport, "%d", DEFAULT_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f8897647..f8e913e1 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -320,7 +320,7 @@ main (int argc, char **argv)
}
/* Nb: *_high_tide are unset when == UINT_MAX */
- asprintf (&perf, "%s %s", perf,
+ xasprintf (&perf, "%s %s", perf,
perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
path->dused_units, units,
(warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide,
@@ -331,20 +331,20 @@ main (int argc, char **argv)
if (disk_result==STATE_OK && erronly && !verbose)
continue;
- asprintf (&output, "%s %s %.0f %s (%.0f%%",
+ xasprintf (&output, "%s %s %.0f %s (%.0f%%",
output,
(!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
path->dfree_units,
units,
path->dfree_pct);
if (path->dused_inodes_percent < 0) {
- asprintf(&output, "%s inode=-);", output);
+ xasprintf(&output, "%s inode=-);", output);
} else {
- asprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent );
+ xasprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent );
}
/* TODO: Need to do a similar debug line
- asprintf (&details, _("%s\n\
+ xasprintf (&details, _("%s\n\
%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
me->me_devname, me->me_type, me->me_mountdir,
@@ -356,7 +356,7 @@ main (int argc, char **argv)
}
if (verbose >= 2)
- asprintf (&output, "%s%s", output, details);
+ xasprintf (&output, "%s%s", output, details);
printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
@@ -473,13 +473,13 @@ process_arguments (int argc, char **argv)
if (*optarg == '@') {
warn_freespace_percent = optarg;
} else {
- asprintf(&warn_freespace_percent, "@%s", optarg);
+ xasprintf(&warn_freespace_percent, "@%s", optarg);
}
} else {
if (*optarg == '@') {
warn_freespace_units = optarg;
} else {
- asprintf(&warn_freespace_units, "@%s", optarg);
+ xasprintf(&warn_freespace_units, "@%s", optarg);
}
}
break;
@@ -494,13 +494,13 @@ process_arguments (int argc, char **argv)
if (*optarg == '@') {
crit_freespace_percent = optarg;
} else {
- asprintf(&crit_freespace_percent, "@%s", optarg);
+ xasprintf(&crit_freespace_percent, "@%s", optarg);
}
} else {
if (*optarg == '@') {
crit_freespace_units = optarg;
} else {
- asprintf(&crit_freespace_units, "@%s", optarg);
+ xasprintf(&crit_freespace_units, "@%s", optarg);
}
}
break;
@@ -509,14 +509,14 @@ process_arguments (int argc, char **argv)
if (*optarg == '@') {
warn_freeinodes_percent = optarg;
} else {
- asprintf(&warn_freeinodes_percent, "@%s", optarg);
+ xasprintf(&warn_freeinodes_percent, "@%s", optarg);
}
break;
case 'K': /* critical inode threshold */
if (*optarg == '@') {
crit_freeinodes_percent = optarg;
} else {
- asprintf(&crit_freeinodes_percent, "@%s", optarg);
+ xasprintf(&crit_freeinodes_percent, "@%s", optarg);
}
break;
case 'u':
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 73b560ca..91af730b 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -103,7 +103,7 @@ main (int argc, char **argv)
}
/* get the command to run */
- asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
+ xasprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
alarm (timeout_interval);
gettimeofday (&tv, NULL);
@@ -208,19 +208,19 @@ main (int argc, char **argv)
for (i=0; i<expected_address_cnt; i++) {
/* check if we get a match and prepare an error string */
if (strcmp(address, expected_address[i]) == 0) result = STATE_OK;
- asprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]);
+ xasprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]);
}
if (result == STATE_CRITICAL) {
/* Strip off last semicolon... */
temp_buffer[strlen(temp_buffer)-2] = '\0';
- asprintf(&msg, _("expected '%s' but got '%s'"), temp_buffer, address);
+ xasprintf(&msg, _("expected '%s' but got '%s'"), temp_buffer, address);
}
}
/* check if authoritative */
if (result == STATE_OK && expect_authority && non_authoritative) {
result = STATE_CRITICAL;
- asprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
+ xasprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
}
microsec = deltime (tv);
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index dd3f86d1..675a547c 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -92,11 +92,11 @@ main (int argc, char **argv)
/* compose the command */
if (target_timeout)
- asprintf(&option_string, "%s-t %d ", option_string, target_timeout);
+ xasprintf(&option_string, "%s-t %d ", option_string, target_timeout);
if (packet_interval)
- asprintf(&option_string, "%s-p %d ", option_string, packet_interval);
+ xasprintf(&option_string, "%s-p %d ", option_string, packet_interval);
- asprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING,
+ xasprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING,
option_string, packet_size, packet_count, server);
if (verbose)
diff --git a/plugins/check_game.c b/plugins/check_game.c
index 5496c4dc..89bb4b12 100644
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
@@ -84,11 +84,11 @@ main (int argc, char **argv)
result = STATE_OK;
/* create the command line to execute */
- asprintf (&command_line, "%s -raw %s -%s %s",
+ xasprintf (&command_line, "%s -raw %s -%s %s",
PATH_TO_QSTAT, QSTAT_DATA_DELIMITER, game_type, server_ip);
if (port)
- asprintf (&command_line, "%s:%-d", command_line, port);
+ xasprintf (&command_line, "%s:%-d", command_line, port);
if (verbose > 0)
printf ("%s\n", command_line);
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 51a0099a..60e922ed 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -227,7 +227,7 @@ main (int argc, char **argv)
/* might not be the problem, but most likely is. */
result = STATE_UNKNOWN ;
- asprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address );
+ xasprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address );
}
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 703e3174..77a235e4 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -147,7 +147,7 @@ main (int argc, char **argv)
/* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */
server_url = strdup(HTTP_URL);
server_url_length = strlen(server_url);
- asprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)",
+ xasprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)",
NP_VERSION, VERSION);
/* Parse extra opts if any */
@@ -265,7 +265,7 @@ process_arguments (int argc, char **argv)
warning_thresholds = optarg;
break;
case 'A': /* User Agent String */
- asprintf (&user_agent, "User-Agent: %s", optarg);
+ xasprintf (&user_agent, "User-Agent: %s", optarg);
break;
case 'k': /* Additional headers */
if (http_opt_headers_count == 0)
@@ -273,7 +273,7 @@ process_arguments (int argc, char **argv)
else
http_opt_headers = realloc (http_opt_headers, sizeof (char *) * (++http_opt_headers_count));
http_opt_headers[http_opt_headers_count - 1] = optarg;
- /* asprintf (&http_opt_headers, "%s", optarg); */
+ /* xasprintf (&http_opt_headers, "%s", optarg); */
break;
case 'L': /* show html link */
display_html = TRUE;
@@ -394,7 +394,7 @@ process_arguments (int argc, char **argv)
server_expect_yn = 1;
break;
case 'T': /* Content-type */
- asprintf (&http_content_type, "%s", optarg);
+ xasprintf (&http_content_type, "%s", optarg);
break;
case 'l': /* linespan */
cflags &= ~REG_NEWLINE;
@@ -690,31 +690,31 @@ check_document_dates (const char *headers, char **msg)
/* Done parsing the body. Now check the dates we (hopefully) parsed. */
if (!server_date || !*server_date) {
- asprintf (msg, _("%sServer date unknown, "), *msg);
+ xasprintf (msg, _("%sServer date unknown, "), *msg);
date_result = max_state_alt(STATE_UNKNOWN, date_result);
} else if (!document_date || !*document_date) {
- asprintf (msg, _("%sDocument modification date unknown, "), *msg);
+ xasprintf (msg, _("%sDocument modification date unknown, "), *msg);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else {
time_t srv_data = parse_time_string (server_date);
time_t doc_data = parse_time_string (document_date);
if (srv_data <= 0) {
- asprintf (msg, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
+ xasprintf (msg, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data <= 0) {
- asprintf (msg, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
+ xasprintf (msg, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data > srv_data + 30) {
- asprintf (msg, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
+ xasprintf (msg, _("%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)) {
- asprintf (msg, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
+ xasprintf (msg, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else {
- asprintf (msg, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
+ xasprintf (msg, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
date_result = max_state_alt(STATE_CRITICAL, date_result);
}
}
@@ -831,10 +831,10 @@ check_http (void)
}
#endif /* HAVE_SSL */
- asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
+ xasprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
/* tell HTTP/1.1 servers not to keep the connection alive */
- asprintf (&buf, "%sConnection: close\r\n", buf);
+ xasprintf (&buf, "%sConnection: close\r\n", buf);
/* optionally send the host header info */
if (host_name) {
@@ -845,16 +845,16 @@ check_http (void)
*/
if ((use_ssl == FALSE && server_port == HTTP_PORT) ||
(use_ssl == TRUE && server_port == HTTPS_PORT))
- asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
+ xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
else
- asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
+ xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
}
/* optionally send any other header tag */
if (http_opt_headers_count) {
for (i = 0; i < http_opt_headers_count ; i++) {
for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER)))
- asprintf (&buf, "%s%s\r\n", buf, pos);
+ xasprintf (&buf, "%s%s\r\n", buf, pos);
}
/* This cannot be free'd here because a redirection will then try to access this and segfault */
/* Covered in a testcase in tests/check_http.t */
@@ -864,29 +864,29 @@ check_http (void)
/* optionally send the authentication info */
if (strlen(user_auth)) {
base64_encode_alloc (user_auth, strlen (user_auth), &auth);
- asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth);
+ xasprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth);
}
/* optionally send the proxy authentication info */
if (strlen(proxy_auth)) {
base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth);
- asprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth);
+ xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth);
}
/* either send http POST data (any data, not only POST)*/
if (http_post_data) {
if (http_content_type) {
- asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type);
+ xasprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type);
} else {
- asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf);
+ xasprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf);
}
- asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
- asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
+ xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
+ xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
}
else {
/* or just a newline so the server knows we're done with the request */
- asprintf (&buf, "%s%s", buf, CRLF);
+ xasprintf (&buf, "%s%s", buf, CRLF);
}
if (verbose) printf ("%s\n", buf);
@@ -896,7 +896,7 @@ check_http (void)
full_page = strdup("");
while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) {
buffer[i] = '\0';
- asprintf (&full_page_new, "%s%s", full_page, buffer);
+ xasprintf (&full_page_new, "%s%s", full_page, buffer);
free (full_page);
full_page = full_page_new;
pagesize += i;
@@ -981,11 +981,11 @@ check_http (void)
/* make sure the status line matches the response we are looking for */
if (!expected_statuscode (status_line, server_expect)) {
if (server_port == HTTP_PORT)
- asprintf (&msg,
+ xasprintf (&msg,
_("Invalid HTTP response received from host: %s\n"),
status_line);
else
- asprintf (&msg,
+ xasprintf (&msg,
_("Invalid HTTP response received from host on port %d: %s\n"),
server_port, status_line);
die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
@@ -994,7 +994,7 @@ check_http (void)
/* Bypass normal status line check if server_expect was set by user and not default */
/* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */
if ( server_expect_yn ) {
- asprintf (&msg,
+ xasprintf (&msg,
_("Status line output matched \"%s\" - "), server_expect);
if (verbose)
printf ("%s\n",msg);
@@ -1017,12 +1017,12 @@ check_http (void)
}
/* server errors result in a critical state */
else if (http_status >= 500) {
- asprintf (&msg, _("%s - "), status_line);
+ xasprintf (&msg, _("%s - "), status_line);
result = STATE_CRITICAL;
}
/* client errors result in a warning state */
else if (http_status >= 400) {
- asprintf (&msg, _("%s - "), status_line);
+ xasprintf (&msg, _("%s - "), status_line);
result = max_state_alt(STATE_WARNING, result);
}
/* check redirected page if specified */
@@ -1032,11 +1032,11 @@ check_http (void)
redir (header, status_line);
else
result = max_state_alt(onredirect, result);
- asprintf (&msg, _("%s - "), status_line);
+ xasprintf (&msg, _("%s - "), status_line);
} /* end if (http_status >= 300) */
else {
/* Print OK status anyway */
- asprintf (&msg, _("%s - "), status_line);
+ xasprintf (&msg, _("%s - "), status_line);
}
} /* end else (server_expect_yn) */
@@ -1056,7 +1056,7 @@ check_http (void)
if(output_string_search[sizeof(output_string_search)-1]!='\0') {
bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
}
- asprintf (&msg, _("%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);
+ xasprintf (&msg, _("%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;
}
}
@@ -1069,15 +1069,15 @@ check_http (void)
}
else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) {
if (invert_regex == 0)
- asprintf (&msg, _("%spattern not found, "), msg);
+ xasprintf (&msg, _("%spattern not found, "), msg);
else
- asprintf (&msg, _("%spattern found, "), msg);
+ xasprintf (&msg, _("%spattern found, "), msg);
result = STATE_CRITICAL;
}
else {
/* FIXME: Shouldn't that be UNKNOWN? */
regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
- asprintf (&msg, _("%sExecute Error: %s, "), msg, errbuf);
+ xasprintf (&msg, _("%sExecute Error: %s, "), msg, errbuf);
result = STATE_CRITICAL;
}
}
@@ -1093,10 +1093,10 @@ check_http (void)
*/
page_len = pagesize;
if ((max_page_len > 0) && (page_len > max_page_len)) {
- asprintf (&msg, _("%spage size %d too large, "), msg, page_len);
+ xasprintf (&msg, _("%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)) {
- asprintf (&msg, _("%spage size %d too small, "), msg, page_len);
+ xasprintf (&msg, _("%spage size %d too small, "), msg, page_len);
result = max_state_alt(STATE_WARNING, result);
}
@@ -1107,7 +1107,7 @@ check_http (void)
msg[strlen(msg)-3] = '\0';
/* check elapsed time */
- asprintf (&msg,
+ xasprintf (&msg,
_("%s - %d bytes in %.3f second response time %s|%s %s"),
msg, page_len, elapsed_time,
(display_html ? "</A>" : ""),
@@ -1214,7 +1214,7 @@ redir (char *pos, char *status_line)
if ((url[0] != '/')) {
if ((x = strrchr(server_url, '/')))
*x = '\0';
- asprintf (&url, "%s/%s", server_url, url);
+ xasprintf (&url, "%s/%s", server_url, url);
}
i = server_port;
strcpy (type, server_type);
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index f83f1397..65db8517 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -99,7 +99,7 @@ main (int argc, char *argv[])
textdomain (PACKAGE);
if (strstr(argv[0],"check_ldaps")) {
- asprintf (&progname, "check_ldaps");
+ xasprintf (&progname, "check_ldaps");
}
/* Parse extra opts if any */
@@ -145,7 +145,7 @@ main (int argc, char *argv[])
#endif
if (ld_port == LDAPS_PORT || ssl_on_connect) {
- asprintf (&SERVICE, "LDAPS");
+ xasprintf (&SERVICE, "LDAPS");
#if defined(HAVE_LDAP_SET_OPTION) && defined(LDAP_OPT_X_TLS)
/* ldaps: set option tls */
tls = LDAP_OPT_X_TLS_HARD;
@@ -162,7 +162,7 @@ main (int argc, char *argv[])
return STATE_CRITICAL;
#endif /* LDAP_OPT_X_TLS */
} else if (starttls) {
- asprintf (&SERVICE, "LDAP-TLS");
+ xasprintf (&SERVICE, "LDAP-TLS");
#if defined(HAVE_LDAP_SET_OPTION) && defined(HAVE_LDAP_START_TLS_S)
/* ldap with startTLS: set option version */
if (ldap_get_option(ld,LDAP_OPT_PROTOCOL_VERSION, &version) == LDAP_OPT_SUCCESS )
@@ -389,7 +389,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", DEFAULT_PORT);
+ xasprintf (&myport, "%d", DEFAULT_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 1bdb06aa..780ffffe 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -186,7 +186,7 @@ main (int argc, char **argv)
/* we got this far, so assume OK until we've measured */
result = STATE_OK;
- asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
+ xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
for(i = 0; i < 3; i++) {
if(la[i] > cload[i]) {
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c
index 4fd9bc0a..a8226514 100644
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
@@ -191,7 +191,7 @@ main (int argc, char **argv)
result = STATE_WARNING;
}
- asprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"),
+ xasprintf (&error_message, _("%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"),
(use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate,
incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"),
adjusted_outgoing_rate, outgoing_speed_rating,
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index d9b4e537..4fbdc2b9 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -369,7 +369,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", MYSQL_PORT);
+ xasprintf (&myport, "%d", MYSQL_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index cf9d8dfb..0bb83c3e 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -233,7 +233,7 @@ process_arguments (int argc, char **argv)
print_help ();
exit (STATE_OK);
case 'q':
- asprintf(&sql_query, "%s", optarg);
+ xasprintf(&sql_query, "%s", optarg);
break;
case 'w':
warning = optarg;
@@ -277,7 +277,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", MYSQL_PORT);
+ xasprintf (&myport, "%d", MYSQL_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c
index 6485aa9a..c8cdbc02 100644
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
@@ -137,7 +137,7 @@ main (int argc, char **argv)
chld_out.line[i][pos+1] = 0x0;
}
if ( cols >= expected_cols ) {
- asprintf (&procargs, "%s", chld_out.line[i] + pos);
+ xasprintf (&procargs, "%s", chld_out.line[i] + pos);
strip (procargs);
/* Some ps return full pathname for command. This removes path */
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 60806bb3..89c4d8d3 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -135,13 +135,13 @@ int main(int argc, char **argv){
case CHECK_CLIENTVERSION:
- asprintf(&send_buffer, "%s&1", req_password);
+ xasprintf(&send_buffer, "%s&1", req_password);
fetch_data (server_address, server_port, send_buffer);
if (value_list != NULL && strcmp(recv_buffer, value_list) != 0) {
- asprintf (&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list);
+ xasprintf (&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list);
return_code = STATE_WARNING;
} else {
- asprintf (&output_message, "%s", recv_buffer);
+ xasprintf (&output_message, "%s", recv_buffer);
return_code = STATE_OK;
}
break;
@@ -167,7 +167,7 @@ int main(int argc, char **argv){
lvalue_list[2+offset]<=(unsigned long)100) {
/* Send request and retrieve data */
- asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
+ xasprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
fetch_data (server_address, server_port, send_buffer);
utilization=strtoul(recv_buffer,NULL,10);
@@ -178,11 +178,11 @@ int main(int argc, char **argv){
else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
return_code=STATE_WARNING;
- asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
- asprintf(&temp_string,"%s%s",temp_string,output_message);
- asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
+ xasprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
+ xasprintf(&temp_string,"%s%s",temp_string,output_message);
+ xasprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
lvalue_list[1+offset], lvalue_list[2+offset]);
- asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
+ xasprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
offset+=3; /* move across the array */
}
@@ -196,13 +196,13 @@ int main(int argc, char **argv){
case CHECK_UPTIME:
- asprintf(&send_buffer, "%s&3", req_password);
+ xasprintf(&send_buffer, "%s&3", req_password);
fetch_data (server_address, server_port, send_buffer);
uptime=strtoul(recv_buffer,NULL,10);
updays = uptime / 86400;
uphours = (uptime % 86400) / 3600;
upminutes = ((uptime % 86400) % 3600) / 60;
- asprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
+ xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
if (check_critical_value==TRUE && uptime <= critical_value)
return_code=STATE_CRITICAL;
else if (check_warning_value==TRUE && uptime <= warning_value)
@@ -218,7 +218,7 @@ int main(int argc, char **argv){
else if (strlen(value_list)!=1)
output_message = strdup (_("wrong -l argument"));
else {
- asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
+ xasprintf(&send_buffer,"%s&4&%s", req_password, value_list);
fetch_data (server_address, server_port, send_buffer);
fds=strtok(recv_buffer,"&");
tds=strtok(NULL,"&");
@@ -232,10 +232,10 @@ int main(int argc, char **argv){
warning_used_space = ((float)warning_value / 100) * total_disk_space;
critical_used_space = ((float)critical_value / 100) * total_disk_space;
- asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
+ xasprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
- asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
+ xasprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
(total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
critical_used_space / 1073741824, total_disk_space / 1073741824);
@@ -262,7 +262,7 @@ int main(int argc, char **argv){
output_message = strdup (_("No service/process specified"));
else {
preparelist(value_list); /* replace , between services with & to send the request */
- asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
+ xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
(show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
fetch_data (server_address, server_port, send_buffer);
return_code=atoi(strtok(recv_buffer,"&"));
@@ -273,7 +273,7 @@ int main(int argc, char **argv){
case CHECK_MEMUSE:
- asprintf(&send_buffer,"%s&7", req_password);
+ xasprintf(&send_buffer,"%s&7", req_password);
fetch_data (server_address, server_port, send_buffer);
mem_commitLimit=atof(strtok(recv_buffer,"&"));
mem_commitByte=atof(strtok(NULL,"&"));
@@ -283,10 +283,10 @@ int main(int argc, char **argv){
/* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
which equals RAM + Pagefiles. */
- asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
+ xasprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
(mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
- asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
+ xasprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
return_code=STATE_OK;
@@ -331,12 +331,12 @@ int main(int argc, char **argv){
strtok (value_list, "&"); /* burn the first parameters */
description = strtok (NULL, "&");
counter_unit = strtok (NULL, "&");
- asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
+ xasprintf (&send_buffer, "%s&8&%s", req_password, value_list);
fetch_data (server_address, server_port, send_buffer);
counter_value = atof (recv_buffer);
if (description == NULL)
- asprintf (&output_message, "%.f", counter_value);
+ xasprintf (&output_message, "%.f", counter_value);
else if (isPercent)
{
counter_unit = strdup ("%");
@@ -371,13 +371,13 @@ int main(int argc, char **argv){
{
/* Let's format the output string, finally... */
if (strstr(description, "%") == NULL) {
- asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
+ xasprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
} else {
/* has formatting, will segv if wrong */
- asprintf (&output_message, description, counter_value);
+ xasprintf (&output_message, description, counter_value);
}
- asprintf (&output_message, "%s |", output_message);
- asprintf (&output_message,"%s %s", output_message,
+ xasprintf (&output_message, "%s |", output_message);
+ xasprintf (&output_message,"%s %s", output_message,
fperfdata (description, counter_value,
counter_unit, 1, warning_value, 1, critical_value,
(!(isPercent) && (minval != NULL)), fminval,
@@ -410,7 +410,7 @@ int main(int argc, char **argv){
output_message = strdup (_("No counter specified"));
else {
preparelist(value_list); /* replace , between services with & to send the request */
- asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
+ xasprintf(&send_buffer,"%s&9&%s", req_password,value_list);
fetch_data (server_address, server_port, send_buffer);
age_in_minutes = atoi(strtok(recv_buffer,"&"));
description = strtok(NULL,"&");
@@ -439,13 +439,13 @@ int main(int argc, char **argv){
if (value_list==NULL)
output_message = strdup (_("No counter specified"));
else {
- asprintf(&send_buffer,"%s&10&%s", req_password,value_list);
+ xasprintf(&send_buffer,"%s&10&%s", req_password,value_list);
fetch_data (server_address, server_port, send_buffer);
if (!strncmp(recv_buffer,"ERROR",5)) {
printf("NSClient - %s\n",recv_buffer);
exit(STATE_UNKNOWN);
}
- asprintf(&output_message,"%s",recv_buffer);
+ xasprintf(&output_message,"%s",recv_buffer);
return_code=STATE_OK;
}
break;
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index ac89def7..76d19ba3 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -800,28 +800,28 @@ int main(int argc, char *argv[]){
switch (result) {
case STATE_CRITICAL :
- asprintf(&result_line, _("NTP CRITICAL:"));
+ xasprintf(&result_line, _("NTP CRITICAL:"));
break;
case STATE_WARNING :
- asprintf(&result_line, _("NTP WARNING:"));
+ xasprintf(&result_line, _("NTP WARNING:"));
break;
case STATE_OK :
- asprintf(&result_line, _("NTP OK:"));
+ xasprintf(&result_line, _("NTP OK:"));
break;
default :
- asprintf(&result_line, _("NTP UNKNOWN:"));
+ xasprintf(&result_line, _("NTP UNKNOWN:"));
break;
}
if(offset_result == STATE_UNKNOWN){
- asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
- asprintf(&perfdata_line, "");
+ xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
+ xasprintf(&perfdata_line, "");
} else {
- asprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
- asprintf(&perfdata_line, "%s", perfd_offset(offset));
+ xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
+ xasprintf(&perfdata_line, "%s", perfd_offset(offset));
}
if (do_jitter) {
- asprintf(&result_line, "%s, jitter=%f", result_line, jitter);
- asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
+ xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
+ xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
}
printf("%s|%s\n", result_line, perfdata_line);
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 62ac9aed..f0dd2d87 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -295,7 +295,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
/* If there's no sync.peer, query all candidates and use the best one */
if (PEER_SEL(peers[i].status) >= min_peer_sel){
if(verbose) printf("Getting offset, jitter and stratum for peer %.2x\n", ntohs(peers[i].assoc));
- asprintf(&data, "");
+ xasprintf(&data, "");
do{
setup_control_request(&req, OP_READVAR, 2);
req.assoc = peers[i].assoc;
@@ -318,7 +318,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
DBG(print_ntp_control_message(&req));
if(!(req.op&REM_ERROR))
- asprintf(&data, "%s%s", data, req.data);
+ xasprintf(&data, "%s%s", data, req.data);
} while(req.op&REM_MORE);
if(req.op&REM_ERROR) {
@@ -603,41 +603,41 @@ int main(int argc, char *argv[]){
switch (result) {
case STATE_CRITICAL :
- asprintf(&result_line, _("NTP CRITICAL:"));
+ xasprintf(&result_line, _("NTP CRITICAL:"));
break;
case STATE_WARNING :
- asprintf(&result_line, _("NTP WARNING:"));
+ xasprintf(&result_line, _("NTP WARNING:"));
break;
case STATE_OK :
- asprintf(&result_line, _("NTP OK:"));
+ xasprintf(&result_line, _("NTP OK:"));
break;
default :
- asprintf(&result_line, _("NTP UNKNOWN:"));
+ xasprintf(&result_line, _("NTP UNKNOWN:"));
break;
}
if(!syncsource_found)
- asprintf(&result_line, "%s %s,", result_line, _("Server not synchronized"));
+ xasprintf(&result_line, "%s %s,", result_line, _("Server not synchronized"));
else if(li_alarm)
- asprintf(&result_line, "%s %s,", result_line, _("Server has the LI_ALARM bit set"));
+ xasprintf(&result_line, "%s %s,", result_line, _("Server has the LI_ALARM bit set"));
if(offset_result == STATE_UNKNOWN){
- asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
- asprintf(&perfdata_line, "");
+ xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
+ xasprintf(&perfdata_line, "");
} else {
- asprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
- asprintf(&perfdata_line, "%s", perfd_offset(offset));
+ xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
+ xasprintf(&perfdata_line, "%s", perfd_offset(offset));
}
if (do_jitter) {
- asprintf(&result_line, "%s, jitter=%f", result_line, jitter);
- asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
+ xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
+ xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
}
if (do_stratum) {
- asprintf(&result_line, "%s, stratum=%i", result_line, stratum);
- asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
+ xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
+ xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
}
if (do_truechimers) {
- asprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
- asprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
+ xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
+ xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
}
printf("%s|%s\n", result_line, perfdata_line);
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index f0f74b4e..d543d6b5 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -564,24 +564,24 @@ int main(int argc, char *argv[]){
switch (result) {
case STATE_CRITICAL :
- asprintf(&result_line, _("NTP CRITICAL:"));
+ xasprintf(&result_line, _("NTP CRITICAL:"));
break;
case STATE_WARNING :
- asprintf(&result_line, _("NTP WARNING:"));
+ xasprintf(&result_line, _("NTP WARNING:"));
break;
case STATE_OK :
- asprintf(&result_line, _("NTP OK:"));
+ xasprintf(&result_line, _("NTP OK:"));
break;
default :
- asprintf(&result_line, _("NTP UNKNOWN:"));
+ xasprintf(&result_line, _("NTP UNKNOWN:"));
break;
}
if(offset_result == STATE_UNKNOWN){
- asprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
- asprintf(&perfdata_line, "");
+ xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
+ xasprintf(&perfdata_line, "");
} else {
- asprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
- asprintf(&perfdata_line, "%s", perfd_offset(offset));
+ xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
+ xasprintf(&perfdata_line, "%s", perfd_offset(offset));
}
printf("%s|%s\n", result_line, perfdata_line);
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index 81c55752..6ebe8f83 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -191,7 +191,7 @@ main(int argc, char **argv) {
netware_version = strdup("");
else {
recv_buffer[strlen(recv_buffer)-1]=0;
- asprintf (&netware_version,_("NetWare %s: "),recv_buffer);
+ xasprintf (&netware_version,_("NetWare %s: "),recv_buffer);
}
} else
netware_version = strdup("");
@@ -215,7 +215,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"UTIL%s\r\n",temp_buffer);
+ xasprintf (&send_buffer,"UTIL%s\r\n",temp_buffer);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -236,7 +236,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && utilization >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"),
state_text(result),
uptime,
@@ -264,7 +264,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && current_connections >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"),
state_text(result),
current_connections,
@@ -289,7 +289,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && cache_hits <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s: Long term cache hits = %lu%%"),
state_text(result),
cache_hits);
@@ -311,7 +311,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && cache_buffers <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"),
state_text(result),
cache_buffers,
@@ -336,7 +336,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && cache_buffers >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"),
state_text(result),
cache_buffers,
@@ -361,7 +361,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && lru_time <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s: LRU sitting time = %lu minutes"),
state_text(result),
lru_time);
@@ -373,13 +373,13 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKF%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKF%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
free_disk_space=strtoul(recv_buffer,NULL,10);
@@ -387,7 +387,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && free_disk_space <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"),
(result==STATE_OK)?"":_("Only "),
free_disk_space,
@@ -401,13 +401,13 @@ main(int argc, char **argv) {
/* check MB free space on volume */
} else if (vars_to_check==VMF) {
- asprintf (&send_buffer,"VMF%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VMF%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
free_disk_space=strtoul(recv_buffer,NULL,10);
@@ -415,7 +415,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && free_disk_space <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"),
(result==STATE_OK)?"":_("Only "),
free_disk_space,
@@ -428,13 +428,13 @@ main(int argc, char **argv) {
/* check MB used space on volume */
} else if (vars_to_check==VMU) {
- asprintf (&send_buffer,"VMU%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VMU%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
free_disk_space=strtoul(recv_buffer,NULL,10);
@@ -442,7 +442,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && free_disk_space <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"),
(result==STATE_OK)?"":_("Only "),
free_disk_space,
@@ -460,14 +460,14 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKF%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKF%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
@@ -477,7 +477,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKS%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -491,7 +491,7 @@ main(int argc, char **argv) {
result=STATE_WARNING;
free_disk_space/=1024;
total_disk_space/=1024;
- asprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"),
+ xasprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"),
free_disk_space,
percent_free_space,
volume_name,
@@ -525,7 +525,7 @@ main(int argc, char **argv) {
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
temp_buffer=strtok(recv_buffer,"\r\n");
- asprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer);
+ xasprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer);
/* check to see if logins are enabled */
} else if (vars_to_check==LOGINS) {
@@ -542,13 +542,13 @@ main(int argc, char **argv) {
else
result=STATE_WARNING;
- asprintf (&output_message,_("Logins are %s"),(result==STATE_OK)?_("enabled"):_("disabled"));
+ xasprintf (&output_message,_("Logins are %s"),(result==STATE_OK)?_("enabled"):_("disabled"));
/* check NRM Health Status Summary*/
} else if (vars_to_check==NRMH) {
- asprintf (&send_buffer,"NRMH\r\n");
+ xasprintf (&send_buffer,"NRMH\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -557,15 +557,15 @@ main(int argc, char **argv) {
if (nrm_health_status==2) {
result=STATE_OK;
- asprintf (&output_message,_("CRITICAL - NRM Status is bad!"));
+ xasprintf (&output_message,_("CRITICAL - NRM Status is bad!"));
}
else {
if (nrm_health_status==1) {
result=STATE_WARNING;
- asprintf (&output_message,_("Warning - NRM Status is suspect!"));
+ xasprintf (&output_message,_("Warning - NRM Status is suspect!"));
}
- asprintf (&output_message,_("OK - NRM Status is good!"));
+ xasprintf (&output_message,_("OK - NRM Status is good!"));
}
@@ -576,7 +576,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S15\r\n");
+ xasprintf (&send_buffer,"S15\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -586,7 +586,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S16\r\n");
+ xasprintf (&send_buffer,"S16\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -607,7 +607,7 @@ main(int argc, char **argv) {
result=STATE_WARNING;
}
- asprintf (&output_message,_("%lu of %lu (%lu%%) packet receive buffers used"),used_packet_receive_buffers,max_packet_receive_buffers,percent_used_packet_receive_buffers);
+ xasprintf (&output_message,_("%lu of %lu (%lu%%) packet receive buffers used"),used_packet_receive_buffers,max_packet_receive_buffers,percent_used_packet_receive_buffers);
/* check SAP table entries */
} else if (vars_to_check==SAPENTRIES) {
@@ -616,9 +616,9 @@ main(int argc, char **argv) {
my_tcp_connect (server_address, server_port, &sd);
if (sap_number==-1)
- asprintf (&send_buffer,"S9\r\n");
+ xasprintf (&send_buffer,"S9\r\n");
else
- asprintf (&send_buffer,"S9.%d\r\n",sap_number);
+ xasprintf (&send_buffer,"S9.%d\r\n",sap_number);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -631,9 +631,9 @@ main(int argc, char **argv) {
result=STATE_WARNING;
if (sap_number==-1)
- asprintf (&output_message,_("%lu entries in SAP table"),sap_entries);
+ xasprintf (&output_message,_("%lu entries in SAP table"),sap_entries);
else
- asprintf (&output_message,_("%lu entries in SAP table for SAP type %d"),sap_entries,sap_number);
+ xasprintf (&output_message,_("%lu entries in SAP table for SAP type %d"),sap_entries,sap_number);
/* check KB purgeable space on volume */
} else if (vars_to_check==VKP) {
@@ -641,13 +641,13 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKP%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKP%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
purgeable_disk_space=strtoul(recv_buffer,NULL,10);
@@ -655,7 +655,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
+ xasprintf (&output_message,_("%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
(result==STATE_OK)?"":_("Only "),
purgeable_disk_space,
volume_name,
@@ -667,13 +667,13 @@ main(int argc, char **argv) {
/* check MB purgeable space on volume */
} else if (vars_to_check==VMP) {
- asprintf (&send_buffer,"VMP%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VMP%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
purgeable_disk_space=strtoul(recv_buffer,NULL,10);
@@ -681,7 +681,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && purgeable_disk_space >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
+ xasprintf (&output_message,_("%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"),
(result==STATE_OK)?"":_("Only "),
purgeable_disk_space,
volume_name,
@@ -697,14 +697,14 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKP%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKP%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
@@ -714,7 +714,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKS%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -727,7 +727,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && percent_purgeable_space >= warning_value)
result=STATE_WARNING;
purgeable_disk_space/=1024;
- asprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"),
+ xasprintf (&output_message,_("%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"),
purgeable_disk_space,
percent_purgeable_space,
volume_name,
@@ -744,13 +744,13 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKNP%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKNP%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
non_purgeable_disk_space=strtoul(recv_buffer,NULL,10);
@@ -758,7 +758,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && non_purgeable_disk_space >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name);
+ xasprintf (&output_message,_("%s%lu KB not yet purgeable on volume %s"),(result==STATE_OK)?"":_("Only "),non_purgeable_disk_space,volume_name);
}
/* check % not yet purgeable space on volume */
@@ -767,14 +767,14 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKNP%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKNP%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
+ xasprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
@@ -784,7 +784,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"VKS%s\r\n",volume_name);
+ xasprintf (&send_buffer,"VKS%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -797,7 +797,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && percent_non_purgeable_space >= warning_value)
result=STATE_WARNING;
purgeable_disk_space/=1024;
- asprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
+ xasprintf (&output_message,_("%lu MB (%lu%%) not yet purgeable on volume %s"),non_purgeable_disk_space,percent_non_purgeable_space,volume_name);
}
/* check # of open files */
@@ -806,7 +806,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S18\r\n");
+ xasprintf (&send_buffer,"S18\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -818,7 +818,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && open_files >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"),
+ xasprintf (&output_message,_("%lu open files|Openfiles=%lu;%lu;%lu;0,0"),
open_files,
open_files,
warning_value,
@@ -831,7 +831,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S17\r\n");
+ xasprintf (&send_buffer,"S17\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -843,7 +843,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && abended_threads >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"),
+ xasprintf (&output_message,_("%lu abended threads|Abends=%lu;%lu;%lu;;"),
abended_threads,
abended_threads,
warning_value,
@@ -855,7 +855,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S20\r\n");
+ xasprintf (&send_buffer,"S20\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -865,7 +865,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S21\r\n");
+ xasprintf (&send_buffer,"S21\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -877,7 +877,7 @@ main(int argc, char **argv) {
else if (check_warning_value==TRUE && current_service_processes >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"),
current_service_processes,
max_service_processes,
@@ -892,7 +892,7 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S22\r\n");
+ xasprintf (&send_buffer,"S22\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -901,10 +901,10 @@ main(int argc, char **argv) {
if (time_sync_status==0) {
result=STATE_CRITICAL;
- asprintf (&output_message,_("CRITICAL - Time not in sync with network!"));
+ xasprintf (&output_message,_("CRITICAL - Time not in sync with network!"));
}
else {
- asprintf (&output_message,_("OK - Time in sync with network!"));
+ xasprintf (&output_message,_("OK - Time in sync with network!"));
}
@@ -927,7 +927,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && lru_time <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time);
+ xasprintf (&output_message,_("LRU sitting time = %lu seconds"),lru_time);
/* check % dirty cacheobuffers as a percentage of the total*/
@@ -946,7 +946,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && dirty_cache_buffers <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"),
+ xasprintf (&output_message,_("Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"),
dirty_cache_buffers,
dirty_cache_buffers,
warning_value,
@@ -968,7 +968,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && total_cache_buffers <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"),
+ xasprintf (&output_message,_("Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"),
total_cache_buffers,
total_cache_buffers,
warning_value,
@@ -979,21 +979,21 @@ main(int argc, char **argv) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S13\r\n");
+ xasprintf (&send_buffer,"S13\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
recv_buffer[strlen(recv_buffer)-1]=0;
- asprintf (&output_message,_("NDS Version %s"),recv_buffer);
+ xasprintf (&output_message,_("NDS Version %s"),recv_buffer);
} else if (vars_to_check==UPTIME) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"UPTIME\r\n");
+ xasprintf (&send_buffer,"UPTIME\r\n");
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
@@ -1002,35 +1002,35 @@ main(int argc, char **argv) {
recv_buffer[sizeof(recv_buffer)-1]=0;
recv_buffer[strlen(recv_buffer)-1]=0;
- asprintf (&output_message,_("Up %s"),recv_buffer);
+ xasprintf (&output_message,_("Up %s"),recv_buffer);
} else if (vars_to_check==NLM) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
- asprintf (&send_buffer,"S24:%s\r\n",nlm_name);
+ xasprintf (&send_buffer,"S24:%s\r\n",nlm_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
recv_buffer[strlen(recv_buffer)-1]=0;
if (strcmp(recv_buffer,"-1")) {
- asprintf (&output_message,_("Module %s version %s is loaded"),nlm_name,recv_buffer);
+ xasprintf (&output_message,_("Module %s version %s is loaded"),nlm_name,recv_buffer);
} else {
result=STATE_CRITICAL;
- asprintf (&output_message,_("Module %s is not loaded"),nlm_name);
+ xasprintf (&output_message,_("Module %s is not loaded"),nlm_name);
}
} else if (vars_to_check==NRMP) {
- asprintf (&send_buffer,"NRMP:%s\r\n",nrmp_name);
+ xasprintf (&send_buffer,"NRMP:%s\r\n",nrmp_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmp_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmp_name);
result=STATE_CRITICAL;
} else {
nrmp_value=strtoul(recv_buffer,NULL,10);
@@ -1038,7 +1038,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nrmp_value <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nrmp_name,
nrmp_value,
@@ -1050,13 +1050,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NRMM) {
- asprintf (&send_buffer,"NRMM:%s\r\n",nrmm_name);
+ xasprintf (&send_buffer,"NRMM:%s\r\n",nrmm_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmm_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrmm_name);
result=STATE_CRITICAL;
} else {
nrmm_value=strtoul(recv_buffer,NULL,10);
@@ -1064,7 +1064,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nrmm_value <= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nrmm_name,
nrmm_value,
@@ -1076,13 +1076,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NRMS) {
- asprintf (&send_buffer,"NRMS:%s\r\n",nrms_name);
+ xasprintf (&send_buffer,"NRMS:%s\r\n",nrms_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrms_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nrms_name);
result=STATE_CRITICAL;
} else {
nrms_value=strtoul(recv_buffer,NULL,10);
@@ -1090,7 +1090,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nrms_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nrms_name,
nrms_value,
@@ -1102,13 +1102,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS1) {
- asprintf (&send_buffer,"NSS1:%s\r\n",nss1_name);
+ xasprintf (&send_buffer,"NSS1:%s\r\n",nss1_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss1_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss1_name);
result=STATE_CRITICAL;
} else {
nss1_value=strtoul(recv_buffer,NULL,10);
@@ -1116,7 +1116,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss1_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss1_name,
nss1_value,
@@ -1128,13 +1128,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS2) {
- asprintf (&send_buffer,"NSS2:%s\r\n",nss2_name);
+ xasprintf (&send_buffer,"NSS2:%s\r\n",nss2_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss2_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss2_name);
result=STATE_CRITICAL;
} else {
nss2_value=strtoul(recv_buffer,NULL,10);
@@ -1142,7 +1142,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss2_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss2_name,
nss2_value,
@@ -1154,13 +1154,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS3) {
- asprintf (&send_buffer,"NSS3:%s\r\n",nss3_name);
+ xasprintf (&send_buffer,"NSS3:%s\r\n",nss3_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss3_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss3_name);
result=STATE_CRITICAL;
} else {
nss3_value=strtoul(recv_buffer,NULL,10);
@@ -1168,7 +1168,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss3_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss3_name,
nss3_value,
@@ -1180,13 +1180,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS4) {
- asprintf (&send_buffer,"NSS4:%s\r\n",nss4_name);
+ xasprintf (&send_buffer,"NSS4:%s\r\n",nss4_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss4_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss4_name);
result=STATE_CRITICAL;
} else {
nss4_value=strtoul(recv_buffer,NULL,10);
@@ -1194,7 +1194,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss4_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss4_name,
nss4_value,
@@ -1206,13 +1206,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS5) {
- asprintf (&send_buffer,"NSS5:%s\r\n",nss5_name);
+ xasprintf (&send_buffer,"NSS5:%s\r\n",nss5_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss5_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss5_name);
result=STATE_CRITICAL;
} else {
nss5_value=strtoul(recv_buffer,NULL,10);
@@ -1220,7 +1220,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss5_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss5_name,
nss5_value,
@@ -1232,13 +1232,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS6) {
- asprintf (&send_buffer,"NSS6:%s\r\n",nss6_name);
+ xasprintf (&send_buffer,"NSS6:%s\r\n",nss6_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss6_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss6_name);
result=STATE_CRITICAL;
} else {
nss6_value=strtoul(recv_buffer,NULL,10);
@@ -1246,7 +1246,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss6_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss6_name,
nss6_value,
@@ -1258,13 +1258,13 @@ main(int argc, char **argv) {
} else if (vars_to_check==NSS7) {
- asprintf (&send_buffer,"NSS7:%s\r\n",nss7_name);
+ xasprintf (&send_buffer,"NSS7:%s\r\n",nss7_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
- asprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss7_name);
+ xasprintf (&output_message,_("CRITICAL - Value '%s' does not exist!"),nss7_name);
result=STATE_CRITICAL;
} else {
nss7_value=strtoul(recv_buffer,NULL,10);
@@ -1272,7 +1272,7 @@ main(int argc, char **argv) {
result=STATE_CRITICAL;
else if (check_warning_value==TRUE && nss7_value >= warning_value)
result=STATE_WARNING;
- asprintf (&output_message,
+ xasprintf (&output_message,
_("%s is %lu|%s=%lu;%lu;%lu;;"),
nss7_name,
nss7_value,
@@ -1591,7 +1591,7 @@ int process_arguments(int argc, char **argv) {
void print_help(void)
{
char *myport;
- asprintf (&myport, "%d", PORT);
+ xasprintf (&myport, "%d", PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c
index 16ada20d..95977e91 100644
--- a/plugins/check_overcr.c
+++ b/plugins/check_overcr.c
@@ -409,7 +409,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", PORT);
+ xasprintf (&myport, "%d", PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 19c3117d..69edae75 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -417,7 +417,7 @@ print_help (void)
{
char *myport;
- asprintf (&myport, "%d", DEFAULT_PORT);
+ xasprintf (&myport, "%d", DEFAULT_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 473f9f24..eef2195b 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -121,12 +121,12 @@ main (int argc, char **argv)
/* does the host address of number of packets argument come first? */
#ifdef PING_PACKETS_FIRST
# ifdef PING_HAS_TIMEOUT
- asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
+ xasprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
# else
- asprintf (&cmd, rawcmd, max_packets, addresses[i]);
+ xasprintf (&cmd, rawcmd, max_packets, addresses[i]);
# endif
#else
- asprintf (&cmd, rawcmd, addresses[i], max_packets);
+ xasprintf (&cmd, rawcmd, addresses[i], max_packets);
#endif
if (verbose >= 2)
@@ -491,7 +491,7 @@ run_ping (const char *cmd, const char *addr)
if (warn_text == NULL) {
warn_text = strdup(_("System call sent warnings to stderr "));
} else {
- asprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr "));
+ xasprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr "));
}
}
}
@@ -540,7 +540,7 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
if (warn_text == NULL)
warn_text = strdup (_(WARN_DUPLICATES));
else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
- asprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
+ xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
return (STATE_WARNING);
}
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index d875a618..2f2dcc58 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -137,7 +137,7 @@ main (int argc, char **argv)
input_buffer = malloc (MAX_INPUT_BUFFER);
procprog = malloc (MAX_INPUT_BUFFER);
- asprintf (&metric_name, "PROCS");
+ xasprintf (&metric_name, "PROCS");
metric = METRIC_PROCS;
/* Parse extra opts if any */
@@ -176,7 +176,7 @@ main (int argc, char **argv)
printf ("%s", input_line);
strcpy (procprog, "");
- asprintf (&procargs, "%s", "");
+ xasprintf (&procargs, "%s", "");
cols = sscanf (input_line, PS_FORMAT, PS_VARLIST);
@@ -186,7 +186,7 @@ main (int argc, char **argv)
}
if ( cols >= expected_cols ) {
resultsum = 0;
- asprintf (&procargs, "%s", input_line + pos);
+ xasprintf (&procargs, "%s", input_line + pos);
strip (procargs);
/* Some ps return full pathname for command. This removes path */
@@ -250,12 +250,12 @@ main (int argc, char **argv)
if (metric != METRIC_PROCS) {
if (i == STATE_WARNING) {
warn++;
- asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
+ xasprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
result = max_state (result, i);
}
if (i == STATE_CRITICAL) {
crit++;
- asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
+ xasprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
result = max_state (result, i);
}
}
@@ -393,7 +393,7 @@ process_arguments (int argc, char **argv)
break;
case 'p': /* process id */
if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
- asprintf (&fmt, "%s%sPPID = %d", (fmt ? fmt : "") , (options ? ", " : ""), ppid);
+ xasprintf (&fmt, "%s%sPPID = %d", (fmt ? fmt : "") , (options ? ", " : ""), ppid);
options |= PPID;
break;
}
@@ -403,7 +403,7 @@ process_arguments (int argc, char **argv)
break;
else
statopts = optarg;
- asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
+ xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
options |= STAT;
break;
case 'u': /* user or user id */
@@ -423,7 +423,7 @@ process_arguments (int argc, char **argv)
uid = pw->pw_uid;
}
user = pw->pw_name;
- asprintf (&fmt, "%s%sUID = %d (%s)", (fmt ? fmt : ""), (options ? ", " : ""),
+ xasprintf (&fmt, "%s%sUID = %d (%s)", (fmt ? fmt : ""), (options ? ", " : ""),
uid, user);
options |= USER;
break;
@@ -433,7 +433,7 @@ process_arguments (int argc, char **argv)
break;
else
prog = optarg;
- asprintf (&fmt, _("%s%scommand name '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
+ xasprintf (&fmt, _("%s%scommand name '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
prog);
options |= PROG;
break;
@@ -443,7 +443,7 @@ process_arguments (int argc, char **argv)
break;
else
args = optarg;
- asprintf (&fmt, "%s%sargs '%s'", (fmt ? fmt : ""), (options ? ", " : ""), args);
+ xasprintf (&fmt, "%s%sargs '%s'", (fmt ? fmt : ""), (options ? ", " : ""), args);
options |= ARGS;
break;
case CHAR_MAX+1:
@@ -459,19 +459,19 @@ process_arguments (int argc, char **argv)
temp_string[i]=',';
i++;
}
- asprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string);
+ xasprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string);
options |= EREG_ARGS;
break;
case 'r': /* RSS */
if (sscanf (optarg, "%d%[^0-9]", &rss, tmp) == 1) {
- asprintf (&fmt, "%s%sRSS >= %d", (fmt ? fmt : ""), (options ? ", " : ""), rss);
+ xasprintf (&fmt, "%s%sRSS >= %d", (fmt ? fmt : ""), (options ? ", " : ""), rss);
options |= RSS;
break;
}
usage4 (_("RSS must be an integer!"));
case 'z': /* VSZ */
if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) {
- asprintf (&fmt, "%s%sVSZ >= %d", (fmt ? fmt : ""), (options ? ", " : ""), vsz);
+ xasprintf (&fmt, "%s%sVSZ >= %d", (fmt ? fmt : ""), (options ? ", " : ""), vsz);
options |= VSZ;
break;
}
@@ -479,13 +479,13 @@ process_arguments (int argc, char **argv)
case 'P': /* PCPU */
/* TODO: -P 1.5.5 is accepted */
if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) {
- asprintf (&fmt, "%s%sPCPU >= %.2f", (fmt ? fmt : ""), (options ? ", " : ""), pcpu);
+ xasprintf (&fmt, "%s%sPCPU >= %.2f", (fmt ? fmt : ""), (options ? ", " : ""), pcpu);
options |= PCPU;
break;
}
usage4 (_("PCPU must be a float!"));
case 'm':
- asprintf (&metric_name, "%s", optarg);
+ xasprintf (&metric_name, "%s", optarg);
if ( strcmp(optarg, "PROCS") == 0) {
metric = METRIC_PROCS;
break;
@@ -523,8 +523,8 @@ process_arguments (int argc, char **argv)
if (cmax == -1 && argv[c])
cmax = atoi (argv[c++]);
if (statopts == NULL && argv[c]) {
- asprintf (&statopts, "%s", argv[c++]);
- asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
+ xasprintf (&statopts, "%s", argv[c++]);
+ xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
options |= STAT;
}
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index c2c93eeb..e54105b0 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -328,7 +328,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", PW_AUTH_UDP_PORT);
+ xasprintf (&myport, "%d", PW_AUTH_UDP_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_real.c b/plugins/check_real.c
index d67e1904..18240f30 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -403,7 +403,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", PORT);
+ xasprintf (&myport, "%d", PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 77ac5ced..6b3f9dd4 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -156,15 +156,15 @@ main (int argc, char **argv)
}
}
if(use_ehlo)
- asprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
+ xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
else
- asprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
+ xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
if (verbose)
printf("HELOCMD: %s", helocmd);
/* initialize the MAIL command with optional FROM command */
- asprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n");
+ xasprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n");
if (verbose && smtp_use_dummycmd)
printf ("FROM CMD: %s", cmd_str);
@@ -299,7 +299,7 @@ main (int argc, char **argv)
}
while (n < ncommands) {
- asprintf (&cmd_str, "%s%s", commands[n], "\r\n");
+ xasprintf (&cmd_str, "%s%s", commands[n], "\r\n");
my_send(cmd_str, strlen(cmd_str));
if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose)
printf("%s", buffer);
@@ -336,12 +336,12 @@ main (int argc, char **argv)
do {
if (authuser == NULL) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("no authuser specified, "));
+ xasprintf(&error_msg, _("no authuser specified, "));
break;
}
if (authpass == NULL) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("no authpass specified, "));
+ xasprintf(&error_msg, _("no authpass specified, "));
break;
}
@@ -351,7 +351,7 @@ main (int argc, char **argv)
printf (_("sent %s\n"), "AUTH LOGIN");
if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
- asprintf(&error_msg, _("recv() failed after AUTH LOGIN, "));
+ xasprintf(&error_msg, _("recv() failed after AUTH LOGIN, "));
result = STATE_WARNING;
break;
}
@@ -360,7 +360,7 @@ main (int argc, char **argv)
if (strncmp (buffer, "334", 3) != 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("invalid response received after AUTH LOGIN, "));
+ xasprintf(&error_msg, _("invalid response received after AUTH LOGIN, "));
break;
}
@@ -374,7 +374,7 @@ main (int argc, char **argv)
if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("recv() failed after sending authuser, "));
+ xasprintf(&error_msg, _("recv() failed after sending authuser, "));
break;
}
if (verbose) {
@@ -382,7 +382,7 @@ main (int argc, char **argv)
}
if (strncmp (buffer, "334", 3) != 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("invalid response received after authuser, "));
+ xasprintf(&error_msg, _("invalid response received after authuser, "));
break;
}
/* encode authpass with base64 */
@@ -395,7 +395,7 @@ main (int argc, char **argv)
}
if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("recv() failed after sending authpass, "));
+ xasprintf(&error_msg, _("recv() failed after sending authpass, "));
break;
}
if (verbose) {
@@ -403,14 +403,14 @@ main (int argc, char **argv)
}
if (strncmp (buffer, "235", 3) != 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("invalid response received after authpass, "));
+ xasprintf(&error_msg, _("invalid response received after authpass, "));
break;
}
break;
} while (0);
} else {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("only authtype LOGIN is supported, "));
+ xasprintf(&error_msg, _("only authtype LOGIN is supported, "));
}
}
@@ -654,7 +654,7 @@ process_arguments (int argc, char **argv)
usage2 (_("Invalid hostname/address"), argv[c]);
}
else {
- asprintf (&server_address, "127.0.0.1");
+ xasprintf (&server_address, "127.0.0.1");
}
}
@@ -787,7 +787,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", SMTP_PORT);
+ xasprintf (&myport, "%d", SMTP_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index a5a88d25..2d9861bc 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -255,9 +255,9 @@ main (int argc, char **argv)
command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *));
command_line[0] = snmpcmd;
command_line[1] = strdup ("-t");
- asprintf (&command_line[2], "%d", timeout_interval);
+ xasprintf (&command_line[2], "%d", timeout_interval);
command_line[3] = strdup ("-r");
- asprintf (&command_line[4], "%d", retries);
+ xasprintf (&command_line[4], "%d", retries);
command_line[5] = strdup ("-m");
command_line[6] = strdup (miblist);
command_line[7] = "-v";
@@ -267,16 +267,16 @@ main (int argc, char **argv)
command_line[9 + i] = authpriv[i];
}
- asprintf (&command_line[9 + numauthpriv], "%s:%s", server_address, port);
+ xasprintf (&command_line[9 + numauthpriv], "%s:%s", server_address, port);
/* This is just for display purposes, so it can remain a string */
- asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s",
+ xasprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s",
snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]",
server_address, port);
for (i = 0; i < numoids; i++) {
command_line[9 + numauthpriv + 1 + i] = oids[i];
- asprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
+ xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
}
command_line[9 + numauthpriv + 1 + numoids] = NULL;
@@ -371,14 +371,14 @@ main (int argc, char **argv)
if (dq_count) { /* unfinished line */
/* copy show verbatim first */
if (!mult_resp) mult_resp = strdup("");
- asprintf (&mult_resp, "%s%s:\n%s\n", mult_resp, oids[i], show);
+ xasprintf (&mult_resp, "%s%s:\n%s\n", mult_resp, oids[i], show);
/* then strip out unmatched double-quote from single-line output */
if (show[0] == '"') show++;
/* Keep reading until we match end of double-quoted string */
for (line++; line < chld_out.lines; line++) {
ptr = chld_out.line[line];
- asprintf (&mult_resp, "%s%s\n", mult_resp, ptr);
+ xasprintf (&mult_resp, "%s%s\n", mult_resp, ptr);
COUNT_SEQ(ptr, bk_count, dq_count)
while (dq_count && ptr[0] != '\n' && ptr[0] != '\0') {
@@ -424,11 +424,11 @@ main (int argc, char **argv)
/* Convert to per second, then use multiplier */
temp_double = temp_double/duration*rate_multiplier;
iresult = get_status(temp_double, thlds[i]);
- asprintf (&show, conv, temp_double);
+ xasprintf (&show, conv, temp_double);
}
} else {
iresult = get_status(response_value[i], thlds[i]);
- asprintf (&show, conv, response_value[i]);
+ xasprintf (&show, conv, response_value[i]);
}
}
@@ -472,16 +472,16 @@ main (int argc, char **argv)
/* Prepend a label for this OID if there is one */
if (nlabels >= (size_t)1 && (size_t)i < nlabels && labels[i] != NULL)
- asprintf (&outbuff, "%s%s%s %s%s%s", outbuff,
+ xasprintf (&outbuff, "%s%s%s %s%s%s", outbuff,
(i == 0) ? " " : output_delim,
labels[i], mark (iresult), show, mark (iresult));
else
- asprintf (&outbuff, "%s%s%s%s%s", outbuff, (i == 0) ? " " : output_delim,
+ xasprintf (&outbuff, "%s%s%s%s%s", outbuff, (i == 0) ? " " : output_delim,
mark (iresult), show, mark (iresult));
/* Append a unit string for this OID if there is one */
if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL)
- asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
+ xasprintf (&outbuff, "%s %s", outbuff, unitv[i]);
/* Write perfdata with whatever can be parsed by strtod, if possible */
ptr = NULL;
@@ -523,7 +523,7 @@ main (int argc, char **argv)
current_length=0;
for(i=0; i<total_oids; i++) {
- asprintf(&temp_string,"%.0f",response_value[i]);
+ xasprintf(&temp_string,"%.0f",response_value[i]);
if(temp_string==NULL)
die(STATE_UNKNOWN,_("Cannot asprintf()"));
response_length = strlen(temp_string);
@@ -869,7 +869,7 @@ validate_arguments ()
die(STATE_UNKNOWN, _("No OIDs specified\n"));
if (proto == NULL)
- asprintf(&proto, DEFAULT_PROTOCOL);
+ xasprintf(&proto, DEFAULT_PROTOCOL);
if ((strcmp(proto,"1") == 0) || (strcmp(proto, "2c")==0)) { /* snmpv1 or snmpv2c */
numauthpriv = 2;
@@ -879,7 +879,7 @@ validate_arguments ()
}
else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */
if (seclevel == NULL)
- asprintf(&seclevel, "noAuthNoPriv");
+ xasprintf(&seclevel, "noAuthNoPriv");
if (strcmp(seclevel, "noAuthNoPriv") == 0) {
numauthpriv = 2;
@@ -892,7 +892,7 @@ validate_arguments ()
}
if (authproto == NULL )
- asprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
+ xasprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
if (secname == NULL)
die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname");
@@ -913,7 +913,7 @@ validate_arguments ()
authpriv[7] = strdup (authpasswd);
} else if ( strcmp(seclevel, "authPriv") == 0 ) {
if (privproto == NULL )
- asprintf(&privproto, DEFAULT_PRIV_PROTOCOL);
+ xasprintf(&privproto, DEFAULT_PRIV_PROTOCOL);
if (privpasswd == NULL)
die(STATE_UNKNOWN, _("Required parameter: %s\n"), "privpasswd");
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 3bbf44dc..4d633949 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -241,7 +241,7 @@ ssh_connect (char *haddr, int hport, char *remote_version)
ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. ");
ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
- asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
+ xasprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
send (sd, buffer, strlen (buffer), MSG_DONTWAIT);
if (verbose)
printf ("%s\n", buffer);
@@ -271,7 +271,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", SSH_DFL_PORT);
+ xasprintf (&myport, "%d", SSH_DFL_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index ce1f6022..1b2a8dd5 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -129,7 +129,7 @@ main (int argc, char **argv)
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
if (verbose)
- asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
+ xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
}
else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) {
@@ -152,15 +152,15 @@ main (int argc, char **argv)
free_swap_mb = dskfree_mb;
#else
# ifdef HAVE_SWAP
- asprintf(&swap_command, "%s", SWAP_COMMAND);
- asprintf(&swap_format, "%s", SWAP_FORMAT);
+ xasprintf(&swap_command, "%s", SWAP_COMMAND);
+ xasprintf(&swap_format, "%s", SWAP_FORMAT);
/* These override the command used if a summary (and thus ! allswaps) is required */
/* The summary flag returns more accurate information about swap usage on these OSes */
# ifdef _AIX
if (!allswaps) {
- asprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
- asprintf(&swap_format, "%s", "%f%*s %f");
+ xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
+ xasprintf(&swap_format, "%s", "%f%*s %f");
conv_factor = 1;
}
# endif
@@ -228,7 +228,7 @@ main (int argc, char **argv)
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
if (verbose)
- asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
+ xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
}
# ifdef _AIX
@@ -290,7 +290,7 @@ main (int argc, char **argv)
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
if (verbose) {
- asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
+ xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
}
@@ -329,7 +329,7 @@ main (int argc, char **argv)
percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
result = max_state (result, check_swap (percent, dskfree_mb));
if (verbose) {
- asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
+ xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
}
}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 1bbb05a3..f464b15f 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -502,7 +502,7 @@ process_arguments (int argc, char **argv)
if (escape)
server_send = np_escaped_string(optarg);
else
- asprintf(&server_send, "%s", optarg);
+ xasprintf(&server_send, "%s", optarg);
break;
case 'e': /* expect string (may be repeated) */
flags &= ~FLAG_EXACT_MATCH;
@@ -522,7 +522,7 @@ process_arguments (int argc, char **argv)
if (escape)
server_quit = np_escaped_string(optarg);
else
- asprintf(&server_quit, "%s\r\n", optarg);
+ xasprintf(&server_quit, "%s\r\n", optarg);
break;
case 'r':
if (!strncmp(optarg,"ok",2))
diff --git a/plugins/check_time.c b/plugins/check_time.c
index 3dcc662c..7ee014e9 100644
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
@@ -329,7 +329,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", TIME_PORT);
+ xasprintf (&myport, "%d", TIME_PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 30c9357a..59dcc264 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -136,56 +136,56 @@ main (int argc, char **argv)
result = STATE_OK;
if (status & UPSSTATUS_OFF) {
- asprintf (&ups_status, "Off");
+ xasprintf (&ups_status, "Off");
result = STATE_CRITICAL;
}
else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) ==
(UPSSTATUS_OB | UPSSTATUS_LB)) {
- asprintf (&ups_status, _("On Battery, Low Battery"));
+ xasprintf (&ups_status, _("On Battery, Low Battery"));
result = STATE_CRITICAL;
}
else {
if (status & UPSSTATUS_OL) {
- asprintf (&ups_status, "%s%s", ups_status, _("Online"));
+ xasprintf (&ups_status, "%s%s", ups_status, _("Online"));
}
if (status & UPSSTATUS_OB) {
- asprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
+ xasprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
result = STATE_WARNING;
}
if (status & UPSSTATUS_LB) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
result = STATE_WARNING;
}
if (status & UPSSTATUS_CAL) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
}
if (status & UPSSTATUS_RB) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
result = STATE_WARNING;
}
if (status & UPSSTATUS_BYPASS) {
- asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
}
if (status & UPSSTATUS_OVER) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
}
if (status & UPSSTATUS_TRIM) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
}
if (status & UPSSTATUS_BOOST) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
}
if (status & UPSSTATUS_CHRG) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
}
if (status & UPSSTATUS_DISCHRG) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
}
if (status & UPSSTATUS_UNKOWN) {
- asprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
+ xasprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
}
}
- asprintf (&message, "%sStatus=%s ", message, ups_status);
+ xasprintf (&message, "%sStatus=%s ", message, ups_status);
}
/* get the ups utility voltage if possible */
@@ -197,7 +197,7 @@ main (int argc, char **argv)
supported_options |= UPS_UTILITY;
ups_utility_voltage = atof (temp_buffer);
- asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage);
+ xasprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage);
if (ups_utility_voltage > 120.0)
ups_utility_deviation = 120.0 - ups_utility_voltage;
@@ -211,13 +211,13 @@ main (int argc, char **argv)
else if (check_warn==TRUE && ups_utility_deviation>=warning_value) {
result = max_state (result, STATE_WARNING);
}
- asprintf (&data, "%s",
+ xasprintf (&data, "%s",
perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
check_warn, (long)(1000*warning_value),
check_crit, (long)(1000*critical_value),
TRUE, 0, FALSE, 0));
} else {
- asprintf (&data, "%s",
+ xasprintf (&data, "%s",
perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
}
@@ -231,7 +231,7 @@ main (int argc, char **argv)
else {
supported_options |= UPS_BATTPCT;
ups_battery_percent = atof (temp_buffer);
- asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
+ xasprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
if (check_variable == UPS_BATTPCT) {
if (check_crit==TRUE && ups_battery_percent <= critical_value) {
@@ -240,13 +240,13 @@ main (int argc, char **argv)
else if (check_warn==TRUE && ups_battery_percent<=warning_value) {
result = max_state (result, STATE_WARNING);
}
- asprintf (&data, "%s %s", data,
+ xasprintf (&data, "%s %s", data,
perfdata ("battery", (long)ups_battery_percent, "%",
check_warn, (long)(1000*warning_value),
check_crit, (long)(1000*critical_value),
TRUE, 0, TRUE, 100));
} else {
- asprintf (&data, "%s %s", data,
+ xasprintf (&data, "%s %s", data,
perfdata ("battery", (long)ups_battery_percent, "%",
FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
}
@@ -260,7 +260,7 @@ main (int argc, char **argv)
else {
supported_options |= UPS_LOADPCT;
ups_load_percent = atof (temp_buffer);
- asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
+ xasprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
if (check_variable == UPS_LOADPCT) {
if (check_crit==TRUE && ups_load_percent>=critical_value) {
@@ -269,13 +269,13 @@ main (int argc, char **argv)
else if (check_warn==TRUE && ups_load_percent>=warning_value) {
result = max_state (result, STATE_WARNING);
}
- asprintf (&data, "%s %s", data,
+ xasprintf (&data, "%s %s", data,
perfdata ("load", (long)ups_load_percent, "%",
check_warn, (long)(1000*warning_value),
check_crit, (long)(1000*critical_value),
TRUE, 0, TRUE, 100));
} else {
- asprintf (&data, "%s %s", data,
+ xasprintf (&data, "%s %s", data,
perfdata ("load", (long)ups_load_percent, "%",
FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
}
@@ -291,12 +291,12 @@ main (int argc, char **argv)
if (temp_output_c) {
tunits="degC";
ups_temperature = atof (temp_buffer);
- asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature);
+ xasprintf (&message, "%sTemp=%3.1fC", message, ups_temperature);
}
else {
tunits="degF";
ups_temperature = (atof (temp_buffer) * 1.8) + 32;
- asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature);
+ xasprintf (&message, "%sTemp=%3.1fF", message, ups_temperature);
}
if (check_variable == UPS_TEMP) {
@@ -306,13 +306,13 @@ main (int argc, char **argv)
else if (check_warn == TRUE && ups_temperature>=warning_value) {
result = max_state (result, STATE_WARNING);
}
- asprintf (&data, "%s %s", data,
+ xasprintf (&data, "%s %s", data,
perfdata ("temp", (long)ups_temperature, tunits,
check_warn, (long)(1000*warning_value),
check_crit, (long)(1000*critical_value),
TRUE, 0, FALSE, 0));
} else {
- asprintf (&data, "%s %s", data,
+ xasprintf (&data, "%s %s", data,
perfdata ("temp", (long)ups_temperature, tunits,
FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
}
@@ -321,7 +321,7 @@ main (int argc, char **argv)
/* if the UPS does not support any options we are looking for, report an error */
if (supported_options == UPS_NONE) {
result = STATE_CRITICAL;
- asprintf (&message, _("UPS does not support any available options\n"));
+ xasprintf (&message, _("UPS does not support any available options\n"));
}
/* reset timeout */
@@ -595,7 +595,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", PORT);
+ xasprintf (&myport, "%d", PORT);
print_revision (progname, NP_VERSION);
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 37662928..c581fb29 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -89,7 +89,7 @@ main (int argc, char **argv)
if (result == STATE_UNKNOWN)
printf ("%s\n", _("Unable to read output"));
else {
- asprintf (&perf, "%s", perfdata ("users", users, "",
+ xasprintf (&perf, "%s", perfdata ("users", users, "",
TRUE, wusers,
TRUE, cusers,
TRUE, 0,
diff --git a/plugins/negate.c b/plugins/negate.c
index 96f45578..493988ee 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -104,7 +104,7 @@ main (int argc, char **argv)
*sub = '\0';
sub += strlen (state_text (result));
/* then put everything back together */
- asprintf (&chld_out.line[i], "%s%s%s", chld_out.line[i], state_text (state[result]), sub);
+ xasprintf (&chld_out.line[i], "%s%s%s", chld_out.line[i], state_text (state[result]), sub);
}
}
printf ("%s\n", chld_out.line[i]);
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 6bb42db0..30b2a353 100644
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
@@ -102,7 +102,7 @@ main (int argc, char **argv)
cmd = strdup (argv[optind++]);
for (c = optind; c < argc; c++) {
- asprintf (&cmd, "%s %s", cmd, argv[c]);
+ xasprintf (&cmd, "%s %s", cmd, argv[c]);
}
child_process = spopen (cmd);
diff --git a/plugins/utils.c b/plugins/utils.c
index 45373909..8827e31a 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -358,7 +358,7 @@ strscpy (char *dest, const char *src)
if (src == NULL)
return NULL;
- asprintf (&dest, "%s", src);
+ xasprintf (&dest, "%s", src);
return dest;
}
@@ -513,6 +513,33 @@ strpcat (char *dest, const char *src, const char *str)
return dest;
}
+
+/******************************************************************************
+ *
+ * asprintf, but die on failure
+ *
+ ******************************************************************************/
+
+int
+xvasprintf (char **strp, const char *fmt, va_list ap)
+{
+ int result = vasprintf (strp, fmt, ap);
+ if (result == -1 || *strp == NULL)
+ die (STATE_UNKNOWN, _("failed malloc in xvasprintf\n"));
+ return result;
+}
+
+int
+xasprintf (char **strp, const char *fmt, ...)
+{
+ va_list ap;
+ int result;
+ va_start (ap, fmt);
+ result = xvasprintf (strp, fmt, ap);
+ va_end (ap);
+ return result;
+}
+
/******************************************************************************
*
* Print perfdata in a standard format
@@ -534,25 +561,25 @@ char *perfdata (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
- asprintf (&data, "'%s'=%ld%s;", label, val, uom);
+ xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
else
- asprintf (&data, "%s=%ld%s;", label, val, uom);
+ xasprintf (&data, "%s=%ld%s;", label, val, uom);
if (warnp)
- asprintf (&data, "%s%ld;", data, warn);
+ xasprintf (&data, "%s%ld;", data, warn);
else
- asprintf (&data, "%s;", data);
+ xasprintf (&data, "%s;", data);
if (critp)
- asprintf (&data, "%s%ld;", data, crit);
+ xasprintf (&data, "%s%ld;", data, crit);
else
- asprintf (&data, "%s;", data);
+ xasprintf (&data, "%s;", data);
if (minp)
- asprintf (&data, "%s%ld", data, minv);
+ xasprintf (&data, "%s%ld", data, minv);
if (maxp)
- asprintf (&data, "%s;%ld", data, maxv);
+ xasprintf (&data, "%s;%ld", data, maxv);
return data;
}
@@ -573,29 +600,29 @@ char *fperfdata (const char *label,
char *data = NULL;
if (strpbrk (label, "'= "))
- asprintf (&data, "'%s'=", label);
+ xasprintf (&data, "'%s'=", label);
else
- asprintf (&data, "%s=", label);
+ xasprintf (&data, "%s=", label);
- asprintf (&data, "%s%f", data, val);
- asprintf (&data, "%s%s;", data, uom);
+ xasprintf (&data, "%s%f", data, val);
+ xasprintf (&data, "%s%s;", data, uom);
if (warnp)
- asprintf (&data, "%s%f", data, warn);
+ xasprintf (&data, "%s%f", data, warn);
- asprintf (&data, "%s;", data);
+ xasprintf (&data, "%s;", data);
if (critp)
- asprintf (&data, "%s%f", data, crit);
+ xasprintf (&data, "%s%f", data, crit);
- asprintf (&data, "%s;", data);
+ xasprintf (&data, "%s;", data);
if (minp)
- asprintf (&data, "%s%f", data, minv);
+ xasprintf (&data, "%s%f", data, minv);
if (maxp) {
- asprintf (&data, "%s;", data);
- asprintf (&data, "%s%f", data, maxv);
+ xasprintf (&data, "%s;", data);
+ xasprintf (&data, "%s%f", data, maxv);
}
return data;
diff --git a/plugins/utils.h b/plugins/utils.h
index 3c3f1892..822be940 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -81,6 +81,8 @@ char *strscpy (char *, const char *);
char *strnl (char *);
char *strpcpy (char *, const char *, const char *);
char *strpcat (char *, const char *, const char *);
+int xvasprintf (char **strp, const char *fmt, va_list ap);
+int xasprintf (char **strp, const char *fmt, ...);
int max_state (int a, int b);
int max_state_alt (int a, int b);