Python based scripts for obtaining system information from Linux.

Overview

sysinfo

Python based scripts for obtaining system information from Linux.

  • Python2 and Python3 compatible
  • Output in JSON format
  • Simple scripts and extensible structure
  • Parallel commands execution
  • Output to stdout or file
  • Output can be processed by jq

Command-line arguments

usage: sysinfo.py [-h] [--all] [--error] [--info] [--list] [--output OUTPUT]
                  [--pool POOL] [--verbose]
                  [commands [commands ...]]

positional arguments:
  commands              Commands

optional arguments:
  -h, --help            show this help message and exit
  --all, -a             Execute all commands.
  --error, -e           Show only error outputs from commands.
  --info, -i            List all commands with command line arguments.
  --list, -l            List all commands.
  --output OUTPUT, -o OUTPUT
                        Path to the output file.
  --pool POOL, -p POOL  Pool size for parallel execution of commands. (default
                        value is 5)
  --verbose, -v         Add more info to output - options, commands, raw
                        command result.

Examples

Standart JSON output

python2 sysinfo.py lscpu
{
    "lscpu": {
        "output": {
            "architecture": "armv6l",
            "bogomips": "996.14",
            "byteOrder": "Little Endian",
            "coresPerSocket": "1",
            "cpuMaxMhz": "1000.0000",
            "cpuMinMhz": "700.0000",
            "cpus": "1",
            "flags": "half thumb fastmult vfp edsp java tls",
            "model": "7",
            "modelName": "ARM1176",
            "onLineCpusList": "0",
            "sockets": "1",
            "stepping": "r0p7",
            "threadsPerCore": "1",
            "vendorId": "ARM"
        }
    }
}

Get single value

python2 sysinfo.py lscpu | jq -r ".lscpu.output.modelName"
ARM1176

Output in CSV format

python2 sysinfo.py lsblk | jq -r ".lsblk.output[] | [.name, .label, .size,
.mountpoint] | @csv"
"mmcblk0","","14.6G",""
"mmcblk0boot0","","4M",""
"mmcblk0boot1","","4M",""
"mmcblk0p1","boot","256M","/boot"
"mmcblk0p2","rootfs","14.3G","/"

Resources

Available commands

