Example #1
0
def check_list_x_tools(par='/tmp/x_pid_infos'):
    if platform.system() not in ['Darwin', 'Linux']:
        print 'WinNT platform not supported.'
    else:
        print 'PID:\t\tSCRIPT:\t\tARGVS:'
        if os.path.exists(par):
            f_li = [x for x in os.listdir(par) if os.path.isfile(os.path.join(par, x))]
            for name in f_li:
                p = Properties(os.path.join(par, name), True)
                pid = p.get_property('PPID')
                pah = p.get_property('PATH')
                arg = p.get_property('ARGV')
                if is_p_alive(int(pid)):
                    print '%s\t\t%s\t\t%s' % (pid, pah, arg)
                else:
                    os.remove(os.path.join(par, name))
Example #2
0
            exit(1)
    
    id_file = ids_dir + os.sep + "id." + str(options.engineid) + "." + str(options.list)
    alarm_id_file = ids_dir + os.sep + "alarmid." + str(options.engineid) + "." + str(options.list)
    
    if not os.path.exists(id_file):
        f = open(id_file,"w")
        f.writelines("id=0")
        f.close()
    
    client_ip = None if '' == options.clientip else options.clientip
    engine_id = None if '' == options.engineid else options.engineid
    active_num = 20
    firstround=True
    p_id = Properties(id_file)
    id = int(p_id.get_property('id')) + 1
    
    try:
    
        old_alarm_ids = readOldAlarmIds(alarm_id_file)
        traps_map = SnmpTrapUtils.read_used_trap_templates(options, template_dir, mapping_file, alarm_oid_file, timestamp_file)

        if not traps_map:
            msg = 'Fail to read the alarm template files.'
            log0.error(msg)    
        else:
            list_engine = SnmpTrapUtils.init_trap_engine(traps_map,options,v3_auth_file,client_ip,engine_id)
        
        if len(old_alarm_ids)!=0:
            log0.info("start alarm sync")
            sendClearAlarms(old_alarm_ids,active_num,traps_map,list_engine)
root_dir = os.path.dirname(os.path.abspath(__file__)).split('sbin')[0]
sys.path.insert(0, root_dir)
# from com.ericsson.xn.server.prop.PyProperties import Properties
from com.ericsson.xn.commons.PyProperties import Properties
lib_dir = os.path.normpath(root_dir + os.path.sep + 'libs' + os.path.sep + 'CrossPlatform')
sys.path.insert(0, lib_dir)
from com.ericsson.xn.xexpect.BashEnvSimulator import BashExpect

cfg_file = os.path.normpath(root_dir + os.path.sep + 'config' + os.path.sep + 'auto_install' + os.path.sep + 'cfg.cfg')
p = Properties(cfg_file, is_strip=True)

log_formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(module)s %(funcName)s(%(lineno)d) %(message)s')
log_dir = root_dir + os.path.sep + 'logs'
if not os.path.isdir(log_dir):
    os.mkdir(log_dir)
log_file = os.path.normpath(log_dir + os.path.sep + p.get_property('log_file'))
log_handler = RotatingFileHandler(log_file, mode='a', maxBytes=10 * 1024 * 1024, backupCount=10, encoding='utf-8',
                                  delay=0)
log_handler.setFormatter(log_formatter)
logger = logging.getLogger('Auto_Install')
log_level = int(p.get_property('log_level'))
logger.setLevel(log_level)
logger.addHandler(log_handler)

if 'yes' == p.get_property('log_console').strip().lower():
    log_stream = logging.StreamHandler()
    log_stream.setLevel(log_level)
    log_stream.setFormatter(log_formatter)
    logger.addHandler(log_stream)

if 'Linux' != platform.system():