{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":30372,"path":"it-operations-management/event-management/custom-configure-threshold-monitoring.md","title":"Create a self-health monitor with a custom script","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create a self-health monitor with a custom script\n\nYou can create a self-health monitor to use custom health monitor script to monitor specified Event Management components.\n\n## Before you begin\n\nRole required: evt\\_mgmt\\_admin\n\n## About this task\n\nTo augment the self-health monitors that are provided with the base system, you can create a self-health monitor to monitor the components that you specify. The health monitor scripts that are provided with the base system are listed in the following table.\n\n<table id=\"table_d5c_tz4_4cb\"><thead><tr><th>\n\nHealth monitor script\n\n</th><th>\n\nUsed by a monitor to:\n\n</th></tr></thead><tbody><tr><td>\n\nCheck delay in event processing\n\n</td><td>\n\nMonitor the duration of events \\[in minutes\\] that remain in Ready state and are not processed.\n\n</td></tr><tr><td>\n\nConnectors Monitor\n\n</td><td>\n\nMonitor:-   Whether the time that a connector in idle state surpassed the threshold \\[in minutes\\] configured.\n-   The active status of connectors.\n\n</td></tr><tr><td>\n\nGet Event Processing state\n\n</td><td>\n\nMonitor the time that events are in Ready state. Alerts are sent when this time exceeds the threshold.\n\n</td></tr><tr><td>\n\nMID Server Threshold Alerts\n\n</td><td>\n\nMonitor MID Server health. Events are sent when changes in MID Server state are detected.\n\n</td></tr></tbody>\n</table>You can create alert management rules to respond to and remediate the issues detected by self-health. Alerts are generated based on the specified severity and threshold. Navigate to **Event Management** &gt; **Administration** &gt; **Self-Health Monitoring** for the monitors that are provided with the base instance to monitor the issues detected by self-health, which are:\n\n<table id=\"table_z5y_qkq_1fb\"><thead><tr><th>\n\nMonitor\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nConnector's idle state monitoring\n\n</td><td>\n\nMonitor to verify whether any of the connectors were in idle state that surpassed the threshold \\[in minutes\\] that was configured.Health Monitor script selected: `Connectors Monitor`.\n\n</td></tr><tr><td>\n\nConnectors Status\n\n</td><td>\n\nMonitor to track the active status of the connectors. Select only one threshold to configure which severity to invoke using 1 to select the threshold field or 0 to ignore the threshold field. For more information, see [Connector status example](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/configure-threshold-monitoring.md). Health Monitor script selected: `Connectors Monitor`.\n\n</td></tr><tr><td>\n\nDelay in event processing\n\n</td><td>\n\nMonitor to track the duration of events \\[in minutes\\] that remain in Ready state and were not processed. This duration period initiates an alert for the event processing CI with severity according to the configured thresholds \\[minutes\\].Health Monitor script selected: `Check delay in event processing`.\n\n</td></tr><tr><td>\n\nEvent Processing job\n\n</td><td>\n\nMonitor the state of the event processing jobs. An alert is generated when the idle time of a job exceeds the configured threshold.Health Monitor script selected: `Get Event Processing state`.\n\n</td></tr><tr><td>\n\nMID Server MID Server Threshold Alerts\n\n</td><td>\n\nMonitor MID Server MID Server health. Events are sent when issues with MID Server availability and resource thresholds are detected.Health Monitor script selected: `MID Server Threshold Alerts`.\n\n</td></tr></tbody>\n</table>**Note:** To prevent a self-health monitor from detecting the connector status, at any time you can clear the **Active** check box of the monitor and then click **Update**.\n\n## Procedure\n\n1.  Navigate to **Event Management** &gt; **Administration** &gt; **Self-Health Monitoring**, and click **New**.\n\n2.  On the form, fill in the fields.\n\n<table id=\"table_xms_j2p_4cb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nDescriptive and meaningful name for the monitor.\n\n</td></tr><tr><td>\n\nDescription\n\n</td><td>\n\nText narrative that describes the monitor.\n\n</td></tr><tr><td>\n\nActive\n\n</td><td>\n\nCheck box to enable the monitor.\n\n</td></tr><tr><td>\n\nMonitoring job frequency \\[seconds\\]\n\n</td><td>\n\nFrequency that the monitoring job should run. Default: `120` seconds.\n\n</td></tr><tr><td>\n\nLast Run\n\n</td><td>\n\nLast run date and time. These values are automatically updated.\n\n</td></tr><tr><td>\n\nScript\n\n</td><td>\n\nMonitoring script. Click the search icon. The existing scripts are listed in the Health Monitor Scripts screen, or click **New** to create a custom health monitor script. For more information about creating a custom health monitor script, see step [3](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/custom-configure-threshold-monitoring.md).\n\n</td></tr><tr><td colspan=\"2\">\n\n**Note:** Regarding all the following threshold configuration fields: All monitored values are compared against the thresholds. If a monitored value exceeds a threshold, an alert with the appropriate severity is issued.\n\n</td></tr><tr><td>\n\nCritical Threshold\n\n</td><td>\n\nAny point above the value is considered a critical consequence.\n\n</td></tr><tr><td>\n\nMajor Threshold\n\n</td><td>\n\nAny point above the value, but below the value of the Critical Threshold, is considered a major consequence.\n\n</td></tr><tr><td>\n\nMinor Threshold\n\n</td><td>\n\nIf exceeded, the value is considered a minor consequence.\n\n</td></tr><tr><td>\n\nWarning Threshold\n\n</td><td>\n\nIf the value is exceeded, a warning is issued.\n\n</td></tr><tr><td>\n\nAdditional information\n\n</td><td>\n\nFurther information about the monitor.\n\n</td></tr></tbody>\n</table>3.  On the Monitoring Configuration form, next to the **Script** field, click the search icon.\n\n    To create a custom health monitor script, click **New**.\n\n4.  On the form, fill in the fields.\n\n<table id=\"table_w34_sg2_2fb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nActive\n\n</td><td>\n\nCheck box to enable the monitor.\n\n</td></tr><tr><td>\n\nDescription\n\n</td><td>\n\nText narrative that describes the custom script.\n\n</td></tr><tr><td>\n\nName\n\n</td><td>\n\nDescriptive and meaningful name for the custom script.\n\n</td></tr><tr><td>\n\nScript\n\n</td><td>\n\nCustom script to run when called from a monitor. A script template is provided as a guide. You can use the [Health monitor scripts provided with the base system](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/custom-configure-threshold-monitoring.md) as examples of how to author the script, and use the [script editor tools](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/scripts/c_SyntaxEditor.md).\n\nEnsure that the custom script includes:Run the monitor function, which is called according to the \"monitoring job frequency” setting **runUpdateHealthMonitorScripts\\(scriptId\\)**. Add this function to run the monitoring logic.\n\n Specify the configuration function that is called every hour **runInsertHealthMonitorScripts\\(scriptId\\)**. Add the configuration logic and add a CI if needed. In the navigation pane search field, enter `em_monitor_state.list`. In the Monitoring States \\[em\\_monitor\\_state\\] table, specify the initialization of the monitor record in the required record.\n\n Use the helper functions defined in **EvtMgmtHealthMonitorCommon** and **EvtMgmtEventAlertGenerator** script includes:\n\n -   EvtMgmtHealthMonitorCommon\n-   healthMonitorCommon.shouldRun\n-   healthMonitorCommon.calculateSeverity\n-   EvtMgmtEventAlertGenerato\n-   openAlert\n-   closeAlert\n\n\n</td></tr></tbody>\n</table>    You can use the Monitoring Configurations \\[em\\_monitor\\_conf\\] table for self-health monitoring configuration, the Health Monitor Scripts \\[em\\_monitor\\_scripts\\] table for scripts. Use the Monitoring States \\[em\\_monitor\\_state\\] table for displaying the results of the monitor.\n\n    These tables are initialized inside **runInsertHealthMonitorScripts**.\n\n    For more information about script includes and APIs, see:Script includes that are [installed with Event Management](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/r_InstalledWithEventManagement.md)\n\n5.  Click **Submit**.\n\n\n## Result\n\nTo monitor the Event Management components that you specify, you can configure a self-health monitor that uses the custom health monitor script that you created.\n\n**Parent Topic:**[Self-health monitors for Event Management](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/self-monitoring.md)\n\n"}}