Ejemplo n.º 1
0
def monitorStore():
    """
    Get monitored information
    Attach the sequence number
    Attach timestamp
    Store in the log file
    delete seen entries
    """
    # commented to use psutil system info system_info = systeminfo.get_all_info()

    system_info = nodeinfo.node_all()

    system_info ['monitored_timestamp'] = config.get_current_system_timestamp()

    # Attach node api info to system info
    rd_tags = getapi.get_nodeinfo_from_API()
    if rd_tags is not None:
        system_info.update(rd_tags)

    # Attach sliver info to system info
    system_info.update(sliverinfo.collectAllDataAPI())


    ## Write current sequence number to file "current_sequence"
    if os.path.exists(config.PATH + '/current_sequence'):
        file_current_sequence_number = open(config.PATH+'/current_sequence', 'r+')
        print "File exists"
        current_sequence_number = int(file_current_sequence_number.read()) +1
    else:
        file_current_sequence_number = open(config.PATH+'/current_sequence', 'w+')
        current_sequence_number = 1

    file_current_sequence_number.close()
    print "Current: ", current_sequence_number

    file_current_sequence_number = open(config.PATH+'/current_sequence', 'r+')
    open(config.PATH+'/current_sequence', 'w').close() #empty the contents of current sequence file before writing in

    file_current_sequence_number.write(str(current_sequence_number))
    file_current_sequence_number.close()

    # write monitored values to a file with name as the current sequence number
    file_content = open (config.PATH + '/'+str(current_sequence_number), 'w')
    file_content.write(str(system_info))
    file_content.close()

    delete_seen_entries()
Ejemplo n.º 2
0
def monitorStore():
    """
    Get monitored information
    Attach the sequence number
    Attach timestamp
    Store in the log file
    delete seen entries
    """
    # commented to use psutil system info system_info = systeminfo.get_all_info()

    system_info = nodeinfo.node_all()
    system_info['monitored_timestamp'] = config.get_current_system_timestamp()

    # Attach sliver info to system info
    system_info.update(sliverinfo.collectAllDataAPI())

    s = shelve.open('log_shelf.db', writeback=True)

    while (1):
        try:
            try:
                if s.has_key('current_seq_number'):
                    #Update current sequence number
                    s['current_seq_number'] += 1
                    current_seq = s['current_seq_number']
                else:
                    current_seq = 1
                    s['current_seq_number'] = current_seq

                print("writing to file: " + str(current_seq))

                #  print("writing to file" + str(system_info))
                s[str(current_seq)] = system_info

            finally:
                s.close()
                break

        except OSError:
            # In some research devices, the underlying dbm has a bug which needs to be handled explicitly
            print(
                "Exception caught while handling shelve file!! OS Error: file not found. Trying again in 1 second"
            )
            time.sleep(1)
            continue

    delete_seen_entries()
Ejemplo n.º 3
0
def monitorStore():
    """
    Get monitored information
    Attach the sequence number
    Attach timestamp
    Store in the log file
    delete seen entries
    """
   # commented to use psutil system info system_info = systeminfo.get_all_info()

    system_info = nodeinfo.node_all()
    system_info ['monitored_timestamp'] = config.get_current_system_timestamp()

    # Attach sliver info to system info
    system_info.update(sliverinfo.collectAllDataAPI())

    s = shelve.open('log_shelf.db', writeback = True)

    while(1):
        try:
            try:
                if s.has_key('current_seq_number'):
                    #Update current sequence number
                    s['current_seq_number']+= 1
                    current_seq = s['current_seq_number']
                else:
                    current_seq = 1
                    s['current_seq_number']= current_seq

                print("writing to file: " + str(current_seq))

            #  print("writing to file" + str(system_info))
                s[str(current_seq)]= system_info


            finally:
                s.close()
                break

        except OSError:
            # In some research devices, the underlying dbm has a bug which needs to be handled explicitly
            print("Exception caught while handling shelve file!! OS Error: file not found. Trying again in 1 second")
            time.sleep(1)
            continue

    delete_seen_entries()
Ejemplo n.º 4
0
def monitorStore():
    """
    Get monitored information
    Attach the sequence number
    Attach timestamp
    Store in the log file
    delete seen entries
    """
    # commented to use psutil system info system_info = systeminfo.get_all_info()

    system_info = nodeinfo.node_all()
    system_info['monitored_timestamp'] = config.get_current_system_timestamp()

    # Attach sliver info to system info
    system_info.update(sliverinfo.collectAllDataAPI())

    ## Write current sequence number to file "current_sequence"
    if os.path.exists(config.PATH + '/current_sequence'):
        file_current_sequence_number = open(config.PATH + '/current_sequence',
                                            'r+')
        print "File exists"
        current_sequence_number = int(file_current_sequence_number.read()) + 1
    else:
        file_current_sequence_number = open(config.PATH + '/current_sequence',
                                            'w+')
        current_sequence_number = 1

    file_current_sequence_number.close()
    print "Current: ", current_sequence_number

    file_current_sequence_number = open(config.PATH + '/current_sequence',
                                        'r+')
    open(config.PATH + '/current_sequence', 'w').close(
    )  #empty the contents of current sequence file before writing in

    file_current_sequence_number.write(str(current_sequence_number))
    file_current_sequence_number.close()

    # write monitored values to a file with name as the current sequence number
    file_content = open(config.PATH + '/' + str(current_sequence_number), 'w')
    file_content.write(str(system_info))
    file_content.close()

    delete_seen_entries()