system_ostent

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2016 License: MIT Imports: 11 Imported by: 0

README

* package system_ostent

Package =system_ostent= implements "=system_ostent=" input plugin.
It derived from "=system=" plugin with the following changes.

#+BEGIN_SRC sh :results raw
fst=../vendor/github.com/influxdata/telegraf/plugins/inputs/system/system.go
snd=../system_ostent/system_ostent.go
printf -- '--- %s\n' "$fst"
printf -- '+++ %s\n' "$snd"

diff --unified --ignore-all-space \
"$fst" \
"$snd" |
sed 1,2d # filenames printed already
exit $? # ......................................................... END HERE .

# bash syntax: have above: #+BEGIN_SRC bash
diff --unified \
<(go run print_ast.go -- "$fst" | grep -vF -- "$fst" | grep -v Rparen:) \
<(go run print_ast.go -- "$snd" | grep -vF -- "$snd" | grep -v Rparen:) |
sed 1,2d # filenames printed already
#+END_SRC

#+BEGIN_SRC diff
#+RESULTS:
--- ../vendor/github.com/influxdata/telegraf/plugins/inputs/system/system.go
+++ ../system_ostent/system_ostent.go
@@ -1,10 +1,8 @@
-package system
+package system_ostent
 
 import (
-	"bufio"
-	"bytes"
-	"fmt"
-	"runtime"
+	"os"
+	"strings"
 
 	"github.com/shirou/gopsutil/host"
 	"github.com/shirou/gopsutil/load"
@@ -27,12 +25,12 @@
 		return err
 	}
 
-	hostinfo, err := host.Info()
+	hostname, err := os.Hostname()
 	if err != nil {
 		return err
 	}
 
-	users, err := host.Users()
+	upseconds, err := host.Uptime()
 	if err != nil {
 		return err
 	}
@@ -41,16 +39,15 @@
 		"load1":         loadavg.Load1,
 		"load5":         loadavg.Load5,
 		"load15":        loadavg.Load15,
-		"uptime":        hostinfo.Uptime,
-		"n_users":       len(users),
-		"uptime_format": format_uptime(hostinfo.Uptime),
-		"n_cpus":        runtime.NumCPU(),
+		"hostname_short": strings.Split(hostname, ".")[0],
+		"uptime_format":  format_uptime(upseconds),
 	}
-	acc.AddFields("system", fields, nil)
+	acc.AddFields("system_ostent", fields, nil)
 
 	return nil
 }
 
+/*
 func format_uptime(uptime uint64) string {
 	buf := new(bytes.Buffer)
 	w := bufio.NewWriter(buf)
@@ -75,9 +72,10 @@
 	w.Flush()
 	return buf.String()
 }
+*/
 
 func init() {
-	inputs.Add("system", func() telegraf.Input {
+	inputs.Add("system_ostent", func() telegraf.Input {
 		return &SystemStats{}
 	})
 }
#+END_SRC

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetIOStats

type NetIOStats struct {
	Interfaces []string
	// contains filtered or unexported fields
}

func (*NetIOStats) Description

func (_ *NetIOStats) Description() string

func (*NetIOStats) Gather

func (s *NetIOStats) Gather(acc telegraf.Accumulator) error

func (*NetIOStats) SampleConfig

func (_ *NetIOStats) SampleConfig() string

type PS

type PS interface{}

type SystemStats

type SystemStats struct{}

func (*SystemStats) Description

func (_ *SystemStats) Description() string

func (*SystemStats) Gather

func (_ *SystemStats) Gather(acc telegraf.Accumulator) error

func (*SystemStats) SampleConfig

func (_ *SystemStats) SampleConfig() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL