Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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