Пример #1
0
def infoVoIP():

	activeLogs('/tmp','astdemo_defs','err')

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: CoreSettings\n\n')
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	returnmsg = "VoIP Informations"
	returnmsg += "\r"
	returnmsg += "Asterisk Version %s " % mgrdict.getitem('AsteriskVersion') 

	s.send('Action: CoreStatus\n\n')
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	returnmsg += "Started: " + mgrdict.getitem('CoreStartupDate').replace('\r','') + ' - ' + mgrdict.getitem('CoreStartupTime')
	returnmsg += "Last reload: " + mgrdict.getitem('CoreReloadDate').replace('\r','')	+ ' - ' + mgrdict.getitem('CoreReloadTime')

	s.close()
	
	return returnmsg
Пример #2
0
def sipPeer(sip):

	activeLogs('/tmp','astdemo_defs','err')

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: SIPshowpeer\nPeer: %s\n\n' % sip)
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	returnmsg = "Extension %s informations: " % sip
	returnmsg += "\r"

	if data.find("Peer %s	ot found" % sip) > 0:

		returnmsg += "Extension %s not registered.\n" % sip
	else:		
		returnmsg += "CallerID: " + mgrdict.getitem('Callerid') 
		returnmsg += "IP: " + mgrdict.getitem('Address-IP')
		returnmsg += "Codecs: " + mgrdict.getitem('Codecs')
		returnmsg += "Status: " + mgrdict.getitem('Status')
		returnmsg += "User Agent: " + mgrdict.getitem('SIP-Useragent')

	s.close()

	return returnmsg
Пример #3
0
def getQueueMembersNumber(queue):

	activeLogs('/tmp','astdemo_classes','err')

	members=0

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: QueueStatus\nQueue: %s\n\n' % queue)
	time.sleep (0.1)

	data = s.recv(65536)
	mgrdict=ManagerDict(data)

	lines = data.split('\n')

	for item in lines:

			data=item.split(":",1)

			try:

					title=data[0]
			except:

					title=""

			if title == "Name":

					members = members + 1

	s.close

	return (members)
Пример #4
0
def iaxPeers():

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: IAXpeers\n\n')
	time.sleep (0.1)

	data = s.recv(65535)

	mgrdictev=ManagerDictEvents(data,'PeerEntry')

	if not mgrdictev.isvalid:

		returnmsg = "IAX peers not found."
		return returnmsg
	
	else:

		returnmsg = "IAX peers Informations - %s peers found.\r" % str(mgrdictev.items) 

		for event in mgrdictev.events:

			returnmsg+="Peer: " + event['ObjectName'] 
			returnmsg+="Type: " + event['ChanObjectType'] 
			returnmsg+="IP: " + event['IPaddress'] 
			returnmsg+="Port: " + event['IPport'] 
			returnmsg+="Trunk: " + event['Trunk'] 
			returnmsg+="Status: " + event['Status'] 
			returnmsg += '\r'

	s.close()
	
	return returnmsg
Пример #5
0
def getQueueMembersNumber(queue):

	activeLogs('/tmp','astdemo_classes','err')

	members=0

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: QueueStatus\nQueue: %s\n\n' % queue)
	time.sleep (0.1)

	data = s.recv(65536)
	mgrdict=ManagerDict(data)

	lines = data.split('\n')

	for item in lines:

			data=item.split(":",1)

			try:

					title=data[0]
			except:

					title=""

			if title == "Name":

					members = members + 1

	s.close

	return (members)
Пример #6
0
def infoVoIP():

	activeLogs('/tmp','astdemo_defs','err')

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: CoreSettings\n\n')
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	returnmsg = "VoIP Informations"
	returnmsg += "\r"
	returnmsg += "Asterisk Version %s " % mgrdict.getitem('AsteriskVersion') 

	s.send('Action: CoreStatus\n\n')
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	returnmsg += "Started: " + mgrdict.getitem('CoreStartupDate').replace('\r','') + ' - ' + mgrdict.getitem('CoreStartupTime')
	returnmsg += "Last reload: " + mgrdict.getitem('CoreReloadDate').replace('\r','')	+ ' - ' + mgrdict.getitem('CoreReloadTime')

	s.close()
	
	return returnmsg
Пример #7
0
def sipPeer(sip):

	activeLogs('/tmp','astdemo_defs','err')

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: SIPshowpeer\nPeer: %s\n\n' % sip)
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	returnmsg = "Extension %s informations: " % sip
	returnmsg += "\r"

	if data.find("Peer %s	ot found" % sip) > 0:

		returnmsg += "Extension %s not registered.\n" % sip
	else:		
		returnmsg += "CallerID: " + mgrdict.getitem('Callerid') 
		returnmsg += "IP: " + mgrdict.getitem('Address-IP')
		returnmsg += "Codecs: " + mgrdict.getitem('Codecs')
		returnmsg += "Status: " + mgrdict.getitem('Status')
		returnmsg += "User Agent: " + mgrdict.getitem('SIP-Useragent')

	s.close()

	return returnmsg
