Script to monitor the progress of an emerge

What does it do ?

It measures the progress of an emerge, and tries to give an estimation on how long it will take to complete.

How does it work ?

It counts the number of files which end with ".c*" and the number of files which end with ".o". The assumption is that every C file should result in an O file (I know this is incorrect, but seems to be a nice indication).
Then it calculates two things: First of all, the percentage of O files related to the C files, so in theory, the percent of files allready compiled.
After that is calculates the number of files processed in the last measurement interval, to get an idea of the speed of the process (An other assumption is made here: All files take the same time to compile, which is never true). To get a more accurate indication, the average of the last 5 intervals is calculated.
With that number, it calculates how long it will take to calculate the remaining C files, which is the time estimation.

Do i need to be root to use it ?

No, any regular user has enough priviledges.

What does it look like ?

This is the result when i started it after i started an emerge of wireshark:
Time      O-Files / C-Files   Done  Estimated time left
13:28:38 :    244 / 1273   =   19%  Unknown min.
13:30:38 :    355 / 1273   =   27%  16 min.
13:32:38 :    467 / 1273   =   36%  14 min.
13:34:39 :    583 / 1273   =   45%  12 min.
13:36:39 :    690 / 1273   =   54%  10 min.
13:38:39 :    803 / 1273   =   63%  8 min.
13:40:40 :    904 / 1273   =   71%  6 min.
13:42:40 :   1049 / 1273   =   82%  3 min.
Emerge ready.

How do i use it ?

First, you should give the script execure permissions, i generally use chmod 755 monitor_emerge.sh, which gives me all permissions, and others may read and execute (but not write/modify).
If you did that, start if with:
./monitor_emerge.sh <package-name-with-version> , so in my case of wireshark it was:
./monitor_emerge.sh wireshark-0.99.2 .

How do i get it ?

You can get it here: Download
(If your browser doesn't start a download, just use the "save link target as ..." option in your browser).

Valid HTML 4.01 Transitional Written in the vi editor