Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
When you monitor a service for availability, you verify only that the service is running. If you need to know whether the service is running at peak efficiency, you need to use a more in-depth type of monitoring (such as performance monitoring). Although relatively simple, availability monitoring is extremely important; other questions, such as whether the service is performing at the expected level, are meaningless if the service is not even running.
Availability monitoring generally involves a probe that returns the status of a service. By saving the results of each probe to a database, you can calculate the availability of a service. For example, if you issue 100 probes and the service responds 99 times, the service has an availability of 99 percent.
Availability is often expressed as the amount of time during a year that the service was not available. For example, a service with an availability of 99 percent means the service was unavailable for a total of 3.7 days. This could be the result of one outage of 3.7 days or several outages that, combined, add up to 3.7 days.
To increase the availability of a service, you can do one of two things:
Unfortunately, a service failure is often the result of a bug, either in the service or in the operating system. Unless you wrote the code for both the service and the operating system, it might be difficult for you to increase the mean time between failures.
If you manually restart the service each time it fails, the service does not return to full functionality unless you are available to restart it. To increase availability, you can write a script that monitors the service state periodically and restarts the service automatically each time it fails.
Reporting on the availability of services can be done by:
Listing 15.1 contains a script that monitors service availability; it does this by querying the list of services installed on a computer and reporting the current state of each service. To carry out this task, the script must perform the following steps:
Listing 15.1 Monitoring Service Availability
|
|
Listing 15.2 contains a script that monitors service availability; it does this by querying the list of services installed on a computer and reporting on all services that are not running. To carry out this task, the script must perform the following steps:
Unlike the WMI Query Language WQL statement in Listing 15.1 that retrieved all the properties for every service, the query in Listing 15.2 retrieves only the values of the display name and state properties. This minimizes the amount of data that must be sent across the network.
Listing 15.2 Monitoring Inactive Services
|
|
An attempt to echo a Win32_Service property other than display name and state would result in an error based on the property list defined in the WQL query.
Send us your feedback | « Previous | Next » |