1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View 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()
}
}
}