blkid                     - Block device attributes
blockdev                  - Block device ioctls
busctl                    - Introspect the bus
chrt                      - Scheduling attributes of all the tasks (threads)
dev_disk                  - Disk devices mapping
df                        - Report file system disk space usage
dmidecode                 - Dumping all information from DMI (SMBIOS)
dmidecode_baseboard       - Dumping BASEBOARD information from DMI (SMBIOS)
dmidecode_bios            - Dumping BIOS information from DMI (SMBIOS)
dmidecode_cache           - Dumping CACHE information from DMI (SMBIOS)
dmidecode_chassis         - Dumping CHASSIS information from DMI (SMBIOS)
dmidecode_connector       - Dumping CONNECTOR information from DMI (SMBIOS)
dmidecode_memory          - Dumping MEMORY information from DMI (SMBIOS)
dmidecode_processor       - Dumping CHASSIS information from DMI (SMBIOS)
dmidecode_slot            - Dumping SLOT information from DMI (SMBIOS)
dmidecode_system          - Dumping SYSTEM information from DMI (SMBIOS)
dnf_installed             - DNF - list installed packages
dnf_repolist              - DNF - defined repositories
env                       - Environment variables
etc_default               - Default configuration for programs
etc_fstab                 - Filesystems mounted on boot
etc_group                 - Groups essential information
etc_hosts                 - Maps hostnames to IP addresses
etc_locale_gen            - Configuration file for locale-gen
etc_mtab                  - Currently mounted filesystems
etc_passwd                - Attributes of each user or account on a computer
etc_release               - OS release info
etc_shadow                - Shadow database of the passwd file
etc_timezone              - Timezone settings
fbset                     - Show frame buffer device settings
fbset_info                - Show frame buffer device information
findmnt                   - List all mounted filesytems
free                      - Amount of free and used memory in the system
getconf                   - Configuration variables for the current system and their values
groups                    - Group names
hardware_platform         - Hardware platform
hostnamectl               - Current system hostname and related information
ifconfig                  - List all interfaces which are currently available, even if down
jobs                      - Job names, if job control is active
kernel_name               - Kernel name
kernel_release            - Kernel release
kernel_version            - Kernel version
lsblk                     - Lists information about all block devices
lscpu                     - Information about the CPU architecture
lsmod                     - Show the status of modules in the Linux Kernel
lsns                      - Block device ioctls
lsof                      - Information about files opened by processes
lspci                     - List all PCI devices
lsusb                     - List USB devices
machine                   - Machine hardware name
modinfo                   - Information about a Linux Kernel modules
nodename                  - Network node hostname
operating_system          - Operating system
parted                    - Lists partition layout on all block devices
proc_cmdline              - Parameters passed to the kernel at the time it is started
proc_consoles             - Information about current consoles including tty
proc_cpuinfo              - Type of processor used by your system
proc_crypto               - Installed cryptographic ciphers used by the Linux kernel
proc_devices              - Installed cryptographic ciphers used by the Linux kernel
proc_diskstats            - I/O statistics of block devices
proc_dma                  - List of the registered ISA DMA channels in use
proc_filesystems          - List of the file system types currently supported by the kernel
proc_fs                   - File system parameters
proc_iomem                - Map of the system's memory for each physical device
proc_ioports              - List of currently registered port regions used for input or output communication with a device
proc_loadavg              - Load average in regard to both the CPU and IO over time
proc_locks                - Files currently locked by the kernel
proc_meminfo              - Reports a large amount of valuable information about the systems RAM usage
proc_modules              - List of all modules loaded into the kernel
proc_mounts               - List mounted filesystems (info provides from kernel)
proc_partitions           - Partition block allocation information
proc_scsi                 - List of every recognized SCSI device
proc_swaps                - Measures swap space and its utilization
proc_sys                  - Information about the system and kernel features
proc_uptime               - Information detailing how long the system has been on since its last restart
proc_version              - Version of the Linux kernel, the version of gcc used to compile the kernel, and the time of kernel compilation
proc_vmstat               - Detailed virtual memory statistics from the kernel
processor                 - Processor type
prtstat                   - Print statistics of a processes
ps                        - Report a snapshot of the current processes
python_pip_packages       - List available python modules
python_platform           - Probe the underlying platform's hardware, operating system, and Python interpreter version information
rpm                       - Querying all RPM packages
services                  - Service names
services_list             - Displays services with status
services_params           - Displays services with status
shell_alias               - Shell alias names
shell_all_commands        - Shell command names
shell_builtins            - Names of shell builtin commands
shell_exported_variables  - Names of exported shell variables
shell_variables           - Names of all shell variables
sysctl                    - Runtime kernel parameters
sysctl_system             - Runtime kernel parameters from all system configuration files
timedatectl               - System time and date
udevadm                   - Queries the udev database for device information stored in the udev database
udevadm_block_devices     - Queries the udev database for block device information stored in the udev database
users                     - User names
vmstat_disk               - Report disk statistics
vmstat_disk_sum           - Report some summary statistics about disk activity
vmstat_forks              - Displays the number of forks since boot
vmstat_stats              - Displays a table of various event counters and memory statistics
yum_installed             - YUM - list installed packages
yum_repolist              - YUM - defined repositories
You might also like...
System Information Utility With Python

System-Information-Utility This is a simple utility, for the terminal, which allows you to find out information about your PC. It's very easy to run t

A student information management system in Python
A student information management system in Python

Student-information-management-system 本项目是一个学生信息管理系统,这个项目是用Python语言实现的,也实现了图形化界面的显示,同时也实现了管理员端,学生端两个登陆入口,同时底层使用的是Redis做的数据持久化。 This project is a stude

Scripts used in the RayStation medical radiation dosimetry treatment planning system

Med Phys Scripts These are scripts that I, the medical physics assistant at Cookeville Regional Medical Center, wrote for use in our radiation therapy

Custom SLURM wrapper scripts to make finding job histories and system resource usage more easily accessible

SLURM Wrappers Executables job-history A simple wrapper for grabbing data for completed and running jobs. nodes-busy Developed for the HPC systems at

Collection of system-wide scripts that I use on my Gentoo

