diff options
Diffstat (limited to 'plugins/check_game.c')
-rw-r--r-- | plugins/check_game.c | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/plugins/check_game.c b/plugins/check_game.c index 2b109915..d5de13db 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c | |||
@@ -25,48 +25,10 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
25 | #include "popen.h" | 25 | #include "popen.h" |
26 | #include "utils.h" | 26 | #include "utils.h" |
27 | 27 | ||
28 | void | ||
29 | print_usage (void) | ||
30 | { | ||
31 | printf (_("\ | ||
32 | Usage: %s <game> <ip_address> [-p port] [-gf game_field] [-mf map_field]\n\ | ||
33 | [-pf ping_field]\n"), progname); | ||
34 | printf (_(UT_HLP_VRS), progname, progname); | ||
35 | } | ||
36 | |||
37 | void | ||
38 | print_help (void) | ||
39 | { | ||
40 | print_revision (progname, revision); | ||
41 | |||
42 | printf (_(COPYRIGHT), copyright, email); | ||
43 | |||
44 | printf (_("This plugin tests %s connections with the specified host."), progname); | ||
45 | |||
46 | print_usage (); | ||
47 | |||
48 | printf (_(UT_HELP_VRSN)); | ||
49 | |||
50 | printf (_("\ | ||
51 | <game> = Game type that is recognised by qstat (without the leading dash)\n\ | ||
52 | <ip_address> = The IP address of the device you wish to query\n\ | ||
53 | [port] = Optional port of which to connect\n\ | ||
54 | [game_field] = Field number in raw qstat output that contains game name\n\ | ||
55 | [map_field] = Field number in raw qstat output that contains map name\n\ | ||
56 | [ping_field] = Field number in raw qstat output that contains ping time\n"), | ||
57 | DEFAULT_SOCKET_TIMEOUT); | ||
58 | |||
59 | printf (_("\n\ | ||
60 | Notes:\n\ | ||
61 | - This plugin uses the 'qstat' command, the popular game server status query tool .\n\ | ||
62 | If you don't have the package installed, you will need to download it from\n\ | ||
63 | http://www.activesw.com/people/steve/qstat.html before you can use this plugin.\n")); | ||
64 | |||
65 | printf (_(UT_SUPPORT)); | ||
66 | } | ||
67 | |||
68 | int process_arguments (int, char **); | 28 | int process_arguments (int, char **); |
69 | int validate_arguments (void); | 29 | int validate_arguments (void); |
30 | void print_help (void); | ||
31 | void print_usage (void); | ||
70 | 32 | ||
71 | #define QSTAT_DATA_DELIMITER "," | 33 | #define QSTAT_DATA_DELIMITER "," |
72 | 34 | ||
@@ -152,7 +114,7 @@ main (int argc, char **argv) | |||
152 | 114 | ||
153 | /* initialize the returned data buffer */ | 115 | /* initialize the returned data buffer */ |
154 | for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++) | 116 | for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++) |
155 | ret[i] = ""; | 117 | ret[i] = strdup(""); |
156 | 118 | ||
157 | i = 0; | 119 | i = 0; |
158 | p = (char *) strtok (input_buffer, QSTAT_DATA_DELIMITER); | 120 | p = (char *) strtok (input_buffer, QSTAT_DATA_DELIMITER); |
@@ -253,7 +215,7 @@ process_arguments (int argc, char **argv) | |||
253 | case 'H': /* hostname */ | 215 | case 'H': /* hostname */ |
254 | if (strlen (optarg) >= MAX_HOST_ADDRESS_LENGTH) | 216 | if (strlen (optarg) >= MAX_HOST_ADDRESS_LENGTH) |
255 | die (STATE_UNKNOWN, _("Input buffer overflow\n")); | 217 | die (STATE_UNKNOWN, _("Input buffer overflow\n")); |
256 | server_ip = strdup (optarg); | 218 | server_ip = optarg; |
257 | break; | 219 | break; |
258 | case 'P': /* port */ | 220 | case 'P': /* port */ |
259 | port = atoi (optarg); | 221 | port = atoi (optarg); |
@@ -261,7 +223,7 @@ process_arguments (int argc, char **argv) | |||
261 | case 'G': /* hostname */ | 223 | case 'G': /* hostname */ |
262 | if (strlen (optarg) >= MAX_INPUT_BUFFER) | 224 | if (strlen (optarg) >= MAX_INPUT_BUFFER) |
263 | die (STATE_UNKNOWN, _("Input buffer overflow\n")); | 225 | die (STATE_UNKNOWN, _("Input buffer overflow\n")); |
264 | game_type = strdup (optarg); | 226 | game_type = optarg; |
265 | break; | 227 | break; |
266 | case 'p': /* index of ping field */ | 228 | case 'p': /* index of ping field */ |
267 | qstat_ping_field = atoi (optarg); | 229 | qstat_ping_field = atoi (optarg); |
@@ -308,3 +270,52 @@ validate_arguments (void) | |||
308 | { | 270 | { |
309 | return OK; | 271 | return OK; |
310 | } | 272 | } |
273 | |||
274 | |||
275 | |||
276 | |||
277 | |||
278 | |||
279 | void | ||
280 | print_help (void) | ||
281 | { | ||
282 | print_revision (progname, revision); | ||
283 | |||
284 | printf (_(COPYRIGHT), copyright, email); | ||
285 | |||
286 | printf (_("This plugin tests %s connections with the specified host."), progname); | ||
287 | |||
288 | print_usage (); | ||
289 | |||
290 | printf (_(UT_HELP_VRSN)); | ||
291 | |||
292 | printf (_("\ | ||
293 | <game> = Game type that is recognised by qstat (without the leading dash)\n\ | ||
294 | <ip_address> = The IP address of the device you wish to query\n\ | ||
295 | [port] = Optional port of which to connect\n\ | ||
296 | [game_field] = Field number in raw qstat output that contains game name\n\ | ||
297 | [map_field] = Field number in raw qstat output that contains map name\n\ | ||
298 | [ping_field] = Field number in raw qstat output that contains ping time\n")); | ||
299 | |||
300 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
301 | |||
302 | printf (_("\n\ | ||
303 | Notes:\n\ | ||
304 | - This plugin uses the 'qstat' command, the popular game server status query tool .\n\ | ||
305 | If you don't have the package installed, you will need to download it from\n\ | ||
306 | http://www.activesw.com/people/steve/qstat.html before you can use this plugin.\n")); | ||
307 | |||
308 | printf (_(UT_SUPPORT)); | ||
309 | } | ||
310 | |||
311 | |||
312 | |||
313 | |||
314 | void | ||
315 | print_usage (void) | ||
316 | { | ||
317 | printf (_("\ | ||
318 | Usage: %s <game> <ip_address> [-p port] [-gf game_field] [-mf map_field]\n\ | ||
319 | [-pf ping_field]\n"), progname); | ||
320 | printf (_(UT_HLP_VRS), progname, progname); | ||
321 | } | ||