Module Expr Str ImportFrom alias alias ImportFrom alias alias ImportFrom alias alias Import alias Import alias Import alias alias alias alias ImportFrom alias alias alias Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Str Assign NameStore Call AttributeLoad NameLoad attr Str Str keyword Num FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr keyword NameLoad Expr Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr Str For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad If Call AttributeLoad NameLoad attr NameLoad NameLoad body Assign NameStore UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad NameLoad Index Str Assign SubscriptStore AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Str NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr NameLoad NameLoad body TryExcept body Delete SubscriptDel AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index Str handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Str NameLoad orelse Expr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str If BoolOpAnd NameLoad CompareGt Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Str Call NameLoad AttributeLoad NameLoad attr orelse Expr Call AttributeLoad NameLoad attr Str Call NameLoad AttributeLoad NameLoad attr decorator_list decorator_list Assign NameStore Call AttributeLoad NameLoad attr If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr
N/A N/A Sample application to watch for PRI exhaustion

This script watches for events on the AMI interface, tracking the identity of
open channels in order to track how many channels are being used.  This would 
be used to send messages to an administrator when network capacity is being 
approached.

Similarly, you could watch for spare capacity on the network and use that 
to decide whether to allow low-priority calls, such as peering framework or
free-world-dialup calls to go through.
 twisted.application service internet twisted.internet reactor defer starpy manager fastagi N/A utilapplication N/A menu N/A os logging pprint time basicproperty common propertied basic N/A log N/A N/A logging getLogger priexhaustion N/A N/A N/A log setLevel N/A logging INFO ChannelTracker N/A N/A propertied Propertied N/A N/A Track open channels on the Asterisk server N/A channels N/A N/A common DictionaryProperty channels Set of open channels on the system N/A thresholdCount N/A N/A common IntegerProperty thresholdCount Storage of threshold below which we don't warn user defaultValue 20 main N/A N/A self N/A N/A N/A Main operation for the channel-tracking demo N/A amiDF N/A N/A N/A N/A N/A APPLICATION amiSpecifier login addCallback N/A self onAMIConnect N/A onAMIConnect N/A N/A self ami N/A N/A N/A Register for AMI events N/A N/A N/A log debug onAMIConnect N/A N/A N/A N/A N/A ami status addCallback N/A self onStatus ami ami N/A N/A N/A ami registerEvent Hangup N/A self onChannelHangup N/A N/A N/A ami registerEvent Newchannel N/A self onChannelNew N/A interestingEvent N/A N/A self event ami N/A None N/A N/A Decide whether this channel event is interesting 
		
		Real-world application would want to take only Zap channels, or only
		channels from a given context, or whatever other filter you want in 
		order to capture *just* the scarce resource (such as PRI lines).
		
		Keep in mind that an "interesting" event must show up as interesting 
		for *both* Newchannel and Hangup events or you will leak 
		references/channels or have unknown channels hanging up.
		 N/A True N/A onStatus N/A N/A self events ami N/A None N/A N/A Integrate the current status into our set of channels N/A N/A N/A log debug Initial channel status retrieved N/A event events N/A N/A N/A N/A self onChannelNew ami event N/A onChannelNew N/A N/A self ami event N/A N/A N/A Handle creation of a new channel N/A N/A N/A log debug Start on channel %s event N/A N/A N/A self interestingEvent event ami N/A N/A opening N/A N/A N/A N/A self channels has_key N/A event N/A uniqueid N/A N/A N/A self channels N/A N/A event N/A uniqueid event N/A opening N/A N/A N/A N/A self onChannelChange ami event opening opening N/A onChannelHangup N/A N/A self ami event N/A N/A N/A Handle hangup of an existing channel N/A N/A N/A self interestingEvent event ami N/A N/A N/A N/A N/A N/A self channels N/A N/A event N/A uniqueid N/A N/A N/A KeyError N/A err N/A N/A N/A N/A log warn Hangup on unknown channel %s event N/A N/A N/A N/A log debug Hangup on channel %s event N/A N/A N/A self onChannelChange ami event opening False N/A onChannelChange N/A N/A self ami event opening N/A False N/A N/A Channel count has changed, do something useful like enforcing limits N/A N/A opening N/A N/A len N/A self channels N/A self thresholdCount N/A N/A N/A N/A log warn Current channel count: %s N/A len N/A self channels N/A N/A N/A N/A log info Current channel count: %s N/A len N/A self channels N/A N/A N/A APPLICATION N/A N/A utilapplication UtilApplication N/A N/A __name__ __main__ N/A N/A N/A N/A logging basicConfig N/A tracker N/A ChannelTracker N/A N/A N/A reactor callWhenRunning N/A tracker main N/A N/A N/A reactor run