You are not logged in.

#1 2013-11-23 23:02:26

studentik
Member
Registered: 2013-05-24
Posts: 38

sysql - use SQL queries against output of linux commands

Hello!

Many linux commands have table-like output. Sometimes it is better to analyze such output as a real table in relational database. I have published prototype of utility that parses output of one or several linux commands, saves it in database and allows to make SQL queries to that data. Program is written on python and uses sqlite database engine.

sysql at AUR
sysql at Github

Here is why I wrote it:

* No need to remember command syntax to format command output - just select necessary fields in SQL query

* No need to know sed, awk, head, join and other linux commands to manipulate with output - it's all SQLite

* Table data is stored with meaningful column name and type (int, text, float, datetime etc)

* All power of SQL can be used to query output (JOIN, WHERE, GROUP BY etc.)

* To support new command, output parser must be developed only once and then can be shared with community to make life easier

* All supported commands are kept in one place as set of python files, so it is easy to find out how to customize existing parsers or create new ones


This is my first community contribution, so kindly ask everyone to share your opinions and advices on what can be done better. Thank you!

Examples:

Display help and list of available commands:

sysql

Display output of ps command:

sysql ps

Query output of lsblk command:

sysql -q "SELECT device,uuid,filesystem FROM lsblk" lsblk 

Query output of several commands:

sysql -q "SELECT ps.pid, ps.command, ps.elapsed_time, lsof.name FROM ps JOIN lsof ON ps.pid = lsof.pid WHERE name LIKE '%LISTEN%'" ps -e --- lsof -Pni4

Offline

#2 2013-11-24 09:16:11

myname
Member
Registered: 2011-04-30
Posts: 6

Re: sysql - use SQL queries against output of linux commands

I am not sure, if I will ever use it, but I do think, this is an _amazing_ idea!
You may consider something like a global repository for output parsers accessable directly via sysql.

Last edited by myname (2013-11-24 09:16:59)

Offline

Board footer

Powered by FluxBB