def sendCommand(self, jbossHome, controller, user, password, domain, cluster, host, instance, offset): self.fillParameters(jbossHome, controller, user, password) startCommand = "/host="+host+"/server-config="+instance+":add(group="+cluster+",socket-binding-port-offset="+offset+",auto-start=false)" print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand) subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd,startCommand]) pm = PropertyManager("Domains/"+domain+".properties") oldInstances = pm.getValue("cluster."+cluster+".instances") if(oldInstances == None): newInstances = instance else: newInstances = ValueUtils.addToValues(instance, oldInstances, ',') pm.updateValue("Domains/"+domain+".properties", "cluster."+cluster+".instances", newInstances) oldHostInstances = pm.getValue("cluster."+cluster+"."+host+".instances") if(oldHostInstances == None): newHostInstances = instance else: newHostInstances = ValueUtils.addToValues(instance, oldHostInstances, ',') pm.updateValue("Domains/"+domain+".properties", "cluster."+cluster+"."+host+".instances", newHostInstances)
def sendCommand(self, jbossHome, controller, user, password, cluster, domain, profile): self.fillParameters(jbossHome, controller, user, password) startCommand = "/server-group="+cluster+":add(profile="+profile+",socket-binding-group=full-ha-sockets)" print("eseguo: "+self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand) subprocess.check_call([self._complPath,self._cliconn,self._complContr,self._complUser,self._complPwd, startCommand]) pm = PropertyManager("Domains/"+domain+".properties") old_clusters = pm.getValue("clusters") if(old_clusters == None): new_clusters = cluster else: new_clusters = ValueUtils.addToValues(cluster, old_clusters, ',') pm.updateValue("Domains/"+domain+".properties", "clusters", new_clusters)
def execute(self, jbossHome, controller, user, password): self.fillParameters(jbossHome, controller, user, password) print chr(27) + "[2J" console.flush() print("hai chiamato check Datasource statistics") try: domain = FindUtils.getDomain("domains") cluster = FindUtils.getCluster(domain) instanceTuple = FindUtils.getInstance(domain,cluster) datasource = FindUtils.getGenericString("inserire il nome del datasource >") pollNumb = FindUtils.getGenericString("inserire il numero di poll >") pollInterval = FindUtils.getGenericString("inserire il polling interval (sec) >") print("Check Datasource Statistics: "+datasource) startCommand ='"/host='+instanceTuple[1]+'/server='+instanceTuple[0]+'/subsystem=datasources/data-source='+datasource+'/statistics=pool:read-resource(include-runtime=true)"' print(startCommand) if(pollInterval != None) and (pollNumb != None): pollNumb = int(pollNumb) pollInterval = int(pollInterval) print("Available Connections | Created Connections | In use Connections | Active Connections | Max used Connections") for i in range(pollNumb): psCons = subprocess.Popen(self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand, shell=True, stdout=subprocess.PIPE) output = psCons.stdout.read() psCons.stdout.close() psCons.wait() statsDict = ValueUtils.parseCliOutput(output) if("outcome" not in statsDict) and (statsDict['outcome'] != "success"): raise EapManagerException("Datasource stats collection failed") print(statsDict['AvailableCount']+" "+ " |"+statsDict['CreatedCount']+" "+ " |"+statsDict['InUseCount']+" "+ " |"+statsDict['ActiveCount']+" "+ " |"+statsDict['MaxUsedCount']+" ") time.sleep(pollInterval) except (CalledProcessError, EapManagerException, ValueError) as e: print(e.message) pass raw_input("premere un tasto per continuare...")
def __init__(self, *args, **kwargs): self.image = kwargs.get("image") self.name = args[1] self.organization = args[2] self.profession = args[3] self.stars = ValueUtils.to_int(args[4]) self.gender = args[5] self.infected = True if args[6] == "是" else False self.obtain = args[7].split("、") if args[7] else [] self.life = ValueUtils.to_int(args[8]) self.attack = ValueUtils.to_int(args[9]) self.attack_resistance = ValueUtils.to_int(args[10]) self.magic_resistance = ValueUtils.to_int(args[11]) self.redeployment = args[12] self.cost = ValueUtils.to_int(args[13]) self.perfect_cost = ValueUtils.to_int(args[14]) or self.cost # 阻挡数2→3视为3。 self.block = ValueUtils.to_int(args[15][-1]) if args[15] else 0 self.attack_speed = args[16] self.comment = args[17] self.raw_tags = args[18].split("、") if args[17] else []
def execute(self, jbossHome, controller, user, password): self.fillParameters(jbossHome, controller, user, password) print chr(27) + "[2J" console.flush() print("hai chiamato check Http statistics") try: domain = FindUtils.getDomain("domains") cluster = FindUtils.getCluster(domain) instanceTuple = FindUtils.getInstance(domain,cluster) pollNumb = FindUtils.getGenericString("inserire il numero di poll >") pollInterval = FindUtils.getGenericString("inserire il polling interval (sec) >") startCommand ='"/host='+instanceTuple[1]+'/server='+instanceTuple[0]+'/subsystem=web/connector=http:read-resource(include-runtime=true)"' if(pollInterval != None) and (pollNumb != None): pollNumb = int(pollNumb) pollInterval = int(pollInterval) print("Bytes Received | Bytes Sent | Error Count | Request Count |") for i in range(pollNumb): psCons = subprocess.Popen(self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand, shell=True, stdout=subprocess.PIPE) output = psCons.stdout.read() psCons.stdout.close() psCons.wait() statsDict = ValueUtils.parseCliOutput(output) print(statsDict['bytesReceived']+" "+ " |"+statsDict['bytesSent']+" "+ " |"+statsDict['errorCount']+" "+ " |"+statsDict['requestCount']+" ") time.sleep(pollInterval) except (CalledProcessError, EapManagerException, ValueError) as e: print(e.message) pass raw_input("premere un tasto per continuare...")
def execute(self, jbossHome, controller, user, password): self.fillParameters(jbossHome, controller, user, password) print chr(27) + "[2J" console.flush() print("hai chiamato check Thread statistics") try: domain = FindUtils.getDomain("domains") cluster = FindUtils.getCluster(domain) instanceTuple = FindUtils.getInstance(domain,cluster) pollNumb = FindUtils.getGenericString("inserire il numero di poll >") pollInterval = FindUtils.getGenericString("inserire il polling interval (sec) >") startCommand ='"/host='+instanceTuple[1]+'/server='+instanceTuple[0]+'/core-service=platform-mbean/type=threading:read-resource"' if(pollInterval != None) and (pollNumb != None): pollNumb = int(pollNumb) pollInterval = int(pollInterval) print("Current Threads Count | Peak Thread Count | Daemon Thread Count ") for i in range(pollNumb): psCons = subprocess.Popen(self._complPath+" "+self._cliconn+" "+self._complContr+" "+self._complUser+" "+self._complPwd+" "+startCommand, shell=True, stdout=subprocess.PIPE) output = psCons.stdout.read() psCons.stdout.close() psCons.wait() statsDict = ValueUtils.parseCliOutput(output) print(statsDict['thread-count']+" "+ " |"+statsDict['peak-thread-count']+" "+ " |"+statsDict['daemon-thread-count']+" ") time.sleep(pollInterval) except (CalledProcessError, EapManagerException, ValueError) as e: print(e.message) pass raw_input("premere un tasto per continuare...")
if(domain == ""): print("USAGE createDomain -domain=<domain name>") destination = base_dir+"/domain/configuration/" domainFile = getDomainFile(domain) profiles = domainFile.find('{urn:jboss:domain:1.4}profiles') for profile in profiles.iter('{urn:jboss:domain:1.4}profile'): name = profile.get('name') if(name == 'full-ha'): copyProfile = deepcopy(profile) copyProfile.set('name',profileName) profiles.append(copyProfile) domainFile.write("domain.xml") if(os.path.isfile(destination+"domain.xml")): shutil.move(destination+"domain.xml", destination+"domain.xml.ORIG") if(os.path.isfile("domain.xml")): shutil.copy("domain.xml", destination+"domain.xml") shutil.move("domain.xml","domain.xml."+domain+".template") if(not(os.path.isfile("Domains/"+domain+".properties"))): pm.create("Domains/"+domain+".properties") old_domains = pm.getValue("domains") if(old_domains.find(domain) == -1): new_domains = ValueUtils.addToValues(domain, old_domains, ',') pm.updateValue("""Domains/domains.properties""", "domains", new_domains) print("RIAVVIARE IL DOMAIN CONTROLLER! \nCAMBIARE UTENTE E PASSWORD NELLA SEZIONE MESSAGING PRIMA DI AVVIARE")