VMware Cloud Community
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Set syslog server settings across all ESXi5 hosts

Hello,

I can set my ESXi5 syslog server settings from the CLI of each server using these commands below:

esxcli system syslog config set --loghost='udp://indexer.domain.com:514'

esxcli system syslog reload

How do I script is so that it makes the change on all ESXi hosts in my vCenter?

Thanks,

Duncan.

0 Kudos
1 Solution

Accepted Solutions
vlife201110141
Enthusiast
Enthusiast
Jump to solution

I do this way

add-pssnapin vmware.vimautomation.core
Connect-VIServer -Server "vcenterserver" -User "xxx" -Password "xxx"
$loghost = "x.x.x.x"
$esxhosts = Get-VMHost
foreach($esx in $esxhosts){
$hview = Get-View -ViewType "hostsystem" -Filter @{"Name"= $esx.Name}

# ------- HostImageConfigGetAcceptance -------

$_this = Get-View -Id $hview.ConfigManager.ImageConfigManager
$_this.HostImageConfigGetAcceptance()

# ------- EnableRuleset -------

$_this = Get-View -Id $hview.ConfigManager.FirewallSystem
$_this.EnableRuleset("syslog")

# ------- ESXCLI enable syslog -------
$esxcli = Get-EsxCli -vmhost $esx.Name
$esxclisetsyslog = $esxcli.system.syslog.config.set($null, $null, $null, $null, $loghost, $null)
$esxcli.system.syslog.reload()
}
Disconnect-VIServer -Server "vcenterserver" -Confirm:$false

View solution in original post

0 Kudos
5 Replies
aravinds3107
Virtuoso
Virtuoso
Jump to solution

Check the script used in this article using ESXCLI

Configuring Multiple Syslog Servers for ESXi 5

Also take a look at Set-VMHostSysLogServer PowerCLI cmdlet

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful |Blog: http://aravindsivaraman.com/ | Twitter : ss_aravind
0 Kudos
Grzesiekk
Expert
Expert
Jump to solution

Hi dbutch1976,

  in addition what was written you can aslo take a look on this

http://psvmware.wordpress.com/2012/07/31/configuring-syslog-for-esxi-hosts/

I have also written somethign about presenting directories in more human readable version.

And also a quick extract from the blog post:

"

get-vmhost| Set-VMHostAdvancedConfiguration -NameValue @{'Config.HostAgent.log.level'='info';'Vpx.Vpxa.config.log.level'='info';'Syslog.global.logHost'='udp://syslogip:514'}

"

This will change logging level and loghost for each esx box in VC.

Or version which select hosts from clusters

"

get-cluster 'your_cluster'|get-vmhost| Set-VMHostAdvancedConfiguration -NameValue @{'Config.HostAgent.log.level'='info';'Vpx.Vpxa.config.log.level'='info';'Syslog.global.logHost'='udp://syslogip:514'}

"

Regards,

Greg

--- @blog https://grzegorzkulikowski.info
vlife201110141
Enthusiast
Enthusiast
Jump to solution

I do this way

add-pssnapin vmware.vimautomation.core
Connect-VIServer -Server "vcenterserver" -User "xxx" -Password "xxx"
$loghost = "x.x.x.x"
$esxhosts = Get-VMHost
foreach($esx in $esxhosts){
$hview = Get-View -ViewType "hostsystem" -Filter @{"Name"= $esx.Name}

# ------- HostImageConfigGetAcceptance -------

$_this = Get-View -Id $hview.ConfigManager.ImageConfigManager
$_this.HostImageConfigGetAcceptance()

# ------- EnableRuleset -------

$_this = Get-View -Id $hview.ConfigManager.FirewallSystem
$_this.EnableRuleset("syslog")

# ------- ESXCLI enable syslog -------
$esxcli = Get-EsxCli -vmhost $esx.Name
$esxclisetsyslog = $esxcli.system.syslog.config.set($null, $null, $null, $null, $loghost, $null)
$esxcli.system.syslog.reload()
}
Disconnect-VIServer -Server "vcenterserver" -Confirm:$false

0 Kudos
vlife201110141
Enthusiast
Enthusiast
Jump to solution

$loghost = "indexer.domain.com"

0 Kudos
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Thanks for the help everyone, I went with your solution vlife.

0 Kudos