port wmstats script to WMCore codebase