Esempio n. 1
0
 def cpuReport(self):
     """ function is printing an returning cpu report {module,[user,system,idle]} """
     logger.info("CPU Report: ")
     report = {}
     for module in self.envs.iterkeys():
         if (
                 module == 'ABP'
         ):  # As WA will work only with ABP there is issue to call ssh , need to rplace awk with sed
             report.update({
                 module: [
                     str((subproc_popen(
                         self.create_ssh_cmd(module, get_cpu_user_cmd()))
                          )[0].rstrip("\n") + "%"),
                     str((subproc_popen(
                         self.create_ssh_cmd(module, get_cpu_system_cmd()))
                          )[0].rstrip("\n") + "%"),
                     str((subproc_popen(
                         self.create_ssh_cmd(module, get_cpu_idle_cmd()))
                          )[0].rstrip("\n") + "%")
                 ]
             })
             print(
                 str(module) + " : " + report[module][0] + "/" +
                 report[module][1] + "/" + report[module][2])
             print ""
     return report
Esempio n. 2
0
 def memReport(self):
     """ function is printing an returning Memory report {module,[total,free,used]} """
     logger.info("Memory Report: ")
     report = {}
     for module in self.envs.iterkeys():
         if (
                 module == 'ABP'
         ):  # As WA will work only with ABP there is issue to call ssh , need to rplace awk with sed
             report.update({
                 module: [
                     str((subproc_popen(
                         self.create_ssh_cmd(
                             module,
                             get_memory_total_cmd())))[0].rstrip("\n")),
                     str((subproc_popen(
                         self.create_ssh_cmd(
                             module,
                             get_memory_free_cmd())))[0].rstrip("\n")),
                     str((subproc_popen(
                         self.create_ssh_cmd(
                             module,
                             get_memory_used_cmd())))[0].rstrip("\n"))
                 ]
             })
             print(
                 str(module) + " : " + "total :" + report[module][0] +
                 " / " + "free :" + report[module][1] + "/ " + "used :" +
                 report[module][2])
             print ""
     return report
Esempio n. 3
0
 def clean_mro(self):
     logger.info("Stopping AMC and MRO....")
     self.handle_daemons('Stop', 'AMC_SERVER', 'MRO')
     logger.info("Cleaning MRO queue ....")
     subproc_popen(clean_mro_queue_cmd())
     logger.info("Starting AMC ,AMC Daemon Manager and MRO ....")
     self.handle_daemons('Trigger', 'AMC_SERVER', 'AMC_DAEMON_MANAGER',
                         'MRO')
Esempio n. 4
0
 def start_daemons(self, *daemons):
     """ get list  of daemons and starting all daemons """
     for daemon_name in daemons:
         if self.IsDaemonNameValid(self.d_name_to_StartCmd[daemon_name]):
             start_cmd = self.d_name_to_StartCmd[daemon_name]
             logger.info("Starting " + str(daemon_name) +
                         "...with command : " +
                         str(start_cmd))  #+ start_cmd
             subproc_popen(start_cmd)
Esempio n. 5
0
 def db_get_all_TCcommands(self):
     """ function return:
      dict {tcdaemonName:StartCommand } and
      list ['command','params','processName',"Type",'psu_string']
      dict {Type: [processName1 ,processName2] }
      dict {'daemonName' : 'psu_string'}        
      dicy {daemonName' :"pass String"}"""
     data = subproc_popen(sqlplus_query(self.GetTCDaemonsCMDsQuery,db))#Run DataBase query to get TC commands
     type_to_names ={}
     name_to_psuString ={} 
     name_to_logFormat={}
     name_to_logLocation={}
     TCDaemons={} 
     name_to_passStr={}
     DaemonData =[]
       
     DaemonData=str(data[0]).rstrip('\n')#Remove last enter in the response and copy tuple to the list        
     DaemonData=str(DaemonData).split('\n')# split the list by '\n' will create list of lists .list per daemon
     i=0
     for daemon in DaemonData:
         DaemonData[i] =daemon.split('#') #go over list of lists and for each one of lists split using predefined '#' sign in query
         DaemonData[i].extend([DaemonData[i][2].rstrip(string.digits)])
         DaemonData[i].extend([self.get_psu_string(DaemonData[i][3],DaemonData[i][2])])
         TCDaemons.update({DaemonData[i][2]: DaemonData[i][0] +'"' + DaemonData[i][1]+ ' "' })#insert daemon name and its command to dictionary
         name_to_psuString.update({ DaemonData[i][2] : DaemonData[i][4] })
         name_to_passStr.update({ DaemonData[i][2] :self.LOG_PASS_STR})
         name_to_logLocation.update({ DaemonData[i][2] : self.get_log_path() })
         name_to_logFormat.update({ DaemonData[i][2] : '*'+DaemonData[i][2]+'*.log*'  })
         if DaemonData[i][3] in type_to_names:
            type_to_names[DaemonData[i][3]].extend( [DaemonData[i][2]] ) 
         else:
            type_to_names.update({  DaemonData[i][3] : [DaemonData[i][2]]}) 
         i=i+1
     return TCDaemons ,DaemonData,type_to_names,name_to_psuString,name_to_passStr,name_to_logLocation,name_to_logFormat
