mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-07-19 11:21:41 +02:00
Delete old files
This commit is contained in:
@@ -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")
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"command": "read_memavg.sh"
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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"
|
Reference in New Issue
Block a user