int main(int argc, char* argv[]){ init_svc(); pthread_t thread1, thread2, thread3; int iret1, iret2, iret3; iret2 = pthread_create( &thread2, NULL, ping_thread, NULL); iret1 = pthread_create( &thread1, NULL, listen_thread, NULL); iret3 = pthread_create( &thread3, NULL, check_thread, NULL); pthread_join( thread2, NULL); pthread_join( thread1, NULL); pthread_join( thread3, NULL); }
int main(void) { /* typical in 10000 service scenario: 150..1000 concurrently scheduled async jobs. */ const int num_checks_at_once = MAX_CONCURRENT_CHECKS; void* neb_handle; int i; char ok = 1; char * test_nebargs[] = { "config=extras/shared.conf", }; struct nebstruct_process_struct data_process_events; data_process_events.type = NEBTYPE_PROCESS_EVENTLOOPSTART; init_externals(); init_host(); init_svc(); init_svc_check(); neb_handle = load_neb("./mod_gearman2.o", test_nebargs[0]); neb_make_callbacks(NEBCALLBACK_PROCESS_DATA, &data_process_events); while (ok) { printf("Sending %i service checks.\n", num_checks_at_once); for (i = 0; i < num_checks_at_once; i++) { nebstruct_service_check_data* data_service_check; char host_name[16]; char service_name[16]; sprintf(host_name, "%i", i / 10); sprintf(service_name, "%i", i); data_service_check = setup_service(host_name, service_name); neb_make_callbacks(NEBCALLBACK_SERVICE_CHECK_DATA, data_service_check); } ok = (reap_cr_from_neb(num_checks_at_once) >= num_checks_at_once); } unload_neb(neb_handle); return 0; }
int main(int argc, char *argv[]) { char buf[1024]; int done = 0; if (argc < 2) { printf("Usage: %s SOCKETFILE\n", argv[0]); return 1; } if (init_svc(argv[1]) == -1) { printf("Cannot get socket\n"); return 1; } printf("Enter the hostname whose RRD cache should be flushed. One host per line\n"); while (!done) { done = (fgets(buf, sizeof(buf), stdin) == NULL); if (done) continue; done = (call_svc(buf) != 0); } return 0; }