void CpuAttributes::publish( ClassAd* cp, amask_t how_much ) { if( IS_UPDATE(how_much) || IS_PUBLIC(how_much) ) { cp->Assign( ATTR_VIRTUAL_MEMORY, (int)c_virt_mem ); cp->Assign( ATTR_TOTAL_DISK, (int)c_total_disk ); cp->Assign( ATTR_DISK, (int)c_disk ); } if( IS_TIMEOUT(how_much) || IS_PUBLIC(how_much) ) { cp->Assign( ATTR_CONDOR_LOAD_AVG, rint(c_condor_load * 100) / 100.0 ); cp->Assign( ATTR_LOAD_AVG, rint((c_owner_load + c_condor_load) * 100) / 100.0 ); cp->Assign( ATTR_KEYBOARD_IDLE, (int)c_idle ); // ConsoleIdle cannot be determined on all platforms; thus, only // advertise if it is not -1. if( c_console_idle != -1 ) { cp->Assign( ATTR_CONSOLE_IDLE, (int)c_console_idle ); } } if( IS_STATIC(how_much) || IS_PUBLIC(how_much) ) { cp->Assign( ATTR_MEMORY, c_phys_mem ); cp->Assign( ATTR_CPUS, c_num_cpus ); cp->Assign( ATTR_TOTAL_SLOT_MEMORY, c_slot_mem ); cp->Assign( ATTR_TOTAL_SLOT_DISK, (int)c_slot_disk ); cp->Assign( ATTR_TOTAL_SLOT_CPUS, c_num_slot_cpus ); // publish local resource quantities for this slot for (slotres_map_t::iterator j(c_slotres_map.begin()); j != c_slotres_map.end(); ++j) { string rname(j->first.c_str()); *(rname.begin()) = toupper(*(rname.begin())); string attr; formatstr(attr, "%s%s", "", rname.c_str()); cp->Assign(attr.c_str(), int(j->second)); formatstr(attr, "%s%s", ATTR_TOTAL_SLOT_PREFIX, rname.c_str()); cp->Assign(attr.c_str(), int(c_slottot_map[j->first])); } } }
void StarterMgr::publish( ClassAd* ad, amask_t mask ) { if( !(IS_STATIC(mask) && IS_PUBLIC(mask)) ) { return; } Starter *tmp_starter; StringList ability_list; starters.Rewind(); while( starters.Next(tmp_starter) ) { tmp_starter->publish( ad, mask, &ability_list ); } // finally, print out all the abilities we added into the // classad so that other folks can know what we did. char* ability_str = ability_list.print_to_string(); // If our ability list is NULL it means that we have no starters. // This is ok for hawkeye; nothing more to do here! if ( NULL == ability_str ) { ability_str = strdup("\0"); } ASSERT(ability_str); ad->Assign( ATTR_STARTER_ABILITY_LIST, ability_str ); free( ability_str ); }
void Starter::publish( ClassAd* ad, amask_t mask, StringList* list ) { if( !(IS_STATIC(mask) && IS_PUBLIC(mask)) ) { return; } // Check for ATTR_STARTER_IGNORED_ATTRS. If defined, // we insert all attributes from the starter ad except those // in the list. If not, we fall back on our old behavior // of only inserting attributes prefixed with "Has" or // "Java". Either way, we only add the "Has" attributes // into the StringList (the StarterAbilityList) char* ignored_attrs = NULL; StringList* ignored_attr_list = NULL; if (s_ad->LookupString(ATTR_STARTER_IGNORED_ATTRS, &ignored_attrs)) { ignored_attr_list = new StringList(ignored_attrs); free(ignored_attrs); // of course, we don't want ATTR_STARTER_IGNORED_ATTRS // in either! ignored_attr_list->append(ATTR_STARTER_IGNORED_ATTRS); } ExprTree *tree, *pCopy; const char *lhstr = NULL; s_ad->ResetExpr(); while( s_ad->NextExpr(lhstr, tree) ) { pCopy=0; if (ignored_attr_list) { // insert every attr that's not in the ignored_attr_list if (!ignored_attr_list->contains(lhstr)) { pCopy = tree->Copy(); ad->Insert(lhstr, pCopy, false); if (strncasecmp(lhstr, "Has", 3) == MATCH) { list->append(lhstr); } } } else { // no list of attrs to ignore - fallback on old behavior if( strncasecmp(lhstr, "Has", 3) == MATCH ) { pCopy = tree->Copy(); ad->Insert( lhstr, pCopy, false ); if( list ) { list->append( lhstr ); } } else if( strncasecmp(lhstr, "Java", 4) == MATCH ) { pCopy = tree->Copy(); ad->Insert( lhstr, pCopy, false); } } } if (ignored_attr_list) { delete ignored_attr_list; } }
void AvailStats::publish( ClassAd* cp, amask_t how_much ) { char line[100]; if( !compute_avail_stats ) return; if( IS_UPDATE(how_much) || IS_PUBLIC(how_much) ) { snprintf( line, 100, "%s=%0.2f", ATTR_AVAIL_TIME, avail_time() ); cp->Insert(line); cp->Assign( ATTR_LAST_AVAIL_INTERVAL, last_avail_interval() ); if( as_start_avail ) { // only insert these attributes when in non-owner state cp->Assign( ATTR_AVAIL_SINCE, (int)avail_since() ); cp->Assign( ATTR_AVAIL_TIME_ESTIMATE, avail_estimate() ); } } }
void MachAttributes::publish( ClassAd* cp, amask_t how_much) { if( IS_STATIC(how_much) || IS_PUBLIC(how_much) ) { // STARTD_IP_ADDR cp->Assign( ATTR_STARTD_IP_ADDR, daemonCore->InfoCommandSinfulString() ); cp->Assign( ATTR_ARCH, m_arch ); cp->Assign( ATTR_OPSYS, m_opsys ); if (m_opsysver) { cp->Assign( ATTR_OPSYSVER, m_opsysver ); } cp->Assign( ATTR_OPSYS_AND_VER, m_opsys_and_ver ); if (m_opsys_major_ver) { cp->Assign( ATTR_OPSYS_MAJOR_VER, m_opsys_major_ver ); } if (m_opsys_name) { cp->Assign( ATTR_OPSYS_NAME, m_opsys_name ); } if (m_opsys_long_name) { cp->Assign( ATTR_OPSYS_LONG_NAME, m_opsys_long_name ); } if (m_opsys_short_name) { cp->Assign( ATTR_OPSYS_SHORT_NAME, m_opsys_short_name ); } if (m_opsys_legacy) { cp->Assign( ATTR_OPSYS_LEGACY, m_opsys_legacy ); } cp->Assign( ATTR_UID_DOMAIN, m_uid_domain ); cp->Assign( ATTR_FILE_SYSTEM_DOMAIN, m_filesystem_domain ); cp->Assign( ATTR_HAS_IO_PROXY, true ); cp->Assign( ATTR_CHECKPOINT_PLATFORM, m_ckptpltfrm ); #if defined ( WIN32 ) // publish the Windows version information if ( m_got_windows_version_info ) { cp->Assign( ATTR_WINDOWS_MAJOR_VERSION, (int)m_window_version_info.dwMajorVersion ); cp->Assign( ATTR_WINDOWS_MINOR_VERSION, (int)m_window_version_info.dwMinorVersion ); cp->Assign( ATTR_WINDOWS_BUILD_NUMBER, (int)m_window_version_info.dwBuildNumber ); // publish the extended Windows version information if we // have it at our disposal if ( sizeof ( OSVERSIONINFOEX ) == m_window_version_info.dwOSVersionInfoSize ) { cp->Assign( ATTR_WINDOWS_SERVICE_PACK_MAJOR, (int)m_window_version_info.wServicePackMajor ); cp->Assign( ATTR_WINDOWS_SERVICE_PACK_MINOR, (int)m_window_version_info.wServicePackMinor ); cp->Assign( ATTR_WINDOWS_PRODUCT_TYPE, (int)m_window_version_info.wProductType ); } } /* Publish .Net versions installed on current machine assuming the option is turned on.. */ if(param_boolean("STARTD_PUBLISH_DOTNET", true)) { if(m_dot_Net_Versions) cp->Assign(ATTR_DOTNET_VERSIONS, m_dot_Net_Versions); } // publish values from the window's registry as specified // in the STARTD_PUBLISH_WINREG param. // m_lst_static.Rewind(); while (AttribValue *pav = m_lst_static.Next()) { if (pav) pav->AssignToClassAd(cp); } /* char * pubreg_param = param("STARTD_PUBLISH_WINREG"); if (pubreg_param) { StringList reg_list(pubreg_param, ";"); reg_list.rewind(); while(char * reg_item = reg_list.next()) { // if the reg_item is of the form attr_name=reg_path; // then skip over the attr_name and '=' and trailing // whitespace. But if the = is after the first \, then // it's a part of the reg_path, so ignore it. // const char * pkey = strchr(reg_item, '='); const char * pbs = strchr(reg_item, '\\'); if (pkey && ( ! pbs || pkey < pbs)) { ++pkey; // skip the '=' } else { pkey = reg_item; } // skip any leading whitespace in the reg_path while (isspace(pkey[0])) ++pkey; // if the keyname begins with 32 or 64, use that to designate either // the WOW64 or WOW32 view of the registry, but don't pass the // leading number on to the lower level code. int options = 0; if (isdigit(pkey[0])) { options = atoi(pkey); while (isdigit(pkey[0])) { ++pkey; } } // get the registry value of the given key, and assign it // to the given attribute name, or a generated name. // char * value = get_windows_reg_value(pkey, NULL, options); if (value) { char * attr_name = generate_reg_key_attr_name("WINREG_", reg_item); if (attr_name) { cp->Assign(attr_name, value); free (attr_name); } free(value); } } free (pubreg_param); } */ #endif // defined ( WIN32 ) } if( IS_UPDATE(how_much) || IS_PUBLIC(how_much) ) { cp->Assign( ATTR_TOTAL_VIRTUAL_MEMORY, (int)m_virt_mem ); cp->Assign( ATTR_TOTAL_CPUS, m_num_cpus ); cp->Assign( ATTR_TOTAL_MEMORY, m_phys_mem ); // KFLOPS and MIPS are only conditionally computed; thus, only // advertise them if we computed them. if ( m_kflops > 0 ) { cp->Assign( ATTR_KFLOPS, m_kflops ); } if ( m_mips > 0 ) { cp->Assign( ATTR_MIPS, m_mips ); } #if defined(WIN32) if ( m_local_credd != NULL ) { cp->Assign(ATTR_LOCAL_CREDD, m_local_credd); } #endif string machine_resources = "cpus memory disk swap"; // publish any local resources for (slotres_map_t::iterator j(m_machres_map.begin()); j != m_machres_map.end(); ++j) { string rname(j->first.c_str()); *(rname.begin()) = toupper(*(rname.begin())); string attr; formatstr(attr, "%s%s", ATTR_DETECTED_PREFIX, rname.c_str()); cp->Assign(attr.c_str(), int(j->second)); formatstr(attr, "%s%s", ATTR_TOTAL_PREFIX, rname.c_str()); cp->Assign(attr.c_str(), int(j->second)); machine_resources += " "; machine_resources += j->first; } cp->Assign(ATTR_MACHINE_RESOURCES, machine_resources.c_str()); } // We don't want this inserted into the public ad automatically if( IS_UPDATE(how_much) || IS_TIMEOUT(how_much) ) { cp->Assign( ATTR_LAST_BENCHMARK, (unsigned)m_last_benchmark ); } if( IS_TIMEOUT(how_much) || IS_PUBLIC(how_much) ) { cp->Assign( ATTR_TOTAL_LOAD_AVG, rint(m_load * 100) / 100.0); cp->Assign( ATTR_TOTAL_CONDOR_LOAD_AVG, rint(m_condor_load * 100) / 100.0); cp->Assign( ATTR_CLOCK_MIN, m_clock_min ); cp->Assign( ATTR_CLOCK_DAY, m_clock_day ); m_lst_dynamic.Rewind(); while (AttribValue *pav = m_lst_dynamic.Next() ) { if (pav) pav->AssignToClassAd(cp); } } // temporary attributes for raw utsname info cp->Assign( ATTR_UTSNAME_SYSNAME, m_utsname_sysname ); cp->Assign( ATTR_UTSNAME_NODENAME, m_utsname_nodename ); cp->Assign( ATTR_UTSNAME_RELEASE, m_utsname_release ); cp->Assign( ATTR_UTSNAME_VERSION, m_utsname_version ); cp->Assign( ATTR_UTSNAME_MACHINE, m_utsname_machine ); // Advertise chroot information if ( m_named_chroot.size() > 0 ) { cp->Assign( "NamedChroot", m_named_chroot.c_str() ); } }