The CPU Usage information is found by reading the file /proc/stat. Based on the data gathering interval either the 1, 5 or 15 minute average is used.
/proc/stat contains information on a per-cpu basis and a total for the system. We look for the CPU keyword and get the first five numbers (user, nice, system, idle, and wait_io times). These numbers grow over time, so next time we read those same numbers and calculate the difference between the last run and this run to obtain numbers for the interval. Percentages are based on how much of the total cpu usage was in each category (again the difference between last number and this one).
The load data is found by reading the file /proc/loadavg. Based on the data gathering interval either the 1, 5 or 15 minute average is used.