4.59 ServiceHung

Use this Knowledge Script to detect if a Windows service is hung. A hung service is a service in a Start-Pending, Stop-Pending, Continue-Pending, or Pause-Pending state for a number of consecutive intervals. This script raises an event if any service is detected as hung. The service can then be stopped or restarted.

4.59.1 Resource Objects

Windows 2003 Server or later

4.59.2 Default Schedule

The default schedule for this script is Every 5 minutes.

4.59.3 Setting Parameter Values

Set the following parameters as needed:

Description

How to Set It

General Settings

Job Failure Notification

Event severity when job fails

Set the event severity level, from 1 to 40, to indicate the importance of an event when a job fails. The default is 5.

Event Notification

Raise event when a service appears to be hung?

Select to Yes to raise an event if a service is detected as hung. The default is Yes.

Event severity level for failure to restart service

Set the event severity level, from 1 to 40, to indicate the importance of an event in which a service is hung and an attempt to restart it was not successful. The default is 5 (red indicator).

Event severity level for success to restart service

Set the event severity level, from 1 to 40, to indicate the importance of an event in which a service is hung and was restarted successfully. The default is 25 (blue event).

Event severity level when service stopped but not being restarted due to job configuration

Set the event severity level, from 1 to 40, to indicate the importance of an event in which a service is hung and the Restart hung service that the job kills? parameter is unselected. The default is 18 (yellow event indicator).

Event severity level when service process cannot be killed

Set the event severity level, from 1 to 40, to indicate the importance of an event in which a service is hung and could not be stopped. The default is 10 (red event indicator).

Monitor Services

Services to monitor (comma-separated list, use * to monitor all services on the agent)

Specify the names of the services you want to monitor, separating the names with commas (,) and no spaces. You can specify the internal service names or the service names displayed in the Control Panel. Type an asterisk (*) to monitor all services on the agent with a startup type of Automatic. The default is EventLog.

Service start-type filter (used only when * used in Services to monitor

Select the startup type for the services you want to monitor. This parameter is used only when monitoring all services in the Services to monitor parameter.

The start-up types include:

  • All

  • Automatic (services that start during the boot process)

  • Automatic - Delayed Start (services that start shortly after the boot process)

  • Automatic - Trigger Start (services that start after a specified triggering event)

  • Automatic - Delayed/Trigger Start

  • Automatic [excludes Delayed and/or Trigger Start]

  • Manual (services that you manually start)

  • Manual - Trigger Start (services that you manually start after a specified triggering event)

  • Manual [excludes Trigger Start]

  • Disabled (services that have been set to not start)

Use this parameter along with the Services to monitor parameter to monitor services by their startup types instead of their names. For example, if you enter an asterisk (*) in the Services to monitor parameter and then select Manual, the script monitors all services whose startup type is Manual. The default is Automatic.

Services to exclude (comma-separated list)

Specify the names of the services you want to exclude, separating the names with commas (,) and no spaces. You should specify the short (internal) name of the service, which can be found as Service Name in the Properties dialog of the respective service in the Services console in the Control Panel.

Maximum number of consecutive iterations before service is considered hung

Specify the maximum number of consecutive times a service can be in a Start-Pending, Stop-Pending, Continue-Pending, or Pause-Pending state before it is considered hung. The default is 2.

Kill the hung service? (y/n)

Select Yes to kill the hung service. The default is Yes.

Restart hung service that the job kills? (y/n)

Select Yes to restart a hung service that the job kills. The default is Yes.

Data Collection

Collect data for monitored services?

Select to Yes to collect data for charts and reports. If enabled, data collection returns:

  • 100 -- the service is not hung

  • 0 -- the service is hung.

The default is unselected.