Skip to content

Instantly share code, notes, and snippets.

View Ciaran0's full-sized avatar

Ciaran O'Connor Ciaran0

View GitHub Profile
@Ciaran0
Ciaran0 / gist:eb626d0336498f8bedc6
Last active August 29, 2015 14:25
Send core usage stats to StatsD
#!/bin/bash
#For this script to run first run top command. press 1 to see core information. Press W to set this a default
#hostname is a parametre
NUM_CPUS=$(top -bn 1 | grep -c "Cpu")
while true;
do
top -bn 2 | grep -o "Cpu.........." | tail -n $NUM_CPUS > /tmp/topLog.txt;
sed -e "s/Cpu[[:alnum:]] : //g" -e "s/Cpu[[:alnum:]][[:alnum:]] : //g" -e "s/ //g" /tmp/topLog.txt > /tmp/topLog2.txt;