Delete old files

This commit is contained in:
Thomas Roehl
2021-03-25 14:45:15 +01:00
parent 6fbaf21841
commit da7faad595
6 changed files with 0 additions and 637 deletions

View File

@@ -1,64 +0,0 @@
package collectors
import (
"bytes"
"fmt"
"time"
protocol "github.com/influxdata/line-protocol"
)
type LikwidCollector struct {
name string
tags []*protocol.Tag
fields []*protocol.Field
t time.Time
encoder *protocol.Encoder
}
func (c *LikwidCollector) Name() string {
return c.name
}
func (c *LikwidCollector) TagList() []*protocol.Tag {
return c.tags
}
func (c *LikwidCollector) FieldList() []*protocol.Field {
return c.fields
}
func (c *LikwidCollector) Time() time.Time {
return c.t
}
func (c *LikwidCollector) New() {
buf := &bytes.Buffer{}
c.encoder = protocol.NewEncoder(buf)
c.encoder.SetMaxLineBytes(1024)
}
func (c *LikwidCollector) Start(
level string,
frequency time.Duration,
duration int) {
ticker := time.NewTicker(frequency * time.Second)
done := make(chan bool)
go func() {
for {
select {
case <-done:
return
case t := <-ticker.C:
fmt.Println("Tick at", t)
c.encoder.Encode(c)
}
}
}()
time.Sleep(1600 * time.Second)
ticker.Stop()
done <- true
fmt.Println("Ticker stopped")
}

View File

@@ -1,3 +0,0 @@
{
"command": "read_memavg.sh"
}

View File

@@ -1,48 +0,0 @@
package main
import (
"strings"
"io/ioutil"
"fmt"
"time"
"os"
"strconv"
)
func main() {
t := time.Now()
hostname, err := os.Hostname()
if err != nil {
fmt.Println("#", err)
os.Exit(1)
}
hostname = strings.Split(hostname, ".")[0]
data, err := ioutil.ReadFile("/proc/meminfo")
if err != nil {
fmt.Println("#", err)
os.Exit(1)
return
}
lines := strings.Split(string(data), "\n")
for _, l := range lines {
if strings.HasPrefix(l, "MemTotal") {
f := strings.Fields(l)
v, err := strconv.ParseInt(f[1], 10, 0)
if err == nil {
fmt.Printf("mem_total,hostname=%s value=%v %v\n", hostname, v*1024, t.UnixNano())
}
} else if strings.HasPrefix(l, "MemAvailable") {
f := strings.Fields(l)
v, err := strconv.ParseInt(f[1], 10, 0)
if err == nil {
fmt.Printf("mem_avail,hostname=%s value=%v %v\n", hostname, v*1024, t.UnixNano())
}
} else if strings.HasPrefix(l, "MemFree") {
f := strings.Fields(l)
v, err := strconv.ParseInt(f[1], 10, 0)
if err == nil {
fmt.Printf("mem_free,hostname=%s value=%v %v\n", hostname, v*1024, t.UnixNano())
}
}
}
return
}

View File

@@ -1,12 +0,0 @@
#!/bin/bash
TOTAL=$(grep "MemTotal" /proc/meminfo | awk '{print $2}')
AVAIL=$(grep "MemAvailable" /proc/meminfo | awk '{print $2}')
FREE=$(grep "MemFree" /proc/meminfo | awk '{print $2}')
HOST=$(hostname -s)
echo "mem_total,host=$HOST value=$TOTAL"
echo "mem_avail,host=$HOST value=$AVAIL"
echo "mem_free,host=$HOST value=$FREE"