code: def count_events (env, evtpath, filter):
      
      with env.slurp (argv=['dmstat', '%s%s[cols energy]' % (evtpath, filter)], linebreak=True) as s:
          for etype, payload in s:
              if etype != 'stdout':
                  continue
  
              if b'good:' not in payload:
                  continue
  
              return int (payload.split ()[-1])
  
      raise Exception ('parsing of dmlist output failed')
docs: TODO: this can probably be replaced with simply reading the file
      ourselves!