you don't have to script anything. the functionality is part of the linux kernel and a tool like ntop (version 2+) will show all sorts of pretty graphs and tables on any browser.