/******************************************************************************
*
* Nagios check_game plugin
*
* License: GPL
* Copyright (c) 1999-2006 nagios-plugins team
*
* Last Modified: $Date: 2007-01-28 21:46:41 +0000 (Sun, 28 Jan 2007) $
*
* Description:
*
* This file contains the check_game plugin
*
* This plugin tests game server connections with the specified host.
* using the qstat program
*
* License Information:
*
* 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.
*
* $Id: check_game.c 1590 2007-01-28 21:46:41Z hweiss $
*****************************************************************************/
const char *progname = "check_game";
const char *revision = "$Revision: 1590 $";
const char *copyright = "2002-2006";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "common.h"
#include "utils.h"
#include "runcmd.h"
int process_arguments (int, char **);
int validate_arguments (void);
void print_help (void);
void print_usage (void);
#define QSTAT_DATA_DELIMITER ","
#define QSTAT_HOST_ERROR "ERROR"
#define QSTAT_HOST_DOWN "DOWN"
#define QSTAT_HOST_TIMEOUT "TIMEOUT"
#define QSTAT_MAX_RETURN_ARGS 12
char *server_ip;
char *game_type;
int port = 0;
int verbose;
int qstat_game_players_max = -1;
int qstat_game_players = -1;
int qstat_game_field = -1;
int qstat_map_field = -1;
int qstat_ping_field = -1;
int
main (int argc, char **argv)
{
char *command_line;
int result = STATE_UNKNOWN;
char *p, *ret[QSTAT_MAX_RETURN_ARGS];
size_t i = 0;
output chld_out;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (process_arguments (argc, argv) == ERROR)
usage_va(_("Could not parse arguments"));
result = STATE_OK;
/* create the command line to execute */
asprintf (&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);
if (verbose > 0)
printf ("%s\n", command_line);
/* run the command. historically, this plugin ignores output on stderr,
* as well as return status of the qstat program */
(void)np_runcmd(command_line, &chld_out, NULL, 0);
=1= |