Changeset 6927


Ignore:
Timestamp:
Feb 26, 2018, 6:28:41 PM (18 months ago)
Author:
mabarracus
Message:

Fix bugs

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

Legend:

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

    r6845 r6927  
     1lliurex-statistics (0.5-2) xenial; urgency=medium
     2
     3  * Fix bugs
     4
     5 -- M.Angel Juan <m.angel.juan@gmail.com>  Mon, 26 Feb 2018 18:25:18 +0100
     6
    17lliurex-statistics (0.5-1) xenial; urgency=medium
    28
  • lliurex-statistics/trunk/fuentes/debian/control

    r6815 r6927  
    88Package: lliurex-statistics
    99Architecture: all
    10 Depends: ${shlibs:Depends}, ${misc:Depends}, debconf | debconf-2.0, auditd, python3-daemon, python3-requests, n4d, acl, lliurex-statistics-blacklist, lliurex-base-files, lliurex-zero-installer-analytics (>= 0.126) | zero-lliurex-analytics
     10Depends: ${shlibs:Depends}, ${misc:Depends}, debconf | debconf-2.0, auditd, python3-daemon, python3-requests, n4d, acl, lliurex-statistics-blacklist, lliurex-base-files, lliurex-zero-installer-analytics (>= 0.126) | zero-lliurex-analytics, python3-psutil
    1111Replaces: lliurex-zero-installer-analytics (<< 0.126)
    1212Conflicts: lliurex-zero-installer-analytics (<< 0.126)
  • lliurex-statistics/trunk/fuentes/lliurex-statistics.install/usr/sbin/analytics

    r6845 r6927  
    1515from logging import config as cfg
    1616import ssl
     17import psutil
    1718
    1819
     
    241242
    242243
    243 def add_item(item):
     244def add_item(item,regexp):
    244245    global glob, log
    245246
     
    249250
    250251    executable = None
    251     not_valid = ['-', ':']
    252252    for i in range(len(parts_item)):
    253253        executable = parts_item[i].strip()
    254         if executable[0] in not_valid:
     254        if not re.match(executable[0]):
    255255            log.debug('Skipping malformed executable {}'.format(executable))
    256256            executable = None
     
    318318    try:
    319319        log.info('Starting monitoring {}'.format(logfilename))
    320 
     320        regexp = re.compile('^[a-zA-Z][a-zA-Z0-9_.+\-]+$')
    321321        while not glob['TERMINATE']:
    322322            if fp.poll() is not None:
     
    329329                    if m:
    330330                        captured = ' '.join(m)
    331                         add_item(captured)
     331                        add_item(captured,regexp)
    332332
    333333    except Exception as e:
     
    863863
    864864if __name__ == '__main__':
     865    exit = False
     866    keyword='analytics'
     867    for proc in psutil.process_iter():
     868        for argument in proc.cmdline():
     869            #print('{} {} {}'.format(proc.cmdline(),keyword,argument[-len(keyword):]))
     870            if keyword in argument[-len(keyword):]:
     871                exit = True
     872                break
     873        if exit:
     874            break
     875    if exit:
     876        log.error('Another daemon is running')
     877        sys.exit(1)
    865878
    866879    try:
Note: See TracChangeset for help on using the changeset viewer.