Compare commits

..

No commits in common. "673e3ea0b2c2f2d5fee2b9cecf31686bdb3e1d71" and "5df32a9b98808d6acb287895ebe094200b199168" have entirely different histories.

2 changed files with 1 additions and 20 deletions

View file

@ -20,7 +20,6 @@ const (
hosnameFile = "/etc/hostname"
osRealeaseFile = "/etc/os-release"
versionFile = "/proc/version"
machineIDFile = "/etc/machine-id"
)
var labels = []string{
@ -29,7 +28,6 @@ var labels = []string{
"os",
"distro",
"distro_version",
"machine_id",
}
type SysinfoCollector struct {
@ -38,12 +36,10 @@ type SysinfoCollector struct {
os string
distro string
distroVersion string
machineID string
hostnameFile string
osReleaseFile string
versionFile string
machineIDFile string
promExporter *prometheus.GaugeVec
updateFreq time.Duration
@ -61,7 +57,6 @@ func (c *SysinfoCollector) labels() prometheus.Labels {
"os": c.os,
"distro": c.distro,
"distro_version": c.distroVersion,
"machine_id": c.machineID,
}
}
@ -116,16 +111,6 @@ func (c *SysinfoCollector) updateDistro() error {
return nil
}
func (c *SysinfoCollector) updateMachineID() error {
machineIDContent, err := os.ReadFile(c.machineIDFile)
if err != nil {
return err
}
c.machineID = strings.TrimSpace(string(machineIDContent))
return nil
}
func (c *SysinfoCollector) update() error {
if err := c.updateKernelVersion(); err != nil {
return fmt.Errorf("failed to get kernel version: %w", err)
@ -136,9 +121,6 @@ func (c *SysinfoCollector) update() error {
if err := c.updateDistro(); err != nil {
return fmt.Errorf("failed to get distro info: %w", err)
}
if err := c.updateMachineID(); err != nil {
return fmt.Errorf("failed to get machine-id: %w", err)
}
c.promExporter.With(c.labels()).Set(1)
return nil
@ -176,7 +158,6 @@ func New() *SysinfoCollector {
hostnameFile: hosnameFile,
osReleaseFile: osRealeaseFile,
versionFile: versionFile,
machineIDFile: machineIDFile,
promExporter: prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "system", Name: "info", Help: "System global information"}, labels),
}
}

View file

@ -82,7 +82,7 @@ func New() *UptimeCollector {
procFileLocation: procUptimeLocation,
uptimeFreq: 1 * time.Second,
uptime: 0,
uptimeProm: prometheus.NewGauge(prometheus.GaugeOpts{Namespace: "system", Name: "uptime_sec", Help: "System uptime in seconds"}),
uptimeProm: prometheus.NewGauge(prometheus.GaugeOpts{Namespace: "system", Name: "uptime_nanosec", Help: "System uptime in nanoseconds"}),
}
}