Esempio n. 6
0
 def stop_daemons(self, *daemons):
     """ get unix function to get status from Unix an list of psu_string """
     logger.info("Stopping daemons....")
     for name in daemons:
         psu_string = str(self.d_name_to_PsuString[name])
         if self.IsDaemonNameValid(psu_string):
             kill_cmd = self.unix_kill_dmn_cmd(psu_string)
             logger.debug("Running stopDaemon -> with : psu_string=" +
                          str(psu_string) + " ,unix_cmd=" + kill_cmd)
             logger.info("Stop daemon  with  : " + kill_cmd)
             data = subproc_popen(kill_cmd)
Esempio n. 7
0
 def cleanFileSys(self, numOfDays=1, StopEnv="N", module=None):
     """Cleans files system from logs and cores with option to bring environment down """
     print "Module " + module
     if str(module) in self.envs.iterkeys():
         logger.info("Running cleanFileSystem in " + module +
                     " with parameters : numOfDays=" + str(numOfDays) +
                     " ,StopEnv =" + str(StopEnv))
         if (str(StopEnv)).upper() == "Y" and self.envs[module] <> "":
             subproc_popen(
                 self.create_ssh_cmd(module, build_kill_cmd(isRemote='Y')))
         elif (str(StopEnv)).upper() == "Y" and self.envs[module] == "":
             self.stop_env()
         elif (str(StopEnv)).upper() <> "N":
             print "PLease provide for" + module + " Y or N if need to stop the environment "
         subproc_popen(self.create_ssh_cmd(module, del_logs_cmd(numOfDays)))
         subproc_popen(
             self.create_ssh_cmd(
                 module, del_logs_cmd(numOfDays,
                                      del_format='core\.[0-9]*')))
         logger.info("Clean " + module + " is done !!!")
         return
     elif str(module) == "All":
         for env in self.envs.iterkeys():
             print("Sending for " + env)
             self.cleanFileSys(numOfDays, StopEnv, env)
     else:
         print(
             "The target system to clean logs is not provided or not exist in the list"
         )
Esempio n. 8
0
 def fsReport(self):
     """ function is printing and returning as dictionary file system space report in percents per environment for all modules in envs """
     logger.info("FS Report: ")
     report = {}
     for module in self.envs.iterkeys():
         report.update({
             module:
             str((subproc_popen(self.create_ssh_cmd(
                 module, fs_report_cmd())))[0].rstrip("\n"))
         })
         print(str(module) + " : " + report[module] + "%")
     print ""
     return report
Esempio n. 9
0
 def clean_trb(self):
     logger.info("Cleaning TRB tables... ")
     TRB_QRY = '''delete from TRB1_AMC_HISTORY;
    delete from TRB1_AUDIT_INTERVAL;
    delete from TRB1_ENG_CNTRL;
    delete from TRB1_ERR_DEPENDENT;
    delete from TRB1_IMP_PERIOD;
    delete from TRB1_MEMBER_ADMIN;
    delete from TRB1_MONITOR_INFO;
    delete from TRB1_QUE_CNTRL;
    delete from TRB1_RECV_DATA;
    delete from TRB1_SUB_APPL_CNTRL;
    delete from TRB1_THR_CNTRL;
    delete from TRB1_USER_CONFIG;
    delete from TRB1_SUB_APPL_CNTRL;
    delete from TRB1_ERR_DEPENDENT;
    commit;'''
     data = subproc_popen(sqlplus_query(TRB_QRY, db, set_echo='On'))
     print_data(data)
Esempio n. 10
0
 def get_daemon_satuses(self, *daemons):
     """get daemons list and return statuses {'UP':['DB2E' ,'F2E'], 'DOWN' :['ES_RB']"""
     logger.info("Checking statuses...")
     statuses = {'UP': [], 'DOWN': []}
     for daemon_name in daemons:
         if daemon_name not in self.d_name_to_PsuString.keys():
             logger.error("Daemon Doesn't exist in the list :" +
                          str(daemon_name))
             return
         psu_string = self.d_name_to_PsuString[daemon_name]
         if self.IsDaemonNameValid(psu_string):
             psu_cmd = self.unix_check_psu_cmd(psu_string)
             logger.info("Checking status with  : " + psu_cmd)
             data = subproc_popen(psu_cmd)
             if int(str(data[0]).rstrip('\n')) > 0:
                 statuses['UP'].extend([daemon_name])
             elif int(str(data[0]).rstrip('\n')) == 0:
                 statuses['DOWN'].extend([daemon_name])
             else:
                 logger.error("checkDaemonStatus-> issue with status " +
                              str(data[0]).rstrip('\n'))
     return statuses
Esempio n. 11
0
 def clean_sharedMemory(self):
     logger.info("Cleaning shared memory...." ) 
     data =subproc_popen(clean_shared_memory_cmd())
     return data
Esempio n. 12
0
def clean_mro_queue(self):
    data = subproc_popen(clean_mro_queue_cmd())