linux-scripts Collection of scripts that I use on my Gentoo machine. I tend to put all scripts in /scripts directory. It is not likely that you would

A free and powerful system for awareness and research of the American judicial system.

CourtListener Started in 2009, CourtListener.com is the main initiative of Free Law Project. The goal of CourtListener.com is to provide high quality

System Design Assignments as part of Arpit's System Design Masterclass
System Design Assignments as part of Arpit's System Design Masterclass

System Design Assignments The repository contains a set of problem statements around Software Architecture and System Design as conducted by Arpit's S

Set of scripts that schedules employees for shifts throughout the week based on availability, shift times, and shift necessities

Automatic-Scheduler Set of scripts that schedules employees for shifts throughout the week based on availability, shift times, and shift necessities *

Unofficial package for fetching users information based on National ID Number (Tanzania)

Nida Unofficial package for fetching users information based on National ID Number made by kalebu Installation You can install it directly or using pi

Comments
  • --all argument fails to run

    --all argument fails to run

    --all argument currently fails with error that buffer is not big enough for all the columns as shown below-

    saksinh@cmtcleu60844879:~/sysinfo$ python3 sysinfo.py --all ['ro', 'ra', 'ssz', 'bsz', 'startsec', 'size', 'device'] [4, 4, 5, 5, 10, 6, 6] ['name', 'pid', 'process', 'user', 'connection', 'unit', 'session', 'description'] [52, 7, 17, 17, 15, 27, 9, 11] Traceback (most recent call last): File "sysinfo.py", line 190, in <module> main(sys.argv) File "sysinfo.py", line 187, in main run (args) File "sysinfo.py", line 140, in run parsed = parser(result.get('stdout', None), result.get('stderr', None)) File "modules/busctl.py", line 7, in parser output = parseTable(stdout) File "modules/sysinfo_lib.py", line 71, in parseTable cols = unpack(packTemplate, bytes(line + (' ' * (totalLength - len(line))), 'utf-8')) struct.error: unpack requires a buffer of 1168 bytes

    opened by disdi 2
Owner
Petr Vavrin
Petr Vavrin
Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

WayDroid 4.7k Jan 8, 2023
LSO, also known as Linux Swap Operator, is a software with both GUI and terminal versions that you can manage the Swap area for Linux operating systems.

LSO - Linux Swap Operator Türkçe - LSO Nedir? LSO, diğer adıyla Linux Swap Operator Linux işletim sistemleri için Swap alanını yönetebileceğiniz hem G

Eren İnce 4 Feb 9, 2022
List of Linux Tools I put on almost every linux / Debian host

Linux-Tools List of Linux Tools I put on almost every Linux / Debian host Installed: geany --> GUI editor/ notepad++ like chkservice --> TUI Linux ser

Stew Alexander 20 Jan 2, 2023
Organize seu linux - organize your linux

OrganizeLinux Organize seu linux - organize your linux Organize seu linux Uma forma rápida de separar arquivos dispersos em pastas. formatos a serem c

Marcus Vinícius Ribeiro Andrade 1 Nov 30, 2021
Linux Security and Monitoring Scripts

Linux Security and Monitoring Scripts These are a collection of security and monitoring scripts you can use to monitor your Linux installation for sec

Andre Pawlowski 65 Aug 27, 2022
python scripts - mostly automation scripts

python python scripts - mostly automation scripts You can set your environment in various ways bash #!/bin/bash python - locally on remote host #!/bi

Enyi 1 Jan 5, 2022
Show Public IP Information In Linux Taskbar

IP Information In Linux Taskbar ?? How Use IP Script? ?? Download ip.py script and save somewhere in your system. Add command applet in your taskbar a

HOP 2 Jan 25, 2022
Linux Pressure Stall Information (PSI) Status App

Linux Pressure Stall Information (PSI) Status App psistat is a simple python3 program to display the PSIs and to capture/display exception events. psi

Joe D 3 Sep 18, 2022
LINUX-AOS (Automatic Optimization System)

LINUX-AOS (Automatic Optimization System)

null 1 Jul 12, 2022
The Begin button and menu for the Meadows operating system. The start button for UNIX/Linux.

By: Seanpm2001, Meadows Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrikaans Afri

Sean P. Myrick V19.1.7.2 4 Aug 28, 2022