Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
>
icinga111
> icinga-legacy.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File icinga-legacy.patch of Package icinga111 (Revision 4)
Currently displaying revision
4
,
show latest
commit 3be1b83c542cf08315f4df5a1c2587a7fa431b46 Author: Michael Friedrich <Michael.Friedrich@netways.de> Date: Fri Jan 3 16:11:54 2014 +0100 Remove legacy code from contrib/. Refs #5406 diff --git a/contrib/Makefile.in b/contrib/Makefile.in index 6fedf02..d591805 100644 --- a/contrib/Makefile.in +++ b/contrib/Makefile.in @@ -23,17 +23,10 @@ CGIDIR=@sbindir@ BINDIR=@bindir@ LIBDIR=@libdir@ -CGIS=traceroute.cgi daemonchk.cgi -UTILS=mini_epn new_mini_epn convertcfg +UTILS=mini_epn new_mini_epn ALL=$(CGIS) $(UTILS) DST=dst -CGI_C=$(SRC_CGI)/getcgi.c -CGI_O=$(SRC_CGI)/getcgi.o $(SNPRINTF_O) -CGI_H=$(SRC_INCLUDE)/getcgi.h -COMMON_H=$(SRC_INCLUDE)/config.h $(SRC_INCLUDE)/common.h $(SRC_INCLUDE)/locations.h - - ############################### # Debug ############################### @@ -50,7 +43,7 @@ endif all: $(ALL) clean: - rm -f convertcfg daemonchk.cgi mini_epn new_mini_epn core dst *.o + rm -f mini_epn new_mini_epn core dst *.o rm -f */*/*~ rm -f */*~ rm -f *~ @@ -63,20 +56,12 @@ distclean: clean devclean: distclean install: - $(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(CGIDIR) $(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(BINDIR) - for f in $(CGIS); do $(INSTALL) -m 775 $(INSTALL_OPTS) $$f $(DESTDIR)$(CGIDIR); done for f in $(UTILS); do $(INSTALL) -m 775 $(INSTALL_OPTS) $$f $(DESTDIR)$(BINDIR); done ############################################################################## # rules and dependencies for actual target programs -daemonchk.cgi: daemonchk.o $(CGI_O) $(CGI_H) $(COMMON_H) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(CGI_O) - -daemonchk.o: daemonchk.c - $(CC) $(CFLAGS) -c -o $@ $< -I$(SRC_INCLUDE) - mini_epn: mini_epn.c perl -MExtUtils::Embed -e xsinit $(CC) $(CFLAGS) -c perlxsi.c `perl -MExtUtils::Embed -e ccopts` @@ -90,16 +75,3 @@ new_mini_epn: new_mini_epn.c $(CC) $(CFLAGS) $(LDFLAGS) perlxsi.o new_mini_epn.o `perl -MExtUtils::Embed -e ccopts -e ldopts` -o $@ dst: dst.c $(CC) $(CFLAGS) -o $@ $< - - -############################################################################## -# dependencies - -$(CGI_O): $(CGI_C) - cd $(SRC_CGI) && make $(CGI_O) - -############################################################################## -# implicit rules - -%.cgi : %.c - $(CC) $(CFLAGS) $(LDFLAGS) $< $(CGI_O) -o $@ diff --git a/contrib/convertcfg.c b/contrib/convertcfg.c deleted file mode 100644 index d3be3ce..0000000 --- a/contrib/convertcfg.c +++ /dev/null @@ -1,741 +0,0 @@ -/************************************************************************ - * - * CONVERTCFG.C - Config File Convertor - * - * Copyright (c) 2001-2005 Ethan Galstad (egalstad@nagios.org) - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - ************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -char *my_strsep(char **, const char *); - -int main(int argc, char **argv) { - FILE *fp; - char *temp_ptr; - char *temp_ptr2; - char input[8096]; - int notify_recovery; - int notify_warning; - int notify_critical; - int notify_down; - int notify_unreachable; - int option; - int have_template = 0; - int x = 0, y = 0; - char *host_name; - char *service_description; - char *host_name2; - char *service_description2; - - if (argc != 3) { - printf("Nagios Config File Converter\n"); - printf("Written by Ethan Galstad (egalstad@nagios.org)\n"); - printf("Last Modified: 08-12-2005\n"); - printf("\n"); - printf("Usage: %s <config file> <object type>\n", argv[0]); - printf("\n"); - printf("Valid object types include:\n"); - printf("\n"); - printf("\ttimeperiods\n"); - printf("\tcommands\n"); - printf("\tcontacts\n"); - printf("\tcontactgroups\n"); - printf("\thosts\n"); - printf("\thostgroups\n"); - printf("\thostgroupescalationss\n"); - printf("\tservices\n"); - printf("\tservicedependencies\n"); - printf("\tserviceescalations\n"); - printf("\n"); - printf("\thostextinfo\n"); - printf("\tserviceextinfo\n"); - printf("\n"); - printf("Notes:\n"); - printf("\n"); - printf("This utility is designed to aide you in converting your old 'host'\n"); - printf("config file(s) to the new template-based config file style. It is\n"); - printf("also capable of converting extended host and service information\n"); - printf("definitions in your old CGI config file.\n"); - printf("\n"); - printf("Supply the name of your old 'host' config file (or your old CGI config\n"); - printf("file if you're converting extended host/service definitions) on the\n"); - printf("command line, along with the type of object you would like to produce\n"); - printf("a new config file for. Your old config file is not overwritten - new\n"); - printf("configuration data is printed to standard output, so you can redirect it\n"); - printf("wherever you like.\n"); - printf("\n"); - printf("Please note that you can only specify one type of object at a time\n"); - printf("on the command line.\n"); - printf("\n"); - printf("IMPORTANT: This utility will generate Nagios 1.x compliant config files.\n"); - printf("However, the config files are not totally compatible with Nagios 2.x, so\n"); - printf("you will have to do some manual tweaking.\n"); - printf("\n"); - return -1; - } - - fp = fopen(argv[1], "r"); - if (fp == NULL) { - printf("Error: Could not open file '%s' for reading.\n", argv[1]); - return -1; - } - - for (fgets(input, sizeof(input) - 1, fp); !feof(fp); fgets(input, sizeof(input) - 1, fp)) { - - /* skip blank lines and comments */ - if (input[0] == '#' || input[0] == '\x0' || input[0] == '\n' || input[0] == '\r') - continue; - - /* timeperiods */ - if (strstr(input, "timeperiod[") && !strcmp(argv[2], "timeperiods")) { - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, "]"); - - printf("# '%s' timeperiod definition\n", temp_ptr); - printf("define timeperiod{\n"); - /*printf("\tname\t\t%s\n",temp_ptr);*/ - printf("\ttimeperiod_name\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\talias\t\t%s\n", temp_ptr + 1); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tsunday\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tmonday\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\ttuesday\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\twednesday\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tthursday\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tfriday\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tsaturday\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - /* commands */ - if (strstr(input, "command[") && !strcmp(argv[2], "commands")) { - - temp_ptr = strtok(input, "["); - temp_ptr = strtok(NULL, "]"); - - printf("# '%s' command definition\n", temp_ptr); - printf("define command{\n"); - /*printf("\tname\t\t%s\n",temp_ptr);*/ - printf("\tcommand_name\t%s\n", temp_ptr); - - temp_ptr = strtok(NULL, "\n"); - - printf("\tcommand_line\t%s\n", temp_ptr + 1); - - printf("\t}\n\n\n"); - } - - /* contacts */ - if (strstr(input, "contact[") && !strcmp(argv[2], "contacts")) { - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, "]"); - - printf("# '%s' contact definition\n", temp_ptr); - printf("define contact{\n"); - /*printf("\tname\t\t\t\t%s\n",temp_ptr);*/ - printf("\tcontact_name\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\talias\t\t\t\t%s\n", temp_ptr + 1); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tservice_notification_period\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\thost_notification_period\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_recovery = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_critical = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_warning = atoi(temp_ptr); - - option = 0; - printf("\tservice_notification_options\t"); - if (notify_recovery == 1 || notify_critical == 1 || notify_warning == 1) { - if (notify_warning == 1) { - printf("w,u"); - option = 1; - } - if (notify_critical == 1) { - if (option == 1) - printf(","); - printf("c"); - option = 1; - } - if (notify_recovery == 1) { - if (option == 1) - printf(","); - printf("r"); - } - } else - printf("n"); - printf("\n"); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_recovery = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_down = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_unreachable = atoi(temp_ptr); - - option = 0; - printf("\thost_notification_options\t"); - if (notify_recovery == 1 || notify_down == 1 || notify_unreachable == 1) { - if (notify_down == 1) { - printf("d"); - option = 1; - } - if (notify_unreachable == 1) { - if (option == 1) - printf(","); - printf("u"); - option = 1; - } - if (notify_recovery == 1) { - if (option == 1) - printf(","); - printf("r"); - } - } else - printf("n"); - printf("\n"); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tservice_notification_commands\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\thost_notification_commands\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\temail\t\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tpager\t\t\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - - /* contactgroups */ - if (strstr(input, "contactgroup[") && !strcmp(argv[2], "contactgroups")) { - - temp_ptr = strtok(input, "["); - temp_ptr = strtok(NULL, "]"); - - printf("# '%s' contact group definition\n", temp_ptr); - printf("define contactgroup{\n"); - /*printf("\tname\t\t\t%s\n",temp_ptr);*/ - printf("\tcontactgroup_name\t%s\n", temp_ptr); - - temp_ptr = strtok(NULL, ";"); - printf("\talias\t\t\t%s\n", temp_ptr + 1); - - temp_ptr = strtok(NULL, "\n"); - - printf("\tmembers\t\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - /* hosts */ - if (strstr(input, "host[") && !strcmp(argv[2], "hosts")) { - - if (have_template == 0) { - - printf("# Generic host definition template\n"); - printf("define host{\n"); - printf("\tname\t\t\t\tgeneric-host\t; The name of this host template - referenced in other host definitions, used for template recursion/resolution\n"); - printf("\tactive_checks_enabled\t\t1\t; Active host checks are enabled\n"); - printf("\tpassive_checks_enabled\t\t1\t; Passive host checks are enabled/accepted\n"); - printf("\tnotifications_enabled\t\t1\t; Host notifications are enabled\n"); - printf("\tevent_handler_enabled\t\t1\t; Host event handler is enabled\n"); - printf("\tflap_detection_enabled\t\t1\t; Flap detection is enabled\n"); - /*printf("\tfailure_prediction_enabled\t1\t; Failure prediction is enabled\n");*/ - printf("\tprocess_perf_data\t\t1\t; Process performance data\n"); - printf("\tretain_status_information\t1\t; Retain status information across program restarts\n"); - printf("\tretain_nonstatus_information\t1\t; Retain non-status information across program restarts\n"); - printf("\n"); - printf("\tregister\t\t\t0\t; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!\n"); - printf("\t}\n\n"); - - have_template = 1; - } - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, "]"); - - printf("# '%s' host definition\n", temp_ptr); - printf("define host{\n"); - printf("\tuse\t\t\tgeneric-host\t\t; Name of host template to use\n\n"); - printf("\thost_name\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\talias\t\t\t%s\n", temp_ptr + 1); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\taddress\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tparents\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tcheck_command\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tmax_check_attempts\t%d\n", atoi(temp_ptr)); - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tnotification_interval\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tnotification_period\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_recovery = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_down = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_unreachable = atoi(temp_ptr); - - option = 0; - printf("\tnotification_options\t"); - if (notify_recovery == 1 || notify_down == 1 || notify_unreachable == 1) { - if (notify_down == 1) { - printf("d"); - option = 1; - } - if (notify_unreachable == 1) { - if (option == 1) - printf(","); - printf("u"); - option = 1; - } - if (notify_recovery == 1) { - if (option == 1) - printf(","); - printf("r"); - } - } else - printf("n"); - printf("\n"); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tevent_handler\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - /* hostgroups */ - if (strstr(input, "hostgroup[") && !strcmp(argv[2], "hostgroups")) { - - temp_ptr = strtok(input, "["); - temp_ptr = strtok(NULL, "]"); - - printf("# '%s' host group definition\n", temp_ptr); - printf("define hostgroup{\n"); - /*printf("\tname\t\t%s\n",temp_ptr);*/ - printf("\thostgroup_name\t%s\n", temp_ptr); - - temp_ptr = strtok(NULL, ";"); - printf("\talias\t\t%s\n", temp_ptr + 1); - - temp_ptr = strtok(NULL, ";"); - /*printf("\tcontact_groups\t%s\n",temp_ptr);*/ - - temp_ptr = strtok(NULL, "\n"); - - printf("\tmembers\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - - /* services */ - if (strstr(input, "service[") && !strcmp(argv[2], "services")) { - - if (have_template == 0) { - - printf("# Generic service definition template\n"); - printf("define service{\n"); - printf("\tname\t\t\t\tgeneric-service\t; The 'name' of this service template, referenced in other service definitions\n"); - printf("\tactive_checks_enabled\t\t1\t; Active service checks are enabled\n"); - printf("\tpassive_checks_enabled\t\t1\t; Passive service checks are enabled/accepted\n"); - printf("\tparallelize_check\t\t1\t; Active service checks should be parallelized (disabling this can lead to major performance problems)\n"); - printf("\tobsess_over_service\t\t1\t; We should obsess over this service (if necessary)\n"); - printf("\tcheck_freshness\t\t\t0\t; Default is to NOT check service 'freshness'\n"); - printf("\tnotifications_enabled\t\t1\t; Service notifications are enabled\n"); - printf("\tevent_handler_enabled\t\t1\t; Service event handler is enabled\n"); - printf("\tflap_detection_enabled\t\t1\t; Flap detection is enabled\n"); - /*printf("\tfailure_prediction_enabled\t1\t; Failure prediction is enabled\n");*/ - printf("\tprocess_perf_data\t\t1\t; Process performance data\n"); - printf("\tretain_status_information\t1\t; Retain status information across program restarts\n"); - printf("\tretain_nonstatus_information\t1\t; Retain non-status information across program restarts\n"); - printf("\n"); - printf("\tregister\t\t\t0\t; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!\n"); - printf("\t}\n\n"); - - have_template = 1; - } - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, "]"); - - printf("# Service definition\n"); - printf("define service{\n"); - printf("\tuse\t\t\t\tgeneric-service\t\t; Name of service template to use\n\n"); - printf("\thost_name\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tservice_description\t\t%s\n", temp_ptr + 1); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tis_volatile\t\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tcheck_period\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tmax_check_attempts\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tnormal_check_interval\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tretry_check_interval\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tcontact_groups\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tnotification_interval\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tnotification_period\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_recovery = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_critical = atoi(temp_ptr); - temp_ptr = my_strsep(&temp_ptr2, ";"); - notify_warning = atoi(temp_ptr); - - option = 0; - printf("\tnotification_options\t\t"); - if (notify_recovery == 1 || notify_critical == 1 || notify_warning == 1) { - if (notify_warning == 1) { - printf("w,u"); - option = 1; - } - if (notify_critical == 1) { - if (option == 1) - printf(","); - printf("c"); - option = 1; - } - if (notify_recovery == 1) { - if (option == 1) - printf(","); - printf("r"); - } - } else - printf("n"); - printf("\n"); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tevent_handler\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tcheck_command\t\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - /* hostgroup escalations */ - if (strstr(input, "hostgroupescalation[") && !strcmp(argv[2], "hostgroupescalations")) { - - x++; - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, "]"); - - printf("# Hostgroup '%s' escalation definition\n", temp_ptr); - printf("define hostgroupescalation{\n"); - - printf("\thostgroup_name\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, "-"); - printf("\tfirst_notification\t\t%d\n", atoi(temp_ptr + 1)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tlast_notification\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tcontact_groups\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - printf("\tnotification_interval\t\t%d\n", atoi(temp_ptr)); - - printf("\t}\n\n\n"); - } - - /* service escalations */ - if (strstr(input, "serviceescalation[") && !strcmp(argv[2], "serviceescalations")) { - - x++; - - printf("# Serviceescalation definition\n"); - printf("define serviceescalation{\n"); - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - host_name = my_strsep(&temp_ptr2, ";"); - service_description = my_strsep(&temp_ptr2, "]"); - - printf("\thost_name\t\t%s\n", host_name); - printf("\tservice_description\t\t%s\n", service_description); - - temp_ptr = my_strsep(&temp_ptr2, "-"); - printf("\tfirst_notification\t\t%d\n", atoi(temp_ptr + 1)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tlast_notification\t\t%d\n", atoi(temp_ptr)); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - printf("\tcontact_groups\t\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - printf("\tnotification_interval\t\t%d\n", atoi(temp_ptr)); - - printf("\t}\n\n\n"); - } - - /* service dependencies */ - if (strstr(input, "servicedependency[") && !strcmp(argv[2], "servicedependencies")) { - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - host_name = my_strsep(&temp_ptr2, ";"); - service_description = my_strsep(&temp_ptr2, "]"); - host_name2 = my_strsep(&temp_ptr2, ";") + 1; - service_description2 = my_strsep(&temp_ptr2, ";"); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - - x++; - - printf("# Servicedependency definition\n"); - printf("define servicedependency{\n"); - - printf("\thost_name\t\t\t%s\n", host_name2); - printf("\tservice_description\t\t%s\n", service_description2); - printf("\tdependent_host_name\t\t%s\n", host_name); - printf("\tdependent_service_description\t%s\n", service_description); - - printf("\texecution_failure_criteria\t"); - for (y = 0; temp_ptr[y] != '\x0'; y++) - printf("%s%c", (y > 0) ? "," : "", temp_ptr[y]); - if (y == 0) - printf("n"); - printf("\t; These are the criteria for which check execution will be suppressed\n"); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - - printf("\tnotification_failure_criteria\t"); - for (y = 0; temp_ptr[y] != '\x0'; y++) - printf("%s%c", (y > 0) ? "," : "", temp_ptr[y]); - if (y == 0) - printf("n"); - printf("\t; These are the criteria for which notifications will be suppressed\n"); - printf("\t}\n\n\n"); - } - - - /* extended host info */ - if (strstr(input, "hostextinfo[") && !strcmp(argv[2], "hostextinfo")) { - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, "]"); - - printf("# '%s' hostextinfo definition\n", temp_ptr); - printf("define hostextinfo{\n"); - printf("\thost_name\t\t%s\t\t; The name of the host this data is associated with\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - - if (temp_ptr + 1 != NULL && strcmp(temp_ptr + 1, "")) - printf("\tnotes_url\t\t\t%s\n", temp_ptr + 1); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\ticon_image\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tvrml_image\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\tstatusmap_image\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\ticon_image_alt\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\t2d_coords\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\t3d_coords\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - - /* extended service info */ - if (strstr(input, "serviceextinfo[") && !strcmp(argv[2], "serviceextinfo")) { - - temp_ptr2 = &input[0]; - temp_ptr = my_strsep(&temp_ptr2, "["); - temp_ptr = my_strsep(&temp_ptr2, ";"); - - printf("# '%s' serviceextinfo definition\n", temp_ptr); - printf("define serviceextinfo{\n"); - printf("\thost_name\t\t%s\t\t; The name of the service this data is associated with\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, "]"); - printf("\tservice_description\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - - if (temp_ptr + 1 != NULL && strcmp(temp_ptr + 1, "")) - printf("\tnotes_url\t\t%s\n", temp_ptr + 1); - - temp_ptr = my_strsep(&temp_ptr2, ";"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\ticon_image\t\t%s\n", temp_ptr); - - temp_ptr = my_strsep(&temp_ptr2, ";\r\n"); - if (temp_ptr != NULL && strcmp(temp_ptr, "")) - printf("\ticon_image_alt\t\t%s\n", temp_ptr); - - printf("\t}\n\n\n"); - } - - } - - - fclose(fp); - - return 0; -} - - - -/* fixes compiler problems under Solaris, since strsep() isn't included */ -/* this code is taken from the glibc source */ -char *my_strsep(char **stringp, const char *delim) { - char *begin, *end; - - begin = *stringp; - if (begin == NULL) - return NULL; - - /* A frequent case is when the delimiter string contains only one - character. Here we don't need to call the expensive `strpbrk' - function and instead work using `strchr'. */ - if (delim[0] == '\0' || delim[1] == '\0') { - char ch = delim[0]; - - if (ch == '\0') - end = NULL; - else { - if (*begin == ch) - end = begin; - else - end = strchr(begin + 1, ch); - } - } - - else - /* Find the end of the token. */ - end = strpbrk(begin, delim); - - if (end) { - - /* Terminate the token and set *STRINGP past NUL character. */ - *end++ = '\0'; - *stringp = end; - } else - /* No more delimiters; this is the last token. */ - *stringp = NULL; - - return begin; -} - - diff --git a/contrib/daemonchk.c b/contrib/daemonchk.c deleted file mode 100644 index 3425889..0000000 --- a/contrib/daemonchk.c +++ /dev/null @@ -1,247 +0,0 @@ -#include "../include/config.h" -#include "../include/common.h" -#include "../include/locations.h" -#include "../include/cgiutils.h" -#include "../include/getcgi.h" -#ifdef HAVE_GETOPT_H -#include <getopt.h> -#endif -#include <stdarg.h> - -#define CHARLEN 256 -#define max(a,b) ((a)>(b))?(a):(b) - -static int process_cgivars(void); - -static char *strscpy(char *dest, const char *src); -static char *ssprintf(char *str, const char *fmt, ...); -static void terminate(int result, const char *fmt, ...); -static void get_expire_time_string(time_t *raw_time, char *buffer, int buffer_length); - -int main(int argc, char **argv) { - FILE *fp; - char *status_file = NULL; - char *lock_file = NULL; - char *proc_file = NULL; - char input_buffer[CHARLEN]; - int c, age, pid, testpid, found; - int wt = -1; - int ct = -1; - struct stat statbuf; - time_t current_time; - -#ifdef DEFAULT_STATUS_FILE - status_file = strscpy(status_file, DEFAULT_STATUS_FILE); -#else - status_file = strscpy(status_file, "/usr/local/icinga/var/status.dat"); -#endif - -#ifdef DEFAULT_LOCK_FILE - lock_file = strscpy(lock_file, DEFAULT_LOCK_FILE); -#else - lock_file = strscpy(lock_file, "/usr/local/icinga/var/icinga.lock"); -#endif - - if (getenv("REQUEST_METHOD")) { - process_cgivars(); - } else { /* get arguments */ - - while ((c = getopt(argc, argv, "+c:w:s:l:")) != EOF) { - switch (c) { - case 'c': - ct = atoi(optarg); - break; - case 'w': - wt = atoi(optarg); - break; - case 's': - status_file = optarg; - break; - case 'l': - lock_file = optarg; - break; - } - } - } - - /* find status file, get lastmod time */ - if (stat(status_file, &statbuf) == -1) { - printf("ICINGA CRITICAL - could not find status log: %s\n", status_file); - exit(STATE_CRITICAL); - } - - time(¤t_time); - age = (int)(current_time - statbuf.st_mtime); - - /* find lock file. get pid if it exists */ - if (stat(lock_file, &statbuf) == -1) { - printf("ICINGA CRITICAL - could not find lock file: %s\n", lock_file); - exit(STATE_CRITICAL); - } - - fp = fopen(lock_file, "r"); - fscanf(fp, "%d", &pid); - fclose(fp); - proc_file = ssprintf(proc_file, "/proc/%d", pid); - - if (stat("/proc", &statbuf) == 0) { - if (stat(proc_file, &statbuf) == -1) { - printf("ICINGA CRITICAL - could not find proc file: %s\n", proc_file); - exit(STATE_CRITICAL); - } - } else if (snprintf(proc_file, CHARLEN - 1, "/bin/ps -o pid -p %d", pid) && (fp = popen(proc_file, "r")) != NULL) { - fgets(input_buffer, CHARLEN - 1, fp); - fgets(input_buffer, CHARLEN - 1, fp); - if (sscanf(input_buffer, "%d", &testpid) == 1) { - if (testpid != pid) { - printf("ICINGA CRITICAL - could not find process(1): %d\n", pid); - exit(STATE_CRITICAL); - } - } - } else if (snprintf(proc_file, CHARLEN - 1, "/bin/ps -eo pid") && (fp = popen(proc_file, "r")) != NULL) { - found = FALSE; - fgets(input_buffer, CHARLEN - 1, fp); - while (fgets(input_buffer, CHARLEN - 1, fp)) { - if (sscanf(input_buffer, "%d", &testpid) == 1) - if (testpid == pid) found = TRUE; - } - if (!found) { - printf("ICINGA CRITICAL - could not find process(2): %d\n", pid); - exit(STATE_CRITICAL); - } - } else if (snprintf(proc_file, CHARLEN - 1, "/bin/ps -Ao pid") && (fp = popen(proc_file, "r")) != NULL) { - found = FALSE; - fgets(input_buffer, CHARLEN - 1, fp); - while (fgets(input_buffer, CHARLEN - 1, fp)) { - if (sscanf(input_buffer, "%d", &testpid) == 1) - if (testpid == pid) found = TRUE; - } - if (!found) { - printf("ICINGA CRITICAL - could not find process(2): %d\n", pid); - exit(STATE_CRITICAL); - } - } - - if (ct > 0 && ct < age) { - printf("ICINGA CRITICAL - status written %d seconds ago\n", age); - exit(STATE_CRITICAL); - } else if (wt > 0 && wt < age) { - printf("ICINGA WARNING - status written %d seconds ago\n", age); - exit(STATE_WARNING); - } else { - printf("ICINGA OK - status written %d seconds ago\n", age); - exit(STATE_OK); - } -} - -static int process_cgivars(void) { - char **variables; - int error = FALSE; - int x; - - variables = getcgivars(); - - for (x = 0; variables[x] != NULL; x++) { - - /* do some basic length checking on the variable identifier to prevent buffer overflows */ - if (strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) { - x++; - continue; - } - } - return error; -} - -/* get date/time string used in META tags for page expiration */ -static void get_expire_time_string(time_t *raw_time, char *buffer, int buffer_length) { - time_t t; - struct tm *tm_ptr; - int day; - int hour; - int minute; - int second; - int year; - char *weekdays[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; - char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"}; - - if (raw_time == NULL) - time(&t); - else - t = *raw_time; - - tm_ptr = gmtime(&t); - - hour = tm_ptr->tm_hour; - minute = tm_ptr->tm_min; - second = tm_ptr->tm_sec; - day = tm_ptr->tm_mday; - year = tm_ptr->tm_year + 1900; - - snprintf(buffer, buffer_length, "%s, %d %s %d %02d:%02d:%02d GMT", weekdays[tm_ptr->tm_wday], day, months[tm_ptr->tm_mon], year, hour, minute, second); - buffer[buffer_length-1] = '\x0'; - - return; -} - -static char *strscpy(char *dest, const char *src) { - int len; - - if (src != NULL) - len = strlen(src) + 1; - else - return dest; - - if (dest == NULL || strlen(dest) < len) - dest = realloc(dest, len); - if (dest == NULL) - terminate(STATE_UNKNOWN, "failed realloc in strscpy\n"); - - strncpy(dest, src, len); - - return dest; -} - -static char *ssprintf(char *str, const char *fmt, ...) { - va_list ap; - int nchars; - int size; - - if (str == NULL) - str = malloc(CHARLEN); - if (str == NULL) - terminate(STATE_UNKNOWN, "malloc failed in ssprintf"); - - size = max(strlen(str), CHARLEN); - - va_start(ap, fmt); - - while (1) { - - nchars = vsnprintf(str, size, fmt, ap); - - if (nchars > -1) - if (nchars < size) { - va_end(ap); - return str; - } else { - size = nchars + 1; - } - - else - size *= 2; - - str = realloc(str, nchars + 1); - - if (str == NULL) - terminate(STATE_UNKNOWN, "realloc failed in ssprintf"); - } - -} - -static void terminate(int result, const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); - exit(result); -}