Esempio n. 13
0
 def update_ar1_control(self, proc_name='AR1BILINTER'):
     AR1_CNTRL_QRY = '''update ar1_control shutdown_flag='Y' where  CONTROL_APPLICATION_ID ='AR1BILINTER';commit;'''
     data = subproc_popen(sqlplus_query(AR1_CNTRL_QRY, db, set_echo='On'))
     print_data(data)
Esempio n. 14
0
 def get_log_path(self):
     data = subproc_popen('echo ${OP_LOG_DIR}')
     return str(data[0]).rstrip('\n')
Esempio n. 15
0
    def run_cycle_maint(self,date=None,CleanInd="Y"):
        """ running cycle maintanence , when indicator is Y will clean existing Cycle instances from tables
        when date is None will set LD to be sytemDate"""
        ClnTRB="""delete from trb1_pub_log where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  delete from trb1_mst_log where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  delete from trb1_sub_log where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%' 
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  delete from trb1_sub_errs where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%' 
                  OR GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';
                  commit;"""
                  
        ClnCycleInstData="""delete ADJ1_CYCLE_STATE;
                            delete BL1_CYCLE_CONTROL;
                            delete CM1_CYCLE_INSTANCE;
                            delete  RPL1_CYCLE_INSTANCE;
                            commit;"""
                            
        InstanceCount="""select trim(count(*)) from bl1_cycle_control where cycle_code=(select CYCLE_CODE 
                          from bl1_cycle_code where FREQUENCY='M' and rownum <=1)  and trunc(END_DATE) >= 
                           (select distinct(logical_date) from logical_date 
                            where LOGICAL_DATE_TYPE='B' and EXPIRATION_DATE is null);"""   
        CheckTRBErrs ='''select count(*) from TRB1_SUB_ERRS where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
          or GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';'''
        GetTRBErrs ='''select ERROR_TEXT1  from TRB1_SUB_ERRS where GENERAL_DATA_C like '%NEW_CYCLE_INSTANCE%'
          or GENERAL_DATA like '%NEW_CYCLE_INSTANCE%';'''
        CheckCM="""Select count(*) from CM1_CYCLE_INSTANCE"""
        CheckADJ="""Select count(*) from ADJ1_CYCLE_STATE"""
                            
        ValBTLSOR =""""""              
                  

        self.handle_daemons('Stop','BLBDI');
        #self.stop_daemons('BL1CYCLEMAINT') # need to update function to woth without PSU string or to write new 
        logger.info("Cleaning TRB tables....")
        data = subproc_popen(sqlplus_query(ClnTRB,db,set_echo='On')); 
        print_data(data);
        if (CleanInd=='Y'):
            logger.info("Cleaning all Cycle instances ....")
            data= subproc_popen(sqlplus_query(ClnCycleInstData,db,set_echo='On'));
            print_data(data);
        logger.info("Updating Logical Date ....")
        if date:   
            set_logical_date(date,'N')
        else:
            set_logical_date('sysdate','N')#will set to sysdate     
                           
        self.handle_daemons('Trigger' ,'AMC_SERVER', 'AMC_DAEMON_MANAGER' , 'TRB', 'INVOKER1' ,'INVOKER2' ,'INVOKER10' , 'BTLSOR' ,'BTLQUOTE')
        self.RunJob('BL1CYCLEMAINT','ENDDAY');
        #Check invoicing is updated
        if wait_db_update(InstanceCount,db) < 2:
            logger.error("BL1_CYCLE_CONTROL was not updated ,Check that Trx 2006 was Processed")
            return
        else:
            logger.info("BL1_CYCLE_CONTROL is updated!")
        time.sleep(10)#waiting for BTLSOR to finish all entries 
        logger.info("Checking CM tables..")
        if wait_db_update(CheckCM,db) < 2:
            logger.error("CM1_CYCLE_INSTANCE is not updated check TRB Tables")
            return
        else:
            logger.info("CM tables are updated.... " + ( subproc_popen(sqlplus_query(CheckCM,db)) )[0].rstrip('/n') +" entries found" )
        logger.info("Running ADJ1CYCMNTEOD ...")
        self.RunJob('ADJ1CYCMNTEOD','ENDDAY');
        #if wait_db_update(InstanceCount,db) < 2:
            
        logger.info("Wating for requests to be processed...")
        #CheckADJ is update is Updated 
        if wait_db_update(CheckADJ,db) <2:
            logger.error("ADJtable is not populated ,check TRB for 3017")
            logger.error( ( subproc_popen(sqlplus_query(CheckADJ,db)) )[0].rstrip('/n') )
            return
        else:
            logger.info("ADJ1_CYCLE_STATE is populated .... " + ( subproc_popen(sqlplus_query(CheckADJ,db)) )[0].rstrip('/n') +" entries found" )       

        # check no errors in TRB 
        if wait_db_update(CheckTRBErrs,db,timeout=0) > 0:
            logger.error("TRB error is detected for Cycle Maintanence")
            logger.error( ( subproc_popen(sqlplus_query(GetTRBErrs,db)) )[0].rstrip('/n') )
            return
        else:
            logger.info("No TRB Errors detected.... ")