/******************************************************************************
*
* Nagios check_by_ssh plugin
*
* License: GPL
* Copyright (c) 1999-2006 nagios-plugins team
*
* Last Modified: $Date: 2007-09-23 13:26:03 +0100 (Sun, 23 Sep 2007) $
*
* Description:
*
* This file contains the check_by_ssh plugin
*
* 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_by_ssh.c 1792 2007-09-23 12:26:03Z psychotrahe $
*
******************************************************************************/
const char *progname = "check_by_ssh";
const char *revision = "$Revision: 1792 $";
const char *copyright = "2000-2006";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "common.h"
#include "netutils.h"
#include "utils.h"
#include "runcmd.h"
int process_arguments (int, char **);
int validate_arguments (void);
void print_help (void);
void print_usage (void);
unsigned int commands = 0;
unsigned int services = 0;
int skip_stdout = 0;
int skip_stderr = 0;
char *remotecmd = NULL;
char *comm = NULL;
char *hostname = NULL;
char *outputfile = NULL;
char *host_shortname = NULL;
char **service;
int passive = FALSE;
int verbose = FALSE;
int
main (int argc, char **argv)
{
char *status_text;
int cresult;
int result = STATE_UNKNOWN;
int i;
time_t local_time;
FILE *fp = NULL;
struct output chld_out, chld_err;
remotecmd = "";
comm = strdup (SSH_COMMAND);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
/* process arguments */
if (process_arguments (argc, argv) == ERROR)
usage_va(_("Could not parse arguments"));
/* Set signal handling and alarm timeout */
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
usage_va(_("Cannot catch SIGALRM"));
}
alarm (timeout_interval);
/* run the command */
if (verbose)
printf ("%s\n", comm);
result = np_runcmd(comm, &chld_out, &chld_err, 0);
if (skip_stdout == -1) /* --skip-stdout specified without argument */
skip_stdout = chld_out.lines;
if (skip_stderr == -1) /* --skip-stderr specified without argument */
skip_stderr = chld_err.lines;
=1= |