- Access to vCenter (network connection, account to read events)
git
(to clone the repository)go
+v1.13 (to build the example binary)
$ git clone https://github.com/vmware/govmomi.git
$ cd govmomi/examples/events
$ GO111MODULE=on go build -o events .
# verify installation worked
$ ./events -h
Usage of ./events:
-b duration
Begin time (default 10m0s)
-e duration
End time
-f Follow event stream
-insecure
Don't verify the server's certificate chain [GOVMOMI_INSECURE]
-url string
ESX or vCenter URL [GOVMOMI_URL]
# -f will follow the event stream and wait for new events
$ ./events -insecure -url https://administrator@vsphere.local:passw0rd@vcenter.ip.or.fqdn:443/sdk -f
💡 By default the event stream will start from t -10min
. This can be
configured with the -b
parameter, e.g. -b 1h
to start streaming events from
one hour ago.
Create a git patch file
$ cat << EOF > patch
diff --git a/examples/events/main.go b/examples/events/main.go
index 9a8bf1a2..d20f162c 100644
--- a/examples/events/main.go
+++ b/examples/events/main.go
@@ -26,6 +26,7 @@
"github.com/vmware/govmomi/event"
"github.com/vmware/govmomi/examples"
"github.com/vmware/govmomi/vim25"
+ "github.com/vmware/govmomi/vim25/debug"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
)
@@ -37,6 +38,7 @@ func main() {
begin := flag.Duration("b", 10*time.Minute, "Begin time") // default BeginTime is 10min ago
end := flag.Duration("e", 0, "End time")
follow := flag.Bool("f", false, "Follow event stream")
+ debug.SetProvider(&debug.LogProvider{})
examples.Run(func(ctx context.Context, c *vim25.Client) error {
m := event.NewManager(c)
EOF
Apply the patch:
$ git apply patch
Rebuild the events
binary as described above.