#!/bin/bash
WARN=85
CRIT=95
TOPLIST=$(ps ax -o pcpu,command --sort=-pcpu | head -n6 | tail -n5)
I=1
while read CPULOAD LINUXCOMMAND PARAMETERS
do
echo "P TOP_5_$I cpuload=$CPULOAD;$WARN;$CRIT $LINUXCOMMAND has a cpu load of $CPULOAD"
I=$((I+1))
done <<< $TOPLIST
This script does not create that useful output. The only relevant information it contains, is: "This process named xyz is currently causing cpu usage abc %.
The command causing the cpu usage may be a different one on every run. So the graphs it generates are completely useless because it consists of values of random programs.
I’m currently too looking for a useful way to do this.