diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/vsphere/discover.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/vsphere/discover.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/vsphere/discover.go b/src/go/collectors/go.d.plugin/modules/vsphere/discover.go new file mode 100644 index 000000000..1ea0a4d6e --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/vsphere/discover.go @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package vsphere + +func (vs *VSphere) goDiscovery() { + if vs.discoveryTask != nil { + vs.discoveryTask.stop() + } + vs.Infof("starting discovery process, will do discovery every %s", vs.DiscoveryInterval) + + job := func() { + err := vs.discoverOnce() + if err != nil { + vs.Errorf("error on discovering : %v", err) + } + } + vs.discoveryTask = newTask(job, vs.DiscoveryInterval.Duration()) +} + +func (vs *VSphere) discoverOnce() error { + res, err := vs.Discover() + if err != nil { + return err + } + + vs.collectionLock.Lock() + vs.resources = res + vs.collectionLock.Unlock() + + return nil +} |