1 |
|
/* |
2 |
|
* i-scream central monitoring system |
3 |
< |
* http://www.i-scream.org.uk |
3 |
> |
* http://www.i-scream.org |
4 |
|
* Copyright (C) 2000-2002 i-scream |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or |
387 |
|
goto error; |
388 |
|
} |
389 |
|
|
390 |
< |
printf("string : %s\n", response_ptr); |
390 |
> |
/*printf("string : %s\n", response_ptr);*/ |
391 |
|
server_udp_port=atoi(response_ptr); |
392 |
|
|
393 |
|
if (server_udp_port==0){ |
712 |
|
|
713 |
|
|
714 |
|
void usage(char *progname){ |
715 |
< |
fprintf(stderr, "Usage %s [options] server port\n", progname); |
716 |
< |
fprintf(stderr, "Options\n"); |
717 |
< |
fprintf(stderr, " -v Verbose mode,-vv would make even more verbose\n"); |
718 |
< |
fprintf(stderr, " -f Foreground mode, print errors to stderr\n"); |
719 |
< |
fprintf(stderr, " -s Set the machine name to be reported as\n"); |
720 |
< |
fprintf(stderr, " -i Set the IP to be reported as\n"); |
721 |
< |
fprintf(stderr, " -V Print version number\n"); |
722 |
< |
fprintf(stderr, " -h Prints this help page\n"); |
715 |
> |
fprintf(stderr, "Usage %s [-v[v]] [-f] [-n name] [-i ip] [-s server] [-p port] [-V] [-h]\n\n", progname); |
716 |
> |
fprintf(stderr, " -v Verbose mode, -vv would make even more verbose\n"); |
717 |
> |
fprintf(stderr, " -f Foreground mode, print errors to stderr\n"); |
718 |
> |
fprintf(stderr, " -n Set the machine name to be reported as\n"); |
719 |
> |
fprintf(stderr, " -i Set the IP to be reported as\n"); |
720 |
> |
fprintf(stderr, " -s Specifies the i-scream server to connect to\n"); |
721 |
> |
fprintf(stderr, " default: %s\n", DEF_SERVER_NAME); |
722 |
> |
fprintf(stderr, " -p Specifies the i-scream server port\n"); |
723 |
> |
fprintf(stderr, " default: %d\n", DEF_SERVER_PORT); |
724 |
> |
fprintf(stderr, " -V Print version number\n"); |
725 |
> |
fprintf(stderr, " -h Prints this help page\n"); |
726 |
> |
fprintf(stderr, "\nReport bugs to <%s>.\n", PACKAGE_BUGREPORT); |
727 |
|
exit(1); |
728 |
|
} |
729 |
|
|
750 |
|
ihost_config.log=stderr; |
751 |
|
|
752 |
|
/* Blank ihost_state to default settings */ |
753 |
< |
ihost_state.filtermanager_host=NULL; |
753 |
> |
ihost_state.filtermanager_host=DEF_SERVER_NAME; |
754 |
> |
ihost_state.filtermanager_port=DEF_SERVER_PORT; |
755 |
|
ihost_state.host_fqdn=NULL; |
756 |
|
ihost_state.host_ip=NULL; |
757 |
|
ihost_state.preset_fqdn = 0; |
771 |
|
ihost_config.daemon=0; |
772 |
|
break; |
773 |
|
|
769 |
– |
case 'h': |
770 |
– |
usage(argv[0]); |
771 |
– |
break; |
772 |
– |
|
774 |
|
case 'V': |
775 |
|
fprintf(stderr, "%s version %s\n", argv[0], VERSION); |
776 |
|
break; |
777 |
< |
case 's': |
777 |
> |
case 'n': |
778 |
|
ihost_state.preset_fqdn = 1; |
779 |
|
ihost_state.host_fqdn = strdup(optarg); |
780 |
|
if(ihost_state.host_fqdn == NULL){ |
792 |
|
} |
793 |
|
break; |
794 |
|
|
795 |
+ |
case 's': |
796 |
+ |
ihost_state.filtermanager_host=strdup(optarg); |
797 |
+ |
break; |
798 |
+ |
|
799 |
+ |
case 'p': |
800 |
+ |
ihost_state.filtermanager_port=atoi(optarg); |
801 |
+ |
break; |
802 |
+ |
|
803 |
+ |
case 'h': |
804 |
|
default: |
805 |
|
usage(argv[0]); |
806 |
|
exit(1); |
807 |
|
} |
808 |
|
} |
809 |
|
|
800 |
– |
if(argc!=optind+2){ |
801 |
– |
usage(argv[0]); |
802 |
– |
exit(1); |
803 |
– |
} |
804 |
– |
|
805 |
– |
ihost_state.filtermanager_host=strdup(argv[optind]); |
806 |
– |
ihost_state.filtermanager_port=atoi(argv[optind+1]); |
807 |
– |
|
810 |
|
if(gethostbyname(ihost_state.filtermanager_host)==NULL){ |
811 |
|
log_msg(LOG_CRIT, "Failed to lookup hostname. Please check settings"); |
812 |
|
exit(1); |
843 |
|
|
844 |
|
} |
845 |
|
|
846 |
< |
log_msg(LOG_INFO, "Starting ihost"); |
846 |
> |
log_msg(LOG_INFO, "Starting ihost..."); |
847 |
|
|
848 |
|
log_msg(LOG_DEBUG,"Writing PID FILE"); |
849 |
|
|
871 |
|
sleep(10); |
872 |
|
} |
873 |
|
|
874 |
< |
printf("%s\n%d\n", ihost_state.server_fqdn, ihost_state.server_udp_port); |
874 |
> |
/*printf("%s\n%d\n", ihost_state.server_fqdn, ihost_state.server_udp_port);*/ |
875 |
|
while((create_udp_sockinfo(&udp_sockinfo, ihost_state.server_fqdn, ihost_state.server_udp_port))!=0){ |
876 |
|
log_msg(LOG_ERR, "Failed to create udp socket"); |
877 |
|
sleep(10); |