CLI tool that can be processed by SQL using gopsutil library.
SQL input/output is handled by trdsql. Therefore, CSV, JSON, LTSV, MarkDown, Raw, Vertical, and TBLN can be selected as the output format.
go get -u github.com/noborus/psutilsql...psutilsql depends on go-sqlite3. Therefore, gcc is required to build.
Linux users can install prebuilt packages from the GitHub Releases page.
- Debian/Ubuntu:
*.deb - RHEL/Fedora/openSUSE:
*.rpm
Asset names are published like this:
psutilsql_<version>_linux_amd64.debpsutilsql_<version>_linux_amd64.rpmpsutilsql_<version>_linux_386.debpsutilsql_<version>_linux_386.rpmpsutilsql_<version>_linux_arm64.debpsutilsql_<version>_linux_arm64.rpm
Example:
# Debian/Ubuntu
sudo dpkg -i psutilsql_<version>_linux_amd64.deb
# RHEL/Fedora/openSUSE
sudo rpm -i psutilsql_<version>_linux_amd64.rpmIf dependencies are missing on Debian/Ubuntu, run:
sudo apt-get install -fDownload and install example (v0.1.0, amd64):
curl -fLO https://github.com/noborus/psutilsql/releases/download/v0.1.0/psutilsql_0.1.0_linux_amd64.deb
sudo dpkg -i psutilsql_0.1.0_linux_amd64.debPrecompiled binaries for psutilsql are available for various platforms and architectures. You can download them from the GitHub Releases page.
The following binaries can be downloaded from release.
- Darwin_arm64
- Darwin_x86_64
- Linux_arm64
- Linux_i386
- Linux_x86_64
- Windows_arm64
- Windows_x86_64
To install a binary, download the appropriate file for your system, extract it, and place the psutilsql executable in a directory included in your system's PATH.
For example, on a Unix-like system, you might do:
tar xvf psutilsql_Darwin_x86_64.tar.gz
mv psutilsql /usr/local/bin/psutilsql commandThe query command(<query> can be omitted) can execute SQL.
$ psutilsql query "SELECT Total,Used,Free FROM virtualmemory"
or
$ psutilsql "SELECT Total,Used,Free FROM virtualmemory"
+-------------+------------+------------+
| Total | Used | Free |
+-------------+------------+------------+
| 16687091712 | 6468083712 | 2399399936 |
+-------------+------------+------------+List of table names that can be used.
Displayed with the following command:
psutilsql table| name |
|---|
| cpuinfo |
| cpupercent |
| cputime |
| diskpartition |
| diskusage |
| docker |
| hostinfo |
| hosttemperature |
| hostuser |
| loadavg |
| loadmisc |
| net |
| process |
| processex |
| swapmemory |
| virtualmemory |
Display values using command and options without using SQL.
$ psutilsql host --users
+---------+----------+------+------------+
| User | Terminal | Host | Started |
+---------+----------+------+------------+
| noborus | tty7 | :0 | 1564096509 |
+---------+----------+------+------------+$ psutilsql --help
SQL for running processes and system utilization.
SQL can be executed on the information acquired using gopsutil library.
Default SQL is provided, so you can omit SQL if you select a command.
Usage:
psutilsql [flags]
psutilsql [command]
Available Commands:
completion Generates bash/zsh completion scripts
cpu CPU information
disk DISK information
docker docker information
help Help about any command
host host information
load load information
mem memory information
net net information
process process information
query SQL query command
table table list
version Print the version number of psutilsql
Flags:
-d, --Delimiter string output delimiter (CSV only) (default ",")
-O, --Header output header (CSV only)
-o, --OutFormat string output format=[AT|CSV|LTSV|JSON|JSONL|TBLN|RAW|MD|VF|YAML] (default "AT")
-q, --Query string query
-h, --help help for psutilsql
-t, --toggle Help message for toggle
Use "psutilsql [command] --help" for more information about a command.--time: cpu time(default)
| CPU | User | System | Idle | Nice | Iowait | Irq | Softirq | Steal | Guest | GuestNice |
|---|
--info, -i: cpu info
| CPU | VendorID | Family | Model | Stepping | PhysicalID | CoreID | Cores | ModelName | Mhz | CacheSize | Flags | Microcode |
|---|
--percent,-p: cpu percent
--partition: disk partition(default)
| Device | Mountpoint | Fstype | Opts |
|---|
--usage [disk]: disk usage
| Path | Fstype | Total | Free | Used | UsedPercent | InodesTotal | InodesUsed | InodesFree | InodesUsedPercent |
|---|
| ContainerID | Name | Image | Status | Running |
|---|
--info: host information(default)
| Hostname | Uptime | BootTime | Procs | OS | Platform | PlatformFamily | PlatformVersion | KernelVersion | VirtualizationSystem | VirtualizationRole | HostID |
|---|
--user,-u: user information
| User | Terminal | Host | Started |
|---|
--temperatures, -t: SensorsTemperatures
| SensorKey | Temperature |
|---|
| Load1 | Load5 | Load15 |
|---|
--misc,-m: miscellaneous host-wide statistics
| ProcsTotal | ProcsRunning | ProcsBlocked | Ctxt |
|---|
VirtualMemory(default)
| Total | Available | Used | UsedPercent | Free | Active | Inactive | Wired | Laundry | Buffers | Cached | Writeback | Dirty | WritebackTmp | Shared | Slab | SReclaimable | SUnreclaim | PageTables | SwapCached | CommitLimit | CommittedAS | HighTotal | HighFree | LowTotal | LowFree | SwapTotal | SwapFree | Mapped | VMallocTotal | VMallocUsed | VMallocChunk | HugePagesTotal | HugePagesFree | HugePageSize |
|---|
--swap, -s: SwapMemory
| Total | Used | Free | UsedPercent | Sin | Sout | PgIn | PgOut | PgFault |
|---|
| Fd | Family | Type | LaddrIP | LaddrPort | RaddrIP | RaddrPort | status | Uids | Pid |
|---|
| pid | name | CPU | MEM | STATUS | START | USER | RSS | VMS | Data | Stack | locked | Swap | COMMAND |
|---|
--ex: memory info ex
| pid | name | CPU | MEM | STATUS | START | USER | RSS | VMS | Shared | Text | Lib | Data | Dirty | COMMAND |
|---|
