Jump to content

Website Check


allanscot

Recommended Posts

I was wondering if there was a plan to monitor website like the ping check but it would go onto a website and look for a specific string of text every X minutes to make sure it is loading correctly. Maybe it could even be a plugin?

This would be great and we could use this for all our monitoring not just the base servers.

Thanks

Allan

Link to comment
Share on other sites

  • Administrators

This can be done with a plugin that's using HttpWebRequest and comparing the output.

Here is some code that can get you starting:


public static string GetPublicIPAddress()

	    {

		    HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://checkip.dyndns.org");

		    request.Method = "GET";

		    WebResponse response = null;

		    StreamReader reader = null;

		    try

		    {

			    response = request.GetResponse();

			    // ReSharper disable AssignNullToNotNullAttribute

			    reader = new StreamReader(response.GetResponseStream());

			    // ReSharper restore AssignNullToNotNullAttribute

			    string result = reader.ReadToEnd();

			    result = result.Remove(0, result.IndexOf("Address:", StringComparison.Ordinal) + 9);

			    return result.Remove(result.IndexOf("</body>", StringComparison.Ordinal));

		    }

		    catch

		    {

			    return null;

		    }

		    finally

		    {

			    if (reader != null)

			    {

				    reader.Close();

				    reader.Dispose();

			    }

			    if (response != null)

				    response.Close();

			    request.Abort();

		    }

	    }

This is a code that will open up http://checkip.dyndns.org and parse the html output.

Also if you are insterested into creating a plugin or a cloud instance you can check out the user friendly tutorial that show you step by step how to get a plugin or a cloud instance in no time!

Windows Plugins 101 Tutorial

or

Cloud API 101 Tutorial

Also if you run into trouble and don't know what to do feel free to ask on the forums and people will gladly help you!

Good Luck,

Paul.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...