コード例 #1
0
ファイル: test.cpp プロジェクト: AlainRoy/htcondor
/* the main entry function, this will do all the magic */
extern "C" int
sysapi_test_dump_all(int argc, char** argv)
{
	int foo;
	int return_val = 0;
	int	tests = TEST_NONE;
	int failed_tests = 0;
	int passed_tests = 0;
	int i;
	int print_help = 0;
#if defined(LINUX)
	const char *linux_cpuinfo_file = NULL;
	int			linux_cpuinfo_debug = 0;
	const char *linux_uname = NULL;
	int 		linux_num = -1;
	int			linux_processors = -1;
	int			linux_hthreads = -1;
	int			linux_hthreads_core = -1;
	int			linux_cpus = -1;
#endif
	int ncpus_trials = NCPUS_TRIALS;
	int skip = 0;
	const char *free_fs_dir = "/tmp";

	if (argc <= 1)
		tests = TEST_ALL;
	for (i=1; i<argc; i++) {
		if ( skip ) {
			skip--;
			continue;
		}
		if (strcmp(argv[i], "--arch") == 0)
			tests |= ARCH;
		else if (strcmp(argv[i], "--kern_memmod") == 0)
			tests |= KERN_MEMMOD;
		else if (strcmp(argv[i], "--kern_vers") == 0)
			tests |= KERN_VERS;
		else if (strcmp(argv[i], "--ckptpltfrm") == 0)
			tests |= CKPTPLTFRM;
		else if (strcmp(argv[i], "--dump") == 0)
			tests |= DUMP;
		else if (strcmp(argv[i], "--free_fs_blocks") == 0) {
			tests |= FREE_FS_BLOCKS;
			if (  ( i+1 < argc ) &&
				  ( (*argv[i+1] == '/') || (*argv[i+1] == '.') )  ) {
				skip = 1;
				free_fs_dir = argv[i+1];
			}
		}
		else if (strcmp(argv[i], "--idle_time") == 0)
			tests |= IDLE_TIME;
		else if (strcmp(argv[i], "--kflops") == 0)
			tests |= KFLOPS;
		else if (strcmp(argv[i], "--last_x_event") == 0)
			tests |= LAST_X_EVENT;
		else if (strcmp(argv[i], "--load_avg") == 0)
			tests |= LOAD_AVG;
		else if (strcmp(argv[i], "--mips") == 0)
			tests |= MIPS;
		else if (strcmp(argv[i], "--ncpus") == 0) {
			tests |= NCPUS;
		}
		else if (strcmp(argv[i], "--phys_mem") == 0)
			tests |= PHYS_MEM;
		else if (strcmp(argv[i], "--virt_mem") == 0)
			tests |= VIRT_MEM;
		else if ( (strcmp(argv[i], "--debug") == 0) && (i+1 < argc)  ) {
			set_debug_flags( argv[i+1], 0 );
			skip = 1;
		}
#	  if defined(LINUX)
		else if (strcmp(argv[i], "--proc_cpuinfo") == 0) {
			tests |= NCPUS;
			linux_cpuinfo_file = "/proc/cpuinfo";
			linux_cpuinfo_debug = 1;	// Turn on debugging
			linux_num = 0;
		}
		else if ( (strcmp(argv[i], "--cpuinfo_file") == 0) && (i+2 < argc)  ) {
			tests |= NCPUS;
			linux_cpuinfo_file = argv[i+1];
			linux_cpuinfo_debug = 1;	// Turn on debugging
			if ( isdigit( *argv[i+2] ) ) {
				linux_num = atoi( argv[i+2] );
			} else {
				linux_uname = argv[i+2];
			}
			skip = 2;
		}
#	  endif
		else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
			print_help = 1;
		else {
			printf("%s is not an understood option. ", argv[i]);
			print_help = 1;
		}

		if (print_help != 0) {
			printf("Please use zero or more or:\n");
			printf("--debug <D_xxx>\n");
			printf("--arch\n");
			printf("--kern_vers\n");
			printf("--kern_memmod\n");
			printf("--ckptpltfrm\n");
			printf("--dump\n");
			printf("--free_fs_blocks [dir]\n");
			printf("--idle_time\n");
			printf("--kflops\n");
			printf("--last_x_event\n");
			printf("--load_avg\n");
			printf("--mips\n");
			printf("--ncpus\n");
			printf("--phys_mem\n");
			printf("--virt_mem\n");
#		  if defined(LINUX)
			printf("--proc_cpuinfo\n");
			printf("--cpuinfo_file <file> <uname match string>|<cpuinfo #>\n");
#		  endif
			return 0;
		}
	}

	if ((tests & KERN_MEMMOD) == KERN_MEMMOD) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		dprintf(D_ALWAYS, "SysAPI: Kernel memory model: %s\n",
			sysapi_kernel_memory_model());
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & KERN_VERS) == KERN_VERS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		dprintf(D_ALWAYS, "SysAPI: Kernel version: %s\n",
			sysapi_kernel_version());
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & CKPTPLTFRM) == CKPTPLTFRM) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		sysapi_ckptpltfrm();
		sysapi_test_dump_internal_vars();
		sysapi_reconfig();
		sysapi_test_dump_internal_vars();
		dprintf(D_ALWAYS, "SysAPI: Checkpoint platform: %s\n",
			sysapi_ckptpltfrm());
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & DUMP) == DUMP) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN SysAPI DUMP!\n");
		sysapi_test_dump_internal_vars();
		sysapi_reconfig();
		sysapi_test_dump_internal_vars();
		//sysapi_test_dump_functions();
		dprintf(D_ALWAYS, "SysAPI: END SysAPI DUMP!\n\n");
	}

	if ((tests & ARCH) == ARCH) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN ARCH_TEST:\n");
		foo = 0;
		foo = arch_test(500);
		dprintf(D_ALWAYS, "SysAPI: END ARCH_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed ARCH_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed ARCH_TEST.\n\n");
			failed_tests++;
		}
	}


	if ((tests & FREE_FS_BLOCKS) == FREE_FS_BLOCKS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN FREE_FS_BLOCKS_TEST:\n");
		foo = 0;
		foo = free_fs_blocks_test(free_fs_dir,
								  FREEBLOCKS_TRIALS,
								  FREEBLOCKS_TOLERANCE,
								  FREEBLOCKS_MAX_WARN_OK );
		dprintf(D_ALWAYS, "SysAPI: END FREE_FS_BLOCKS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed FREE_FS_BLOCKS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed FREE_FS_BLOCKS_TEST.\n\n");
			failed_tests++;
		}
	}
	

	if ((tests & IDLE_TIME) == IDLE_TIME) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN IDLE_TIME_TEST:\n");
		foo = 0;
		foo = idle_time_test(IDLETIME_TRIALS,
							 IDLETIME_INTERVAL,
							 IDLETIME_TOLERANCE,
							 IDLETIME_MAX_WARN_OK );
		dprintf(D_ALWAYS, "SysAPI: END IDLE_TIME_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed IDLE_TIME_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed IDLE_TIME_TEST.\n\n");
			failed_tests++;
		}
	}

	
	if ((tests & KFLOPS) == KFLOPS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN KFLOPS_TEST:\n");
		foo = 0;
		foo = kflops_test(KFLOPS_TRIALS,
						  KFLOPS_MAX_SD_VAR,
						  KFLOPS_MAX_WARN_OK
						  );
		dprintf(D_ALWAYS, "SysAPI: END KFLOPS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed KFLOPS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed KFLOPS_TEST.\n\n");
			failed_tests++;
		}
	}


	if ((tests & LAST_X_EVENT) == LAST_X_EVENT) {
		dprintf(D_ALWAYS, "SysAPI: SKIPPING LASE_X_EVENT_TEST: internally used variable only.\n\n");
	}
	

	if ((tests & LOAD_AVG) == LOAD_AVG) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN LOAD_AVG_TEST:\n");
		foo = 0;
		foo = load_avg_test(LOADAVG_TRIALS,
							LOADAVG_INTERVAL,
							LOADAVG_CHILDREN,
							LOADAVG_MAX_WARN_OK);
		dprintf(D_ALWAYS, "SysAPI: END LOAD_AVG_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed LOAD_AVG_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed LOAD_AVG_TEST.\n\n");
			failed_tests++;
		}
	}

	
	if ((tests & MIPS) == MIPS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN MIPS_TEST:\n");
		foo = 0;
		foo = mips_test(MIPS_TRIALS,
						MIPS_MAX_SD_VAR,
						MIPS_MAX_WARN_OK );
		dprintf(D_ALWAYS, "SysAPI: END MIPS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed MIPS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed MIPS_TEST.\n\n");
			failed_tests++;
		}
	}
	
	/* Special test: /proc/cpuinfo on a file */
