Last active
September 23, 2023 01:19
-
-
Save faizann/04bb49427958f3a2e8b169b1e675f7d8 to your computer and use it in GitHub Desktop.
Restcomm JSS7/SMSC SIGTRAN Association monitor script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import jpype | |
import sys | |
from jpype import java | |
from jpype import javax | |
# Configuration | |
JAVA_HOME='/home/faizan/downloads/jdk1.7.0_79' | |
HOST = 'localhost' | |
#PORT = 1099 | |
PORT = 4444 | |
LIBJVM=JAVA_HOME+'/jre/lib/amd64/server/libjvm.so' | |
RESTCOMM_SMSC_LIBS="/home/faizan/gsm/smscgateway/release/target/jboss-5.1.0.GA/server/simulator/deploy/restcomm-smsc-server/lib/" | |
URL = "service:jmx:rmi://localhost/jndi/rmi://localhost:1090/jmxconnector" | |
class RestCommJmx: | |
def __init__(self): | |
self.connection = None # mbeanServerConnection | |
def connectToJmx(self): | |
#this it the path of your libjvm /usr/lib/jvm/sun-jdk-1.6/jre/lib/amd64/server/libjvm.so on linux | |
#jpype.startJVM(LIBJVM,"-Djava.class.path="+CLASSPATH+" -Djava.ext.dirs="+CLASSPATH) | |
jpype.startJVM(LIBJVM,"-Djava.ext.dirs="+RESTCOMM_SMSC_LIBS) | |
jmxurl = javax.management.remote.JMXServiceURL(URL) | |
jmxsoc = javax.management.remote.JMXConnectorFactory.connect(jmxurl) | |
self.connection = jmxsoc.getMBeanServerConnection() | |
def check_association_alarm(self, assocLevel): | |
object="org.mobicents.ss7:layer=ALARM,type=Management,name=AlarmHost" | |
attribute="CurrentAlarmList" | |
attr=self.connection.getAttribute(javax.management.ObjectName(object),attribute) | |
alarmList = attr.getCurrentAlarmList() | |
errMsg = "" | |
for alarmMessage in alarmList: | |
objName = alarmMessage.getObjectName() | |
if str(objName).lower().startswith("%s:" % assocLevel.lower()) == False: | |
continue | |
if len(errMsg) > 0 : | |
errMsg += "\n" | |
errMsg += "%s - %s" % (objName, alarmMessage.getProblemName()) | |
return errMsg | |
def usage(): | |
scriptName = sys.argv[0] | |
return "Usage: python %s association_type\n Where association_type is: Association for SCTP, ASP for ASP and AS for AS state check" % scriptName | |
if __name__=="__main__": | |
rjmx = RestCommJmx() | |
rjmx.connectToJmx() | |
if len(sys.argv)<2: | |
print usage() | |
sys.exit() | |
errMsg = rjmx.check_association_alarm(sys.argv[1]) | |
print "%s" % errMsg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment