#!/bin/sh

#The very first  "cpu" line aggregates the  numbers in all  of the other "cpuN"
#lines.  These numbers identify the amount of time the CPU has spent performing
#different kinds of work.  Time units are in USER_HZ (typically hundredths of a
#second).  The meanings of the columns are as follows, from left to right:
#
#- user: normal processes executing in user mode
#- nice: niced processes executing in user mode
#- system: processes executing in kernel mode
#- idle: twiddling thumbs
#- iowait: waiting for I/O to complete
#- irq: servicing interrupts
#- softirq: servicing softirqs

#cpu  762809 10329 405359 118868625 469963 349362 903357
#cpu0 762809 10329 405359 118868625 469963 349362 903357

cat /proc/stat | awk -W source '
BEGIN {
	load = 0;
	io = 0;
};

/^cpu[^0-9]/ { load = $2 + $3 + $4 + $6 + $7 + $8; io = $6 + $7 + $8; }

END {
	print load;
	print io;
}
'
uptime 
uname -n