#if defined(LINUX)
	if ((tests & NCPUS) == NCPUS && linux_cpuinfo_file ) {
		bool is_proc_cpuinfo = false;

		/* set_debug_flags(NULL, D_FULLDEBUG); */
		if ( strcmp( linux_cpuinfo_file, "/proc/cpuinfo" ) == 0 ) {
			is_proc_cpuinfo = true;
			dprintf( D_ALWAYS, "Using the real /proc/cpuinfo\n" );
		}

		FILE	*fp = safe_fopen_wrapper_follow( linux_cpuinfo_file, "r", 0644 );
		if ( !fp ) {
			dprintf(D_ALWAYS, "SysAPI: Can't open cpuinfo file '%s'.\n\n",
					linux_cpuinfo_file);
			return(++failed_tests);
		}
		else {
			/* Skip 'til we find the "right" uname */
			char	buf[256];
			char	uname[256];
			int		found = 0;
			int		linenum = 1;
			int		cpuinfo_num = 0;		/* # of this cpuinfo block */

			if ( is_proc_cpuinfo ) {
				found = true;
				strcpy( uname, "" );
			}
			else {
				while( fgets( buf, sizeof(buf), fp) ) {
					linenum++;
					buf[sizeof(buf)-1] = '\0';
					if ( !strncmp( buf, "UNAME:", 6 ) && ( strlen(buf) > 6 ) ){
						cpuinfo_num++;
						if ( ( ( linux_num >= 0 ) &&
							   ( linux_num == cpuinfo_num ) ) ||
							 ( linux_uname &&
							   strstr( buf, linux_uname ) )   ) {
							strncpy( uname, buf+6, sizeof(uname) );
							found = linenum;
						}
					}
					else if ( found ) {
						if ( !strncmp( buf, "START", 5 ) && found ) {
							break;
						}
						sscanf( buf, "PROCESSORS: %d", &linux_processors );
						sscanf( buf, "HTHREADS: %d", &linux_hthreads );
						sscanf( buf, "HTHREADS_CORE: %d",
								&linux_hthreads_core );
					}
				}
			}

			// Store the current file position & file name
			_SysapiProcCpuinfo.file = linux_cpuinfo_file;
			_SysapiProcCpuinfo.debug = linux_cpuinfo_debug;
			_SysapiProcCpuinfo.offset = ftell( fp );
			fclose( fp );
			fp = NULL;

			// Calculate total "non-primary" hyper threads
			if ( ! is_proc_cpuinfo ) {
				if ( ( linux_hthreads < 0 )		  &&
					 ( linux_hthreads_core > 0 )  &&
					 ( linux_processors > 0 )  )  {
					linux_hthreads = (  linux_processors -
										( linux_processors /
										  linux_hthreads_core )  );
				}
			}

			// Calculate the total # of CPUs
			if ( linux_processors ) {
				if ( param_boolean_int("COUNT_HYPERTHREAD_CPUS", 1) ) {
					linux_cpus = linux_processors;
				}
				else {
					linux_cpus = linux_processors - linux_hthreads;
				}
			}

			if ( !found ) {
				if ( linux_num >= 0 ) {
					dprintf(D_ALWAYS,
							"SysAPI: Can't find uname # %d in %s.\n\n",
							linux_num, linux_cpuinfo_file );
				}
				else {
					dprintf(D_ALWAYS,
							"SysAPI: Can't find uname '%s' in %s.\n\n",
							linux_uname, linux_cpuinfo_file );
				}
				return(++failed_tests);
			}
			if ( strlen( uname ) ) {
				dprintf(D_ALWAYS,
						"SysAPI: Using uname string on line %d:\n%s\n",
						found, uname );
			}
			ncpus_trials = 1;
		}
	}
