pamiller21
Enthusiast
Enthusiast

Checking NTP/DNS Report

Jump to solution

Hey all,

I am looking for a script that would check the NTP services status on vHosts and if possible print out what time the vHost thinks it is.  Then on top of that print out what the vHosts has for the DNS server settings?

So what I am looking for:

NTP Service Status          Time               DNS Server Setting

Let me know if this is possible, thanks!

1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Oops, forgot that one.

Try like this

Get-VMHost | Select Name,

    @{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}},

    @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' | '}},

    @{N='Time';E={(Get-View -Id $_.ExtensionData.ConfigManager.DatetimeSystem).QueryDateTime()}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

5 Replies
LucD
Leadership
Leadership

Try like this

Get-VMHost | Select Name,

    @{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}},

    @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' | '}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

pamiller21
Enthusiast
Enthusiast

That worked for the most part but did not report the time itself.

0 Kudos
LucD
Leadership
Leadership

Oops, forgot that one.

Try like this

Get-VMHost | Select Name,

    @{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}},

    @{N='DNS Server(s)';E={$_.Extensiondata.Config.Network.DnsConfig.Address -join ' | '}},

    @{N='Time';E={(Get-View -Id $_.ExtensionData.ConfigManager.DatetimeSystem).QueryDateTime()}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

kandan_2014
Contributor
Contributor

Hello Lucd,

I have seen your other posts for creating a scheduled task to generate , need help on creating a scheduled task.

And the one below is reporting the status of NTP service but i need alarms generated if in case the ntp service is stopped.

Is there any way that can be done?

Get-VMHost | Select Name,

@{N='NTP Service Running';E={Get-VMHostService -VMHost $_ | where{$_.Key -eq 'ntpd'} | select -ExpandProperty Running}}

Thanks,

vikram M

0 Kudos
LucD
Leadership
Leadership

Afaik, there is no event fired when an ESXi service is stopped or started.

The only way to have this implemented would be to run a script in the background (scheduled), that checks the status of the service.

And warns you when the service is not running (by email for example)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos