def killCallGenUAS(genIP): "Connect with remote shell" ssh = sessionManager.SSH(genIP) #Kill the UAS if any instance is running killcmd = "pkill -9 nxgen" ssh.assertCommand(killcmd) sleep(2) ssh.disconnect()
def runSecCacheUpdate(remoteIp): "Connect with remote shell" ssh = sessionManager.SSH(remoteIp) #Remotely Start the script cmd = "/bin/bash /tmp/46110Scripts/secCacheUpdate.sh" ssh.assertCommand(cmd) ssh.disconnect()
def setDebugLevel(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) cmd = "/usr/local/nextone/bin/nxconfig.pl -e debug-modcache -v 1" ssh.assertCommand(cmd) cmd = "/usr/local/nextone/bin/nxconfig.pl -e maxcallduration -v 1800" ssh.assertCommand(cmd) ssh.disconnect()
def getPIDs(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) cmd = "ps -ef | grep gis | grep -v gis_sa | grep -v grep | awk '{print $2}'>/tmp/gis_id" ssh.assertCommand(cmd) cmd = "ps -ef | grep postmaster | grep -v grep | awk '{print $2}'>/tmp/postgres_id" ssh.assertCommand(cmd) ssh.disconnect()
def captureVPort(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) cmd = ">/tmp/vportStat" ssh.assertCommand(cmd) cmd = "/bin/bash /tmp/46110Scripts/captureVportStat.sh &" ssh.assertCommand(cmd) ssh.disconnect()
def runCallGenUAS(genIP, gwIP): "Connect with remote shell" ssh = sessionManager.SSH(genIP) cdcmd = "cd /opt/nxgen/bin" ssh.assertCommand(cdcmd) #Run nxgen in server mode cmd = "nxgen -i %s -i %s -sf uas.xml -bg" %(gwIP, genIP) ssh.assertCommand(cmd) ssh.disconnect()
def runCallGenUAC(genIP, gwIP, rate): "Connect with remote shell" ssh = sessionManager.SSH(genIP) cdcmd = "cd /root/" ssh.assertCommand(cdcmd) #Run nxgen in client mode cmd = "./nexgen %s -i %s -s 222 -r %s -d 40000 -bg -trace_stat -stf /tmp/callstat.log" %(gwIP, genIP, rate) ssh.assertCommand(cmd) ssh.disconnect()
def cleanUpinSecondaryMSX(secMSX): "Connect with remote shell" ssh = sessionManager.SSH(secMSX) #cleanUp result files cmd = ">/home/brenda/lcr-cron-getlocal-day1" ssh.assertCommand(cmd) cmd = ">/tmp/result" ssh.assertCommand(cmd) ssh.disconnect()
def tarCDR(priMSX, currdate, stage): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) cdcmd = "cd /var/cdrs" ssh.assertCommand(cdcmd) cmd = "tar -cvf %s-stage-%s-cdr.tar D%s.CDT" % (currdate, stage, currdate) ssh.assertCommand(cmd) cmd = "rm D%s.CDT" % (currdate) ssh.assertCommand(cmd) ssh.disconnect()
def runIedgeCacheScript(remoteIp, no): "Connect with remote shell" ssh = sessionManager.SSH(remoteIp) #Remotely Start the script cmd = "echo ----------Iedge update time T%s ----------- >> /root/iedgeCacheOutput" % ( no) ssh.assertCommand(cmd) cmd = "/bin/bash /tmp/46110Scripts/iedge_cache.sh >> /root/iedgeCacheOutput" ssh.assertCommand(cmd) ssh.disconnect()
def killVPort(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) ###Killing the existing instace of the script to be added pid = 'None' cmd = " ps x | grep captureVportStat | grep -v grep | awk '{print $1}'" pid = ssh.filter(cmd) if (pid != 'None'): cmd = "kill -9 %s" % pid ssh.assertCommand(cmd) ssh.disconnect()
def checkLicense(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) cmd = "iserver all status | grep 'Total VPORTS' | awk '{print $3}'" maxCalls = ssh.filter(cmd) maxCalls = maxCalls.strip() ssh.disconnect() if (int(maxCalls) > 2800): return 0 else: return 1
def main(argv): #for arg in sys.argv: print argv remoteIp = argv #priority=argv[2] #region=argv[3] #runIedgeCacheScript(remoteIp) ssh = sessionManager.SSH(remoteIp) local = sessionManager.LocalShell() copyScripts(local, ssh, remoteIp)
def cleanUpinPrimaryMSX(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) #cleanUp result files cmd = ">/root/iedgeCacheOutput" ssh.assertCommand(cmd) cmd = ">/tmp/result" ssh.assertCommand(cmd) cmd = ">/tmp/vportStat" ssh.assertCommand(cmd) cmd = ">/opt/mem_stats" ssh.assertCommand(cmd) ssh.disconnect()
def checkPIDs(priMSX): "Connect with remote shell" ssh = sessionManager.SSH(priMSX) cmd = "ps -ef | grep gis | grep -v gis_sa | grep -v grep | awk '{print $2}'" curr_pid = ssh.filter(cmd) cmd = "cat /tmp/gis_id" init_pid = ssh.filter(cmd) if (curr_pid != init_pid): return 4 cmd = "ps -ef | grep postmaster | grep -v grep | awk '{print $2}'" curr_pid = ssh.filter(cmd) cmd = "cat /tmp/postgres_id" init_pid = ssh.filter(cmd) if (curr_pid != init_pid): return 5 ssh.disconnect() return 0
def runGetLocalDBScript(ip): "Connect with remote shell" ssh = sessionManager.SSH(ip) #--------Setp 2--- #copy the script on secondary MSX confFile = '46110Scripts/getlocaldbinfo.sh' cmd = "scp %s root@%s:/tmp/46110Scripts/" % (confFile, ip) print cmd os.system(cmd) #--------Step 3------ ###Killing the existing instace of the script to be added pid = 'None' cmd = " ps x | grep getlocal | awk '{print $1}'" pid = ssh.filter(cmd) if (pid != 'None'): print pid cmd = "kill -9 %s" % pid ssh.assertCommand(cmd) print "Executing command" cmd = " nohup /bin/bash /tmp/46110Scripts/getlocaldbinfo.sh >> /home/brenda/lcr-cron-getlocal-day1 &" newpid = ssh.filter(cmd) print newpid
def copyCallStat(remoteIP): "Connect with remote shell" ssh = sessionManager.SSH(remoteIP) cmd = "scp /tmp/callstat.log [email protected]:/tmp" ssh.assertCommand(cmd) ssh.disconnect()