mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-07-19 11:21:41 +02:00
Script version, no time loop
This commit is contained in:
10
collectors/likwid/README.md
Normal file
10
collectors/likwid/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# LIKWID collector
|
||||
|
||||
Measure hardware performance counters with LIKWID
|
||||
|
||||
# Build
|
||||
- Download LIKWID
|
||||
- Configure LIKWID with SHARED=false
|
||||
- Build
|
||||
- Copy static libraries in current folder
|
||||
- Copy likwid.h, likwid-marker.h and bstrlib.h in current folder
|
31
collectors/likwid/likwid.go
Normal file
31
collectors/likwid/likwid.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
/*
|
||||
#cgo CFLAGS: -I.
|
||||
#cgo LDFLAGS: -L. -llikwid -llikwid-hwloc -lm
|
||||
#include <stdlib.h>
|
||||
#include <likwid.h>
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
import "unsafe"
|
||||
|
||||
func main() {
|
||||
var topo C.CpuTopology_t
|
||||
C.topology_init();
|
||||
topo = C.get_cpuTopology()
|
||||
cpulist := make([]C.int, topo.numHWThreads)
|
||||
for a := 0; a < int(topo.numHWThreads); a++ {
|
||||
cpulist[C.int(a)] = C.int(a)
|
||||
}
|
||||
C.perfmon_init(C.int(topo.numHWThreads), &cpulist[0])
|
||||
gstring := C.CString("INSTR_RETIRED_ANY:FIXC0")
|
||||
gid := C.perfmon_addEventSet(gstring)
|
||||
C.perfmon_setupCounters(gid)
|
||||
C.perfmon_startCounters()
|
||||
C.perfmon_stopCounters()
|
||||
v := C.perfmon_getResult(gid, 0, 0)
|
||||
fmt.Println(v)
|
||||
C.free(unsafe.Pointer(gstring))
|
||||
C.perfmon_finalize()
|
||||
C.topology_finalize();
|
||||
}
|
3
collectors/memavg/config.json
Normal file
3
collectors/memavg/config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"command": "read_memavg.sh"
|
||||
}
|
12
collectors/memavg/read_memavg.sh
Executable file
12
collectors/memavg/read_memavg.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/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 $TOTAL"
|
||||
echo "mem_avail,host=$HOST $AVAIL"
|
||||
echo "mem_free,host=$HOST $FREE"
|
Reference in New Issue
Block a user