Back to index

nagios-plugins  1.4.16
Defines | Functions | Variables
check_cluster.c File Reference
#include "common.h"
#include "utils.h"
#include "utils_base.h"

Go to the source code of this file.

Defines

#define CHECK_SERVICES   1
#define CHECK_HOSTS   2

Functions

void print_help (void)
void print_usage (void)
int process_arguments (int, char **)
int main (int argc, char **argv)

Variables

const char * progname = "check_cluster"
const char * copyright = "2000-2007"
const char * email = "nagiosplug-devel@lists.sourceforge.net"
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

Define Documentation

#define CHECK_HOSTS   2

Definition at line 34 of file check_cluster.c.

#define CHECK_SERVICES   1

Definition at line 33 of file check_cluster.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 62 of file check_cluster.c.

                               {
       char *ptr;
       int data_val;
       int return_code=STATE_OK;
       thresholds *thresholds = NULL;

       setlocale (LC_ALL, "");
       bindtextdomain (PACKAGE, LOCALEDIR);
       textdomain (PACKAGE);

       /* Parse extra opts if any */
       argv=np_extra_opts(&argc, argv, progname);

       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;
                     default:
                            break;
                      }
               }
              else{
                     switch(data_val){
                     case 0:
                            total_hosts_up++;
                            break;
                     case 1:
                            total_hosts_down++;
                            break;
                     case 2:
                            total_hosts_unreachable++;
                            break;
                     default:
                            break;
                      }
               }
        }


       /* return the status of the cluster */
       if(check_type==CHECK_SERVICES){
              return_code=get_status(total_services_warning+total_services_unknown+total_services_critical, thresholds);
              printf("CLUSTER %s: %s: %d ok, %d warning, %d unknown, %d critical\n",
                     state_text(return_code), (label==NULL)?"Service cluster":label,
                     total_services_ok,total_services_warning,
                     total_services_unknown,total_services_critical);
       }
       else{
              return_code=get_status(total_hosts_down+total_hosts_unreachable, thresholds);
              printf("CLUSTER %s: %s: %d up, %d down, %d unreachable\n",
                     state_text(return_code), (label==NULL)?"Host cluster":label,
                     total_hosts_up,total_hosts_down,total_hosts_unreachable);
       }

       return return_code;
}

Here is the call graph for this function:

void print_help ( void  )
void print_usage ( void  )

Definition at line 389 of file check_cpqarray.c.

{
  printf("cpqarrayd [options]\n");
  printf("   -h         prints this text\n");
  printf("   -d         enables debugging\n");
}
int process_arguments ( int  argc,
char **  argv 
)

Variable Documentation

Definition at line 51 of file check_cluster.c.

const char* copyright = "2000-2007"

Definition at line 26 of file check_cluster.c.

Definition at line 49 of file check_cluster.c.

char* data_vals = NULL

Definition at line 53 of file check_cluster.c.

const char* email = "nagiosplug-devel@lists.sourceforge.net"

Definition at line 27 of file check_cluster.c.

char* label = NULL

Definition at line 54 of file check_cluster.c.

const char* progname = "check_cluster"

Definition at line 25 of file check_cluster.c.

Definition at line 45 of file check_cluster.c.

Definition at line 46 of file check_cluster.c.

int total_hosts_up = 0

Definition at line 44 of file check_cluster.c.

Definition at line 42 of file check_cluster.c.

Definition at line 39 of file check_cluster.c.

Definition at line 41 of file check_cluster.c.

Definition at line 40 of file check_cluster.c.

int verbose = 0

Definition at line 56 of file check_cluster.c.

Definition at line 48 of file check_cluster.c.