Exemplo n.º 1
0
    def printable_info(self):

        def format_out(key, val):
            return "{0:40s}|    {1}\n".format(key, val)

        out = ''
        if not self.connected:
            out += header_h1('PGSQL Error')
            out += key_val_h1('Test connection', 'Failed')
            return out
        out += header_h1('PostgreSQL')
        out += key_val_h1('version', self.common_info[1][0])
        out += key_val_h1('uptime', self.common_info[1][1])
        out += key_val_h1('cache hit', '{0} %'.format(self.common_info[1][2]))
        out += key_val_h1('tps', self.rate['_TPS'])
        out += key_val_h1('rollbacks', self.rate['_ROLLBACKS'])
        out += header_h1('Connections')
        for info in self.connections:
            count, name = info
            out += key_val_h1(name, count)
        for key in self.QueryPgSettings[2]:
            out += header_h1(key)
            for row in self.settings:
                for name in self.QueryPgSettings[2][key]:
                    if row[0] == name:
                        val = row[1]
                        if row[2] is not None:
                            val += ' {0}'.format(row[2])
                            val = humansize(val)
                        out += key_val_h1(
                            name, val, 30)
        out += header_h1('Database sizes')
        for i, row in enumerate(self.dblist):
            if i == 0:
                continue
            out += key_val_h1(row[0], humansize(row[1]))
        out += header_h1('Biggest tables')
        out += key_val_h1(
            self.BigTableInfo[1][0],
            "\t\t" + "\t\t".join(self.BigTableInfo[1][1:]),
            30)
        for key in self.biggest_tables:
            out += key_val_h1(
                key, self.biggest_tables[key], 30)
        return out
Exemplo n.º 2
0
    def printable_info(self):

        def format_out(key, val):
            return "{0:40s}|    {1}\n".format(key, val)

        out = ''
        if not self.connected:
            out += header_h1('PGSQL Error')
            out += key_val_h1('Test connection', 'Failed')
            return out
        out += header_h1('PostgreSQL')
        out += key_val_h1('version', self.common_info[1][0])
        out += key_val_h1('uptime', self.common_info[1][1])
        out += key_val_h1('cache hit', '{0} %'.format(self.common_info[1][2]))
        out += key_val_h1('tps', self.rate['_TPS'])
        out += key_val_h1('rollbacks', self.rate['_ROLLBACKS'])
        out += header_h1('Connections')
        for info in self.connections:
            count, name = info
            out += key_val_h1(name, count)
        for key in self.QueryPgSettings[2]:
            out += header_h1(key)
            for row in self.settings:
                for name in self.QueryPgSettings[2][key]:
                    if row[0] == name:
                        val = row[1]
                        if row[2] is not None:
                            val += ' {0}'.format(row[2])
                            val = humansize(val)
                        out += key_val_h1(
                            name, val, 30)
        out += header_h1('Database sizes')
        for i, row in enumerate(self.dblist):
            if i == 0:
                continue
            out += key_val_h1(row[0], humansize(row[1]))
        out += header_h1('Biggest tables')
        out += key_val_h1(
            self.BigTableInfo[1][0],
            "\t\t" + "\t\t".join(self.BigTableInfo[1][1:]),
            30)
        for key in self.biggest_tables:
            out += key_val_h1(
                key, self.biggest_tables[key], 30)
        return out
Exemplo n.º 3
0
    def printable_info(self):
        def format_out(key, val):
            return "{0:40s}|    {1}\n".format(key, val)

        out = ""
        if not self.connected:
            out += header_h1("PGSQL Error")
            out += key_val_h1("Test connection", "Failed")
            return out
        out += header_h1("PostgreSQL")
        out += key_val_h1("version", self.common_info[1][0])
        out += key_val_h1("uptime", self.common_info[1][1])
        out += key_val_h1("cache hit", "{0} %".format(self.common_info[1][2]))
        out += key_val_h1("tps", self.rate["_TPS"])
        out += key_val_h1("rollbacks", self.rate["_ROLLBACKS"])
        out += header_h1("Connections")
        for info in self.connections:
            count, name = info
            out += key_val_h1(name, count)
        for key in self.QueryPgSettings[2]:
            out += header_h1(key)
            for row in self.settings:
                for name in self.QueryPgSettings[2][key]:
                    if row[0] == name:
                        val = row[1]
                        if row[2] is not None:
                            val += " {0}".format(row[2])
                            val = humansize(val)
                        out += key_val_h1(name, val, 30)
        out += header_h1("Database sizes")
        for i, row in enumerate(self.dblist):
            if i == 0:
                continue
            out += key_val_h1(row[0], humansize(row[1]))
        out += header_h1("Biggest tables")
        out += key_val_h1(self.BigTableInfo[1][0], "\t\t" + "\t\t".join(self.BigTableInfo[1][1:]), 30)
        for key in self.biggest_tables:
            out += key_val_h1(key, self.biggest_tables[key], 30)
        return out
