Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force use of birthdate rather than change date #631

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions agent/jobmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ package agent
import (
"errors"
"io"
"os"
"os/exec"
"strconv"
"strings"
"sync"
"syscall"
"time"

"github.com/apex/log"
Expand Down Expand Up @@ -120,12 +120,21 @@ func (mgr *JobManager) CleanupJob(job *model.Job) {
}

func (mgr *JobManager) updateOnlineTime(src string) {
fi, err := os.Stat(src)
cmd := exec.Command("stat", src, "-c", "%W")
var out strings.Builder
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
log.WithField("statSrcFile", src).WithError(err).Error("unable to run stat against original dir")
return
}
stat := fi.Sys().(*syscall.Stat_t)
mgr.node.OnlineTime = time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec))
secondsSinceEpochStr := strings.TrimSpace(out.String())
secondsSinceEpoch, parseerr := strconv.ParseInt(secondsSinceEpochStr, 10, 64)
if parseerr != nil {
log.WithField("statOutput", secondsSinceEpochStr).WithError(parseerr).Error("unable to convert stat output to number")
return
}
mgr.node.OnlineTime = time.Unix(int64(secondsSinceEpoch), 0)
log.WithField("onlineTime", mgr.node.OnlineTime).Info("Updated online time (node installation time)")
}

Expand Down
6 changes: 5 additions & 1 deletion server/modules/influxdb/influxdbmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ func (metrics *InfluxDBMetrics) fetchLatestValuesByHostDirect(filter string, val
} else {
values[hostname] = result.Record().ValueByKey(valueField)
}
log.WithFields(log.Fields{
"hostname": hostname,
"value": values[hostname],
}).Debug("Got value from InflubDB for host")
} else {
log.Warn("Host key is not of the expected type 'string'")
}
Expand Down Expand Up @@ -316,7 +320,7 @@ func (metrics *InfluxDBMetrics) updateOsStatus() {
metrics.swapTotalGB = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("swap", "total", "", ""), bytesToGB)
metrics.swapUsedPct = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("swap", "used_percent", "", ""), identity)
metrics.pcapDays = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("pcapage", "seconds", "", ""), secondsToDays)
metrics.stenoLossPct = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("stenodrop", "drop", "", ""), toPercent)
metrics.stenoLossPct = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("stenodrop", "drop", "", ""), identity)
metrics.suriLossPct = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("suridrop", "drop", "", ""), toPercent)
metrics.zeekLossPct = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("zeekdrop", "drop", "", ""), toPercent)
metrics.captureLossPct = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("zeekcaptureloss", "loss", "", ""), identity)
Expand Down
Loading