Class WebMonitorSite

This class contains all the settings relevant for monitoring a site, handling an error and notifying a recipient.

The key methods of the class are CheckSite and CheckSiteAsync which are high level methods that perform all the tasks associated with a single site check. These methods call lower level methods like AccessSiteHttp, SendEmail, Log which are the actual worker methods.

Async operation is supported via CheckSiteAsync and the OnMessage event which runs on a separate newly created thread. OnMessage events are fired as requests are started and finished with error information embedded.

System.Object
  System.MarshalByRefObject
    Westwind.WebMonitor.Components.WebMonitorSite
public class WebMonitorSite : MarshalByRefObject

Class Members

MemberDescription

Constructor

Default constructor for this class. Pass in a WebMonitorConfig object that is required for operation of this object.

ProcessHttpRequest

The OnHttpRequest Event fires when the site is going out to check HTTP Requests. You can return true to indicate you've handled HTTP Retrieval.

ProcessLogDetail

Called when an entry is logged into the detail log. Note that the log could be turned off in which case this event won't fire.

ProcessLogError

Fires when an error is logged into the Error Log.

ProcessRunProcess

Fired when the failure process is launched

ProcessSendMail

This event fires when an email message is sent. You can return true to indicate you've handled this event and don't want Web Monitor to send a further message.

ProcessValidateResponse

Fired at the beginning of the check routine that checks to see if the request has failed. This is your hook to override the default failure behavior.

UpdateMessage

The OnMessage Event fires on various occasions during the request process. When a request is started and when it completes. The event provides references to the Site a message and a Event Id that describes which kind of event is being fired.

AccessSiteHttp

Low level method that goes out and accesses a URL based on the internal URL propoerty settings. Request checks for timeout, response code and the actual content compared to the SearchFor property value.

public bool AccessSiteHttp();

CheckSite

High level method that performs an entire site check, notifies the recipients on errors and takes the action specified.

public bool CheckSite();

CheckSiteAsync

This method performs the same functionality as CheckSite does, but does so Asynchronously. It fires a new thread and then calls CheckSite from this new thread.

public void CheckSiteAsync();

Clone

public WebMonitorSite Clone();

GetNextCheckTime

Figures out when to perform the next site check

public DateTime GetNextCheckTime();

LogDetailRequest

Logs every event check to file.

public void LogDetailRequest( EventMessageId MessageType );

public void LogDetailRequest( EventMessageId MessageType,
    string Message );

LogError

Writes out request errors in XML format to the application log file.

public void LogError( string Message,
    ErrorType Type );

RaiseOnMessage

Raises a message event on this site. You can use this to fire special events to the front end layer of the application. Normally this method is called only internally.

public void RaiseOnMessage( string Message,
    EventMessageId EventId );

RequiresChecking

Queries the current site and sees if it has to be run. Based on the values contained in the NextCheck, LastCheck, CheckFrequency and Active properties.

public bool RequiresChecking();

RunProcess

Executes a process when the site is down

public bool RunProcess( int lnFailures );

SendEmail

Sends an email using the oConfig and internal mail settings.

public bool SendEmail( string lcHeader,
    string Message );

SetConfig

Assigns the Config member on the WebMonitorSite object. The config object is used to specify default HTTP and system settings.

public void SetConfig( WebMonitorConfig Config );

SetDefaultValuesFromConfig

Assigns the default values that are stored in the main configuration. This method is called when a new entry is created with default values.

public bool SetDefaultValuesFromConfig();

SetError

Sets the Error and ErrorMsg flags.

public void SetError( string lcErrorMsg );

public void SetError();

StopThread

Handles shutting down the currently executing thread of this instance when running CheckSiteAsync.

public void StopThread();

ToString

Executes a URL or EXE file. Used for 'running' any actions to take on failure.

public virtual string ToString();

Active

Determines whether the site is active and checked for in the RequiresChecking() check whether this request needs to be run.

AsyncResult

The result value from an Async request check

BackUpMessage

Message assigned to email if a failed server comes back up.

CheckFrequency

Timeout in seconds for the site to wait for completion of the request. If exceeded an alert is sent.

Config

Configuration object that is used to get information for calling the mail server and default configuration information. This property must be assigned in the constructor!

EmailAddress

Email Address used to send alert messages.

EmailFrom

Email address used as the return address when error emails are sent.

Error

Error flag that is true if an operation fails.

ErrorMsg

Error Message that was set when the last request failed.

FailureMessage

Message assigned to email if a failure occurs. If not set defaults to the Site Url.

LastCheck

DateTime of the last request that was run.

LastRequestTime

Contains the time it took to run the last HTTP request.

LastResponseText

Contains the HTTP response from the last request. Typically this will be HTML.

NextCheck

DateTime of when the next check should occur.

Password

HTTP Password to access this HTTP request.

PostContentType

The content type for the data posted.

PostData

Any raw POST data to send to the server

ProcessToRun

Contains an external process to fire when the request fails.

ProcessToRun2

Contains an external process to fire when the request fails.

SearchFor

String the HTTP content is searched for on a site check. If the string is not found the request fails. If this string is empty no search matching is performed.

SearchType

Determines the mechanism on how the Text result from the HTTP response is searched.

SiteCheckStarted

Time and Date that a site check was started.

SiteId

Identifier for this site in GUID string format.

SiteName

Descriptive Name of this Web Monitor Site

SortOrder

Can be used to force a Site to sort higher in the list. The higher the number the higher the item displays in the list.

Tag

General purpose field you can use to attach some information to the request. Not used internally but can be used to pass generic info to a handler

Timeout

Timeout in seconds for the site to wait for completion of the request. If exceeded an alert is sent.

Url

The Url to hit for a given site check. Should be in format: http://site.com:port/page.ext

Username

Username for authentication if required.

Requirements

Namespace: Westwind.WebMonitor.Components
Assembly: webmonitorcomponents.dll

© West Wind Technologies, 2018 • Updated: 01/02/14
Comment or report problem with topic