{"name":"Monitor replication jobs","description":"<p>This metric investigates replication jobs, searching for any that may be disabled inappropriately.<\/p> \r\n<p>If any of your replication jobs have been disabled inappropriately, you may not be aware of their state. If too much time passes, your publication may expire. This will inevitably cause you grief in recreating the publication. Ensuring that your replication jobs are functioning as desired is paramount. Monitoring them is vital to the health of your replication topology.<\/p>\r\n<p>The associated alert will keep a vigilant eye on your systems, ensuring that the appropriate jobs remain in an enabled state and allowing their functionality to continue executing properly.<\/p>\r\n<p>To analyze further and see the status of all replication jobs, execute the following query:<\/p>\r\n\r\n    <pre class=\"sql\">SELECT @@ServerName AS [ServerName],\r\n    sj.[Name],\r\n    CASE WHEN sj.[enabled] = 1 THEN 'Enabled'\r\n         ELSE 'Not Enabled - Please Investigate'\r\n    END AS [Enabled],\r\n    ISNULL(run_date, '') AS [Run_Date]\r\n  FROM msdb.dbo.sysjobs sj \r\n  LEFT OUTER JOIN (SELECT MAX(CASE WHEN run_date IS NULL THEN ''\r\n                                   ELSE SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                  1, 4) + '-'\r\n                                        + SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                    5, 2) + '-'\r\n                                        + SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                    7, 2)\r\n                              END) AS [run_date],\r\n                      job_id\r\n                    FROM msdb.dbo.sysjobhistory sh\r\n                    WHERE Step_id = 0\r\n                    GROUP BY job_id\r\n                  ) AS sh\r\n  ON\r\n    sh.job_id = sj.job_id\r\n  WHERE (sj.name LIKE '%Distribution%'\r\n    OR sj.name LIKE '%LogReader%')\r\n    AND sj.name NOT LIKE '%backup%'\r\n    AND sj.name NOT LIKE 'Replication monitoring refresher for distribution.'\r\n  ORDER BY [run_date] DESC,\r\n    sj.[name];<\/pre>","tsql":"SELECT COUNT(*) AS [Count]\r\n  FROM msdb.dbo.sysjobs sj \r\n  LEFT OUTER JOIN (SELECT MAX(CASE WHEN run_date IS NULL THEN ''\r\n                                   ELSE SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                  1, 4) + '-'\r\n                                        + SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                    5, 2) + '-'\r\n                                        + SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                    7, 2)\r\n                              END) AS [run_date],\r\n                      job_id\r\n                    FROM msdb.dbo.sysjobhistory sh\r\n                    WHERE Step_id = 0\r\n                    GROUP BY job_id\r\n                  ) AS sh\r\n  ON\r\n    sh.job_id = sj.job_id\r\n  WHERE (sj.name LIKE '%Distribution%'\r\n    OR sj.name LIKE '%LogReader%')\r\n    AND sj.name NOT LIKE '%backup%'\r\n    AND sj.name NOT LIKE 'Replication monitoring refresher for distribution.'\r\n    AND sj.[enabled] <> 1;","instances":false,"frequency":3600,"databases":{"mode":1},"rateofchange":false,"metricenabled":true,"alertname":"Disabled replication jobs","alertdescription":"<p>This alert is raised when replication jobs that may have been disabled inappropriately are detected. It ensures that the appropriate jobs remain in an enabled state, allowing their functionality to continue executing properly.<\/p> \r\n<p>If any of your replication jobs have been disabled inappropriately, you may not be aware of their state. If too much time passes, your publication may expire. This will inevitably cause you grief in recreating the publication. Ensuring that your replication jobs are functioning as desired is paramount. Monitoring them is vital to the health of your replication topology.<\/p>\r\n<p>To analyze further and see the status of all replication jobs, execute the following query:<\/p>\r\n\r\n    <pre class=\"sql\">SELECT @@ServerName AS [ServerName],\r\n    sj.[Name],\r\n    CASE WHEN sj.[enabled] = 1 THEN 'Enabled'\r\n         ELSE 'Not Enabled - Please Investigate'\r\n    END AS [Enabled],\r\n    ISNULL(run_date, '') AS [Run_Date]\r\n  FROM msdb.dbo.sysjobs sj \r\n  LEFT OUTER JOIN (SELECT MAX(CASE WHEN run_date IS NULL THEN ''\r\n                                   ELSE SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                  1, 4) + '-'\r\n                                        + SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                    5, 2) + '-'\r\n                                        + SUBSTRING(CONVERT(VARCHAR, sh.run_date),\r\n                                                    7, 2)\r\n                              END) AS [run_date],\r\n                      job_id\r\n                    FROM msdb.dbo.sysjobhistory sh\r\n                    WHERE Step_id = 0\r\n                    GROUP BY job_id\r\n                  ) AS sh\r\n  ON\r\n    sh.job_id = sj.job_id\r\n  WHERE (sj.name LIKE '%Distribution%'\r\n    OR sj.name LIKE '%LogReader%')\r\n    AND sj.name NOT LIKE '%backup%'\r\n    AND sj.name NOT LIKE 'Replication monitoring refresher for distribution.'\r\n  ORDER BY [run_date] DESC,\r\n    sj.[name];<\/pre>","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":0},"_thresholds_medium":{"selected":false},"_thresholds_low":{"selected":false},"instances_comment":"Note: Turn on the check boxes for instances that perform replication tasks.","thresholds_comment":"Note: These thresholds are intended as guideline values. If they seem too high or too low for your environment, replace them with values more suited to your server performance.","tsql_comment":"Note: This query, limits the results to specifically named jobs. Replace the following terms with appropriate values for your system and needs, ensuring that they match your naming convention:\r\n<p>[sql]\u2018%Distribution%\u2019[\/sql]<\/p>\r\n<p>'%LogReader%'<\/p>\r\n<p>'%backup%'<\/p>\r\n<p>'Replication monitoring refresher for distribution.'[\/sql]<\/p>","targetentitytype":0}