#endif

	if ((tests & NCPUS) == NCPUS) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN NUMBER_CPUS_TEST:\n");
		foo = 0;
		foo = ncpus_test(ncpus_trials,
						 NCPUS_MAX_WARN_OK);
		dprintf(D_ALWAYS, "SysAPI: END NUMBER_CPUS_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed NUMBER_CPUS_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed NUMBER_CPUS_TEST.\n\n");
			failed_tests++;
		}
#    if defined(LINUX)
		if ( ( linux_processors >= 0 ) &&
			 ( _SysapiProcCpuinfo.found_processors != linux_processors )  )  {
			dprintf(D_ALWAYS,
					"SysAPI/Linux: # Processors (%d) != expected (%d)\n",
					_SysapiProcCpuinfo.found_processors,
					linux_processors );
		}
		if ( ( linux_hthreads >= 0 ) &&
			 ( _SysapiProcCpuinfo.found_hthreads != linux_hthreads ) ) {
			dprintf(D_ALWAYS,
					"SysAPI/Linux: # HyperThreads (%d) != expected (%d)\n",
					_SysapiProcCpuinfo.found_hthreads,
					linux_hthreads );
		}
		if ( ( linux_cpus > 0 ) &&
			 ( _SysapiProcCpuinfo.found_ncpus != linux_cpus )  )    {
			dprintf(D_ALWAYS,
					"SysAPI/Linux: # CPUs (%d) != expected (%d)\n",
					_SysapiProcCpuinfo.found_ncpus,
					linux_cpus );
		}
		int	level = D_FULLDEBUG;
		if (linux_cpuinfo_debug) {
			level = D_ALWAYS;
		}
		dprintf( level,
				 "SysAPI: Detected %d Processors, %d HyperThreads"
				 " => %d CPUS\n",
				 _SysapiProcCpuinfo.found_processors,
				 _SysapiProcCpuinfo.found_hthreads,
				 _SysapiProcCpuinfo.found_ncpus );
				
