Posts

Showing posts from September, 2022

Management pack variables

I was having a problem importing a custom mp because the PowerShell discovery script I'd written had the reserved mp variable $Data in it. For background, the script queried a SQL table and the results populated a SCOM group. This was the error during import: Error 1: Found error in 1|TestA.SQL.Monitoring|1.0.0.0|SQL.Discovery.AgPrimaryDb/DS|| with message: The configuration specified for Module DS is not valid. : Incorrect expression specified: $Data baseReplica] ad on ar.MachineName_EA844CA4_B2CD_69E3_D8A9_C2E4489C53C7 = ad.MachineName_EA844CA4_B2CD_69E3_D8A9_C2E4489C53C7 AND ar.AvailabilityGroupName_2B65F5C7_DE13_BC25_C1EB_AA53047BB141=ad.AvailabilityGroupName_BE1A08AB_595A_3684_51F5_BDA703BC96C9 where ar.Role_52418D34_8CEA_2508_880C_DE9B8EE7DAB2 = 'Primary'" <# FOR TESTING #. Unable to resolve this expression. Check the expression for errors. (Hints: Check for correct character casing (upper case/lower case), mismatched "$" signs, double quotes(&

VSCode

Image
Shortcuts Task Shortcut Command palette Ctrl + Shift + P Word wrap Alt + Z Copy line Shift + Alt + Up Arrow / Down Arrow Delete line Ctrl + Shift + K Show/hide sidebar Ctrl + B Bookmark: jump next Ctrl + Alt + L Bookmark: toggle on/off Ctrl + Alt + K Extensions I use these extensions:

Monitoring last backup on SQL availability group database

Image
Problem I wanted to monitor database backup age on SQL Availability Group (AG) databases, but only on the primary replica, not secondary replicas as they weren't being backed up. Here's a summary of my experience for future reference. I  think  I got there in the end - still testing - but this was harder than I thought it would be. First, here's the monitor that does the job, we don't need to build one! Name: Microsoft.SQLServer.Windows.Monitor.AvailabilityDatabaseHealth.BackupStatus MP: Microsoft.SQLServer.Windows.Monitoring It's disabled by default and doesn't generate an alert (which will cause us headaches later). There's also an interesting override called Track 'Availability Group Backup Preferences' that looks like it might do what you want. I tested it and it still generated duplicate alerts. Solution Write a PowerShell discovery that runs a SQL query to return all dbs hosted by the primary replica and add them to a group then enable the moni