# bestman.conf
# sample Bestman config file for nl_dbquery

[DEFAULT]
# put defaults here

# These are the query sections
[event_names]
   desc = "List all event names for srm"
   query = """select name, from_unixtime(min(time)), from_unixtime(max(time))
              from event where name like 'srm.%' group by name order by name;"""
   header = event_type first last

[finished_requests]
   desc = "Total number of finished requests"
   query = """select name, count(id) from event where name like 'srm.server.req.%' and startend = 1 group by name;"""
   header=request_type number

[request_latency]
   desc = "Mean, min, and max latency for request queued to request scheduled"
   query = """select e1.name, avg(e2.time - e1.time), min(e2.time - e1.time), max(e2.time - e1.time) from event e1
   join ident req on e1.id = req.e_id
   join ident req2 on req2.value = req.value
   join event e2 on req2.e_id = e2.id
   where e1.name like 'srm.server.req.%.queued' 
   and e2.name like 'srm.server.req.%.scheduled'
   and req.name='req' 
   group by e1.name;"""
   header=request_type mean_time min_time max_time

[transfer_latency]
      desc = "Mean, min, and max latency for data transfers"
      query = """select e1.name, avg(e2.time - e1.time), min(e2.time - e1.time), max(e2.time - e1.time) from event e1
      join ident req on e1.id = req.e_id
      join ident req2 on req2.value = req.value
      join event e2 on req2.e_id = e2.id
      where e1.name like 'srm.server.tx.%' and e1.startend = 0 
      and e2.name like 'srm.server.tx.%' and e2.startend = 1
      and req.name='req' 
      and req.value != 'unknown'
      group by e1.name;"""
      header=transfer_type mean_time min_time max_time

[transfer_bw]
        desc = "Mean, min, and max bandwidth for data transfers"
        query = """select e1.name, avg(sz.value/(e2.time - e1.time)/131072), min(sz.value/(e2.time - e1.time)/131072), max(sz.value/(e2.time - e1.time)/131072) from event e1
        join ident req on e1.id = req.e_id
        join ident req2 on req2.value = req.value
        join event e2 on req2.e_id = e2.id
        join ident req3 on req3.value = req.value
        join event e3 on req3.e_id = e3.id
        join attr sz on sz.e_id = e3.id
        where e1.name like 'srm.server.tx.%' and e1.startend = 0 
        and e2.name like 'srm.server.tx.%' and e2.startend = 1
        and e3.name  like 'srm.server.tx.%.size'
        and req.name = 'req' 
        and req.value <> 'unknown'
        and sz.name = 'bytes'
        group by e1.name;"""
        header=transfer_type mean_Mbs min_time max_time