#    endif
	}
	

	if ((tests & PHYS_MEM) == PHYS_MEM) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN PHYSICAL_MEMORY_TEST:\n");
		foo = 0;
		foo = phys_memory_test(PHYSMEM_TRIALS, PHYSMEM_MAX_WARN_OK);
		dprintf(D_ALWAYS, "SysAPI: END PHYSICAL_MEMORY_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed PHYSICAL_MEMORY_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed PHYSICAL_MEMORY_TEST.\n\n");
			failed_tests++;
		}
	}

	
	if ((tests & VIRT_MEM) == VIRT_MEM) {
		dprintf(D_ALWAYS, "SysAPI: BEGIN VIRTUAL_MEMORY_TEST:\n");
		foo = 0;
		foo = virt_memory_test(VIRTMEM_TESTBLOCK_SIZE,
							   VIRTMEM_MAX_SD_VAR,
							   VIRTMEM_MAX_FAIL_OK);
		dprintf(D_ALWAYS, "SysAPI: END VIRTUAL_MEMORY_TEST:\n");
		return_val |= foo;
		if (foo == 0) {
			dprintf(D_ALWAYS, "SysAPI: Passed VIRTUAL_MEMORY_TEST.\n\n");
			passed_tests++;
		} else {
			dprintf(D_ALWAYS, "SysAPI: Failed VIRTUAL_MEMORY_TEST.\n\n");
			failed_tests++;
		}
	}
	printf("Passed tests = %d\n",passed_tests);
	return(failed_tests);
}
コード例 #2
0
MachAttributes::MachAttributes()
   : m_user_specified(NULL, ";"), m_user_settings_init(false), m_named_chroot()
{
	m_mips = -1;
	m_kflops = -1;
	m_last_benchmark = 0;
	m_last_keypress = time(0)-1;
	m_seen_keypress = false;

	m_arch = NULL;
	m_opsys = NULL;
	m_opsysver = 0;
	m_opsys_and_ver = NULL;
	m_opsys_major_ver = 0;
	m_opsys_name = NULL;
	m_opsys_long_name = NULL;
	m_opsys_short_name = NULL;
	m_opsys_legacy = NULL;
	m_uid_domain = NULL;
	m_filesystem_domain = NULL;
	m_idle_interval = -1;
	m_ckptpltfrm = NULL;

	m_clock_day = -1;
	m_clock_min = -1;
	m_condor_load = -1.0;
	m_console_idle = 0;
	m_idle = 0;
	m_load = -1.0;
	m_owner_load = -1.0;
	m_virt_mem = 0;

		// Number of CPUs.  Since this is used heavily by the ResMgr
		// instantiation and initialization, we need to have a real
		// value for this as soon as the MachAttributes object exists.
	m_num_cpus = sysapi_ncpus();

	m_num_real_cpus = sysapi_ncpus_raw();

		// The same is true of physical memory.  If we had an error in
		// sysapi_phys_memory(), we need to just EXCEPT with a message
		// telling the user to define MEMORY manually.
	m_phys_mem = sysapi_phys_memory();
	if( m_phys_mem <= 0 ) {
		dprintf( D_ALWAYS, 
				 "Error computing physical memory with calc_phys_mem().\n" );
		dprintf( D_ALWAYS | D_NOHEADER, 
				 "\t\tMEMORY parameter not defined in config file.\n" );
		dprintf( D_ALWAYS | D_NOHEADER, 
				 "\t\tTry setting MEMORY to the number of megabytes of RAM.\n"
				 );
		EXCEPT( "Can't compute physical memory." );
	}

	dprintf( D_FULLDEBUG, "Memory: Detected %d megs RAM\n", m_phys_mem );

		// identification of the checkpointing platform signature
    const char * ckptpltfrm = param( ATTR_CHECKPOINT_PLATFORM );
	if( ckptpltfrm == NULL ) {
    	ckptpltfrm = sysapi_ckptpltfrm();
    }
    m_ckptpltfrm = strdup( ckptpltfrm );

        // temporary attributes for raw utsname info
	m_utsname_sysname = NULL;
	m_utsname_nodename = NULL;
	m_utsname_release = NULL;
	m_utsname_version = NULL;
	m_utsname_machine = NULL;


#if defined ( WIN32 )
	// Get the version information of the copy of Windows 
	// we are running
	ZeroMemory ( &m_window_version_info, sizeof ( OSVERSIONINFOEX ) );
	m_window_version_info.dwOSVersionInfoSize = 
		sizeof ( OSVERSIONINFOEX );	
	m_got_windows_version_info = 
		GetVersionEx ( (OSVERSIONINFO*) &m_window_version_info );
	if ( !m_got_windows_version_info ) {
		m_window_version_info.dwOSVersionInfoSize = 
			sizeof ( OSVERSIONINFO );	
		m_got_windows_version_info = 
			GetVersionEx ( (OSVERSIONINFO*) &m_window_version_info );
		if ( !m_got_windows_version_info ) {
			dprintf ( D_ALWAYS, "MachAttributes: failed to "
				"get Windows version information.\n" );
		}
	}
	m_local_credd = NULL;
	m_last_credd_test = 0;
    m_dot_Net_Versions = NULL;
#endif
}
コード例 #3
0
ファイル: test.cpp プロジェクト: AlainRoy/htcondor
/* 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);
}
コード例 #4
0
void
MachAttributes::compute( amask_t how_much )
{
	// the startd doesn't normally call the init() method (bug?),
	// it just starts calling compute, so in order to gurantee that
	// init happens, we put check here to see if user settings have been initialized
	if ( ! m_user_settings_init)
		init_user_settings();

	if( IS_STATIC(how_much) && IS_SHARED(how_much) ) {

			// Since we need real values for them as soon as a
			// MachAttributes object is instantiated, we handle number
			// of CPUs and physical memory in the constructor, not
			// here.  -Derek Wright 2/5/99 

			// Arch, OpSys, FileSystemDomain and UidDomain.  Note:
			// these will always return something, since config() will
			// insert values if we don't have them in the config file.
		if( m_arch ) {
			free( m_arch );
		}
		m_arch = param( "ARCH" );

		if( m_opsys ) {
			free( m_opsys );
		}
		m_opsys = param( "OPSYS" );
		m_opsysver = param_integer( "OPSYSVER", 0 );

		if( m_opsys_and_ver ) {
			free( m_opsys_and_ver );
		}
		m_opsys_and_ver = param( "OPSYSANDVER" );
		m_opsys_major_ver = param_integer( "OPSYSMAJORVER", 0 );

		if( m_opsys_name ) {
			free( m_opsys_name );
                } 
		m_opsys_name = param( "OPSYSNAME" );

		if( m_opsys_long_name ) {
			free( m_opsys_long_name );
                } 
		m_opsys_long_name = param( "OPSYSLONGNAME" );

		if( m_opsys_short_name ) {
			free( m_opsys_short_name );
                } 
		m_opsys_short_name = param( "OPSYSSHORTNAME" );

		if( m_opsys_legacy ) {
			free( m_opsys_legacy );
                } 
		m_opsys_legacy = param( "OPSYSLEGACY" );

       		// temporary attributes for raw utsname info
		if( m_utsname_sysname ) {
			free( m_utsname_sysname );
		}
		if( m_utsname_nodename ) {
			free( m_utsname_nodename );
		}
		if( m_utsname_release ) {
			free( m_utsname_release );
		}
		if( m_utsname_version ) {
			free( m_utsname_version );
		}
		if( m_utsname_machine ) {
			free( m_utsname_machine );
		}

       		m_utsname_sysname = param( "UTSNAME_SYSNAME" );
		m_utsname_nodename = param( "UTSNAME_NODENAME" );
		m_utsname_release = param( "UTSNAME_RELEASE" );
		m_utsname_version = param( "UTSNAME_VERSION" );
		m_utsname_machine = param( "UTSNAME_MACHINE" );

		if( m_uid_domain ) {
			free( m_uid_domain );
		}
		m_uid_domain = param( "UID_DOMAIN" );
		dprintf( D_FULLDEBUG, "%s = \"%s\"\n", ATTR_UID_DOMAIN,
				 m_uid_domain );

		if( m_filesystem_domain ) {
			free( m_filesystem_domain );
		}
		m_filesystem_domain = param( "FILESYSTEM_DOMAIN" );
		dprintf( D_FULLDEBUG, "%s = \"%s\"\n", ATTR_FILE_SYSTEM_DOMAIN,
				 m_filesystem_domain );

		m_idle_interval = param_integer( "IDLE_INTERVAL", -1 );

			// checkpoint platform signature
		if (m_ckptpltfrm) {
			free(m_ckptpltfrm);
		}

        const char * ckptpltfrm = param( ATTR_CHECKPOINT_PLATFORM );
    	if( ckptpltfrm == NULL ) {
        	ckptpltfrm = sysapi_ckptpltfrm();
        }
        m_ckptpltfrm = strdup( ckptpltfrm );

		pair_strings_vector root_dirs = root_dir_list();
		std::stringstream result;
		unsigned int chroot_count = 0;
		for (pair_strings_vector::const_iterator it=root_dirs.begin();
				it != root_dirs.end(); 
				++it, ++chroot_count) {
			if (chroot_count) {
				result << ", ";
			}
			result << it->first;
		}
		if (chroot_count > 1) {
			std::string result_str = result.str();
			dprintf(D_FULLDEBUG, "Named chroots: %s\n", result_str.c_str() );
			m_named_chroot = result_str;
		}

    }


	if( IS_UPDATE(how_much) && IS_SHARED(how_much) ) {

		m_virt_mem = sysapi_swap_space();
		dprintf( D_FULLDEBUG, "Swap space: %lu\n", m_virt_mem );

#if defined(WIN32)
		credd_test();
#endif
	}


	if( IS_TIMEOUT(how_much) && IS_SHARED(how_much) ) {
		m_load = sysapi_load_avg();

		sysapi_idle_time( &m_idle, &m_console_idle );

		time_t my_timer;
		struct tm *the_time;
		time( &my_timer );
		the_time = localtime(&my_timer);
		m_clock_min = (the_time->tm_hour * 60) + the_time->tm_min;
		m_clock_day = the_time->tm_wday;

		if (m_last_keypress < my_timer - m_idle) {
			if (m_idle_interval >= 0) {
				int duration = my_timer - m_last_keypress;
				if (duration > m_idle_interval) {
					if (m_seen_keypress) {
						dprintf(D_IDLE, "end idle interval of %d sec.\n",
								duration);
					} else {
						dprintf(D_IDLE,
								"first keyboard event %d sec. after startup\n",
								duration);
					}
				}
			}
			m_last_keypress = my_timer;
			m_seen_keypress = true;
		}

#ifdef WIN32
        update_all_WinPerf_results();
#endif

        AttribValue *pav = NULL;
        m_lst_dynamic.Rewind();
        while ((pav = m_lst_dynamic.Next()) ) {
           if (pav) {
             #ifdef WIN32
              if ( ! update_WinPerf_Value(pav))
                 pav->vtype = AttribValue_DataType_Max; // undefined vtype
             #else
              if (pav->pquery) {
                 // insert code to update pav from pav->pquery
              }
             #endif
           }
        }
	}

	if( IS_TIMEOUT(how_much) && IS_SUMMED(how_much) ) {
		m_condor_load = resmgr->sum( &Resource::condor_load );
		if( m_condor_load > m_load ) {
			m_condor_load = m_load;
		}
	}


}