Skip to content

Instantly share code, notes, and snippets.

View li-zhixin's full-sized avatar

历知辛 li-zhixin

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
namespace MemTestPlain
{
class Program
{
static void Main(string[] args)
{
@pcolby
pcolby / cpu.sh
Created September 14, 2013 04:29
Calculating CPU Usage from /proc/stat
#!/bin/bash
# by Paul Colby (http://colby.id.au), no rights reserved ;)
PREV_TOTAL=0
PREV_IDLE=0
while true; do
CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
unset CPU[0] # Discard the "cpu" prefix.
IDLE=${CPU[4]} # Get the idle CPU time.