riaps.deplo.netmon module

Resource monitors

Created on Nov 23, 2017

@author: riaps

class riaps.deplo.netmon.NHAction[source]

Bases: object

MAP = {1: 'SET', 2: 'REMOVE'}
REMOVE = 2
SET = 1
class riaps.deplo.netmon.NHLoopStatus[source]

Bases: object

Return codes from nethogsmonitor_loop()

FAILURE = 1
MAP = {0: 'OK', 1: 'FAILURE', 2: 'NO_DEVICE'}
NO_DEVICE = 2
OK = 0
class riaps.deplo.netmon.NHMonitorRecord[source]

Bases: Structure

ctypes version of the struct of the same name from libnethogs.h

device_name

Structure/Union member

name

Structure/Union member

pid

Structure/Union member

record_id

Structure/Union member

recv_bytes

Structure/Union member

recv_kbs

Structure/Union member

sent_bytes

Structure/Union member

sent_kbs

Structure/Union member

uid

Structure/Union member

class riaps.deplo.netmon.NetMonitorThread(parent)[source]

Bases: Thread

addClientDevice(appName, actorName, device, proc, rate)[source]
addProc(appName, actName, proc)[source]
delProc(appName, actName, proc)[source]
dev_args(devnames)[source]

Return the appropriate ctypes arguments for a device name list, to pass to libnethogs nethogsmonitor_loop_devices. The return value is a 2-tuple of devc (ctypes.c_int) and devicenames (ctypes.POINTER) to an array of ctypes.c_char).

Parameters:

devnames (list) – list of device names to monitor

Returns:

2-tuple of devc, devicenames ctypes arguments

Return type:

tuple

is_running()[source]
network_activity_callback(_action, data)[source]
restart()[source]
run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

stop()[source]
terminate()[source]