Documentation
¶
Overview ¶
Package system ingests monitoring information from system
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MonitorProvider = stage.IngestProvider{ StageType: "sysmon", Instantiator: func(cfg interface{}) *node.Init { log := logrus.WithField("stageType", "sysmon") interval, err := time.ParseDuration(cfg.(Monitor).Interval) if err != nil { log.WithField("interval", defaultInterval).Infof("using default interval") interval = defaultInterval } return node.AsInit(func(out chan<- map[string]interface{}) { ticker := time.NewTicker(interval) defer ticker.Stop() for { <-ticker.C stats := map[string]interface{}{} vmem, err := mem.VirtualMemory() if err != nil { log.WithError(err).Warn("can't fetch virtual memory. Skipping") continue } stats["memoryPercent"] = 100 * vmem.Available / vmem.Total scpu, err := cpu.Percent(0, true) if err != nil { log.WithError(err).Warn("can't fetch cpu stats. Skipping") continue } for i, sc := range scpu { stats[fmt.Sprintf("cpuPercent%d", i)] = sc } scpu, err = cpu.Percent(0, false) if err != nil { log.WithError(err).Warn("can't fetch cpu stats. Skipping") continue } stats["cpuPercentTotal"] = scpu[0] nios, err := net.IOCounters(false) if err != nil { log.WithError(err).Warn("can't fetch cpu stats. Skipping") continue } for _, nio := range nios { stats["netBytesSentPerSecond_"+nio.Name] = nio.BytesSent stats["netBytesRecvPerSecond_"+nio.Name] = nio.BytesRecv } out <- stats } }) }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.