+ Post New Thread
Page 2 of 13 FirstFirst 12345612 ... LastLast
Results 16 to 30 of 187
Wireless Networks Thread, Helpdesk network status. in Technical; Use this to execute commands: system (PHP 4, PHP 5) system — Execute an external program and display the output ...
  1. #16
    Unvalidated User
    Join Date
    Nov 2007
    Location
    the Pub
    Posts
    255
    Thank Post
    7
    Thanked 11 Times in 10 Posts
    Rep Power
    0
    Use this to execute commands:

    system

    (PHP 4, PHP 5)

    system — Execute an external program and display the output


    http://uk3.php.net/manual/en/function.system.php

  2. #17

    Join Date
    Jan 2008
    Location
    London
    Posts
    9
    Thank Post
    0
    Thanked 4 Times in 2 Posts
    Rep Power
    0
    Has anyone had any joy getting this working on a Windows IIS server? I just seem to get all my server listed as down.

  3. #18

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318
    For Windows you will need to grab the output of the ping command and parse it. We don't run PHP on Windows here so I can't help I'm afraid.

  4. #19
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,088
    Thank Post
    437
    Thanked 149 Times in 94 Posts
    Rep Power
    71
    Quote Originally Posted by webman View Post
    For Windows you will need to grab the output of the ping command and parse it. We don't run PHP on Windows here so I can't help I'm afraid.
    idot guide? so raher than have "ping $host -c 1 -w 1" you mean change to just "ping $host" ?

  5. #20

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318
    Not exactly. You only need to send one packet, and you can adjust how long you want the timeout. For example:

    Code:
    ping hostname -n 1 -w 500
    Will ping 'hostname' once and wait a maximum of 500ms for a reply. You will need to get the output from this command and parse it to see if it was successful. Ping failures will contain "Request timed out." and successful pings will have something like "Reply from " in them.

  6. Thanks to webman from:

    PEO (18th March 2008)

  7. #21
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,530
    Thank Post
    815
    Thanked 380 Times in 317 Posts
    Blog Entries
    12
    Rep Power
    80
    To get it working on IIS/Windows

    Change these 2 lines. Its just because windows returns a different message when a ping fails.

    Code:
    	$rv = exec( "ping $host -n 1 -w 1" );
    	if( $rv != "Ping request could not find host ". $host . ". Please check the name and try again." )	{
    This only works for named servers though and not the IP address as it comes back with a different reply.

    I will see if I can modify it later.
    Last edited by zag; 18th March 2008 at 12:17 PM.

  8. #22

    Join Date
    Jan 2008
    Location
    London
    Posts
    9
    Thank Post
    0
    Thanked 4 Times in 2 Posts
    Rep Power
    0
    If you want to use this on IIS/Windows and use IP addresses rather than named hosts you can use these lines in the ping function.

    Code:
    $connect = "    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss)," ;
    $rv = exec("ping $host -n 1 -w 1");
        if( $connect == $rv )
    You could combine this with the previous guys post to cover named servers and IP addresses.

  9. #23

    Join Date
    Jan 2008
    Location
    London
    Posts
    9
    Thank Post
    0
    Thanked 4 Times in 2 Posts
    Rep Power
    0
    Here is the combined code to cover using an IP address or a named server.

    Code:
    function ping($host){
    	$hostconnect = "Ping request could not find host ". $host . ". Please check the name and try again." ;
    	$ipconnect = "    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss)," ;
    	$rv = exec("ping $host -n 1 -w 1");
    	if( $ipconnect == $rv )	{
    		return false;
    	} else {
    		if( $hostconnect == $rv ) {
    		return false;
    	} else {
    		return true;
    	}
    	}
    }
    Just replace the whole of the ping function in the original code.

  10. 3 Thanks to christhack:

    PEO (18th March 2008), SimpleSi (19th June 2008), zag (18th March 2008)

  11. #24
    zag
    zag is offline
    zag's Avatar
    Join Date
    Mar 2007
    Posts
    3,530
    Thank Post
    815
    Thanked 380 Times in 317 Posts
    Blog Entries
    12
    Rep Power
    80
    I went a bit far with this Looks cool though!


  12. #25

    Sylv3r's Avatar
    Join Date
    Jul 2005
    Location
    Co. Durham
    Posts
    3,151
    Thank Post
    369
    Thanked 365 Times in 323 Posts
    Rep Power
    145
    That does look good and thats what I want to be able to do with ours. It will prove useful on our AP's and printers.

  13. #26
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,088
    Thank Post
    437
    Thanked 149 Times in 94 Posts
    Rep Power
    71
    Quote Originally Posted by ittech View Post
    I went a bit far with this Looks cool though!

    Hi could you put the code on here? looks really smart

  14. #27
    Joedetic's Avatar
    Join Date
    Jan 2006
    Location
    Walsall
    Posts
    1,316
    Thank Post
    6
    Thanked 13 Times in 13 Posts
    Rep Power
    21
    I'd be interested in getting that code too Maybe a nice RAR or Zip archive with the pages and everything in?

  15. #28
    mullet_man's Avatar
    Join Date
    Oct 2005
    Location
    Oldham
    Posts
    726
    Thank Post
    34
    Thanked 46 Times in 45 Posts
    Rep Power
    26
    I would like the code as well ittech if you don't mind sharing??


  16. #29

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,691
    Thank Post
    824
    Thanked 2,570 Times in 2,187 Posts
    Blog Entries
    9
    Rep Power
    731
    I would also be interested in checking out the code. Also I remembered a way to monitor individual service status on Windows servers using WMI I dont think that you can use it via php though just through ASP.

    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")
    
    For Each objService in colRunningServices 
        'in VBS script form
        'Wscript.Echo objService.DisplayName  & VbTab & objService.State
        'In ASP form
        Response.write objService.DisplayName  & VbTab & objService.State
    Next
    Just replace the * with your service name and the strComputer string with the name of the server.
    Last edited by SYNACK; 25th March 2008 at 06:30 PM.

  17. #30
    mullet_man's Avatar
    Join Date
    Oct 2005
    Location
    Oldham
    Posts
    726
    Thank Post
    34
    Thanked 46 Times in 45 Posts
    Rep Power
    26
    Anyone got a Windows one working yet?

SHARE:
+ Post New Thread
Page 2 of 13 FirstFirst 12345612 ... LastLast

Similar Threads

  1. BCS Charter Status
    By russdev in forum Educational IT Jobs
    Replies: 13
    Last Post: 14th February 2008, 01:40 PM
  2. Just got a letter about Single Status through
    By j17sparky in forum General Chat
    Replies: 17
    Last Post: 31st October 2007, 01:33 PM
  3. Single Status
    By faza in forum General Chat
    Replies: 36
    Last Post: 2nd February 2007, 09:37 AM
  4. Just got ICT college status YAY!!!
    By Mr_T in forum General Chat
    Replies: 3
    Last Post: 1st February 2007, 12:20 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •