Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
NAME=sysinfo
IMAGE_NAME=sysinfo

ifndef VERSION
VERSION := $(shell python3 -c "from setup import find_version;find_version("src/sysinfo/__init__.py")" || echo 0.0.0)
endif

ifndef BRANCH
BRANCH := $(shell git branch --show-current)
endif

ifndef COMMIT
COMMIT := $(shell git log -n1 --format="%h")
endif

ifndef SRC
SRC := src/sysinfo/*.py
endif

ifndef TESTS
TESTS := src/tests
endif

BUILD_RUN=docker run --rm "$(IMAGE_NAME):$(COMMIT)"

.PHONY: git black lint build test coverage security

git:
@echo $(branch: [$(BRANCH)] commit: [$(COMMIT)])

black:
isort $(SRC)
black $(SRC)
autoflake --remove-all-unused-imports --remove-duplicate-keys --expand-star-imports --recursive --in-place $(SRC)

lint:
flake8 --max-line-length=120 --max-complexity 8 $(SRC)
interrogate $(SRC)
mypy $(SRC)
pylint -d C0301 -d R0902 $(SRC)

build:
python setup.py build

install:
python setup.py install

build_docker:
docker build -t $(IMAGE_NAME):$(COMMIT) . -f docker/build.Dockerfile

test_docker:
docker build -t $(IMAGE_NAME):$(COMMIT) . -f docker/test.Dockerfile

test:
pytest $(TESTS)

coverage:
pytest --cov-report term-missing --cov=sysinfo $(TESTS)

security:
safety check
bandit -r $(SRC)
83 changes: 62 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ positional arguments:
optional arguments:
-h, --help Show this help message and exit
--all, -a Execute all commands.
--camel-case, -c Convert keys to CamelCase.
--error, -e Show only error outputs from commands.
--export-only Export output from commands without processing.
--export-dir PATH Path to the directory for saving output from commands.
Expand All @@ -32,13 +33,14 @@ optional 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)
--system SYSTEM, -s SYSTEM Execute or parse commands for selected system [linux, darwin, java, windows].
--verbose, -v Add more info to output - options, commands, raw command result.
```
## Examples

### Standart JSON output
```
python2 sysinfo.py lscpu
python sysinfo.py lscpu
```
```json
{
Expand Down Expand Up @@ -66,15 +68,15 @@ python2 sysinfo.py lscpu

### Get single value
```
python2 sysinfo.py lscpu | jq -r ".lscpu.output.modelName"
python sysinfo.py lscpu | jq -r ".lscpu.output.modelName"
```
```
ARM1176
```

### Output in CSV format
```
python2 sysinfo.py lsblk | jq -r ".lsblk.output[] | [.name, .label, .size,
python sysinfo.py lsblk | jq -r ".lsblk.output[] | [.name, .label, .size,
.mountpoint] | @csv"
```

Expand All @@ -101,12 +103,21 @@ sudo python sysinfo.py --import-dir ./out blkid
* [jq](https://stedolan.github.io/jq/)

## Available commands

### Linux

```
arp - System ARP cache
blkid - Block device attributes
blockdev - Block device ioctls
blockdev_detail - Block device ioctls details
busctl - Introspect the bus
busctl_status - Process information and credentials of a bus service
busctl_tree - Object tree for services
chage - Users password expiration information
chrt - Scheduling attributes of all the tasks (threads)
dev_disk - Disk devices mapping
dev_input - Input devices mapping
df - Report file system disk space usage
dmidecode - Dumping all information from DMI (SMBIOS)
dmidecode_baseboard - Dumping BASEBOARD information from DMI (SMBIOS)
Expand Down Expand Up @@ -136,26 +147,29 @@ 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
groups - Group names (compgen)
hardware_platform - Hardware platform (uname)
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
jobs - Job names, if job control is active (compgen)
kernel_name - Kernel name (uname)
kernel_release - Kernel release (uname)
kernel_version - Kernel version (uname)
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
machine - Machine hardware name (uname)
modinfo - Information about a Linux Kernel modules
nodename - Network node hostname
operating_system - Operating system
nodename - Network node hostname (uname)
operating_system - Operating system (uname)
parted - Lists partition layout on all block devices
proc_buddyinfo - Memory fragmentation
proc_bus_input - Input devices
proc_cgroups - Control groups
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
Expand All @@ -172,37 +186,64 @@ 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_net_arp - ARP
proc_net_ax25_route - AX25 routing information
proc_net_ipx_route - IPX routing information
proc_net_route - IP routing information
proc_net_tcp - TCP socket table
proc_net_tcp6 - TCP6 socket table
proc_net_udp - UDP socket table
proc_net_udp6 - UDP6 socket table
proc_partitions - Partition block allocation information
proc_scsi - List of every recognized SCSI device
proc_slabinfo - Kernel caches informations
proc_stat - Kernel/system statistics
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_version_signature - OS version signature
proc_vmstat - Detailed virtual memory statistics from the kernel
processor - Processor type
processor - Processor type (uname)
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
route - IP routing table
rpm - Querying all RPM packages
services - Service names
services - Service names (compgen)
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
services_params - Displays services with params
shell_alias - Shell alias names (compgen)
shell_all_commands - Shell command names (compgen)
shell_builtins - Names of shell builtin commands (compgen)
shell_exported_variables - Names of exported shell variables (compgen)
shell_variables - Names of all shell variables (compgen)
sysctl - Runtime kernel parameters
sysctl_system - Runtime kernel parameters from all system configuration files
timedatectl - System time and date
timedatectl_timesync - Status of systemd-timesyncd.service
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
update_alternatives - Symbolic links determining default commands
users - User names (compgen)
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
```

### Windows

```
arp - System ARP cache
assoc - File associations
driverquery - List of installed device drivers.
driverquery_signed - List of installed device signed drivers.
tasklist - Get currently running processes
tasklist_apps - Get services hosted in each process
tasklist_modules - Get modules loaded in each process
tasklist_services - Get services hosted in each process
```
14 changes: 14 additions & 0 deletions docker/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.10-alpine
# LABEL instruction creates labels.
LABEL "maintainer"="Petr Vavrin" "appname"="sysinfo"

ENV applocation /usr/src
COPY src/sysinfo $applocation/sysinfo
ENV app $applocation/sysinfo
WORKDIR $app/

RUN apk add --update python py-pip
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
#EXPOSE 5000
CMD ["python", "sysinfo.py"]
28 changes: 28 additions & 0 deletions docker/test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM python:3.10-alpine
# LABEL instruction creates labels.
LABEL "maintainer"="Petr Vavrin" "appname"="sysinfo"

ENV applocation /usr/src
COPY src/sysinfo $applocation/sysinfo
COPY src/tests $applocation/tests
ENV app $applocation/sysinfo
ENV tests $applocation/tests
WORKDIR $app/

RUN apk add --update python py-pip && \
pip install --upgrade pip && \
pip install -r requirements-test.txt && \
isort $app && \
black $app && \
autoflake --remove-all-unused-imports --remove-duplicate-keys --expand-star-imports --recursive --in-place $app && \
flake8 --max-line-length=120 --max-complexity 8 $app && \
interrogate $app && \
mypy $app && \
pylint -d C0301 -d R0902 $app && \
pytest $tests && \
pytest --cov-report term-missing --cov=sysinfo $tests && \
safety check && \
bandit -r $app

#EXPOSE 5000
CMD ["python", "sysinfo.py"]
33 changes: 0 additions & 33 deletions modules/blkid.py

This file was deleted.

16 changes: 0 additions & 16 deletions modules/blockdev.py

This file was deleted.

16 changes: 0 additions & 16 deletions modules/busctl.py

This file was deleted.

29 changes: 0 additions & 29 deletions modules/chrt.py

This file was deleted.

Loading