/************************************************************************
*
* CONVERTCFG.C - Config File Convertor
*
* Copyright (c) 2001-2005 Ethan Galstad (nagios@nagios.org)
* Last Modified: 08-12-2005
*
* 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., 675 Mass Ave, Cambridge, MA 02139, 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 (nagios@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;
}
=1= |