Пример #8
0
def iaxPeers():

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: IAXpeers\n\n')
	time.sleep (0.1)

	data = s.recv(65535)

	mgrdictev=ManagerDictEvents(data,'PeerEntry')

	if not mgrdictev.isvalid:

		returnmsg = "IAX peers not found."
		return returnmsg
	
	else:

		returnmsg = "IAX peers Informations - %s peers found.\r" % str(mgrdictev.items) 

		for event in mgrdictev.events:

			returnmsg+="Peer: " + event['ObjectName'] 
			returnmsg+="Type: " + event['ChanObjectType'] 
			returnmsg+="IP: " + event['IPaddress'] 
			returnmsg+="Port: " + event['IPport'] 
			returnmsg+="Trunk: " + event['Trunk'] 
			returnmsg+="Status: " + event['Status'] 
			returnmsg += '\r'

	s.close()
	
	return returnmsg
Пример #9
0
def call(number,extension,callerid,context,priority):

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: Originate\nChannel: SIP/' + number + '\nExten: ' + extension + '\nCallerID: ' + callerid + '\nContext: ' + context + '\nPriority: ' + priority + '\nAsync: true\n\n')
	time.sleep (0.1)

	s.close()
Пример #10
0
def call(number,extension,callerid,context,priority):

	myConnect=connectAMI()
	s = myConnect.socket

	#s.send('Action: Originate\nChannel: SIP/%s\nExten: %s\nCallerID: %s\nContext: %s\nPriority: %s\n\n') % (number,extension,callerid,context,priority)
	s.send('Action: Originate\nChannel: SIP/' + number + '\nExten: ' + extension + '\nCallerID: ' + callerid + '\nContext: ' + context + '\nPriority: ' + priority + '\nAsync: true\n\n') % (number,extension,callerid,context,priority)
	time.sleep (0.1)

	s.close()
Пример #11
0
def iaxPeerStatus(iax):

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: IAXpeerlist\n\n')
	time.sleep (0.1)

	data = s.recv(65535)

	mgrdictev=ManagerDictEvents(data,'PeerEntry')

	returnmsg=""

	if not mgrdictev.isvalid:

		returnmsg = "UNAVAILABLE"
		return returnmsg
	
	else:

		found=False

		for event in mgrdictev.events:

			if not found:

				if (event['ObjectName'].replace("\\","").replace("\r","").replace("\n","")).strip() == iax.strip():

					found=True
					returnmsg=event['Status'].split("(")[0].replace("\\","").replace("\r","").replace("\n","")
					break
				
		if not found:

			returnmsg = "UNAVAILABLE"

	s.close()
	
	return returnmsg
Пример #12
0
def iaxPeerStatus(iax):

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: IAXpeerlist\n\n')
	time.sleep (0.1)

	data = s.recv(65535)

	mgrdictev=ManagerDictEvents(data,'PeerEntry')

	returnmsg=""

	if not mgrdictev.isvalid:

		returnmsg = "UNAVAILABLE"
		return returnmsg
	
	else:

		found=False

		for event in mgrdictev.events:

			if not found:

				if (event['ObjectName'].replace("\\","").replace("\r","").replace("\n","")).strip() == iax.strip():

					found=True
					returnmsg=event['Status'].split("(")[0].replace("\\","").replace("\r","").replace("\n","")
					break
				
		if not found:

			returnmsg = "UNAVAILABLE"

	s.close()
	
	return returnmsg
Пример #13
0
def sipPeerStatus(sip):

	activeLogs('/tmp','astdemo_defs','err')

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: SIPshowpeer\nPeer: %s\n\n' % sip)
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	if data.find("Peer %s not found" % sip) > 0:

		returnmsg = "UNAVAILABLE"
	else:		
		returnmsg = mgrdict.getitem('Status').split("(")[0].replace("\\","").replace("\r","").replace("\n","")

	s.close()

	return returnmsg
Пример #14
0
def sipPeerStatus(sip):

	activeLogs('/tmp','astdemo_defs','err')

	myConnect=connectAMI()
	s = myConnect.socket

	s.send('Action: SIPshowpeer\nPeer: %s\n\n' % sip)
	time.sleep (0.1)

	data = s.recv(65536)

	mgrdict=ManagerDict(data)

	if data.find("Peer %s not found" % sip) > 0:

		returnmsg = "UNAVAILABLE"
	else:		
		returnmsg = mgrdict.getitem('Status').split("(")[0].replace("\\","").replace("\r","").replace("\n","")

	s.close()

	return returnmsg