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 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.º 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 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.º 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)
Ejemplo n.º 6
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.º 7
0
    def __init__(self):

        activeLogs("/tmp", "astdemo_db", "err")

        cfg = Config()

        dsn = "dbname=%s host=%s user=%s password=%s" % (cfg.db_dbname, cfg.db_host, cfg.db_user, cfg.db_pwd)

        conn = psycopg2.connect(dsn)
        curs = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
        self.cursor = curs
        self.config = cfg
Ejemplo n.º 8
0
    def __init__(self):

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

        cfg = Config()

        dsn = 'dbname=%s host=%s user=%s password=%s' % (
            cfg.db_dbname, cfg.db_host, cfg.db_user, cfg.db_pwd)

        conn = psycopg2.connect(dsn)
        curs = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
        self.cursor = curs
        self.config = cfg
Ejemplo n.º 9
0
def getChannel(jid,number):

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

	cfg = Config()

	dsn = 'dbname=%s host=%s user=%s password=%s' % (cfg.db_dbname, cfg.db_host, cfg.db_user, cfg.db_pwd)

	conn = psycopg2.connect(dsn)
	curs = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)

	sql = 'SELECT p.channel FROM jids_phones as r,jids as j,phones as p where r.jid_id = j.id and r.phone_id=p.id and j.jid = %s and p.phone = %s'
	curs.execute(sql, (jid,number))

	if not curs.rowcount:
		return ""

	value = curs.fetchone()['channel']
	return value
Ejemplo n.º 10
0
def getChannel(jid,number):

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

	cfg = Config()

	dsn = 'dbname=%s host=%s user=%s password=%s' % (cfg.db_dbname, cfg.db_host, cfg.db_user, cfg.db_pwd)

	conn = psycopg2.connect(dsn)
	curs = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)

	sql = 'SELECT p.channel FROM jids_phones as r,jids as j,phones as p where r.jid_id = j.id and r.phone_id=p.id and j.jid = %s and p.phone = %s'
	curs.execute(sql, (jid,number))

	if not curs.rowcount:
		return ""

	value = curs.fetchone()['channel']
	return value
Ejemplo n.º 11
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.º 12
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.º 13
0
#

import xmpp

from asterisk import agi

from astdemo_defs import iaxPeerStatus
from astdemo_defs import sipPeerStatus
from astdemo_defs import getQueueMembersNumber

from astdemo_db import DB
from astdemo_classes import XMPPp
from astdemo_classes import Config
from astdemo_classes import activeLogs

activeLogs('/tmp', 'astdemo_monitor', 'all')

db = DB()
cfg = Config()

xmppdomain = cfg.xmppdomain
xmppresource = cfg.xmppresource

myXMPP = XMPPp()

db_cursor = db.returnAllItems()

totalRows = db_cursor.rowcount

print "-----------"
Ejemplo n.º 14
0
#

import xmpp

from asterisk import agi

from astdemo_defs import iaxPeerStatus
from astdemo_defs import sipPeerStatus
from astdemo_defs import getQueueMembersNumber

from astdemo_db	import DB
from astdemo_classes import XMPPp
from astdemo_classes import Config
from astdemo_classes import activeLogs

activeLogs('/tmp','astdemo_monitor','all')

db=DB()
cfg=Config()

xmppdomain = cfg.xmppdomain
xmppresource = cfg.xmppresource

myXMPP=XMPPp()

db_cursor=db.returnAllItems()

totalRows=db_cursor.rowcount

print "-----------"