question

Pauciloquent avatar image
0 Votes"
Pauciloquent asked Pauciloquent commented

SCOM: How do I monitor external DNS resolution?

Hi Folks

I am wondering if External resolution monitor has been removed from DNS MP? I need to create a monitor or rule that runs on the DNS server to query an address frequently. If 3 queries are failed, generate an alert.

Should I write a Powershell script and create a script monitor? In this case, please point me to the document where I can learn about powershell monitoring.

Thanks in advance.

msc-operations-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StoyanChalakov avatar image
0 Votes"
StoyanChalakov answered Pauciloquent commented

Hi @Pauciloquent,

I didn't have the chance to test the script itself, but if your are collecting the proper data in your property bags (see belolw hpw yyou can test thiss - the artcle i pasted), then the steps that you need to do to make the script work, are descriibed here (an article I wrote about how to integrate a PowerShell script with SCOM) and run it on your SCOM management server:

Monitoring Active Directory User Account Expiration using SCOM and PowerShell (Step by Step Guide)
https://www.pohn.ch/monitor-active-directory-user-account-expiration-using-scom-and-powershell-step-by-step-guide/

You will see in the article how to test you script and make sure it returns the right proerty bags and also how to integrate in SCOM. It has also nice screennshots and lots of details. Please post back if you need further help.


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Stoyan Chalakov




· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

As Per @StoyanChalakov instructions. I downloaded the Community Powersell monitoring MP and imported to my SCOM 2019 environment.

Created a Powershell based Script monitor that will run every 5 mins. Wrote the following script to resolve the DNS Name using the local computer name because I will enable the script for DNS servers only:


Author: Naj

Date: 05 May, 2022

Any arguments specified will be sent to the script as a single string

If you need to send multiple values, delimit then with a space, semicolon or other separator and then use split.


param([string]$Arguments)

$ScomAPI = New-Object -comObject "MOM.ScriptAPI"
$PropertyBag = $ScomAPI.CreatePropertyBag()

$output = $Null
$count = 0

for ($i=1; $i -le 3: $i++)

{
$output = resolve-DNSname -name abc.com.au -server $emv:COMPUTERNAME -erroraction SilentlyContinue

if ($output -eq $Null)

{

$count++

}

sleep 3

}

if ($count -eq 3)
{

$PropertyBag.AddValue("State","Failure")
}
else
{
$PropertyBag.AddValue("State","Success")
}

send output to SCOOM

$PropertyBag

======================

Set the unhealthy expression: "Property[@Name='State') equals Failure
Set the healthy expression: "Property[@Name='State') equals Success

Enabled the monitor for relevant DNS serverx via override

0 Votes 0 ·
Pauciloquent avatar image
0 Votes"
Pauciloquent answered Pauciloquent published

Hi @CyrAz @SimonRenMSFT-3639 @StoyanChalakov

Need your kind attention to my question :)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StoyanChalakov avatar image
1 Vote"
StoyanChalakov answered Pauciloquent commented

Hi @Pauciloquent,

you have a custom use case, so I would also use PowerShell if I had to solve this same challenge. What you need is:

  • Cookdown's PowerShell MP, so that you can build a PowerShell based monitor.

PowerShell Authoring
https://www.cookdown.com/scom-essentials/powershell-authoring

The link contains also a refernce to a video, where you can see how to create Property Bags and pass their values to SCOM.

  • You can use the following cmdlets to build your script, depending on the particular use case and requirements:

Resolve-DnsName
https://docs.microsoft.com/en-us/powershell/module/dnsclient/resolve-dnsname?view=windowsserver2022-ps

Here you can lookup some examples:

Resolve-DnsName: Resolving DNS Records with PowerShell
https://adamtheautomator.com/resolve-dnsname/

Don't hesitate to ask if you have further questions.


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Stoyan Chalakov


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks heaps @StoyanChalakov

Lemme look at the articles, will get back,

0 Votes 0 ·

Hi @StoyanChalakov

I have wrote a script that will resolve the address using specific DNS server, Now I don't want to run that script on any server but looking for a way that SCOM runs it from the management server as a monitor and if it couldn't resolve the address using that specific DNS server, generates an alert. How can I do it?

Here is the script:

param([string]$Arguments)
$ScomAPI=new-object -comObject "MOM.ScriptAPI"
$PropertyBag = $ScomAPI.CreatePropertyBag()

$output = $Null
$Count = 0
for ($i=1; $i -le 3; $i++)
{
$output = resolve-DNSName -name <address> -server <DNS Server> -erroraction SilentlyContinue
if ($output -eq $Null)
{
$count++
}
sleep 3
}
if ($count -eg 3)
{
$PropertyBag.AddValue("State","Failure"
}
else
{
$PropertyBag.AddValue("State","Success")
}

$PropertyBag

Once I create a monitor and disabled it by default. Now override it for which server?

0 Votes 0 ·