void CpuAttributes::compute( amask_t how_much ) { double val; if( IS_UPDATE(how_much) && IS_SHARED(how_much) ) { // Shared attributes that we only get a fraction of val = map->virt_mem(); if (!IS_AUTO_SHARE(c_virt_mem_fraction)) { val *= c_virt_mem_fraction; } c_virt_mem = (unsigned long)floor( val ); } if( IS_TIMEOUT(how_much) && !IS_SHARED(how_much) ) { // Dynamic, non-shared attributes we need to actually compute c_condor_load = rip->compute_condor_load(); c_total_disk = sysapi_disk_space(rip->executeDir()); if (IS_UPDATE(how_much)) { dprintf(D_FULLDEBUG, "Total execute space: %lu\n", c_total_disk); } val = c_total_disk * c_disk_fraction; c_disk = (int)floor( val ); if (0 == (int)c_slot_disk) { // only use the 1st compute ignore subsequent. c_slot_disk = c_disk; } } }
void sysapi_set_resource_limits(int stack_size) { rlim_t lim; if(stack_size == 0) { stack_size = (int) RLIM_INFINITY; } long long free_blocks = sysapi_disk_space( "." ); long long core_lim = (free_blocks - SLOP) * 1024; PRAGMA_REMIND("FIXME: disk_space truncation to INT_MAX here") if( core_lim > INT_MAX ) { lim = INT_MAX; } else { lim = (int) core_lim; } limit( RLIMIT_CORE, lim, CONDOR_SOFT_LIMIT, "max core size" ); limit( RLIMIT_CPU, RLIM_INFINITY, CONDOR_SOFT_LIMIT, "max cpu time" ); limit( RLIMIT_FSIZE, RLIM_INFINITY, CONDOR_SOFT_LIMIT, "max file size" ); limit( RLIMIT_DATA, RLIM_INFINITY, CONDOR_SOFT_LIMIT, "max data size" ); limit( RLIMIT_STACK, stack_size, CONDOR_SOFT_LIMIT, "max stack size" ); dprintf( D_ALWAYS, "Done setting resource limits\n" ); }
void XferSummary::time_out(time_t now, char *hostaddr) { ClassAd info; char line[128], *tmp; char *str = NULL; info.SetMyTypeName("CkptServer"); info.SetTargetTypeName("CkptFile"); sprintf(line, "%s = \"%s\"", ATTR_NAME, my_full_hostname() ); info.Insert(line); sprintf(line, "%s = \"%s\"", ATTR_MACHINE, hostaddr ); info.Insert(line); sprintf(line, "%s = \"%s\"", ATTR_VERSION, CondorVersion() ); info.Insert(line); sprintf(line, "%s = \"%s\"", ATTR_PLATFORM, CondorPlatform() ); info.Insert(line); sprintf(line, "NumSends = %d", num_sends); info.Insert(line); sprintf(line, "BytesSent = %d", (int) bytes_sent); info.Insert(line); sprintf(line, "TimeSending = %d", time_sending); info.Insert(line); sprintf(line, "AvgSendBandwidth = %f", num_sends ? tot_send_bandwidth / num_sends : 0.0); info.Insert(line); sprintf(line, "NumRecvs = %d", num_recvs); info.Insert(line); sprintf(line, "BytesReceived = %d", (int) bytes_recv); info.Insert(line); sprintf(line, "TimeReceiving = %d", time_recving); info.Insert(line); sprintf(line, "AvgReceiveBandwidth = %f", num_recvs ? tot_recv_bandwidth / num_recvs : 0.0); info.Insert(line); /* ctime adds a newline at the end of the ascii conversion.... */ str = ctime(&start_time); sprintf(line, "CkptServerIntervalStart = \"%s\"", str ? str : "Unknown\n"); tmp = strchr( line, '\n' ); if (tmp != NULL) { /* delete the newline */ *tmp = '\"'; tmp++; *tmp = '\0'; } info.Insert(line); /* ctime adds a newline at the end of the ascii conversion.... */ str = ctime(&now); sprintf(line, "CkptServerIntervalEnd = \"%s\"", str ? str : "Unknown\n"); tmp = strchr( line, '\n' ); if (tmp != NULL) { /* delete the newline */ *tmp = '\"'; tmp++; *tmp = '\0'; } info.Insert(line); sprintf(line, "Disk = %d", sysapi_disk_space(pwd.Value()) ); info.Insert(line); // Send to collector if ( Collectors ) { dprintf(D_NETWORK, "Sending CkptServer ClassAd:\n"); info.dPrint(D_NETWORK); Collectors->sendUpdates (UPDATE_CKPT_SRVR_AD, &info, NULL, true); } init(); }
/* this function calls every function in sysapi that makes sense to call and prints out its value */ extern "C" void sysapi_test_dump_functions(void) { int foo = 0; long long loo = 0; float bar = 0; const char *qux = NULL; time_t t0, t1; dprintf(D_ALWAYS, "SysAPI: Calling SysAPI functions....\n"); qux = sysapi_ckptpltfrm_raw(); dprintf(D_ALWAYS, "SysAPI: sysapi_ckptpltfrm_raw -> %s\n", qux); qux = sysapi_ckptpltfrm(); dprintf(D_ALWAYS, "SysAPI: sysapi_ckptpltfrm -> %s\n", qux); foo = sysapi_phys_memory_raw(); dprintf(D_ALWAYS, "SysAPI: sysapi_phys_memory_raw() -> %d\n", foo); foo = sysapi_phys_memory(); dprintf(D_ALWAYS, "SysAPI: sysapi_phys_memory() -> %d\n", foo); loo = sysapi_disk_space_raw("/"); dprintf(D_ALWAYS, "SysAPI: sysapi_disk_space_raw() -> %" PRIi64 "\n", loo); loo = sysapi_disk_space("/"); dprintf(D_ALWAYS, "SysAPI: sysapi_disk_space() -> %" PRIi64 "\n", loo); sysapi_ncpus_raw(&foo,NULL); dprintf(D_ALWAYS, "SysAPI: sysapi_ncpus_raw() -> %d\n", foo); sysapi_ncpus_raw(&foo, NULL); dprintf(D_ALWAYS, "SysAPI: sysapi_ncpus() -> %d\n", foo); foo = sysapi_mips_raw(); dprintf(D_ALWAYS, "SysAPI: sysapi_mips_raw() -> %d\n", foo); foo = sysapi_mips(); dprintf(D_ALWAYS, "SysAPI: sysapi_mips() -> %d\n", foo); foo = sysapi_kflops_raw(); dprintf(D_ALWAYS, "SysAPI: sysapi_kflops_raw() -> %d\n", foo); foo = sysapi_kflops(); dprintf(D_ALWAYS, "SysAPI: sysapi_kflops() -> %d\n", foo); sysapi_idle_time_raw(&t0, &t1); dprintf(D_ALWAYS,"SysAPI: sysapi_idle_time_raw() -> (%f,%f)\n",(float)t0,(float)t1); sysapi_idle_time(&t0, &t1); dprintf(D_ALWAYS, "SysAPI: sysapi_idle_time() -> (%f,%f)\n", (float)t0, (float)t1); bar = sysapi_load_avg_raw(); dprintf(D_ALWAYS, "SysAPI: sysapi_load_avg_raw() -> %f\n", bar); bar = sysapi_load_avg(); dprintf(D_ALWAYS, "SysAPI: sysapi_load_avg() -> %f\n", bar); qux = sysapi_condor_arch(); dprintf(D_ALWAYS, "SysAPI: sysapi_condor_arch -> %s\n", qux); qux = sysapi_uname_arch(); dprintf(D_ALWAYS, "SysAPI: sysapi_uname_arch -> %s\n", qux); qux = sysapi_opsys(); dprintf(D_ALWAYS, "SysAPI: sysapi_opsys -> %s\n", qux); foo = sysapi_swap_space_raw(); dprintf(D_ALWAYS, "SysAPI: sysapi_swap_space_raw() -> %d\n", foo); foo = sysapi_swap_space(); dprintf(D_ALWAYS, "SysAPI: sysapi_swap_space() -> %d\n", foo); }