Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
38
plugins/outputs/zabbix/autoregister.go
Normal file
38
plugins/outputs/zabbix/autoregister.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package zabbix
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Add adds a host to the list of hosts to send autoregister data to Zabbix.
|
||||
// Only store information if autoregister is enabled (config Autoregister is not empty).
|
||||
func (z *Zabbix) autoregisterAdd(hostname string) {
|
||||
if z.Autoregister == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if _, exists := z.autoregisterLastSend[hostname]; !exists {
|
||||
z.autoregisterLastSend[hostname] = time.Time{}
|
||||
}
|
||||
}
|
||||
|
||||
// Push sends autoregister data to Zabbix for each host.
|
||||
func (z *Zabbix) autoregisterPush() {
|
||||
if z.Autoregister == "" {
|
||||
return
|
||||
}
|
||||
|
||||
// For each "host" tag seen, send an autoregister request to Zabbix server.
|
||||
// z.AutoregisterSendPeriod is the interval at which requests are resend.
|
||||
for hostname, timeLastSend := range z.autoregisterLastSend {
|
||||
if time.Since(timeLastSend) > time.Duration(z.AutoregisterResendInterval) {
|
||||
z.Log.Debugf("Autoregistering host %q", hostname)
|
||||
|
||||
if err := z.sender.RegisterHost(hostname, z.Autoregister); err != nil {
|
||||
z.Log.Errorf("Autoregistering host %q: %v", hostname, err)
|
||||
}
|
||||
|
||||
z.autoregisterLastSend[hostname] = time.Now()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue