PgOSQuery: Expose the operating system as a Postgres database
github.com
github.com
Wow. That does look easy.
Or I guess you could start from the other direction, and make a FDW/Multicorn-compatible API for SQLite? (Facebook's OSQuery is SQLite-based, but it looks like the virtual table interface over there is way more complex)
The interface is not quite as nice as Multicorn's but certainly nicer than the C/C++ SQLlite interface. But you could probably create a wrapper around apsw so it looked similar to Multicorn.
It could be made a bit more efficient by filtering the processes[1], but the code would not look nearly as lovely.
1. http://multicorn.org/implementing-an-fdw/#idoptimizations
It's amazing to see how with the multicorn[2] FDW it takes less than 40 lines of python to put this together.
Step 1: The OS-as-Postgres-DB system in this thread.
Step 2: FUSE filesystem wrapping the DB, as in https://github.com/petere/postgresqlfs
Q.E.D.
if (geteuid() == 0)
{
write_stderr("\"root\" execution of the PostgreSQL server is not permitted.\n"
"The server must be started under an unprivileged user ID to prevent\n"
"possible system security compromise. See the documentation for\n"
"more information on how to properly start the server.\n");
exit(1);
}One thing I am planning on doing is to let the user mix in just about any data source: any list of objects with properties/values can be used really. So you can take your database (in proprietary format) and join it up with a text file (quite a useful thing for me). But you could also mix in an API call (again done using your identity). I've been thinking about how many REST APIs suport a subset of SQL via letting you seletct what fields to output, how to order things etc. -- if you instead allow the user to process it via SQL/sqlite you will allow the user quite powerful remixing/aggregation facilities.
http://www.oid-info.com/get/1.3.6.1.2.1.25.4.2.1
or
I guess using SQL instead of regex is the benefit you mean? Certainly more readable.
Not that it really matters much to conversation at hand but standard SQL is not really that much older than SNMP. Both were late 80s if memory serves.
Of course, SQL was around quite a while before being standardized.
I'm not sure how to use snmptable, as I've never had the need, and while I suspect in the simple cases it may be easier to learn and use than SQL, I'm highly skeptical the medium complexity cases that SQL handles are even possible in it (unless it has a fairly well fleshed out query language of it's own, as opposed to specifying parameters on a command line).
(I actually understand completely why SNMP uses OIDs, and why they actually have advantages, but man is it tough to get into SNMP)
~/$ ps af | perl -lne 's/(^\s+|\s+$)//g;next if(!@h&&(@h=split(/\s+/,$_)));@_=map{s/"/\\"/g;$_}split(/\s+/,$_,@h);print "INSERT INTO process_table (".join(",",@h).") VALUES (".join(",",map{"\"$_\""}@_).");"'
INSERT INTO process_table (PID,TTY,STAT,TIME,COMMAND) VALUES ("19789","pts/8","Ss+","0:00","/bin/bash");
INSERT INTO process_table (PID,TTY,STAT,TIME,COMMAND) VALUES ("30616","pts/23","Ss+","0:00","/bin/bash");
INSERT INTO process_table (PID,TTY,STAT,TIME,COMMAND) VALUES ("29661","pts/22","Ss+","0:00","/bin/bash");Ironic, I know.
In the 30 minutes where the example was moved to the top, so you could see it without scrolling: 30 upvotes.
Given the fast-paced nature of HN, getting to the point ASAP seems to have significant merit. All the other projects that I've announced on HN, with weeks of work put into them, and websites which expect the user to spend 5 minutes reading before they get the point, have had no upvotes or comments at all :-P
It is a more informal version of papers having an abstract on the front page.
I'm not particularly fond myself of that name having caught on for that use, but I can't manage to be as put-off by it as you say you are.
Abstract:
Content: