#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG 7.0				#
#							#
# Licensed under GNU LESSER GENERAL PUBLIC LICENSE v3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

NICE_IGNORE=20

t="0"
while
read cpu ni;
do
if [[ $ni -le $NICE_IGNORE ]]; then
	t="$t + $cpu"
fi
if [[ ${cpu%%.*} -eq 0 ]]; then
break
fi
done < <(ps -Ao "%cpu= ni="| sort -r)
cpu=$(echo "$t" | bc)
if [[ ! "${cpu#.}x" = "${cpu}x" ]]; then
	cpu="0${cpu}"
fi
cpu=${cpu%%.*}
if [[ $cpu -gt 100 ]]; then
cpu=100
fi
echo $cpu 