Exemplo n.º 4
0
 def printable_info(self):
     out = ''
     out += header_h1('Report')
     out += key_val_h1('Version', mamonsu_version)
     out += key_val_h1('Platform', sys.platform)
     out += key_val_h1('Python', ' '.join(sys.version.split("\n")))
     out += header_h1('System')
     out += key_val_h1('Date', self.date)
     out += key_val_h1('Host', self.hostname)
     out += key_val_h1('Uptime', self.uptime_raw)
     out += key_val_h1('Boot time', self.boot_time_raw)
     out += key_val_h1('System', self.dmi_info['TOTAL'])
     out += key_val_h1('Serial', self.dmi_info['SERIAL'])
     out += key_val_h1('Release', self.release)
     out += header_h2('Kernel:')
     out += key_val_h2('name', self.kernel)
     out += key_val_h2('cmdline', self.kernel_cmdline)
     out += key_val_h1('Arch', 'CPU = {0}, OS = {1}'.format(
         self.cpu_arch, self.os_arch))
     out += key_val_h1('Virt', self.virtualization)
     out += header_h1('Processors')
     out += key_val_h1('Total', self.cpu_model['_TOTAL'])
     out += key_val_h1('Speed', self.cpu_model['speed'])
     out += key_val_h1('Model', self.cpu_model['model'])
     out += key_val_h1('Flags', self.cpu_model['_FLAGS_IMPORTANT'])
     out += key_val_h1('Cache', self.cpu_model['cache'])
     out += key_val_h1('Bench', self.cpu_bench())
     out += header_h1('TOP (by cpu)')
     out += format_raw_h1(self.top_by_cpu)
     out += header_h1('Memory')
     out += key_val_h1('Total', humansize_bytes(self.meminfo['_TOTAL']))
     out += key_val_h1('Committed', humansize_bytes(self.meminfo['_COMMITTED']))
     out += key_val_h1('CommitLimit', humansize_bytes(self.meminfo['_COMMITLIMIT']))
     out += key_val_h1('Shmem', humansize_bytes(self.meminfo['_SHMEM']))
     out += key_val_h1('Slab', humansize_bytes(self.meminfo['_SLAB']))
     out += key_val_h1('PageTables', humansize_bytes(self.meminfo['_PAGETABLES']))
     out += key_val_h1('Free', humansize_bytes(self.meminfo['_FREE']))
     out += key_val_h1('Cached', humansize_bytes(self.meminfo['_CACHED']))
     out += key_val_h1('Buffers', humansize_bytes(self.meminfo['_BUFFERS']))
     out += key_val_h1('Dirty', humansize_bytes(self.meminfo['_DIRTY']))
     out += key_val_h1('HugePages', humansize_bytes(self.meminfo['_HUGEPAGES']))
     out += key_val_h1('SwapTotal', humansize_bytes(self.meminfo['_SWAPTOTAL']))
     out += key_val_h1('SwapUsed', humansize_bytes(self.meminfo['_SWAPUSED']))
     out += header_h1('TOP (by memory)')
     out += format_raw_h1(self.top_by_memory)
     out += header_h1('System settings')
     for k in self.systemd['_main']:
         out += key_val_h1(k, self.systemd['_main'][k])
     out += header_h1('Sysctl')
     out += header_h2('kernel.')
     out += key_val_h2('hostname', self.sysctl_fetch('kernel.hostname'), ' = ')
     out += key_val_h2('osrelease', self.sysctl_fetch('kernel.osrelease'), ' = ')
     out += key_val_h2('shmall', self.sysctl_fetch('kernel.shmall'), ' [4-KiB pages, max size of shared memory] = ')
     out += key_val_h2('shmmax', self.sysctl_fetch('kernel.shmmax'), ' [max segment size in bytes] = ')
     out += key_val_h2('shmmni', self.sysctl_fetch('kernel.shmmni'), ' [max number of segments] = ')
     out += key_val_h2('sched_min_granularity_ns', self.sysctl_fetch('kernel.sched_min_granularity_ns'), ' [nanosecs, min execution time] = ')
     out += key_val_h2('sched_latency_ns', self.sysctl_fetch('kernel.sched_latency_ns'), ' [nanosecs, rescheduling] = ')
     out += header_h2('fs.')
     out += key_val_h2('file-max', self.sysctl_fetch('fs.file-max'), ' [fd system] = ')
     out += key_val_h2('nr_open', self.sysctl_fetch('fs.nr_open'), ' [fd per proc] = ')
     out += key_val_h2('file-nr', self.sysctl_fetch('fs.file-nr'), ' [fd: open, 0, max] = ')
     out += key_val_h2('inode-nr', self.sysctl_fetch('fs.inode-nr'), ' [inode cache: total, free] = ')
     out += header_h2('vm.')
     out += key_val_h2('dirty_ratio', self.sysctl_fetch('vm.dirty_ratio'), ' [% of RAM for dirty pages, only if dirty_bytes=0] = ')
     out += key_val_h2('dirty_bytes', self.sysctl_fetch('vm.dirty_bytes'), ' [bytes for dirty pages] = ')
     out += key_val_h2('dirty_background_ratio', self.sysctl_fetch('vm.dirty_background_ratio'), ' [% of RAM then flusher start, only if dirty_background_bytes=0] = ')
     out += key_val_h2('dirty_background_bytes', self.sysctl_fetch('vm.dirty_background_bytes'), ' [bytes then flusher start] = ')
     out += key_val_h2('dirty_expire_centisecs', self.sysctl_fetch('vm.dirty_expire_centisecs'), ' [max age of dirty data] = ')
     out += key_val_h2('dirty_writeback_centisecs', self.sysctl_fetch('vm.dirty_writeback_centisecs'), ' [flusher wakeup timer] = ')
     out += key_val_h2('overcommit_memory', self.sysctl_fetch('vm.overcommit_memory'), ' [overcommit policy] = ')
     out += key_val_h2('overcommit_ratio', self.sysctl_fetch('vm.overcommit_ratio'), ' [% physical RAM, if policy=2] = ')
     out += key_val_h2('oom_kill_allocating_task', self.sysctl_fetch('vm.oom_kill_allocating_task'), ' [0 - heuristics, else simple kill task who triggered] = ')
     out += key_val_h2('panic_on_oom', self.sysctl_fetch('vm.panic_on_oom'), ' [0 - no panic, 1 - panic only if only not limited (mempolicy/cpusets), 2 - panic] = ')
     out += key_val_h2('swappiness', self.sysctl_fetch('vm.swappiness'), ' [how aggressive use swap] = ')
     out += key_val_h2('nr_hugepages', self.sysctl_fetch('vm.nr_hugepages'), ' [count of persistent huge page pool] = ')
     out += key_val_h2('nr_overcommit_hugepages', self.sysctl_fetch('vm.nr_overcommit_hugepages'), ' [max count of additional huge pages] = ')
     out += header_h1('Mount')
     out += format_raw_h1(self.df_raw)
     out += header_h1('Disks')
     for disk in self.block_info:
         out += key_val_h1(disk, 'Scheduler: {0} Queue: {1}'.format(
             self.block_info[disk]['scheduler'],
             self.block_info[disk]['nr_requests']))
     out += header_h1('IOstat')
     if not self.is_empty(self.iostat_raw):
         out += format_raw_h1(self.iostat_raw)
     out += header_h1('LVM')
     if not self.is_empty(self.vgs_raw):
         out += format_raw_h1(self.vgs_raw)
     if not self.is_empty(self.lvs_raw):
         out += format_raw_h1(self.lvs_raw)
     out += header_h1('Raid')
     if not self.is_empty(self.raid):
         for raid in self.raid:
             out += key_val_h1('Controller', raid)
     out += header_h1('Sockstat')
     for line in self.sockstat.split("\n"):
         try:
             key, val = line.split(":")
             out += key_val_h1(key, val)
         except:
             pass
     out += header_h1('LSPCI')
     for line in self.pci_network_devices:
         out += key_val_h1('net', line)
     for line in self.pci_storage_devices:
         out += key_val_h1('storage', line)
     return out
