Hello, not quite sure if this is the best place to ask this but here it goes.

I'm currently in the process of creating a intranet site for my company and would like to know if it’s possible to have something like a status page where you can see the usage of our server (unix). I can manually check the usage when logging onto the server using AIX (v4) with a username, password and using the command: topas this gives me the idle status which I need.

So my question is, can I do the same or similar thing using php or is there a program/script already out there that does something like this.

Thanks

Mark

    You could try:

    $topas = `topas`;  // note that those are "back-ticks", not single quotes.
    echo "<pre>$topas</pre>\n";
    

    This may or may not work, depending on a number of configuration options, environment settings, permissions, etc. You may need to give the full path to the "topas" command if the user under whom your PHP scripts are run does not have the requisite path setting to find it just by the filename.

      first of all thanks for the fast reply.
      how would the script connect to the unix server in the first place?

        I was making the possibly mistaken assumption that the server in question was the one on which your PHP script would be running. If that is not the case, then things get more complicated, as you would need to somehow establish a connection with that server. Off the top of my head, I do not know a convenient way of doing that from within a PHP script.

          You could put NogDog's script on the server which reports, then access the page from any browser connected to the intranet.

            yeah the unix server and the host server are on two different machines, but i will give kudose's idea a try.. thanks, keep you posted.

              unfortunately i cant write to the server, so is it possible to connect via a script that sits on the intranet server?

                7 days later
                NogDog wrote:

                I was making the possibly mistaken assumption that the server in question was the one on which your PHP script would be running. If that is not the case, then things get more complicated, as you would need to somehow establish a connection with that server. Off the top of my head, I do not know a convenient way of doing that from within a PHP script.

                i dont think you have had any thoughts about this. cant blame you, however does any one else have any idea on how i could do this?

                explain it a bit better:

                I am currently running apache server on a windows pc and from here i need to get access to the other server (unix, same network).

                  Possibly you could do something with the [man]expect[/man] extension?

                    ok here is an update.

                    to test if i can connect to my server via ssh2 im just running this little script but every time i open the file.php my cpu usage goes to 50% (taskmanager says httpd.exe) even when i close the window, when i run it again it goes to 100%.

                    what am i doing wrong? ip of server, username and password are all correct

                    <?php 
                    echo "line 1";
                    $connection = ssh2_connect('ip', 23); 
                    
                    echo "line 2";
                    ssh2_auth_password($connection, 'user', 'pass'); 
                    
                    echo "line 3";
                    $stream = ssh2_exec($connection, 'cd /data/msoft'); 
                    
                    echo "line 4";
                    echo $stream;
                    ?> 

                    the error message im getting is:

                    Warning: ssh2_connect() [function.ssh2-connect]: Unable to connect to 172.19.1.38 on port 22 in C:\www\webroot\test\test.php on line 2
                    
                    Warning: ssh2_connect() [function.ssh2-connect]: Unable to connect to 172.19.1.38 in C:\www\webroot\test\test.php on line 2
                    
                    Fatal error: Maximum execution time of 30 seconds exceeded in C:\www\webroot\test\test.php on line 2

                      ok i think i've managed to get at least something.
                      (see code and images)

                      i want to get the value next to idle but dont quite know how i can do that. and also the value does not display on the output (image 2). any one know y that is?

                      image 1
                      image 2

                      <? 
                      	$username='root';
                      	$password='sibi123';
                      
                      $header1=(	
                      			chr(0xFF).chr(0xFB).chr(0x1F).chr(0xFF).chr(0xFB).chr(0x20).chr(0xFF).chr(0xFB).chr(0x18).chr(0xFF).chr(0xFB).chr(0x27).chr(0xFF).chr(0xFD).chr(0x01).
                      			chr(0xFF).chr(0xFB).chr(0x03).chr(0xFF).chr(0xFD).chr(0x03).chr(0xFF).chr(0xFC).chr(0x23).chr(0xFF).chr(0xFC).chr(0x24).chr(0xFF).chr(0xFA).chr(0x1F).chr(0x00).chr(0x50).
                      			chr(0x00).chr(0x18).chr(0xFF).chr(0xF0).chr(0xFF).chr(0xFA).chr(0x20).chr(0x00).chr(0x33).chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0x2C).chr(0x33).chr(0x38).chr(0x34).
                      			chr(0x30).chr(0x30).chr(0xFF).chr(0xF0).chr(0xFF).chr(0xFA).chr(0x27).chr(0x00).chr(0xFF).chr(0xF0).chr(0xFF).chr(0xFA).chr(0x18).chr(0x00).chr(0x58).chr(0x54).chr(0x45).
                      			chr(0x52).chr(0x4D).chr(0xFF).chr(0xF0)
                      		); 
                      
                      $header2=(	
                      			chr(0xFF).chr(0xFC).chr(0x01).chr(0xFF).chr(0xFC).chr(0x22).chr(0xFF).chr(0xFE).chr(0x05).chr(0xFF).chr(0xFC).chr(0x21)
                      		);
                      
                      $fp=pfsockopen("172.19.1.38",23); 
                      
                      fputs($fp,$header1); 
                      sleep(1); 
                      fputs($fp,$header2); 
                      sleep(1); 
                      
                      fputs($fp,"$username\r"); 
                      sleep(1); 
                      fputs($fp,"$password\r"); 
                      sleep(1); 
                      fputs($fp,"\r"); 
                      sleep(3); 
                      fputs($fp,"\r"); 
                      sleep(3); 
                      fputs($fp,"q \r"); 
                      sleep(3); 
                      fputs($fp,"topas \r"); 
                      sleep(1); 
                      
                      $output=fread($fp,128); 
                      $stat=socket_get_status($fp); 
                      $output.=fread($fp, $stat["unread_bytes"]); 
                      
                      $output = explode("\n", $output); 
                      unset($output['0']); 
                      $output = implode("\n", $output); 
                      
                      $output = str_replace("\n", "<br>", $output); 
                      echo $output; 
                      fclose($fp); 
                      ?> 
                        Write a Reply...