{"id":125,"date":"2007-01-14T14:43:27","date_gmt":"2007-01-14T12:43:27","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=125"},"modified":"2007-01-14T14:43:27","modified_gmt":"2007-01-14T12:43:27","slug":"monitor-recovery-mode","status":"publish","type":"post","link":"https:\/\/contoso.se\/blog\/?p=125","title":{"rendered":"Monitor recovery mode"},"content":{"rendered":"<p>This script will check recovery mode of a MS SQL database. Its pretty simple to modify to check other databases or all databases. This example will check if the Onepoint database is running with SIMPLE recovery mode. If it does, a local event will be generated. You can then create a event rule to collect that event and generate an alert in MOM.<\/p>\n<p><code>set cn = Nothing<br \/>\nset rs = nothing<\/code><code>strSQLServer = \"localhost\"<br \/>\nSet cn = CreateObject(\"ADODB.Connection\")<br \/>\nSet rs = CreateObject(\"ADODB.Recordset\")<br \/>\ncn.Open \"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=\" & strSQLServer & \"\"<br \/>\nstrSQLQuery = \"select name, databasepropertyex(name, 'recovery') as RECOVERY from sysdatabases WHERE NAME = 'OnePoint'\"<\/p>\n<p>Set rs = cn.execute(strSQLQuery)<br \/>\nstrDBName = rs(\"Name\")<br \/>\nstrMode = rs(\"Recovery\")<\/p>\n<p>If strMode = \"SIMPLE\" then<br \/>\n\u00c2\u00a0Const EVENT_WARNING = 2<br \/>\n\u00c2\u00a0Set objShell = CreateObject(\"Wscript.Shell\")<br \/>\n\u00c2\u00a0objShell.LogEvent 2, \"The \" & strDBName & \" database is running in simple recovery mode\"<br \/>\nEnd If<\/p>\n<p \/><\/code><\/p>\n<ol>\n<li>Create a new script and paste this source<\/li>\n<li>Create a rule that run the script every X minute<\/li>\n<li>Create a rule that collects and generate alerts on event ID 2 from WSH in the application log.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This script will check recovery mode of a MS SQL database. Its pretty simple to modify to check other databases or all databases. This example will check if the Onepoint database is running with SIMPLE recovery mode. If it does, a local event will be generated. You can then create a event rule to collect &hellip; <a href=\"https:\/\/contoso.se\/blog\/?p=125\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[2,13],"tags":[],"_links":{"self":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125"}],"version-history":[{"count":0,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}