141 |
|
|
142 |
/** |
/** |
143 |
* Search the system for the monit control file. Try first ~/.monitrc, |
* Search the system for the monit control file. Try first ~/.monitrc, |
144 |
* if that fails try /etc/monitrc and finally ./monitrc. Exit the |
* if that fails try /etc/monitrc, then /usr/local/etc/monitrc and |
145 |
* application if the control file is not found. |
* finally ./monitrc. Exit the application if the control file was |
146 |
|
* not found. |
147 |
* @return The location of monits control file (monitrc) |
* @return The location of monits control file (monitrc) |
148 |
*/ |
*/ |
149 |
char *File_findControlFile() { |
char *File_findControlFile() { |
159 |
if(File_exist(rcfile)) { |
if(File_exist(rcfile)) { |
160 |
return (rcfile); |
return (rcfile); |
161 |
} |
} |
162 |
|
memset(rcfile, 0, STRLEN); |
163 |
|
snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC); |
164 |
|
if(File_exist(rcfile)) { |
165 |
|
return (rcfile); |
166 |
|
} |
167 |
if(File_exist(MONITRC)) { |
if(File_exist(MONITRC)) { |
168 |
memset(rcfile, 0, STRLEN); |
memset(rcfile, 0, STRLEN); |
169 |
snprintf(rcfile, STRLEN, "%s/%s", Run.Env.cwd, MONITRC); |
snprintf(rcfile, STRLEN, "%s/%s", Run.Env.cwd, MONITRC); |
170 |
return (rcfile); |
return (rcfile); |
171 |
} |
} |
172 |
log("%s: Cannot find the control file at ~/.%s, /etc/%s or at ./%s \n", |
log("%s: Cannot find the control file at " |
173 |
prog, MONITRC, MONITRC, MONITRC); |
"~/.%s, /etc/%s, /usr/local/etc/%s or at ./%s \n", |
174 |
|
prog, MONITRC, MONITRC, MONITRC, MONITRC); |
175 |
exit(1); |
exit(1); |
176 |
|
|
177 |
} |
} |