Merge pull request #125 from teh-hippo/issue-124

Replace empty names with 'unknown' when pushing to InfluxDB.
This commit is contained in:
Andrew Erlikh 2024-09-07 18:22:57 +07:00 committed by GitHub
commit 1eaf237ba6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,6 +33,9 @@ func Add(appConfig models.Conf, oneHist models.Host) {
oneHist.Name = strings.ReplaceAll(oneHist.Name, " ", "\\ ")
oneHist.Name = strings.ReplaceAll(oneHist.Name, ",", "\\,")
oneHist.Name = strings.ReplaceAll(oneHist.Name, "=", "\\=")
if oneHist.Name == "" {
oneHist.Name = "unknown"
}
line := fmt.Sprintf("WatchYourLAN,IP=%s,iface=%s,name=%s,mac=%s,known=%d state=%d", oneHist.IP, oneHist.Iface, oneHist.Name, oneHist.Mac, oneHist.Known, oneHist.Now)
// slog.Debug("Writing to InfluxDB", "line", line)