This commit is contained in:
27
main.go
27
main.go
@@ -61,9 +61,9 @@ func getEvents(eventTypes []string, entities []types.ManagedObjectReference, beg
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error getting vCenter time: %s\n", err)
|
fmt.Fprintf(os.Stderr, "Error getting vCenter time: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
} else {
|
} //else {
|
||||||
//log.Printf("vCenter time is '%v'\n", now)
|
//log.Printf("vCenter time is '%v'\n", now)
|
||||||
}
|
//}
|
||||||
|
|
||||||
m := event.NewManager(c.Client)
|
m := event.NewManager(c.Client)
|
||||||
root := c.ServiceContent.RootFolder
|
root := c.ServiceContent.RootFolder
|
||||||
@@ -89,7 +89,11 @@ func getEvents(eventTypes []string, entities []types.ManagedObjectReference, beg
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range entities {
|
for _, e := range entities {
|
||||||
log.Printf("getEvents setting entity '%v' to filter\n", entities[0])
|
// Only log the entity we're filtering if it isn't the vcenter root
|
||||||
|
if e != root {
|
||||||
|
log.Printf("getEvents setting entity '%v' to filter\n", e)
|
||||||
|
}
|
||||||
|
|
||||||
filter.Entity = &types.EventFilterSpecByEntity{
|
filter.Entity = &types.EventFilterSpecByEntity{
|
||||||
Entity: e,
|
Entity: e,
|
||||||
Recursion: types.EventFilterSpecRecursionOptionAll,
|
Recursion: types.EventFilterSpecRecursionOptionAll,
|
||||||
@@ -151,6 +155,7 @@ func getCluster(name string) mo.ClusterComputeResource {
|
|||||||
return mo.ClusterComputeResource{}
|
return mo.ClusterComputeResource{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func getVM(name string) mo.VirtualMachine {
|
func getVM(name string) mo.VirtualMachine {
|
||||||
// Create a container view so that we can search vCenter for a VM if we found any failure events
|
// Create a container view so that we can search vCenter for a VM if we found any failure events
|
||||||
m := view.NewManager(c.Client)
|
m := view.NewManager(c.Client)
|
||||||
@@ -174,7 +179,7 @@ func getVM(name string) mo.VirtualMachine {
|
|||||||
// If we reached here then we didn't find a VM
|
// If we reached here then we didn't find a VM
|
||||||
return mo.VirtualMachine{}
|
return mo.VirtualMachine{}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
func getVmInCluster(name string, cluster types.ManagedObjectReference) mo.VirtualMachine {
|
func getVmInCluster(name string, cluster types.ManagedObjectReference) mo.VirtualMachine {
|
||||||
// Create a container view so that we can search vCenter for a VM if we found any failure events
|
// Create a container view so that we can search vCenter for a VM if we found any failure events
|
||||||
m := view.NewManager(c.Client)
|
m := view.NewManager(c.Client)
|
||||||
@@ -324,19 +329,7 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else { // Didn't find any VM disconnected events
|
||||||
/*
|
|
||||||
disconnectedHost := disconnectedEvents[0]
|
|
||||||
log.Printf("First disconnected message indicates that VM was running on host '%s' previously\n", disconnectedHost.Host.Name)
|
|
||||||
|
|
||||||
// Capture all the failure events for this host
|
|
||||||
for _, hostEvent := range hostFailures {
|
|
||||||
if hostEvent.Host.Name == disconnectedHost.Host.Name {
|
|
||||||
possibleHosts = append(possibleHosts, hostEvent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} else {
|
|
||||||
log.Printf("could not determine previous host for this VM. Filtering all host failures for events prior to VM restart time '%s'\n", vmRestartTime)
|
log.Printf("could not determine previous host for this VM. Filtering all host failures for events prior to VM restart time '%s'\n", vmRestartTime)
|
||||||
|
|
||||||
// Search for host failures
|
// Search for host failures
|
||||||
|
Reference in New Issue
Block a user