コード例 #1
0
def print_iostat_summary(old, new, devices):
    global timestamp
    # Tells pyostat to start collecting data.
    pyostat_device.start_collecting()
    stats, diff_stats = {}, {}

    if old:
        devicelist = [x for x in old if x in devices]
    else:
        devicelist = devices

    for device in devicelist:
        stats[device] = DeviceData()
        stats[device].parse_stats(new[device])
        if old:
            old_stats = DeviceData()
            old_stats.parse_stats(old[device])
            diff_stats[device] = stats[device].compare_iostats(old_stats)

    # Stores the timestamp for the current data.
    timestamp = datetime.datetime.fromtimestamp(time.time()).strftime(
        '%Y-%m-%d %H:%M:%S')  # <-- Weird Python Magic.
    for device in devicelist:
        if old:
            diff_stats[device].display_iostats()
        else:
            stats[device].display_iostats()

    # Tells pyostat to stop collecting data, calculate averages, save the data to a file, and print to stdout.
    pyostat_device.stop_collecting()
    pyostat_device.calculate_data(timestamp)
    pyostat_device.print_to_file()
    pyostat_device.print_to_stdout()
コード例 #2
0
ファイル: pyostat_functions.py プロジェクト: qwertos/pyostat
def print_iostat_summary(old, new, devices):
	global timestamp
	# Tells pyostat to start collecting data.
	pyostat_device.start_collecting()
	stats, diff_stats = {}, {}

	if old:
		devicelist = [x for x in old if x in devices]
	else:
		devicelist = devices

	for device in devicelist:
		stats[device] = DeviceData()
		stats[device].parse_stats(new[device])
		if old:
			old_stats = DeviceData()
			old_stats.parse_stats(old[device])
			diff_stats[device] = stats[device].compare_iostats(old_stats)

	# Stores the timestamp for the current data.
	timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') # <-- Weird Python Magic.
	for device in devicelist:
		if old:
			diff_stats[device].display_iostats()
		else:
			stats[device].display_iostats()

	# Tells pyostat to stop collecting data, calculate averages, save the data to a file, and print to stdout.
	pyostat_device.stop_collecting()
	pyostat_device.calculate_data(timestamp)
	pyostat_device.print_to_file()
	pyostat_device.print_to_stdout()
コード例 #3
0
ファイル: pyostat_functions.py プロジェクト: meyersbs/pyostat
def print_iostat_summary(old, new, devices):
	"""
	Parses the device list so that only the intersection of old and new data is given.
	This addresses umounts due to autofs mountpoints.
	"""
	global TIMESTAMP
	pyostat_device.start_collecting() # Start collecting data
	stats, diff_stats = {}, {}

	if old:
		devicelist = [x for x in old if x in devices]
	else:
		devicelist = devices

	for device in devicelist:
		stats[device] = DeviceData()
		stats[device].parse_stats(new[device])
		if old:
			old_stats = DeviceData()
			old_stats.parse_stats(old[device])
			diff_stats[device] = stats[device].compare_iostats(old_stats)

	TIMESTAMP = datetime.datetime.now() # Capture timestamp for the current data
	for device in devicelist:
		if old:
			diff_stats[device].display_iostats()
		else:
			stats[device].display_iostats()

	pyostat_device.stop_collecting() # Stop collecting data
	pyostat_device.calculate_data(TIMESTAMP) # Calculate averages
	pyostat_device.print_to_syslog() # Write to /var/log/syslog.log
	pyostat_device.print_to_stdout() # Print to stdout
	pyostat_device.print_to_dev_file()
コード例 #4
0
def list_nfs_mounts(list_param, mountstats):
    mount_list = []
    if len(list_param) > 0:
        for device in list_param:
            stats = DeviceData()
            stats.parse_stats(mountstats[device])
            if stats.is_nfs_mountpoint():
                mount_list += [device]
    else:
        for device, dev_description in mountstats.items():
            stats = DeviceData()
            stats.parse_stats(dev_description)
            if stats.is_nfs_mountpoint():
                mount_list += [device]

    return mount_list
コード例 #5
0
ファイル: pyostat_functions.py プロジェクト: qwertos/pyostat
def list_nfs_mounts(list_param, mountstats):
	mount_list = []
	if len(list_param) > 0:
		for device in list_param:
			stats = DeviceData()
			stats.parse_stats(mountstats[device])
			if stats.is_nfs_mountpoint():
				mount_list += [device]
	else:
		for device, dev_description in mountstats.items():
			stats = DeviceData()
			stats.parse_stats(dev_description)
			if stats.is_nfs_mountpoint():
				mount_list += [device]

	return mount_list