Hello Everyone,
Can any one help me in doing this:
I have lager environment where syslog settings has been misconfigured so the hosts are runing out of space on its root partition.
I need a script that can take care of the: syslog global directory enabling, rotate options, size options.
Thank you,
vamsi.
Hi there,
get-cluster |get-vmhost| Set-VMHostAdvancedConfiguration -NameValue @{'Syslog.global.logHost'='udp://10.10.10.12:514';'Syslog.global.logDirUnique'='true';'Syslog.global.defaultSize'='8192';'Syslog.global.defaultRotate'='8'}
or
get-cluster 'your_cluster_name' | get-vmhost| Set-VMHostAdvancedConfiguration -NameValue @{'Syslog.global.logHost'='udp://10.10.10.12:514';'Syslog.global.logDirUnique'='true';'Syslog.global.defaultSize'='8192';'Syslog.global.defaultRotate'='8'}
Name Value
---- -----
Syslog.global.defaultRotate 7
Syslog.global.logHost udp://10.10.10.12:514
Syslog.global.defaultSize 8192
Syslog.global.logDirUnique True
as a sample output should be returned.
Greg
update:
you can check if everything was set fine:
get-view -viewtype HostSystem | % { write-host -Foregroundcolor red $_.Name; get-view $_.ConfigManager.AdvancedOption | select -ExpandProperty Setting|?{$_.Key -like "Syslog.global*"} }
Or you can do
get-view -viewtype HostSystem -SearchRoot (get-cluster 'My_cluster').id | % { write-host -Foregroundcolor red $_.Name; get-view $_.ConfigManager.AdvancedOption | select -ExpandProperty Setting|?{$_.Key -like "Syslog.global*"} }
for hostsystems in particular cluster
let me know if that worked for you
Message was edited by: Grzesiekk
Have a look at Setting Syslog default size via PowerCLI
The other settings can also be configured with the Set-VMHostAdvancedConfiguration cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanku for your reply, right now i am trying this and it's doing nothing. Can you help me find out what's missing.
Import-Csv "C:\Powershell\Syslog\clusters.csv" -UseCulture | %{
$cl = get-cluster -Name $_.Clusters |get-vmhost
foreach($h in $cl){
#Set-VMHostSysLogServer -SysLogServer 'XXXX'-VMHost $h.name
Set-VMHostSysLogServer -SysLogServer $null -VMHost $h.name
#Set Logging Settings
$LogSize = "1024"
$LogRotate = "8"
#$syslog = Get-VMHostFirewallException -name ‘syslog’ -vmhost $h.name
#$syslog | Set-VMHostFirewallException -Enabled:$true
}
}
Hi there,
You can take a look how i did that
http://psvmware.wordpress.com/?s=Syslog
What specific options do you want to set for syslog,mi assume you have some remote syslog server right?
Regards greg
Hi Grzesiekk,
Yes I have remote syslog servers, the settings i want to set is: Syslog.global.logDirUnique should be cheked, Roate options =8, size should be 1024.
Thank you,
vamsi.
Hi there,
get-cluster |get-vmhost| Set-VMHostAdvancedConfiguration -NameValue @{'Syslog.global.logHost'='udp://10.10.10.12:514';'Syslog.global.logDirUnique'='true';'Syslog.global.defaultSize'='8192';'Syslog.global.defaultRotate'='8'}
or
get-cluster 'your_cluster_name' | get-vmhost| Set-VMHostAdvancedConfiguration -NameValue @{'Syslog.global.logHost'='udp://10.10.10.12:514';'Syslog.global.logDirUnique'='true';'Syslog.global.defaultSize'='8192';'Syslog.global.defaultRotate'='8'}
Name Value
---- -----
Syslog.global.defaultRotate 7
Syslog.global.logHost udp://10.10.10.12:514
Syslog.global.defaultSize 8192
Syslog.global.logDirUnique True
as a sample output should be returned.
Greg
update:
you can check if everything was set fine:
get-view -viewtype HostSystem | % { write-host -Foregroundcolor red $_.Name; get-view $_.ConfigManager.AdvancedOption | select -ExpandProperty Setting|?{$_.Key -like "Syslog.global*"} }
Or you can do
get-view -viewtype HostSystem -SearchRoot (get-cluster 'My_cluster').id | % { write-host -Foregroundcolor red $_.Name; get-view $_.ConfigManager.AdvancedOption | select -ExpandProperty Setting|?{$_.Key -like "Syslog.global*"} }
for hostsystems in particular cluster
let me know if that worked for you
Message was edited by: Grzesiekk
Greg,
Thank you so much it worked, But the weird part is i have a cluster with 15hosts and it worked with 13 of them 2 hosts didn't work. So it should be problem in my environment i feel.
Thank you,
vamsi.
Hi there,
im glad that helped, can you paste
get-view -viewtype HostSystem | % { write-host -Foregroundcolor red $_.Name; get-view $_.ConfigManager.AdvancedOption | select -ExpandProperty Setting|?{$_.Key -like "Syslog.global*"} }
for the 2 hosts that had errors ? or just paste the errors that came ?
Greg