Categorygithub.com/noborus/psutilsql
modulepackage
0.0.5
Repository: https://github.com/noborus/psutilsql.git
Documentation: pkg.go.dev

# README

psutilsql

PkgGoDev

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.

psutilsql.gif

install

go get -u github.com/noborus/psutilsql...

psutilsql depends on go-sqlite3. Therefore, gcc is required to build.

Usage

psutilsql command

SQL

The 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 |
+-------------+------------+------------+

Table list

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

Command

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

Flags:
  -d, --Delimiter string   output delimiter (CSV only) (default ",")
  -O, --Header             output header (CSV only)
  -o, --OutFormat string   output format=at|csv|ltsv|json|tbln|raw|md|vf (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.

cpu

--time: cpu time(default)

CPUUserSystemIdleNiceIowaitIrqSoftirqStealGuestGuestNice

--info, -i: cpu info

CPUVendorIDFamilyModelSteppingPhysicalIDCoreIDCoresModelNameMhzCacheSizeFlagsMicrocode

--percent,-p: cpu percent

disk

--partition: disk partition(default)

DeviceMountpointFstypeOpts

--usage [disk]: disk usage

PathFstypeTotalFreeUsedUsedPercentInodesTotalInodesUsedInodesFreeInodesUsedPercent

docker

ContainerIDNameImageStatusRunning

host

--info: host information(default)

HostnameUptimeBootTimeProcsOSPlatformPlatformFamilyPlatformVersionKernelVersionVirtualizationSystemVirtualizationRoleHostID

--user,-u: user information

UserTerminalHostStarted

--temperatures, -t: SensorsTemperatures

SensorKeyTemperature

load

Load1Load5Load15

--misc,-m: miscellaneous host-wide statistics

ProcsTotalProcsRunningProcsBlockedCtxt

mem

VirtualMemory(default)

TotalAvailableUsedUsedPercentFreeActiveInactiveWiredLaundryBuffersCachedWritebackDirtyWritebackTmpSharedSlabSReclaimableSUnreclaimPageTablesSwapCachedCommitLimitCommittedASHighTotalHighFreeLowTotalLowFreeSwapTotalSwapFreeMappedVMallocTotalVMallocUsedVMallocChunkHugePagesTotalHugePagesFreeHugePageSize

--swap, -s: SwapMemory

TotalUsedFreeUsedPercentSinSoutPgInPgOutPgFault

net

FdFamilyTypeLaddrIPLaddrPortRaddrIPRaddrPortstatusUidsPid

process

pidnameCPUMEMSTATUSSTARTUSERRSSVMSDataStacklockedSwapCOMMAND

--ex: memory info ex

pidnameCPUMEMSTATUSSTARTUSERRSSVMSSharedTextLibDataDirtyCOMMAND

# Packages

No description provided by the author

# Functions

CPUInfoQuery executes SQL on cpu.Info.
CPUInfoReader returns cpu.Info result as trdsql.SliceReader.
CPUPercentQuery executes SQL on cpu.Percent.
CPUPercentReader returns cpu.Percent result as trdsql.SliceReader.
CPUTimeQuery executes SQL on cpu.Time.
CPUTimeReader returns cpu.Times result as trdsql.SliceReader.
DiskPartitionQuery executes SQL on disk.Partitions.
DiskPartitionReader returns disk.Partitions result as trdsql.SliceReader.
DiskUsageQuery executes SQL on disk.Usage.
DiskUsageReader returns disk.Usage result as trdsql.SliceReader.
DockerQuery executes SQL on docker.GetDockerStat.
DockerReader returns docker.GetDockerStat result as trdsql.SliceReader.
HostInfoReader returns host.Info result as trdsql.SliceReader.
HostQuery executes SQL on host.Info or host.Users or host.SensorsTemperatures.
HostTemperatureReader returns host.SensorsTemperatures result as trdsql.SliceReader.
HostUsersReader returns host.Users result as trdsql.SliceReader.
LoadAvgReader returns load.Avg result as trdsql.SliceReader.
LoadMiscReader returns load.Misc result as trdsql.SliceReader.
LoadQuery executes SQL on Load.Avg or Load.Misc.
MEMQuery executes SQL on mem.VirtualMemory or mem.SwapMemory.
NetQuery executes SQL on net.Connections.
NetReader returns net.Connections result as trdsql.SliceReader.
NewMultiImporter takes multiple readers as arguments and returns a MultiImporter.
NewProcessReader returns process.Processes result as ProcessReader.
ProcessQuery executes SQL on process.Processes.
PSTableQuery executes SQL on tables.
QueryExec actually executes the passed query and writes it to the writer.
SwapMemoryReader returns mem.SwapMemory result as trdsql.SliceReader.
TableReader return table name as trdsql.SliceReader.
VirtualMemoryReader returns mem.VirtualMemory result as trdsql.SliceReader.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author

# Structs

MultiImporter is a structure for importing multiple readers.
The ProcessReader structure represents a process and satisfies the trdsql.Reader interface.

# Interfaces

Reader is an interface that can be passed to MultiImporter.