Created
November 22, 2011 22:23
-
-
Save olegp/1387227 to your computer and use it in GitHub Desktop.
Cloudkick plugin for reporting CPU usage of processes based on their name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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