# derived metrics for processes

# metrics to provide additional process details
proc.psinfo.age = kernel.all.uptime - proc.psinfo.start_time
proc.psinfo.age(oneline) = time in seconds since process was started
proc.psinfo.age(helptext) = '\
time in seconds since process was started, calculated from
proc.psinfo.start_time subtracted from kernel.all.uptime.'

proc.io.total_bytes = instant(proc.io.read_bytes) + instant(proc.io.write_bytes) - instant(proc.io.cancelled_write_bytes)
proc.io.total_bytes(oneline) = total bytes read and written by process
proc.io.total_bytes(helptext) = '\
total bytes read and written by the process, less cancelled written bytes.'

# metrics to identify resource hogs
proc.hog.cpu = 100 * (rate(proc.psinfo.utime) + rate(proc.psinfo.stime)) / (kernel.all.uptime - proc.psinfo.start_time)
proc.hog.cpu(oneline) = average percentage CPU utilization of each process
proc.hog.cpu(helptext) = '\
average CPU utilization of each process expressed as a percentage
of time since the process started.'

proc.hog.mem = proc.memory.vmrss + proc.memory.vmswap
proc.hog.mem(oneline) = sum of resident and swapped memory used by the process
proc.hog.mem(helptext) = '\
amount of resident and swapped memory used by each process.'

proc.hog.disk = (rate(proc.io.read_bytes) + rate(proc.io.write_bytes) - rate(proc.io.cancelled_write_bytes)) / (kernel.all.uptime - proc.psinfo.start_time)
proc.hog.disk(oneline) = average I/O rate of each process since it was started
proc.hog.disk(helptext) = '\
average I/O rate (reads and writes less cancelled writes) of each process
since it was started.'

proc.hog.net = rate(bcc.proc.net.tcp.recv.bytes) + rate(bcc.proc.net.tcp.send.bytes) + rate(bcc.proc.net.udp.recv.bytes) + rate(bcc.proc.net.udp.send.bytes)
proc.hog.net(oneline) = sum of network usage by the process
proc.hog.net(helptext) = '\
sum of network usage (TCP/UDP recv/send) by each process.'
