summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 65ca899)
raw | patch | inline | side by side (parent: 65ca899)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 8 Aug 2003 05:09:40 +0000 (05:09 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 8 Aug 2003 05:09:40 +0000 (05:09 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@663 f882894a-f735-0410-b71e-b25c423dba1c
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 8527b727e1df458d4a388dd435ded0b75c731d4f..59e8ea0ca42e8491ff8fa224fa27b53800de3c08 100644 (file)
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
}
if (commands > 1)
- remotecmd = strscat (remotecmd, ";echo STATUS CODE: $?;");
+ asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
if (remotecmd == NULL || strlen (remotecmd) <= 1)
usage (_("No remotecmd\n"));
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 3d82298fe25546b0149bd08b055271260123869f..7c39a243c507c5adc8812255eedcf5de15b30885 100644 (file)
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
/*****************************************************************************
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
*****************************************************************************/
-#include "config.h"
#include "common.h"
#include "netutils.h"
#include "utils.h"
DEFAULT_PORT = 53
};
-void
-print_usage (void)
-{
- printf (_("\
-Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\
- [-c <critical interval>] [-t <timeout>] [-v]\n"),
- progname);
- printf (" %s (-h|--help)\n", progname);
- printf (" %s (-V|--version)\n", progname);
-}
-
-void
-print_help (void)
-{
- char *myport;
-
- asprintf (&myport, "%d", DEFAULT_PORT);
-
- print_revision (progname, revision);
-
- printf (_(COPYRIGHT), copyright, email);
-
- printf (_("Test the DNS service on the specified host using dig\n\n"));
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_(UT_HOST_PORT), 'P', myport);
-
- printf (_("\
- -l, --lookup=STRING\n\
- machine name to lookup\n"));
-
- printf (_(UT_WARN_CRIT));
-
- printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
-
- printf (_(UT_VERBOSE));
-
- support ();
-}
-\f
-
char *query_address = NULL;
char *dns_server = NULL;
int verbose = FALSE;
int critical_interval = -1;
+
+
+
+\f
int
main (int argc, char **argv)
{
char input_buffer[MAX_INPUT_BUFFER];
- char *command_line = NULL;
- char *output = "";
+ char *command_line;
+ char *output;
int result = STATE_UNKNOWN;
+ output = strdup ("");
+
/* Set signal handling and alarm */
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR)
usage (_("Cannot catch SIGALRM\n"));
return result;
}
+
+
+
+
+\f
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
{
return OK;
}
+
+
+
+
+
+
\f
+void
+print_help (void)
+{
+ char *myport;
+
+ asprintf (&myport, "%d", DEFAULT_PORT);
+
+ print_revision (progname, revision);
+
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("Test the DNS service on the specified host using dig\n\n"));
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_HOST_PORT), 'P', myport);
+
+ printf (_("\
+ -l, --lookup=STRING\n\
+ machine name to lookup\n"));
+
+ printf (_(UT_WARN_CRIT));
+
+ printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(UT_VERBOSE));
+
+ support ();
+}
+
+
+
+
+void
+print_usage (void)
+{
+ printf (_("\
+Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\
+ [-c <critical interval>] [-t <timeout>] [-v]\n"),
+ progname);
+ printf (" %s (-h|--help)\n", progname);
+ printf (" %s (-V|--version)\n", progname);
+}
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7feb5a571a85873149825f217d762e96c323018d..7bed4d43960dccbda14f0434a8a591ef9873b0a8 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
/******************************************************************************
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
*****************************************************************************/
const char *progname = "check_disk";
int process_arguments (int, char **);
void print_path (char *mypath);
int validate_arguments (uintmax_t, uintmax_t, double, double, char *);
-int check_disk (int usp, uintmax_t free_disk);
+int check_disk (double usp, uintmax_t free_disk);
int walk_name_list (struct name_list *list, const char *name);
void print_help (void);
void print_usage (void);
uintmax_t c_df = 0;
double w_dfp = -1.0;
double c_dfp = -1.0;
-char *path = "";
-char *exclude_device = "";
-char *units = NULL;
+char *path;
+char *exclude_device;
+char *units;
uintmax_t mult = 1024 * 1024;
int verbose = 0;
int erronly = FALSE;
int result = STATE_UNKNOWN;
int disk_result = STATE_UNKNOWN;
char file_system[MAX_INPUT_BUFFER];
- char *output = "";
- char *details = "";
+ char *output;
+ char *details;
float free_space, free_space_pct, total_space;
struct mount_entry *me;
struct fs_usage fsp;
struct name_list *temp_list;
+ output = strdup ("");
+ details = strdup ("");
+
mount_list = read_filesystem_list (0);
if (process_arguments (argc, argv) != OK)
if (c_dfp < 0 && argc > c && is_intnonneg (argv[c]))
c_dfp = (100.0 - atof (argv[c++]));
- if (argc > c && strlen (path) == 0) {
+ if (argc > c && path == NULL) {
se = (struct name_list *) malloc (sizeof (struct name_list));
se->name = strdup (argv[c++]);
se->name_next = NULL;
@@ -482,7 +485,7 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
\f
int
-check_disk (int usp, uintmax_t free_disk)
+check_disk (double usp, uintmax_t free_disk)
{
int result = STATE_UNKNOWN;
/* check the percent used space against thresholds */
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index dcb6e68aff2024a5d5439e94ec27834729db98bf..e22d8a0b5eacf2ee864627c5f1ecdbaf35d83e65 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
ptr = strpbrk (ptr, "\n");
}
if (ptr && strstr (ptr, delimiter) == NULL) {
- response = strscat (response, ptr);
+ asprintf (&response, "%s%s", response, ptr);
ptr = NULL;
}
}
diff --git a/plugins/utils.c b/plugins/utils.c
index 959541bf53f382939e677b29fa450e8feeda1a29..aed03c4e49402e2b0dd3c2dc53a4835e791dc0b8 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
}
void
-usage3 (char *msg, char arg)
+usage3 (char *msg, int arg)
{
printf ("%s: %s - %c\n", progname, msg, arg);
print_usage();
}
-char *
+const char *
state_text (int result)
{
switch (result) {
-/******************************************************************************
- *
- * Concatenates one string to the end of another
- *
- * Given a pointer destination string, which may or may not already
- * hold some text, and a source string with additional text (possibly
- * NULL or empty), returns a pointer to a string that is the first
- * string with the second concatenated to it. Uses realloc to free
- * memory held by the dest argument if new storage space is required.
- *
- * Example:
- *
- * char *str=NULL;
- * str = strscpy("This is a line of text with no trailing newline");
- * str = strscat(str,"\n");
- *
- *****************************************************************************/
-
-char *
-strscat (char *dest, const char *src)
-{
-
- if (dest == NULL)
- return src;
- if (src != NULL)
- asprintf (&dest, "%s%s", dest, src);
-
- return dest;
-}
-
-
-
-
-
/******************************************************************************
*
* Returns a pointer to the next line of a multiline string buffer
diff --git a/plugins/utils.h b/plugins/utils.h
index 9dc2654c51a3e412c6e812da51656a1cd8911a4d..a852e86aeb3ae32752084fcedb1cf2fc918d5b2b 100644 (file)
--- a/plugins/utils.h
+++ b/plugins/utils.h
#ifdef LOCAL_TIMEOUT_ALARM_HANDLER
extern unsigned int timeout_interval;
-RETSIGTYPE timeout_alarm_handler (int) __attribute__((noreturn));
+RETSIGTYPE timeout_alarm_handler (int);
#else
unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
-extern RETSIGTYPE timeout_alarm_handler (int) __attribute__((noreturn));
+extern RETSIGTYPE timeout_alarm_handler (int);
#endif
time_t start_time, end_time;
void strip (char *buffer);
char *strscpy (char *dest, const char *src);
-char *strscat (char *dest, const char *src);
char *strnl (char *str);
-char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */
char *strpcpy (char *dest, const char *src, const char *str);
char *strpcat (char *dest, const char *src, const char *str);
void usage (char *msg) __attribute__((noreturn));
void usage2(char *msg, char *arg) __attribute__((noreturn));
-void usage3(char *msg, char arg) __attribute__((noreturn));
+void usage3(char *msg, int arg) __attribute__((noreturn));
-char *state_text (int result);
+const char *state_text (int result);
#define max(a,b) (((a)>(b))?(a):(b))