complicated question....

For system help, all hardware / software topics NOTE: use Coders Corner for all coders topics.

Moderators: Krom, Grendel

Post Reply
User avatar
Capm
DBB DemiGod
DBB DemiGod
Posts: 2267
Joined: Thu Nov 05, 1998 12:01 pm
Location: Topeka, KS
Contact:

complicated question....

Post by Capm »

Is there any way to make a script (or cronjob) or something that could log into a machine and run a command, then take the text output of that command and sort it into an mysql database from which say an MRTG graph of the data could be made?
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6539
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

Post by Jeff250 »

Like you said, you can schedule the task with cron.

You can login remotely into a machine and run a command with ssh (see `man ssh' for details):
ssh user@hostname command
edit: To avoid an interactive password prompt in your cron script, you will need to set up public/private key authentication (see Google for details).

With your remote command, use Unix pipes to take a first program's output as the input of a second.

You will have to write the second program, parse the inputted text with it, and insert the data into the database with it, so choose your favorite scripting language with regular expressions and MySQL bindings (python or perl would be good choices).

To make a pretty plot, you can have your second program also generate gnuplot script and then pipe that to a third program--gnuplot.

edit: Then scp (see `man scp') the plot from the remote server back locally. (You could vary this order somewhat, i.e., write the first program's output to a text file, scp that back locally, and then run the second and third programs locally, etc.)
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Post by fliptw »

depending on the format of the output, you could just run mysqlimport.

But it would make things easier to use something like python or perl.
Post Reply