LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Integrating bash with sql. (https://www.linuxquestions.org/questions/linux-newbie-8/integrating-bash-with-sql-825726/)

pinga123 08-12-2010 02:41 AM

Integrating bash with sql.
 
Hi Guys,
I m just curious to know whether it is possible to store the output of a shell command to a database .

My main aim is to use a full capacity of sql language to analyze the output generated by shell script.
for example.

by storing the 5 instances of of top at different interval we can simply predict lot of things like.
Which process has Maximum cpu utilization, Which user has maximum processes running.
I think writing a scripts for doing these tasks will require lot of overheads and file creation.

I hope i have clear my point .Please reply if any further clarification is required.

acid_kewpie 08-12-2010 03:17 AM

Sure it's possible, you might want to look at something lightweight like sqlite which basically pretends to be a full sql database but is actually just a small file, which makes using it really simple. You can just pipe SQL commands into the sqlite program directly. e.g. "echo select * from mytable | sqlite mydb.sql". This is also pretty trivial with other proper DB's like mysql or postgresql.

Alternatively why not use a proper program to do this? It's not GPL software, but Splunk is an amazingly good tool for doing exactly what you want, running arbitrary commands and reading any log data and then hacking about the output to provide all osrts of graphs and data baout the logs.

pinga123 08-12-2010 04:46 AM

Quote:

Originally Posted by acid_kewpie (Post 4063835)
Sure it's possible, you might want to look at something lightweight like sqlite which basically pretends to be a full sql database but is actually just a small file, which makes using it really simple. You can just pipe SQL commands into the sqlite program directly. e.g. "echo select * from mytable | sqlite mydb.sql". This is also pretty trivial with other proper DB's like mysql or postgresql.

Alternatively why not use a proper program to do this? It's not GPL software, but Splunk is an amazingly good tool for doing exactly what you want, running arbitrary commands and reading any log data and then hacking about the output to provide all osrts of graphs and data baout the logs.

We are using Oracle enterprise manager as an alternative to Splunk.However i will try the sqlite seems goods but i m yet to explore the it. I will share my views if found useful.


All times are GMT -5. The time now is 07:28 AM.