Skip to content

Instantly share code, notes, and snippets.

@olegp
Created November 22, 2011 22:23
Show Gist options
  • Save olegp/1387227 to your computer and use it in GitHub Desktop.
Save olegp/1387227 to your computer and use it in GitHub Desktop.
Cloudkick plugin for reporting CPU usage of processes based on their name
#!/bin/bash
# reports the combined cpu usage across all processes that include $1 in their name
N=0
LINES=$(ps -eo pcpu,args | grep $1)
while read -r LINE; do
C=$(echo $LINE | cut -d" " -f1)
N=$(echo "$N+$C" | bc)
done <<< "$LINES"
echo "status ok ok"
echo "metric cpu float $N"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment