MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / GetHostname

Method GetHostname

agent-source-code/internal/system/system.go:272–284  ·  view source on GitHub ↗

GetHostname returns the system hostname

()

Source from the content-addressed store, hash-verified

270
271// GetHostname returns the system hostname
272func (d *Detector) GetHostname() (string, error) {
273 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
274 defer cancel()
275
276 info, err := host.InfoWithContext(ctx)
277 if err != nil {
278 d.logger.WithError(err).Warn("Failed to get hostname")
279 // Fallback to os.Hostname
280 return os.Hostname()
281 }
282
283 return info.Hostname, nil
284}
285
286// GetIPAddress gets the primary IP address using network interfaces
287func (d *Detector) GetIPAddress() string {

Callers 6

refreshDockerInventoryFunction · 0.80
runDockerImageScanFunction · 0.80
sendReportFunction · 0.80
sendIntegrationDataFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected