Hello.
I did some refactoring to previous patch. Improvements:
1) Wait is determined by class and event without affecting to atomic usage of it. 
They are still stored in one variable. This improvement gives an opportunity to make  
more detailed views later (waits can be grouped by class).
2) Only active wait of each backend is visible. pg_report_wait_end() function called
 on the end of wait and clears it.
 3) Wait name determination was optimized (last version used cycles for each of them, 
and was very heavy). I added lazy `group` field to LWLock, which used as index in
 lwlock names array.
4) New wait can be added by more simpler way. For example an individual lwlock
requires only specifying its name in LWLock names arrayb
5) Added new types of waits: Storage, Network, Latch
This patch is more informative and it'll be easier to extend.
Sample:
 b1=# select pid, wait_event from pg_stat_activity;
  pid  |          wait_event          
 -------+------------------------------
  17099 | LWLocks: BufferCleanupLock
  17100 | Locks: Transaction
  17101 | LWLocks: BufferPartitionLock
  17102 | 
  17103 | Network: READ
  17086 | 
 (6 rows)
-- 
Ildus Kurbangaliev
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company