def __init__(self, logger): Check.__init__(self, logger) self.gauge('system.proc.queue_length') self.gauge('system.proc.count') self.numprocs = WinPDHSingleCounter('System', 'Processes') self.pql = WinPDHSingleCounter('System', 'Processor Queue Length')
def __init__(self, logger): Check.__init__(self, logger) self.gauge('system.mem.free') self.gauge('system.mem.used') self.gauge('system.mem.total') # area of physical memory that stores recently used pages of data # for applications self.gauge('system.mem.cached') # Committed memory is physical memory for which space has been # reserved on the disk paging file in case it must be written # back to disk self.gauge('system.mem.committed') # physical memory used by the operating system, for objects # that can be written to disk when they are not being used self.gauge('system.mem.paged') # physical memory used by the operating system for objects that # cannot be written to disk, but must remain in physical memory # as long as they are allocated. self.gauge('system.mem.nonpaged') # usable = free + cached self.gauge('system.mem.usable') self.gauge('system.mem.pct_usable') # details about the usage of the pagefile. self.gauge('system.mem.pagefile.total') self.gauge('system.mem.pagefile.used') self.gauge('system.mem.pagefile.free') self.gauge('system.mem.pagefile.pct_free') self.cache_bytes_counter = WinPDHSingleCounter('Memory', 'Cache Bytes') self.committed_bytes_counter = WinPDHSingleCounter('Memory', 'Committed Bytes') self.pool_paged_bytes_counter = WinPDHSingleCounter('Memory', 'Pool Paged Bytes') self.pool_non_paged_bytes_counter = WinPDHSingleCounter('Memory', 'Pool Nonpaged Bytes')
class Processes(Check): def __init__(self, logger): Check.__init__(self, logger) self.gauge('system.proc.queue_length') self.gauge('system.proc.count') self.numprocs = WinPDHSingleCounter('System', 'Processes') self.pql = WinPDHSingleCounter('System', 'Processor Queue Length') def check(self, agentConfig): processor_queue_length = self.pql.get_single_value() processes = self.numprocs.get_single_value() if processor_queue_length is not None: self.save_sample('system.proc.queue_length', processor_queue_length) if processes is not None: self.save_sample('system.proc.count', processes) return self.get_metrics()
class Memory(Check): def __init__(self, logger): Check.__init__(self, logger) self.gauge('system.mem.free') self.gauge('system.mem.used') self.gauge('system.mem.total') # area of physical memory that stores recently used pages of data # for applications self.gauge('system.mem.cached') # Committed memory is physical memory for which space has been # reserved on the disk paging file in case it must be written # back to disk self.gauge('system.mem.committed') # physical memory used by the operating system, for objects # that can be written to disk when they are not being used self.gauge('system.mem.paged') # physical memory used by the operating system for objects that # cannot be written to disk, but must remain in physical memory # as long as they are allocated. self.gauge('system.mem.nonpaged') # usable = free + cached self.gauge('system.mem.usable') self.gauge('system.mem.pct_usable') # details about the usage of the pagefile. self.gauge('system.mem.pagefile.total') self.gauge('system.mem.pagefile.used') self.gauge('system.mem.pagefile.free') self.gauge('system.mem.pagefile.pct_free') self.cache_bytes_counter = WinPDHSingleCounter('Memory', 'Cache Bytes') self.committed_bytes_counter = WinPDHSingleCounter('Memory', 'Committed Bytes') self.pool_paged_bytes_counter = WinPDHSingleCounter('Memory', 'Pool Paged Bytes') self.pool_non_paged_bytes_counter = WinPDHSingleCounter('Memory', 'Pool Nonpaged Bytes') def check(self, agentConfig): total = 0 free = 0 cached = 0 mem = psutil.virtual_memory() total_visible_memory_size = mem.total / B2KB free_physical_memory = mem.available / B2KB if total_visible_memory_size is not None and free_physical_memory is not None: total = int(total_visible_memory_size) / KB2MB free = int(free_physical_memory) / KB2MB self.save_sample('system.mem.total', total) self.save_sample('system.mem.free', free) self.save_sample('system.mem.used', total - free) cache_bytes = self.cache_bytes_counter.get_single_value() committed_bytes = self.committed_bytes_counter.get_single_value() pool_paged_bytes = self.pool_paged_bytes_counter.get_single_value() pool_non_paged_bytes = self.pool_non_paged_bytes_counter.get_single_value() if cache_bytes is not None: cached = int(cache_bytes) / B2MB self.save_sample('system.mem.cached', cached) if committed_bytes is not None: self.save_sample('system.mem.committed', int(committed_bytes) / B2MB) if pool_paged_bytes is not None: self.save_sample('system.mem.paged', int(pool_paged_bytes) / B2MB) if pool_non_paged_bytes is not None: self.save_sample('system.mem.nonpaged', int(pool_non_paged_bytes) / B2MB) usable = free + cached self.save_sample('system.mem.usable', usable) if total > 0: pct_usable = float(usable) / total self.save_sample('system.mem.pct_usable', pct_usable) # swap_memory pulls from the pagefile data, # rather than from the whole virtual memory data. page = psutil.swap_memory() if page.total is not None: self.save_sample('system.mem.pagefile.total', page.total) self.save_sample('system.mem.pagefile.used', page.used) self.save_sample('system.mem.pagefile.free', page.free) self.save_sample('system.mem.pagefile.pct_free', (100 - page.percent) / 100) return self.get_metrics()