Changeset 8243


Ignore:
Timestamp:
Nov 13, 2018, 2:54:26 PM (2 years ago)
Author:
mabarracus
Message:

Remove filter for root executable files
New mac calculation process

Location:
lliurex-statistics/trunk/fuentes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lliurex-statistics/trunk/fuentes/debian/changelog

    r8232 r8243  
    22
    33  * Remove filter for root executable files
     4  * New mac calculation process
    45
    56 -- M.Angel Juan <m.angel.juan@gmail.com>  Mon, 12 Nov 2018 12:04:10 +0100
  • lliurex-statistics/trunk/fuentes/lliurex-statistics.install/usr/sbin/analytics

    r7174 r8243  
    629629    global log
    630630
     631    default_mac = '00:00:00:00:00:00'
    631632    dirmac = '/sys/class/net'
    632     eth = 'eth0'
     633    eth = None
    633634    filemac = 'address'
    634     file = '{}/{}/{}'.format(dirmac, eth, filemac)
    635635    uid = None
    636     try:
    637         with open(file, 'r') as fp:
    638             uid = bin_to_ascii(fp.read()).strip()
    639     except:
    640         log.warning('Unable to read {}'.format(file))
    641         eth = sorted(os.listdir(dirmac))
    642         if len(eth) > 0:
    643             eth = eth[0]
    644         file = '{}/{}/{}'.format(dirmac, eth, filemac)
    645         try:
    646             with open(file, 'r') as fp:
    647                 uid = bin_to_ascii(fp.read()).strip()
     636    eths = sorted(os.listdir(dirmac))
     637
     638    def remove_mac(mac):
     639        try:
     640            eths.remove(mac)
     641        except:
     642            pass
     643
     644    remove_mac('lo')
     645    while len(eths):
     646        eth = eths[0]
     647        f = '{}/{}/{}'.format(dirmac, eth, filemac)
     648        try:
     649            with open(f, 'r') as fp:
     650                uid = str(bin_to_ascii(fp.read()).strip())
     651                if uid == default_mac:
     652                    raise Exception('Zero MAC')
     653                else:
     654                    break
    648655        except Exception as e:
    649             log.error('Unable to read mac address, {}'.format(e))
    650 
    651     return str(uid)
    652 
     656            log.warning('Exception {} on {}'.format(e,eth))
     657            remove_mac(eths[0])
     658
     659    if not uid:
     660        log.error('Unable to read mac address, {}'.format(e))
     661        uid = default_mac
     662
     663    return uid
    653664
    654665def get_cpu():
Note: See TracChangeset for help on using the changeset viewer.