Hi, I'm hoping someone can help here, I'm trying to setup an email alert action to show a list of vm's in an email, when a host failure is detected. That host failure event is caught by the vmware events log, which works just fine. Not all VM's are nodes though, so I can't use a parent/child node relationship here.
I've got as far as being able to get the host name out of the vm event log but i can't get the macro to populate with a list of vm's.
This is what I currently have.
${N=SQL:M=select vm.name from vim_VirtualMachines vm
left join vim_Hosts H on vm.HostID = h.HostID
where H.HostName = '${SQL: SELECT
SUBSTRING('${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}',
CHARINDEX('host failure of host ','${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}') + LEN('host failure of host '),
CHARINDEX(' in cluster','${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}') - CHARINDEX('host failure of host ','${N=OLM.AlertingMacros;M=OLMAlertMessage.EventMessage}') - LEN('host failure of host ')
) AS Message
}' FOR XML PATH ('')}
the hostname part of the macro is fine, it extracts the name from the event log message.
Here's what I end up with in the email content, though.
${N=SQL:M=select vm.name from vim_VirtualMachines vm
left join vim_Hosts H on vm.HostID = h.HostID
where H.HostName = 'esxi-host-01.mgmt.cloud' FOR XML PATH ('')}
What am I doing wrong?