------=_20130912133309_19235
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
This should be a patch for
A) allowing multiple main config files
i haven't compiled/run/tested this yet, but this is the kind of thing i
thought would be good.
can someone please tell me if i'm working in the right direction or not?
------=_20130912133309_19235
Content-Type: text/x-patch; name="nagios_extra_config_files.patch"
Content-Disposition: attachment; filename="nagios_extra_config_files.patch"
Content-Transfer-Encoding: quoted-printable
diff --git a/base/config.c b/base/config.c
index 142292d..cb7935f 100644
--- a/base/config.c
+++ b/base/config.c
@@ -60,16 +60,20 @@ static command *find_bang_command(char *name)
/******************************************************************/
/* read all configuration data */
-int read_all_object_data(char *main_config_file) {
+int read_all_object_data(char **config_files) {
int result =3D OK;
int options =3D 0;
+ int i =3D 0;
options =3D READ_ALL_OBJECT_DATA;
/* read in all host configuration data from external sources */
- result =3D read_object_config_data(main_config_file, options);
- if(result !=3D OK)
- return ERROR;
+ while (config_files !=3D NULL) {
+ result =3D read_object_config_data(config_files, optio=
ns);
+ if(result !=3D OK)
+ return ERROR;
+ i++;
+ }
return OK;
}
diff --git a/base/nagios.c b/base/nagios.c
index 4f78ffe..39d2eab 100644
--- a/base/nagios.c
+++ b/base/nagios.c
@@ -348,7 +348,7 @@ int main(int argc, char **argv) {
/* if there are no command line options (or if we encountered an =
error), print usage */
if(error =3D=3D TRUE || display_help =3D=3D TRUE) {
- printf("Usage: %s [options] \n", argv[0=
]);
+ printf("Usage: %s [options] [] ...\n", argv[0]);
printf("\n");
printf("Options:\n");
printf("\n");
@@ -370,17 +370,24 @@ int main(int argc, char **argv) {
exit(ERROR);
}
-
- /*
- * config file is last argument specified.
- * Make sure it uses an absolute path
- */
- config_file =3D nspath_absolute(argv[option_index], NULL);
- if(config_file =3D=3D NULL) {
- printf("Error allocating memory.\n");
- exit(ERROR);
+ /* get all config files */
+ config_files =3D malloc(sizeof(*config_files) * (argc - option_in=
dex));
+ i =3D 0;
+ while (option_index + i < argc) {
+ /* Make sure it uses an absolute path */
+ config_files =3D nspath_absolute(argv[option_index + i=
], NULL);
+ if(config_file =3D=3D NULL) {
+ printf("Error allocating memory.\n");
+ exit(ERROR);
+ }
+ i++;
}
+ config_files =3D NULL;
+ /* The main config file is first of the config files. */
+ config_file =3D config_files[0];
+
+ /* Also initialize the main config directory */
config_file_dir =3D nspath_absolute_dirname(config_file, NULL);
/*
@@ -417,6 +424,21 @@ int main(int argc, char **argv) {
if(verify_config)
printf(" Read main config file okay...\n");
+ /* read extra config files */
+ i =3D 1;
+
+ if(verify_config && config_files !=3D NULL)
+ printf(" Reading extra config files...\n");
+
+ while (config_files !=3D NULL) {
+ result =3D read_main_config_file(config_files)=
;
+ if(result !=3D OK) {
+ printf(" Error processing extra config =
file!\n\n");
+ exit(EXIT_FAILURE);
+ }
+ i++;
+ }
+
/* drop privileges */
if((result =3D drop_privileges(nagios_user, nagios_group)=
) =3D=3D ERROR) {
printf(" Failed to drop privileges. Aborting."=
);
@@ -433,7 +455,7 @
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: alien@rmail.be