/******************************************************************************
*
* Nagios check_nagios 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_nagios plugin
*
* This plugin checks the status of the Nagios process on the local machine
* The plugin will check to make sure the Nagios status log is no older than
* the number of minutes specified by the expires option.
* It also checks the process table for a process matching the command argument.
*
*
* 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_nagios.c 1590 2007-01-28 21:46:41Z hweiss $
******************************************************************************/
const char *progname = "check_nagios";
const char *revision = "$Revision: 1590 $";
const char *copyright = "1999-2006";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "common.h"
#include "runcmd.h"
#include "utils.h"
int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
char *status_log = NULL;
char *process_string = NULL;
int expire_minutes = 0;
int verbose = 0;
int
main (int argc, char **argv)
{
int result = STATE_UNKNOWN;
char input_buffer[MAX_INPUT_BUFFER];
unsigned long latest_entry_time = 0L;
unsigned long temp_entry_time = 0L;
int proc_entries = 0;
time_t current_time;
char *temp_ptr;
FILE *fp;
int procuid = 0;
int procpid = 0;
int procppid = 0;
int procvsz = 0;
int procrss = 0;
float procpcpu = 0;
char procstat[8];
#ifdef PS_USES_PROCETIME
char procetime[MAX_INPUT_BUFFER];
#endif /* PS_USES_PROCETIME */
char procprog[MAX_INPUT_BUFFER];
char *procargs;
int pos, cols;
int expected_cols = PS_COLS - 1;
const char *zombie = "Z";
char *temp_string;
output chld_out, chld_err;
size_t i;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
if (process_arguments (argc, argv) == ERROR)
usage_va(_("Could not parse arguments"));
/* Set signal handling and alarm timeout */
if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
usage_va(_("Cannot catch SIGALRM"));
}
=1= |