diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 (GMT) |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 (GMT) |
commit | 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch) | |
tree | a1a4d9f7b92412a17ab08f34f04eec45433048b7 /plugins/utils.h.in | |
parent | 54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff) | |
download | monitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz |
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.h.in')
-rw-r--r-- | plugins/utils.h.in | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/utils.h.in b/plugins/utils.h.in new file mode 100644 index 0000000..a21d63d --- /dev/null +++ b/plugins/utils.h.in | |||
@@ -0,0 +1,92 @@ | |||
1 | /* header file for nagios plugins uitls.c */ | ||
2 | |||
3 | /* this file should be included in all plugins */ | ||
4 | |||
5 | /* The purpose of this package is to provide safer alternantives to C | ||
6 | functions that might otherwise be vulnerable to hacking. This | ||
7 | currently includes a standard suite of validation routines to be sure | ||
8 | that an string argument acually converts to its intended type and a | ||
9 | suite of string handling routine that do their own memory management | ||
10 | in order to resist overflow attacks. In addition, a few functions are | ||
11 | provided to standardize version and error reporting accross the entire | ||
12 | suite of plugins. */ | ||
13 | |||
14 | /* Standardize version information, termination */ | ||
15 | |||
16 | char *my_basename (char *); | ||
17 | void support (void); | ||
18 | char *clean_revstring (const char *revstring); | ||
19 | void print_revision (char *, const char *); | ||
20 | void terminate (int result, char *msg, ...); | ||
21 | extern RETSIGTYPE timeout_alarm_handler (int); | ||
22 | |||
23 | /* Handle timeouts */ | ||
24 | |||
25 | time_t start_time, end_time; | ||
26 | int timeout_interval = DEFAULT_SOCKET_TIMEOUT; | ||
27 | |||
28 | /* Test input types */ | ||
29 | |||
30 | int is_host (char *); | ||
31 | int is_dotted_quad (char *); | ||
32 | int is_hostname (char *); | ||
33 | |||
34 | int is_integer (char *); | ||
35 | int is_intpos (char *); | ||
36 | int is_intneg (char *); | ||
37 | int is_intnonneg (char *); | ||
38 | int is_intpercent (char *); | ||
39 | |||
40 | int is_numeric (char *); | ||
41 | int is_positive (char *); | ||
42 | int is_negative (char *); | ||
43 | int is_nonnegative (char *); | ||
44 | int is_percentage (char *); | ||
45 | |||
46 | int is_option (char *); | ||
47 | |||
48 | /* Handle strings safely */ | ||
49 | |||
50 | void strip (char *buffer); | ||
51 | char *strscpy (char *dest, char *src); | ||
52 | char *strscat (char *dest, char *src); | ||
53 | char *strnl (char *str); | ||
54 | char *ssprintf (char *str, const char *fmt, ...); | ||
55 | char *strpcpy (char *dest, const char *src, const char *str); | ||
56 | char *strpcat (char *dest, const char *src, const char *str); | ||
57 | |||
58 | #define max(a,b) ((a)>(b))?(a):(b) | ||
59 | |||
60 | #define usage(msg) {\ | ||
61 | printf(msg);\ | ||
62 | print_usage();\ | ||
63 | exit(STATE_UNKNOWN);\ | ||
64 | } | ||
65 | |||
66 | #define usage2(msg,arg) {\ | ||
67 | printf("%s: %s - %s\n",PROGNAME,msg,arg);\ | ||
68 | print_usage();\ | ||
69 | exit(STATE_UNKNOWN);\ | ||
70 | } | ||
71 | |||
72 | #define state_text(a) \ | ||
73 | (a)==0?"OK":\ | ||
74 | (a)==1?"WARNING":\ | ||
75 | (a)==2?"CRITICAL":\ | ||
76 | (a)==-2?"DEPENDENT":\ | ||
77 | "UNKNOWN" | ||
78 | |||
79 | /* The idea here is that, although not every plugin will use all of these, | ||
80 | most will or should. Therefore, for consistency, these very common | ||
81 | options should have only these meanings throughout the overall suite */ | ||
82 | |||
83 | #define STD_OPTS "Vvht:c:w:H:F:" | ||
84 | #define STD_OPTS_LONG \ | ||
85 | {"version",no_argument,0,'V'},\ | ||
86 | {"verbose",no_argument,0,'v'},\ | ||
87 | {"help",no_argument,0,'h'},\ | ||
88 | {"timeout",required_argument,0,'t'},\ | ||
89 | {"critical",required_argument,0,'c'},\ | ||
90 | {"warning",required_argument,0,'w'},\ | ||
91 | {"hostname",required_argument,0,'H'},\ | ||
92 | {"file",required_argument,0,'F'} | ||