Script to detect server response time & reboot if necessary...
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Script to detect server response time & reboot if necessary...

  1. #1
    Join Date
    Feb 2010
    Posts
    5

    Question Script to detect server response time & reboot if necessary...

    At my university we use a server for learning ASP by making dynamic web pages. When a page with some dodgy code is uploaded and run, the server confuses itself and needs to be rebooted before anyone can do anything with it. The only people with the ability to reboot the server are a few IT staff. The problem is that with so many people using it, it often goes down and it takes ages for someone to get round to checking their emails and rebooting it.

    What I want to do is create a script/program that checks the server response time every 2 minutes or so and if it is over a certain time (1 minute), to reboot the server automatically. I will have full access to the server etc.

    I would like some pointers on where to start.

    E.g. what language to use, how to run the script every 2 minutes etc...

    Hope you can help, thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,951

    Re: Script to detect server response time & reboot if necessary...

    You'd need ADMIN rights, but most scripting languages can do something like that.

    Look into POWERSHELL 2.0. It's the new DOS-like language
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2010
    Posts
    5

    Re: Script to detect server response time & reboot if necessary...

    I'd have admin rights. The university have asked me to do it.

    What kind of program would I be making?

    I have done various web development projects but nothing like this.

  4. #4
    Join Date
    Feb 2010
    Posts
    5

    Re: Script to detect server response time & reboot if necessary...

    Bit more information:

    The server is running Microsoft Windows Server 2003. I'm pretty sure I could find a reliable server to run the script. I have access to a couple of other servers. Currently to restart it, I simply login using VNC and do a manual restart...all very basic stuff.

    When it goes down it's only the http sites. FTP still works so the reboot script could be hosted and run locally but triggered from another machine.

    Any ideas?

  5. #5
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,951

    Re: Script to detect server response time & reboot if necessary...

    Powershell lets you INVOKE scripts, to run on any WMI-enabled machine that you set up. It'd be perfect to be able to stop and start services.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,860

    Re: Script to detect server response time & reboot if necessary...

    I think some questions need to be answered before there can be a clear cut answer to your problem.

    Are you talking about rebooting the physical server or just the web service? Does just the web service become unresponsive or does the whole OS?

    If you're talking about just the web service, then just use VBScript on a scheduled Task. VBScript has the full ability to check the status of Windows services and start/stop them.

    If the whole OS is what's the problem, then you are out of luck and need to be physically present with the machine.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Feb 2010
    Posts
    5

    Re: Script to detect server response time & reboot if necessary...

    It's just the web service.
    Web pages will not load but ftp can be accessed and used.
    At the moment the whole system is just restarted but restarting the web service is a possibility.
    How would I get the script to run every few minutes?

  8. #8
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,860

    Re: Script to detect server response time & reboot if necessary...

    As stated before...Scheduled Task.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center