allow for the checker to be cron'd instead of daemonised

master
darkrose 2015-09-26 02:09:50 +10:00
parent 1a139a3d69
commit b565547cd1
2 changed files with 26 additions and 1 deletions

4
README
View File

@ -25,6 +25,10 @@ vl-checker [OPTION]
OPTIONS:
-d Daemonise the process (default).
-D Do not daemonise the process.
-a Check all servers on startup (default).
-A Do not check all servers on startup.
-o Run check only once.
-O Run check repeatedly in a loop (default).
-? Show this help info.
CONFIG:

View File

@ -100,6 +100,10 @@ static void usage()
"OPTIONS:\n"
" -d Daemonise the process (default).\n"
" -D Do not daemonise the process.\n"
" -a Check all servers on startup (default).\n"
" -A Do not check all servers on startup.\n"
" -o Run check only once.\n"
" -O Run check repeatedly in a loop (default).\n"
" -? Show this help info.\n",
TARGET,
VERSION,
@ -115,6 +119,8 @@ int main(int argc, char** argv)
time_t b;
time_t e;
int daemonise = 1;
int all = 1;
int once = 0;
for (i=1; i<argc; i++) {
if (argv[i][0] == '-') {
@ -126,6 +132,18 @@ int main(int argc, char** argv)
case 'D':
daemonise = 0;
break;
case 'a':
all = 1;
break;
case 'A':
all = 0;
break;
case 'o':
once = 1;
break;
case 'O':
once = 0;
break;
case '?':
usage();
return 0;
@ -170,7 +188,7 @@ int main(int argc, char** argv)
}
/* first check all */
s = db_getservers(1);
s = db_getservers(all);
if (s) {
for (i=0; s[i]!=0; i++) {
check_server(s[i]);
@ -178,6 +196,9 @@ int main(int argc, char** argv)
free(s);
}
if (once)
return 0;
/* then loop checking recent */
while (1) {
b = time(NULL);