Exemplo n.º 5
0
 def printable_info(self):
     out = ''
     out += header_h1('Report')
     out += key_val_h1('Version', mamonsu_version)
     out += key_val_h1('Platform', sys.platform)
     out += key_val_h1('Python', ' '.join(sys.version.split("\n")))
     out += header_h1('System')
     out += key_val_h1('Date', self.date)
     out += key_val_h1('Host', self.hostname)
     out += key_val_h1('Uptime', self.uptime_raw)
     out += key_val_h1('Boot time', self.boot_time_raw)
     out += key_val_h1('System', self.dmi_info['TOTAL'])
     out += key_val_h1('Serial', self.dmi_info['SERIAL'])
     out += key_val_h1('Release', self.release)
     out += header_h2('Kernel:')
     out += key_val_h2('name', self.kernel)
     out += key_val_h2('cmdline', self.kernel_cmdline)
     out += key_val_h1(
         'Arch', 'CPU = {0}, OS = {1}'.format(self.cpu_arch, self.os_arch))
     out += key_val_h1('Virt', self.virtualization)
     out += header_h1('Processors')
     out += key_val_h1('Total', self.cpu_model['_TOTAL'])
     out += key_val_h1('Speed', self.cpu_model['speed'])
     out += key_val_h1('Model', self.cpu_model['model'])
     out += key_val_h1('Flags', self.cpu_model['_FLAGS_IMPORTANT'])
     out += key_val_h1('Cache', self.cpu_model['cache'])
     out += key_val_h1('Bench', self.cpu_bench())
     out += header_h1('TOP (by cpu)')
     out += format_raw_h1(self.top_by_cpu)
     out += header_h1('Memory')
     out += key_val_h1('Total', humansize_bytes(self.meminfo['_TOTAL']))
     out += key_val_h1('Committed',
                       humansize_bytes(self.meminfo['_COMMITTED']))
     out += key_val_h1('CommitLimit',
                       humansize_bytes(self.meminfo['_COMMITLIMIT']))
     out += key_val_h1('Shmem', humansize_bytes(self.meminfo['_SHMEM']))
     out += key_val_h1('Slab', humansize_bytes(self.meminfo['_SLAB']))
     out += key_val_h1('PageTables',
                       humansize_bytes(self.meminfo['_PAGETABLES']))
     out += key_val_h1('Free', humansize_bytes(self.meminfo['_FREE']))
     out += key_val_h1('Cached', humansize_bytes(self.meminfo['_CACHED']))
     out += key_val_h1('Buffers', humansize_bytes(self.meminfo['_BUFFERS']))
     out += key_val_h1('Dirty', humansize_bytes(self.meminfo['_DIRTY']))
     out += key_val_h1('HP Total',
                       humansize_bytes(self.meminfo['_HUGEPAGES_SIZE']))
     out += key_val_h1('HP Free',
                       humansize_bytes(self.meminfo['_HUGEPAGES_FREE']))
     out += key_val_h1('SwapTotal',
                       humansize_bytes(self.meminfo['_SWAPTOTAL']))
     out += key_val_h1('SwapUsed',
                       humansize_bytes(self.meminfo['_SWAPUSED']))
     out += header_h1('TOP (by memory)')
     out += format_raw_h1(self.top_by_memory)
     out += header_h1('System settings')
     for k in self.systemd['_main']:
         out += key_val_h1(k, self.systemd['_main'][k])
     out += header_h1('Sysctl')
     out += header_h2('kernel.')
     out += key_val_h2('hostname', self.sysctl_fetch('kernel.hostname'),
                       ' = ')
     out += key_val_h2('osrelease', self.sysctl_fetch('kernel.osrelease'),
                       ' = ')
     out += key_val_h2('shmall', self.sysctl_fetch('kernel.shmall'),
                       ' [4-KiB pages, max size of shared memory] = ')
     out += key_val_h2('shmmax', self.sysctl_fetch('kernel.shmmax'),
                       ' [max segment size in bytes] = ')
     out += key_val_h2('shmmni', self.sysctl_fetch('kernel.shmmni'),
                       ' [max number of segments] = ')
     out += key_val_h2('sched_min_granularity_ns',
                       self.sysctl_fetch('kernel.sched_min_granularity_ns'),
                       ' [nanosecs, min execution time] = ')
     out += key_val_h2('sched_latency_ns',
                       self.sysctl_fetch('kernel.sched_latency_ns'),
                       ' [nanosecs, rescheduling] = ')
     out += header_h2('fs.')
     out += key_val_h2('file-max', self.sysctl_fetch('fs.file-max'),
                       ' [fd system] = ')
     out += key_val_h2('nr_open', self.sysctl_fetch('fs.nr_open'),
                       ' [fd per proc] = ')
     out += key_val_h2('file-nr', self.sysctl_fetch('fs.file-nr'),
                       ' [fd: open, 0, max] = ')
     out += key_val_h2('inode-nr', self.sysctl_fetch('fs.inode-nr'),
                       ' [inode cache: total, free] = ')
     out += header_h2('vm.')
     out += key_val_h2(
         'dirty_ratio', self.sysctl_fetch('vm.dirty_ratio'),
         ' [% of RAM for dirty pages, only if dirty_bytes=0] = ')
     out += key_val_h2('dirty_bytes', self.sysctl_fetch('vm.dirty_bytes'),
                       ' [bytes for dirty pages] = ')
     out += key_val_h2(
         'dirty_background_ratio',
         self.sysctl_fetch('vm.dirty_background_ratio'),
         ' [% of RAM then flusher start, only if dirty_background_bytes=0] = '
     )
     out += key_val_h2('dirty_background_bytes',
                       self.sysctl_fetch('vm.dirty_background_bytes'),
                       ' [bytes then flusher start] = ')
     out += key_val_h2('dirty_expire_centisecs',
                       self.sysctl_fetch('vm.dirty_expire_centisecs'),
                       ' [max age of dirty data] = ')
     out += key_val_h2('dirty_writeback_centisecs',
                       self.sysctl_fetch('vm.dirty_writeback_centisecs'),
                       ' [flusher wakeup timer] = ')
     out += key_val_h2('overcommit_memory',
                       self.sysctl_fetch('vm.overcommit_memory'),
                       ' [overcommit policy] = ')
     out += key_val_h2('overcommit_ratio',
                       self.sysctl_fetch('vm.overcommit_ratio'),
                       ' [% physical RAM, if policy=2] = ')
     out += key_val_h2(
         'oom_kill_allocating_task',
         self.sysctl_fetch('vm.oom_kill_allocating_task'),
         ' [0 - heuristics, else simple kill task who triggered] = ')
     out += key_val_h2(
         'panic_on_oom', self.sysctl_fetch('vm.panic_on_oom'),
         ' [0 - no panic, 1 - panic only if only not limited (mempolicy/cpusets), 2 - panic] = '
     )
     out += key_val_h2('swappiness', self.sysctl_fetch('vm.swappiness'),
                       ' [how aggressive use swap] = ')
     out += key_val_h2('nr_hugepages', self.sysctl_fetch('vm.nr_hugepages'),
                       ' [count of persistent huge page pool] = ')
     out += key_val_h2('nr_overcommit_hugepages',
                       self.sysctl_fetch('vm.nr_overcommit_hugepages'),
                       ' [max count of additional huge pages] = ')
     out += header_h1('Mount')
     out += format_raw_h1(self.df_raw)
     out += header_h1('Disks')
     for disk in self.block_info:
         out += key_val_h1(
             disk, 'Scheduler: {0} Queue: {1}'.format(
                 self.block_info[disk]['scheduler'],
                 self.block_info[disk]['nr_requests']))
     out += header_h1('IOstat')
     if not self.is_empty(self.iostat_raw):
         out += format_raw_h1(self.iostat_raw)
     out += header_h1('LVM')
     if not self.is_empty(self.vgs_raw):
         out += format_raw_h1(self.vgs_raw)
     if not self.is_empty(self.lvs_raw):
         out += format_raw_h1(self.lvs_raw)
     out += header_h1('Raid')
     if not self.is_empty(self.raid):
         for raid in self.raid:
             out += key_val_h1('Controller', raid)
     out += header_h1('Sockstat')
     for line in self.sockstat.split("\n"):
         try:
             key, val = line.split(":")
             out += key_val_h1(key, val)
         except:
             pass
     out += header_h1('LSPCI')
     for line in self.pci_network_devices:
         out += key_val_h1('net', line)
     for line in self.pci_storage_devices:
         out += key_val_h1('storage', line)
     return out