This module contains functionality for accessing the realtime parts of the PacketLogic system, such as system diagnostics, channel statistics and dynamic netobject items.
Do NOT import this module directly. The PLConnection object should be used, e.g:
>>> import packetlogic2 >>> pl = packetlogic2.connect("192.168.1.25", "admin", "password") >>> rt = pl.Realtime()
Operations on dynamic netobject items.
Methods: | ||
---|---|---|
Ungrouped | add(self, no, ip, subscriber='', is_subscriber=False, linkspeed_in=0, linkspeed_out=0, natcfg='', properties={}) Add a dynamic netobject item |
|
list of tuple
|
list(self, netobject=None, ip=None, recurse=False, properties=[]) List dynamic netobject items |
|
remove(self, no, ip) Remove a dynamic netobject item |
||
int
|
remove_orphans(self) Removes all orphan dynamic netobject items |
|
set(self, baseno, ip, items) Set multiple dynamic netobject items under a base netobject |
||
set_begin(self, baseno) Starts a session of following set() operations under a base netobject |
||
int
|
set_end(self, baseno, abort=False) Ends a session of set() operations, started by set_begin(), under a base |
Class Variables: | |
---|---|
SUBSCRIBER_NAME | Constant for the "subscriber name" key in property lists. |
IS_SUBSCRIBER | Constant for the "is subscriber" key in property lists. |
LINKSPEED_IN | Constant for the "inbound linkspeed" key in property lists. |
LINKSPEED_OUT | Constant for the "outbound linkspeed" key in property lists. |
NATCFG | Constant for the "nat config" key in property lists. |
Add a dynamic netobject item Please note that netobject will not be verified with regard to performance and flexibility when adding to a uncommitted netobject. >>> rt.dyn.add(31682, '127.0.0.1') @type id: C{int} @param id: the id number of the netobject to add the item to. @type ip: C{str} @param ip: the IP address to add. @type subscriber: C{str} @param subscriber: Subscriber name - or empty string to not create subscriber. @type is_subscriber: C{bool} @param is_subscriber: is subscriber property - used for subscriber count in statistics. @type linkspeed_in: C{int} @param linkspeed_in: linkspeed_in property - used in statistics. @type linkspeed_out: C{int} @param linkspeed_out: linkspeed_out property - used in statistics. @type natcfg: C{str} @param natcfg: natcfg property - used to config subscribers NAT. Requires v14.0 firmware or newer. @type properties: C{dict} @param properties: Dict of properties. Requires v15.1 firmware of newer. properties is a dict which may contain zero or more of the keys rt.dyn.SUBSCRIBER_NAME, rt.dyn.IS_SUBSCRIBER, rt.dyn.LINKSPEED_IN, rt.dyn.LINKSPEED_OUT, rt.dyn.NATCFG, rt.dyn.USERDATA{1-8} @raises PLDPermissionError: If the user lacks permission for requested action @raises PLDServerError: If server reported an error @raises ValueError: If an invalid IP address is used
List dynamic netobject items.
>>> rt.dyn.list(netobject=300, recurse=True, properties=[rt.dyn.SUBSCRIBER_NAME]) [('10.0.0.2', [(339L, [{1: 'User0001'}]), (337L, [{1: 'User0001'}])]), ('10.0.0.3', [(339L, [{1: 'User0002'}]), (335L, [{1: 'User0002'}])])]
list
of tuple
int
) - Only list items in specified netobject (or any netobject under it if
recurse parameter is True)
str
) - Only list items for specified ip/mask address (or any ip under it if
recurse parameter is True)
bool
) - Also list items below specified netobject/ip
list
) - Properties to include in result. Should be a list containing zero or more
of SUBSCRIBER_NAME, IS_SUBSCRIBER, LINKSPEED_IN, LINKSPEED_OUT, NATCFG
Remove a dynamic netobject item
>>> rt.dyn.remove(31682, '127.0.0.1')
int
) - the id number of the netobject to remove the item from.
str
) - the ip number to remove.
Removes all orphan dynamic netobject items. An orphan dynamic netobject item is a dynamic netobject item created in a netobject that no longer exists. For example:
>>> rs=pl.Ruleset() >>> rt=pl.Realtime() >>> o=rs.object_add("/NetObjects/example") >>> rs.commit() >>> # Wait for plrcd to read up the commit
>>> rt.dyn.add(o.id, '127.0.0.1', "subscriber") True >>> rs.object_remove(o) >>> rs.commit() >>> # Wait for plrcd to read up the commit
>>> rt.dyn.remove_orphans() 1L
Note that created/removed object will not appear/disappear until the change has been committed. Be warned that the following might remove wanted dynamic netobject items:
>>> rs=pl.Ruleset() >>> rt=pl.Realtime() >>> o=rs.object_add("/NetObjects/example2") >>> rt.dyn.add(o.id, '127.0.0.2', "subscriber2") True >>> rt.dyn.remove_orphans() 1L
In this example the newly added dynamic netobject item '127.0.0.2' will be removed by remove_orphan() as the parent netobject was not yet committed.
int
Set multiple dynamic netobject items under a base netobject. >>> rt.dyn.set(300, "10.0.0.4", [(339, {rt.dyn.SUBSCRIBER_NAME: 'User0003', rt.dyn.IS_SUBSCRIBER: True}), ... (337, {rt.dyn.SUBSCRIBER_NAME:'User0003', rt.dyn.IS_SUBSCRIBER: True})]) >>> rt.dyn.set(300, "10.0.0.3", []) This function replaces all dynamic netobject items that exists for the specified ip address in the netobject tree under the specified base netobject id. @type baseno: C{int} @param baseno: the id number of the netobject to operate under. @type ip: C{str} @param ip: the ip number to set items for. @type items: C{sequence} of C{tuples} @param items: the items to add, each item should be a tuple of (netobjectid, properties), where properties is a dict which may contain zero or more of the keys rt.dyn.SUBSCRIBER_NAME, rt.dyn.IS_SUBSCRIBER, rt.dyn.LINKSPEED_IN, rt.dyn.LINKSPEED_OUT rt.dyn.NATCFG rt.dyn.USERDATA{1-8} @raises PLDPermissionError: If the user lacks permission for requested action @raises PLDUnsupportedInFirmware: If firmware doesn't support this function. @raises PLDServerError: If server reported an error
Starts a session of following set() operations under a base netobject.
When zero or more set() have been performed and set_end() is called, all dynamic netobject items under the baseno NetObject that were not set by any set() will be removed.
Performing a series of set() operations between a pair of set_begin() and set_end() will make sure that all dynamic netobject items under the baseno NetObject will be exactly defined by the of set() operations.
Note that a new set_begin() can not be issued until the corresponding closing set_end() has been performed.
Also note that all following set() operations must have the same baseno NetObject id as the one provided in set_begin().
int
) - the id number of the netobject to operate under.
Ends a session of set() operations, started by set_begin(), under a base netobject.
When zero or more set() have been performed and set_end() is called all dynamic netobject items under the baseno NetObject that were not set by any set() operation will be removed.
Performing a series of set() operations between a pair of set_begin() and set_end() will make sure that all dynamic NetObject items under the baseno NetObject will be exactly defined by the series of dyn_set() operations.
int
int
) - Id number of the netobject to operate under.
bool
) - Set to True to abort the session without removing items belonging to ip
addresses that did not receive a call to set() in the session.
Operations on the key vault used for encrypted property objects.
>>> # Set key at index 3 >>> rt.keyvault.set(3, "abc123") >>> # Add an property object with encryption >>> obj = rs.object_add("/PropertyObject/Sensitive") >>> o.attributes['encrypted'] = "3"
Methods: | ||
---|---|---|
Ungrouped | int
|
index(self, key) Find index of key |
reset(self, index) Remove a key from the key vault |
||
set(self, index, key) Set a key in the key vault to the specified string |
Find index of key.
int
str
) - The encryption key
Remove a key from the key vault.
int
) - Index of the key to remove.
Set a key in the key vault to the specified string.
int
) - Index of the key to remove.
str
) - The new encryption key.
Class for connecting and communicating with packetlogicd, the realtime part of PacketLogic.
When using the multiversion API you will access this class via the PLConnection.Realtime() method.
All functions that communicate with the PacketLogic Realtime system might raise errors common to all or many of the functions.Here is a list of such errors, that might not be listed on each method:
Methods: | ||
---|---|---|
Dynamic NetObject items | boolean
|
dyn_add(self, id, ip, subscriber='', is_subscriber=False, linkspeed_in=0, linkspeed_out=0, natcfg='') Add a dynamic netobject item |
list of tuple
|
dyn_list(self) List all dynamic netobject items |
|
list of tuple
|
dyn_list_full(self) List all dynamic netobject items including subscriber names |
|
list of tuple
|
dyn_list_mask(self, ip, mask) List all dynamic netobject items matching the specified ipaddress and |
|
list of tuple
|
dyn_list_no(self, id) List dynamic netobject items matching the specified netobject id |
|
boolean
|
dyn_remove(self, id, ip) Remove a dynamic netobject item |
|
Firewall Log | fwlog_clear(self) Clear the firewall log |
|
tuple of list and dict
|
fwlog_query_offsets(self, first_nr, last_nr, clear=False, no_reverse=False) Query the firewall log for a list of entries between two offsets |
|
tuple of dict and list
|
fwlog_query_rule(self, id) Query the firewall log for a list of entries matching a specific firewall |
|
tuple of list and dict
|
fwlog_query_time_range(self, timefr, timeto) Query the firewall log for a list between two points in time |
|
Internal | tuple of list
|
dump_bgptable(self) Dump the bgp table |
inject_packet(self, iface, pkt) Inject a packet |
||
reload_drdl(self) Reload drdl signatures |
||
Realtime Data | add_channels_callback(self, func) Add a callback to call with channel statistics data while updating |
|
add_netobj_callback(self, func, under=None, include_hosts=False) Add a callback to call with realtime NetObject data while updating |
||
add_service_callback(self, func) Add a callback to call with realtime service data while updating |
||
add_shapingcnt_callback(self, func) Add a callback for byte counters |
||
add_shapingobject_callback(self, func) Add a callback to call with realtime shapingobject data while updating |
||
add_sysdiag_callback(self, func) Add a callback to call with system diagnostics data while updating |
||
add_update_done_callback(self, func) Add a callback to call after each update is done |
||
dict
|
get_channels_data(self, maxage=5) Get channel statistics data once |
|
RealtimeNetObjectTree | get_netobj_data(self, under=None) Get Realtime NetObject data once |
|
get_services_data(self) Get Realtime Services data once |
||
dict
|
get_sysdiag_data(self, maxage=5) Get system diagnostics data once |
|
shapingcnt_request_all(self) Requests all shaping counters, regardless if they have changed or not |
||
stop_updating(self) Stop the updating and clear callback functions |
||
update_forever(self, interval=5) Start updating |
||
Volume Based Shaping | list of tuple
|
vbs_list(self) List available vbs objects |
list of dict
|
vbs_query(self, machine, objid, extra=0) Query vbs data from a specific vbs object |
|
vbs_reset(self, machine, soid, extra=0) Reset vbs accounting data for a vbs object |
||
vbs_set(self, invalue, outvalue, machine, soid, extra=0) Set transfer to the specified value |
||
Ungrouped | add_aggr_view_callback(self, viewbuilder, callback) Add a view reporting aggregated data |
|
add_conn_view_callback(self, viewbuilder, func) Add a view reporting all connections matching the filter in specified |
||
add_fwrule_callback(self, func) Add a callback to call with realtime filtering rule data while updating |
||
add_host_callback(self, hostip, func) Add a callback to be called with realtime connection information for all |
||
break_update_forever(self) Stop the updating, but keep callback functions |
||
close(self) Immediately disconnect from packetlogic system |
||
str
|
drdl_revision(self) Retrieve revision string for currently loaded drdl ARM |
|
list of tuple
|
dyn_list_no_recurse(self, id) List dynamic netobject items matching the specified netobject id or an |
|
boolean
|
dyn_set(self, baseno, ip, items) Set multiple dynamic netobject items under a base netobject |
|
str
|
dyn_strerror(self) Return last error message from dyn_add/dyn_remove/dyn_set |
|
dynrule_clear(self, realm) Re-enable all rules in given realm |
||
dynrule_disable(self, realm, ruletype, rulename) Disable a rule |
||
dynrule_enable(self, realm, ruletype, rulename) Enable a previously disabled rule |
||
force_statistics_write(self) Force Statistics write to the disk |
||
ViewBuilder | get_view_builder(self) Get a ViewBuilder object for creating views |
|
shapingcnt_subscriber_flush(self, subscriber) Requests all shaping counters for a specific subscriber, regardless if they |
||
vcrc(self, criteria) Run virtual connection ruleset checker |
||
boolean
|
wait_for_ruleset(self, commitid, timeout=60) Waits for a ruleset of 'commitid' to be loaded and compiled by plrcd |
Properties: | |
---|---|
add_stats_callback | Deprecated alias for add_sysdiag_callback |
current_ruleset | |
distversion | |
dyn | Get a handle for dynamic netobject operations |
get_stats_data | Deprecated alias for get_sysdiag_data |
instanceid | |
keyvault | Get a handle for KeyVault operations |
systemid |
Add a view reporting aggregated data.
Data is aggregated in a tree structure according to the distribution and filter in the specified viewbuilder.
str
) - ViewBuilder defining the filter or string of name for existing LiveView in
PLDB
callable
) - function to call. The function is called with a RealtimeAggrNode
as its argument. This is the root of the aggregation tree.
Add a callback to call with channel statistics data while updating.
callable
) - function to call. The function is called with a dict with the channel ids
as key and a inner dict as value.
Add a view reporting all connections matching the filter in specified viewbuilder.
str
) - ViewBuilder defining the filter or string of name for existing LiveView in
PLDB
callable
) - function to call. The function is called with a list of RealtimeConn as its
argument.
Add a callback to call with realtime filtering rule data while updating.
callable
) - function to call. The function is called with one argument, a
dict
with filtering rule data. Key is filtering rule id, value
is a dict
of its properties.
Add a callback to be called with realtime connection information for all connections on specified host
str
) - IP address of host to retrieve realtime connection information for. Should
be an IP address as a string.
callable
) - function to call. The function is called with two arguments, the ipaddress
and a list of connections RealtimeConn on that
host. The list is None (not to be confused with the empty list) when the
host is removed and no more updates will happen.
Add a callback to call with realtime NetObject data while updating.
>>> PATH="/NetObjects/Everyone" >>> def cb(objs): ... print "#%d subscribers active under %s" % (len(objs), PATH) ... # print top10 ... objs.sort(key=lambda no: no.speed[0] + no.speed[1]) ... print "%-40s %9s %9s" % ("# Name", "inkbps", "outkbps") ... for no in objs[:10]: ... # convert to kbps ... inspd = no.speed[0]*8.0/1000 ... outspd = no.speed[1]*8.0/1000 ... print "%-40s %8.2f %8.2f" % (no.name, inspd, outspd) ... >>> rt.add_netobj_callback(cb, under=PATH) >>> rt.update_forever()
callable
) - function to call. The function is called with one argument, an RealtimeNetObjectTree
containing the list of RealtimeNetObjects
data, which is fetched with that objects methods.
str
) - Request netobject data under a specified path. In v12.0 and newer only
toplevel objects are included by default, and this in required to get data
for a specific path. Observe that only the objects directly under the
specified path is reported, no recursive listing. When 'under' is used the
callback is called with a list of RealtimeNetObjects
directly, no RealtimeNetObjectTree
intermediate layer.
bool
) - Request information about hosts under the netobject specified with the
under parameter. The argument passed to func will have an attribute named
"hosts" which is an iterable of RealtimeHost objects.
Add a callback to call with realtime service data while updating.
callable
) - function to call. The function is called with one argument, a
dict
of services. Key is servicename, value is a
dict
of its properties.
Add a callback for byte counters.
The signature of the callback should be:
cb(idx, oid, sk, flags, _in, _out)
idx is counter index in PL (i.e a number between 0 and MAX_COUNTERS) oidx is shaping object id sk is split key (i.e netobject id on split-by-netobject, ip on split-by-localhost, subscriber name on split-by-subscriber, and 0 on no split) flags is flags bitmask, if (1<<13) is set it means that this is the last update for this counter, and it will be reset to 0. _in and _out are bytecounters.
Add a callback to call with realtime shapingobject data while updating.
callable
) - function to call. The function is called with one argument, a
dict
with shapingobject data. Key is shaping object index,
value is a dict
of its properties.
Add a callback to call with system diagnostics data while updating.
callable
) - function to call. The function is called with a huge dict containing all
system diagnostics data.
Add a callback to call after each update is done.
callable
) - function to call. The function is called without any arguments
Stop the updating, but keep callback functions.
Like stop_updating but allows resuming updating by calling update_forever again.
Immediately disconnect from packetlogic system.
After this method has been called this object becomes useless.
It may be used to force a disconnect when the garbage collector can't be trusted to do a timely disconnect.
Retrieve revision string for currently loaded drdl ARM.
str
Dump the bgp table.
This function is just for debugging purposes. It will return the BGP table in packetlogicd.
tuple
of list
Add a dynamic netobject item
Please note that netobject will not be verified with regard to performance and flexibility when adding to a uncommitted netobject.
>>> rt.dyn_add(31682, '127.0.0.1') True
boolean
int
) - the id number of the netobject to add the item to.
str
) - the IP address to add.
str
) - Subscriber name - or empty string to not create subscriber. Requires v12.0
firmware or newer.
bool
) - is subscriber property - used for subscriber count in statistics. Requires
v12.4 firmware or newer.
int
) - linkspeed_in property - used in statistics. Requires v12.4 firmware or
newer.
int
) - linkspeed_out property - used in statistics. Requires v12.4 firmware or
newer.
str
) - natcfg property - used to config subscribers NAT. Requires v14.0 firmware
or newer.
List all dynamic netobject items
>>> rt.dyn_list() [(31589, '127.0.0.1'), (31576, '192.168.1.1'), (31589, '192.168.0.131'), (31688, '192.168.0.131'), (31577, '192.168.1.1'), (31682, '127.0.0.1')]
list
of tuple
List all dynamic netobject items including subscriber names
>>> rt.dyn_list() [(31589, '127.0.0.1', 'User 1'), (31576, '192.168.1.1', 'User 123'), (31589, '192.168.0.131', 'User 124'), (31688, '192.168.0.131', 'User 124'), (31577, '192.168.1.1', 'User 123'), (31682, '127.0.0.1', 'User 1')]
list
of tuple
List all dynamic netobject items matching the specified ipaddress and netmask
This command is NOT supported on system with PacketLogic version v11.359 or earlier. Using it will raise a timeout exception after about a minute.
>>> rt.dyn_list_mask('192.168.0.0', '255.255.252.0') [(31576, '192.168.1.1'), (31589, '192.168.0.131'), (31688, '192.168.0.131'), (31577, '192.168.1.1'), (31682, '192.168.2.33'), (31697, '192.168.3.142')]
list
of tuple
str
) - the ip number to use for matching.
str
) - the netmask to use for matching.
List dynamic netobject items matching the specified netobject id
This command is NOT supported on system with PacketLogic version v11.359 or earlier. Using it will raise a timeout exception after about a minute.
>>> rt.dyn_list_no(31576) [(31576, '192.168.1.1'), (31576, '192.168.0.131'), (31576, '192.168.2.13')]
list
of tuple
int
) - the id number of the netobject to match against.
List dynamic netobject items matching the specified netobject id or an netobject under it.
>>> rt.dyn_list_no_recurse(31576) [(31576, '192.168.1.1'), (31577, '192.168.0.131'), (31576, '192.168.2.13')]
list
of tuple
int
) - the id number of the parent netobject to match against.
Remove a dynamic netobject item
>>> rt.dyn_remove(31682, '127.0.0.1') True
boolean
int
) - the id number of the netobject to remove the item from.
str
) - the ip number to remove.
Set multiple dynamic netobject items under a base netobject.
This function replaces all dynamic netobject items that exists for the specified ip address in the netobject tree under the specified base netobject id.
boolean
int
) - the id number of the netobject to operate under.
str
) - the ip number to set items for.
sequence
of tuples
) - the items to add, each item should be a tuple of (netobjectid,
subscribername) or (netobject, subscribername, properties). Where
properties is a dict which may contain the keys is_subscriber, linkspeed_in
and linkspeed_out
Return last error message from dyn_add/dyn_remove/dyn_set
>>> rt.dyn_add(19, '10.0.0.1') True >>> rt.dyn_add(19, '10.0.0.1') False >>> rt.dyn_strerror() 'Item already exists'
str
Re-enable all rules in given realm.
Disable a rule.
Enable a previously disabled rule.
Force Statistics write to the disk.
Clear the firewall log.
Query the firewall log for a list of entries between two offsets
>>> info, results = rt.fwlog_query_offsets (0, 50) >>> print info {'logentries': 14054L} >>> print len(results) 50 >>> for i in results[0:3]: ....: print i ....: {'clientport': 39682, 'protocol': 6, 'service': 'Lunarstorm live', 'clienthostname': '', 'serverhostname': '', 'rule': 'Monitor ', 'server': '1.2.3.4', 'client': '5.6.7.8', 'serverport': 8080, 'time': 1138204688, 'type': 0, 'properties': ''} {'clientport': 55172, 'protocol': 6, 'service': 'HTTP', 'clienthostname': '', 'serverhostname': 'www.google.com', 'rule': 'Log HTTP', 'server': '209.85.129.104', 'client': '192.168.9.174', 'serverport': 80, 'time': 1250775399L, 'type': 0, 'properties': 'File length=0\nServer Hostname=www.google.com\nURL=http://www.google.com/search?q=packetlogic&ie=utf-8&oe=utf-8&aq=t\nRequest method=GET\nDirection=Inbound\nFilename=/search?q=packetlogic&ie=utf-8&oe=utf-8&aq=t\nUser-Agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.12) Gecko/2009072221\nTransfer-Encoding=None\nUpload file length=0\n'} {'clientport': 3252, 'protocol': 6, 'service': 'eDonkey transfer', 'clienthostname': '', 'serverhostname': '', 'rule': 'Monitor ', 'server': '10.10.11.11', 'client': '40.50.60.70', 'serverport': 7804, 'time': 1138204688, 'type': 0, 'properties': ''}
Grab all entries in the firewall log and clear once we get the last batch
>>> l = [] >>> numentries = rt.fwlog_query_offsets(0,0)[0]['logentries'] >>> for x in range(0, numentries, 500): ....: l += rt.fwlog_query_offsets(x, min(x+500, numentries), no_reverse=True)[1] ....: >>> l += rt.fwlog_query_offsets(numentries, -1, clear=True, no_reverse=True)[1] # grab entries logged while quering
tuple
of list
and dict
str
) - Start the list at this offset. 0 means the start of the firewall log.
str
) - End the list at this offset.
bool
) - If True, log is cleared after values are retrieved. This clears the whole
log and not the selected portion. Not supported in v12.0 firmwares.
bool
) - If True, the offsets are handled from oldest entry, not newest entry. i.e
fwlog_query_offsets(0,10,no_reverse=True) will list 10 oldest entries, not
10 newest. Not supported in v12.0 firmwares.
Query the firewall log for a list of entries matching a specific firewall rule
>>> info, results = rt.fwlog_query_rule(58) >>> print info {'logentries': 14054L} >>> print results [{'client': '10.0.0.2', 'clienthostname': '', 'clientport': 2985, 'properties': '', 'protocol': 6, 'rule': 'Monitor ', 'server': '10.0.1.3', 'serverhostname': '', 'serverport': 1512, 'service': 'Skype', 'time': 1138204680, 'type': 0}, {'client': '1.2.3.4', 'clienthostname': '', 'clientport': 3247, 'properties': '', 'protocol': 6, 'rule': 'Monitor ', 'server': '10.3.2.1', 'serverhostname': '', 'serverport': 17561, 'service': 'Undetermined', 'time': 1138204680, 'type': 0}, {'client': '3.2.1.2', 'clienthostname': '', 'clientport': 52263, 'properties': 'Serverinfo= AAMAILE.int.aalogistik.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Wed, 25 Jan 2006 16:57:54 +0100 \n', 'protocol': 6, 'rule': 'Monitor ', 'server': '1.2.4.3', 'serverhostname': '', 'serverport': 25, 'service': 'Undetermined', 'time': 1138204680, 'type': 0}]
tuple
of dict
and list
int
) - Rule id
Query the firewall log for a list between two points in time
>>> info,results = rt.fwlog_query_time_range ("2006-01-01 00:00", "2006-02-02 00:00") >>> print results[0] {'clientport': 38742, 'protocol': 6, 'service': 'eDonkey transfer', 'clienthostname': '', 'serverhostname': '', 'rule': 'Monitor ', 'server': '3.3.3.3', 'client': '1.1.1.1', 'serverport': 4662, 'time': 1138204658, 'type': 0, 'properties': ''}
tuple
of list
and dict
str
) - Start the list at this date, the date has to be in YYYY-MM-DD HH:MM
format
str
) - End the list at this date, the date has to be in YYYY-MM-DD HH:MM
format
Get channel statistics data once.
(Should not be used simultaneously to add_channels_callback and update_forever)
dict
int
) - Max age in seconds of cached information. If longer time has passed since
last call, new data will be requested from PacketLogic.
Get Realtime NetObject data once.
(Should not be used simultaneously to add_netobj_callback and update_forever)
str
) - Path to netobject
Get Realtime Services data once.
(Should not be used simultaneously to add_service_callback and update_forever)
Get system diagnostics data once.
(Should not be used simultaneously to add_stats_callback and update_forever)
dict
int
) - Max age in seconds of cached information. If longer time has passed since
last call, new data will be requested from PacketLogic.
Get a ViewBuilder object for creating views.
See ViewBuilder object documentation for details.
Inject a packet.
This function is just for testing purposes.
Reload drdl signatures. For internal use only.
Requests all shaping counters, regardless if they have changed or not.
Requests all shaping counters for a specific subscriber, regardless if they have changed or not.
Stop the updating and clear callback functions.
Start updating.
This method will enter a loop that requests updates every 5 seconds (or other interval specified by the interval argument). Updates are sent to the callback functions registered with methods named add_*_callback (among others add_service_callback, add_channels_callback and add_update_done_callback). To break out of the updating loop call the stop_updating method.
float
) - Interval (seconds) at which updates are requested.
List available vbs objects
>>> rt.vbs_list() [('00E081600B81', 24, 'VBS low', 1), ('00E081600B81', 74, 'VBS medium', 1), ('00E081600B81', 26, 'VBS max', 1)]
split type is one of SPLIT_NONE, SPLIT_LOCALHOST, SPLIT_HOST_NETOBJECT, SPLIT_SERVER_NETOBJECT, SPLIT_CLIENT_NETOBJECT, SPLIT_CONNECTION
list
of tuple
Query vbs data from a specific vbs object
>>> rt.vbs_query('0010F3067C3A', 24) [{'bidirectional': 0L, 'bidirectional speed': 0, 'extra': -183572567, 'id': 24, 'inbound': 0L, 'inbound speed': 0, 'machineid': '0010F3067C3A', 'name': 'VBS Grund', 'outbound': 0L, 'outbound speed': 0, 'splitname': '169.231.14.245'}]
list
of dict
str
) - MachineID of the PacketLogic you want to query.
int
) - ID of VBS shapingobject
int
) - Extra key; netobject id in case of split by netobject, or ip number in case
of split by local host (encoded as an integer). If argument isn't given ALL
available split keys are listed.
Reset vbs accounting data for a vbs object.
str
) - MachineID of the PacketLogic you want to query.
int
) - ID of VBS object
int
) - Extra key; netobject id in case of split by netobject, or ip number in case
of split by local host (encoded as an integer). See the return value of vbs_query for
details.
Set transfer to the specified value. Can only be used on object without sliding window (duration=1).
int
) - The new value of inbound transfer (in KiB)
int
) - The new value of outbound transfer (in KiB)
str
) - MachineID of the PacketLogic you want to query.
int
) - ID of VBS object
int
) - Extra key; netobject id in case of split by netobject, or ip number in case
of split by local host (encoded as an integer). See the return value of vbs_query for
details.
Run virtual connection ruleset checker.
>>> rt.vcrc({'serverip':'192.168.9.1'})
>>> rt.vcrc({'serverip': '192.168.9.1', 'service': 'HTTP', 'vlan': 1234})
>>> rt.vcrc({'serverip':'217.73.103.54'}) {'fwrules': [(60L, 2031L), (63L, 2031L)], 'shapingrules': [(65L, 2031L), (66L, 1903L)], 'monitor_iface': 0L, 'fwrule': 63, 'ruleset_state': 3, 'test_id': 1L, 'rewrite_obj': 0L}
dict
) - Dict with any of the following keys:
* vlan * mpls * protocol * clientip * serverip * clientport * serverport * service * xfb * properties
Waits for a ruleset of 'commitid' to be loaded and compiled by plrcd. wait_for_ruleset() will return when plrcd sees a commitid that is at least as new as 'commitid' given. If plrcd already has loaded or loads a newer commitid than the given 'commitid' it will also return with True.
Typical use:
>>> # Add Test netobject to pldb >>> test = rs.object_add("/NetObjects/Test") >>> commitid = rs.commit() >>> # Wait for Test netobject to be visible in plrcd >>> rt.wait_for_ruleset(commitid) >>> # Add a dynnetobj item in plrcd under Test netobject >>> rt.dyn.add(test.id, "10.0.0.1")
boolean
CommitID
) - CommitID to wait for.
int
) - Max seconds to wait before returning with False.
Deprecated alias for add_sysdiag_callback
Deprecated alias for get_sysdiag_data
This object should not be instantiated manually. Instances will be passed as argument to the function registered with PLD.add_aggr_view_callback.
Properties: | |
---|---|
children | List of child nodes (if any) |
connections | Number of connections |
cps | inbound/outbound cps |
external_quality | inbound/outbound external quality |
internal_quality | inbound/outbound internal quality |
name | The name of this node |
rawname | The name of this node in its original type without any prefix |
rtt | inbound/outbound handshake rtt |
speed | inbound/outbound bps |
List of child nodes (if any).
Number of connections
inbound/outbound cps
inbound/outbound external quality
inbound/outbound internal quality
The name of this node
The name of this node in its original type without any prefix
inbound/outbound handshake rtt
inbound/outbound bps
Object containing realtime information of a connection. This object should not be instantiated manually. Use the add_host_callback method.
>>> def cb(ip, connections): ... print "=" * 30 ... print time.ctime() ... print ip ... if connections is None: ... print " * Host removed" ... rt.stop_updating() ... else: ... for c in connections: ... if c.service != "HTTP": ... continue ... f = " * " ... f += "%s:%d" % c.client ... f += "->%s:%d" % c.server ... if c.server_hostname: ... f += "[%r]" % c.server_hostname ... f += " in=%dbps out=%dbps" % c.speed ... f += " prio=%d" % c.shaping_prio ... print f >>> rt.add_host_callback(host, cb) >>> rt.update_forever(5.0)
Properties: | |
---|---|
base_service | Base Service of the connection as a string |
client | Client endpoint of the connection as a tuple (clientip, clientport) |
dscp | DSCP value of the connection in inbound and outbound directions |
engineflags | Engineflags on the connection |
external_quality | External QoE values (inbound, outbound) |
internal_quality | Internal QoE values (inbound, outbound) |
ls_device_id | The id of estimated line sharing device |
ls_device_type | The type of line sharing device estimation |
mpls | MPLS label of the connection in inbound and outbound directions |
outbound_hoplimit | The hoplimit/ttl value from outbound packets in this connection |
protocol | IP protocol used by connection |
server | Server endpoint of the connection as a tuple (serverip, serverport) |
server_hostname | Server hostname if extracted by signatures |
service | Service of the connection as a string |
session_contexts | |
shaping_prio | Priority value of the connection as assigned by shaping rules |
shaping_rules | Shaping rules matching the connection as a list of rule names |
speed | Average speed of the connection during the last update interval as a tuple |
starttime | Unix timestamp when first packet in connection was seen (according to the |
vlan | VLAN IDs of the connection in inbound and outbound direction |
vlan_priority | VLAN priorities of the connection in inbound and outbound direction |
xfbflags | XFBflags on the connection |
xfer | Bytes transferred during the lifetime of the connection as a tuple (inbound |
Base Service of the connection as a string
Client endpoint of the connection as a tuple (clientip, clientport)
DSCP value of the connection in inbound and outbound directions
Engineflags on the connection
External QoE values (inbound, outbound).
External Quality of Experience values in range 0-100 (percent) for this connection. Value is -1 if not available.
Internal QoE values (inbound, outbound).
Internal Quality of Experience values in range 0-100 (percent) for this connection. Value is -1 if not available.
The id of estimated line sharing device
The type of line sharing device estimation
MPLS label of the connection in inbound and outbound directions
The hoplimit/ttl value from outbound packets in this connection
IP protocol used by connection
Server endpoint of the connection as a tuple (serverip, serverport)
Server hostname if extracted by signatures
Service of the connection as a string
Priority value of the connection as assigned by shaping rules
Shaping rules matching the connection as a list of rule names
Average speed of the connection during the last update interval as a tuple (inbound bps, outbound bps)
Unix timestamp when first packet in connection was seen (according to the clock on the PacketLogic system)
VLAN IDs of the connection in inbound and outbound direction
VLAN priorities of the connection in inbound and outbound direction
XFBflags on the connection
Bytes transferred during the lifetime of the connection as a tuple (inbound bytes, outbound bytes)
Object containing realtime information of a host. This object should not be instantiated manually. Use the add_netobj_callback method.
>>> def cb(data): ... print "Number of hosts: %d" % len(data.hosts) ... interesting_hosts = ["10.2.200.188", "10.2.20.58"] ... for h in data.hosts: ... if h in interesting_hosts: ... print " %s: %s" % (h.addr, h.speed) ... >>> rt.add_netobj_callback(cb, under="/NetObjects/<Ungrouped>", include_hosts=True) >>> rt.update_forever()
Properties: | |
---|---|
external_quality | External QoE values (inbound, outbound) |
internal_quality | Internal QoE values (inbound, outbound) |
Instance variables: | |
---|---|
addr | IP address of host |
speed | Speed in byte/s in/out. |
connections | Connections all/unestablished. |
cps | Connections per second in/out. |
External QoE values (inbound, outbound).
External Quality of Experience values in range 0-100 (percent) for this host. Value is -1 if not available.
Internal QoE values (inbound, outbound).
Internal Quality of Experience values in range 0-100 (percent) for this host. Value is -1 if not available.
Object containing Realtime NetObject data.
Properties: | |
---|---|
fullpath | Full path of this object including the object's name |
path | Path which this object resides under |
Instance variables: | |
---|---|
id | The internal id. |
parent | References the parent NetObject, if any. |
name | Name of NetObject. |
speed | Speed in bps in/out. |
forwarded | Forwarded bytes in/out. Obsolete in v12.0 and newer, will always be 0 in these versions. |
connections | Connections in/out. |
cps | Connections per second in/out. |
Full path of this object including the object's name.
Path which this object resides under.
NetObject data accessed through the NetObject callback function
>>> import packetlogic2 >>> pl = packetlogic2.connect('192.168.1.25', 'admin', 'password') >>> rt = pl.Realtime() >>> count = 1 >>> def f(data): ... global count ... ... if count > 100: ... rt.stop_updating() ... if data: ... for m in data.list('/NetObjects/DSL'): ... print "name: %s" % m.fullpath ... print "speed: ", m.speed ... print "connections: ", m.connections ... m = data.find('/NetObjects/DSL/Lab') ... if m is not None: ... print "name: %s" % m.fullpath ... print "speed: ", m.speed ... print "connections: ", m.connections ... count +=1 ... >>> rt.add_netobj_callback(f) >>> rt.update_forever()
Methods: | ||
---|---|---|
Ungrouped | RealtimeNetObject | find(self, path) Find a single Realtime NetObject with the given full path |
list of RealtimeNetObjects
|
list(self, path='/NetObjects', recursive=True) Return a list of Realtime NetObject data, matching the given path, and |
Find a single Realtime NetObject with the given full path.
Return a list of Realtime NetObject data, matching the given path, and optional recursive flag.
list
of RealtimeNetObjects
str
) - Path where to start looking. If the path ends with a slash (in recursive
mode), it will include the children of that NetObject (if any) but not the
NetObject itself. The path should begin with '/NetObjects'.
bool
) - If True any level of children NetObjects will also be returned. Otherwise
only the NetObjects that is direct children to the given full path is
returned. (Do not end path with / if recursive is True).
Builder for creating views with filters and distributions.
This object should not be instantiated manually. Use the PLD.get_view_builder to create a new object.
Methods: | ||
---|---|---|
Ungrouped | distribution(self, field, arg=None) Add a distribution to the view |
|
dump_meta(self) Print a human readable representation of available filters and fields to |
||
filter(self, key, *values) Add a filter to the view |
||
filter_out(self, key, *values) Add a filter to exclude traffic from the view |
Properties: | |
---|---|
available_fields | List of fields available for use in distributions |
available_filters | List of available filter keys |
Add a distribution to the view.
Adds the specified field as a sub-distribution of current distribution.
>>> v = rt.get_view_builder() >>> v.filter_out("Service", "QUIC") >>> v.distribution("Server Hostname") >>> v.distribution("NetObject Level", "DHCP/By MAC") >>> v.distribution("Local Host")
str
) - The field to distribute based on.
str
) - Argument as required by some fields
Print a human readable representation of available filters and fields to stdout.
Add a filter to the view.
Makes filter only include connections where the property specified by key is one of the specified values. The key can be either string or a tuple containing additional arguments to the filter.
>>> v = rt.get_view_builder() >>> v.filter(("Incoming VLAN Id", "1"), 100) >>> v.filter(("Session Context", "myschema/mycolumn"), xyz,) >>> v.filter("Host", "10.0.0.1") >>> v.filter("Server Port", 443)
str
or tuple
) - The key to filter on plus additional arguments if required by the filter.
Add a filter to exclude traffic from the view.
Makes filter exclude connections where the property specified by key is one of the specified values. The key can be either string or a tuple containing additional arguments to the filter.
>>> v = rt.get_view_builder() >>> v.filter("Host", "10.0.0.1") >>> v.filter("Server Port", 443) >>> v.filter_out("Service", "SSL v3")
str
or tuple
) - The key to filter on plus additional arguments if required by the filter.
List of fields available for use in distributions.
List of available filter keys.