Jump to content

Converting output to database


Boxerman
Go to solution Solved by Boxerman,

Recommended Posts

Hey guys,

 

So a short write of what i'm trying to do, i'm trying to SSH connect to a SAN to grab details about the virtual volumes on the SAN and display them on a page. The final aim is to have this run as a cron and inserted into MySQL.

 

However, I have the script below with connects perfectly and displays the information i need, however, i am at a loss on how to actually break the output up into tables..

 

for example (the exact output):

  Id Name                         Rd Mstr  Prnt Roch Rwch PPrnt PBlkRemain -----VV_WWN----- -----CreationTime------
   0 admin                        RW 2/3/1  ---  ---  ---   ---         -- 500name0405 2007-03-02 12:35:19 EST
1112 name.boot                    RW 2/3/1  ---  ---  ---   ---         -- 50002name0405 2012-02-24 16:54:48 EST
1113 name.0                       RW 3/2/1  ---  ---  ---   ---         -- 5000name90405 2012-02-24 17:16:23 EST
1171 name.1                       RW 1/3/2  ---  ---  ---   ---         -- 5000name405 2012-10-29 17:25:17 EDT
1306 name.boot                    RW 1/2/3  ---  ---  ---   ---         -- 50002name0405 2014-04-10 02:44:31 EDT
1307 name.boot                    RW 1/2/3  ---  ---  ---   ---         -- 5000name405 2014-04-10 08:49:09 EDT
1308 name.boot                    RW 1/2/3  ---  ---  ---   ---         -- 5000name0405 2014-04-10 08:50:00 EDT

AS you can see it is currently display rows called ID, Name etc..

 

how would i echo only the Name's of the the volume?

 

So the desired output is:

admin
name.boot
name.0
name.1
name.boot
name.boot
name.boot

Thanks so much for reading! hope you can help!

 

Here is my script so far:

<?PHP
//Array in place as more SAN's to be connected so writing to prepare for future SAN's
$servers = array(
    array('ip'=>'hostname','user'=>'username','pass'=>'password'));
foreach($servers as $server)
{
    $connection = ssh2_connect($server['ip'], 22);
    if (ssh2_auth_password($connection, $server['user'], $server['pass']))
    {
        $stream = ssh2_exec($connection, 'showvv -d');
        stream_set_blocking($stream, true);
        $data = '';
        while($buffer = fread($stream, 4096)) {
    $data .= $buffer;
        }
        fclose($stream);
        echo '<pre>'.$data.'</pre>';
    }
}
?>

Thanks again guys! you rock!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.