VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

Checking NTP/DNS Report

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
Jump to solution

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
Jump to solution

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
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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