Ejemplo n.º 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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
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()