/*****************************************************************************
*
* CHECK_CLUSTER2.C - Host and Service Cluster Plugin for Nagios 2.x
*
* Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)
* Copyright (c) 2007 nagios-plugins team
* License: GPL
* Last Modified: $Date: 2007-06-20 10:01:07 +0100 (Wed, 20 Jun 2007) $
*
* 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_cluster.c 1745 2007-06-20 09:01:07Z psychotrahe $
*
******************************************************************************/
const char *progname = "check_cluster";
const char *revision = "$Revision: 1745 $";
const char *copyright = "2007";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "common.h"
#include "utils.h"
#include "utils_base.h"
#define CHECK_SERVICES 1
#define CHECK_HOSTS 2
void print_help (void);
void print_usage (void);
int total_services_ok=0;
int total_services_warning=0;
int total_services_unknown=0;
int total_services_critical=0;
int total_hosts_up=0;
int total_hosts_down=0;
int total_hosts_unreachable=0;
char *warn_threshold;
char *crit_threshold;
int check_type=CHECK_SERVICES;
char *data_vals=NULL;
char *label=NULL;
int verbose=0;
int process_arguments(int,char **);
int main(int argc, char **argv){
char *ptr;
int data_val;
int return_code=STATE_OK;
thresholds *thresholds = NULL;
if(process_arguments(argc,argv)==ERROR)
usage(_("Could not parse arguments"));
/* Initialize the thresholds */
set_thresholds(&thresholds, warn_threshold, crit_threshold);
if(verbose)
print_thresholds("check_cluster", thresholds);
/* check the data values */
for(ptr=strtok(data_vals,",");ptr!=NULL;ptr=strtok(NULL,",")){
data_val=atoi(ptr);
if(check_type==CHECK_SERVICES){
switch(data_val){
case 0:
total_services_ok++;
break;
case 1:
total_services_warning++;
break;
case 2:
total_services_critical++;
break;
case 3:
total_services_unknown++;
break;
=1= |