import re
import snmpy

class log_processor(snmpy.plugin):
    def create(self):
        for k, v in sorted(self.conf['objects'].items()):
            extra = {
                'count':  re.compile(v['count']),
                'reset':  re.compile(v['reset']) if 'reset' in v else None,
                'start':  int(v['start']) if 'start' in v else 0,
                'rotate': bool(v['rotate']) if 'rotate' in v else False
            }

            self.data['1.%s' % k] = 'string', v['label']
            self.data['2.%s' % k] = 'integer', extra['start'], extra

        self.tail()

    @snmpy.plugin.task
    def tail(self):
        for line in snmpy.plugin.tail(self.conf['file_name'], True):
            if line is True:
                for item in self.data['2.0':]:
                    if self.data[item:'rotate'] and line is True:
                        self.data[item] = self.data[item:'start']
                continue

            for item in self.data['2.0':]:
                count = self.data[item:'count'].search(line)
                if count:
                    self.data[item] = self.data[item:True] + (int(count.group(1)) if len(count.groups()) > 0 else 1)
                    break
                if self.data[item:'reset'] is not None and self.data[item:'reset'].search(line):
                    self.data[item] = self.data[item:'start']
                    break

import glob
import re
import snmpy

class log_processor(snmpy.plugin):
    def create(self):
        for k, v in sorted(self.conf['objects'].items()):
            extra = {
                'count':  re.compile(v['count']),
                'reset':  re.compile(v['reset']) if 'reset' in v else None,
                'start':  int(v['start']) if 'start' in v else 0,
                'rotate': bool(v['rotate']) if 'rotate' in v else False
            }

            self.data['1.%s' % k] = 'string', v['label']
            self.data['2.%s' % k] = 'integer', extra['start'], extra

        self.tail()

    @snmpy.plugin.task
    def tail(self):
        for line in snmpy.plugin.tail(glob.glob(self.conf['file_name'])[0], True):
            if line is True:
                for item in self.data['2.0':]:
                    if self.data[item:'rotate'] and line is True:
                        self.data[item] = self.data[item:'start']
                continue

            for item in self.data['2.0':]:
                count = self.data[item:'count'].search(line)
                if count:
                    self.data[item] = self.data[item:True] + (int(count.group(1)) if len(count.groups()) > 0 else 1)
                    break
                if self.data[item:'reset'] is not None and self.data[item:'reset'].search(line):
                    self.data[item] = self.data[item:'start']
                    break

Support file globbing for log processor since names could be dynamic (based on hostname, etc.).
Support file globbing for log processor since names could be dynamic (based on hostname, etc.).

+ import glob
  import re
  import snmpy
  
  class log_processor(snmpy.plugin):
      def create(self):
          for k, v in sorted(self.conf['objects'].items()):
              extra = {
                  'count':  re.compile(v['count']),
                  'reset':  re.compile(v['reset']) if 'reset' in v else None,
                  'start':  int(v['start']) if 'start' in v else 0,
                  'rotate': bool(v['rotate']) if 'rotate' in v else False
              }
  
              self.data['1.%s' % k] = 'string', v['label']
              self.data['2.%s' % k] = 'integer', extra['start'], extra
  
          self.tail()
  
      @snmpy.plugin.task
      def tail(self):
-         for line in snmpy.plugin.tail(self.conf['file_name'], True):
+         for line in snmpy.plugin.tail(glob.glob(self.conf['file_name'])[0], True):
              if line is True:
                  for item in self.data['2.0':]:
                      if self.data[item:'rotate'] and line is True:
                          self.data[item] = self.data[item:'start']
                  continue
  
              for item in self.data['2.0':]:
                  count = self.data[item:'count'].search(line)
                  if count:
                      self.data[item] = self.data[item:True] + (int(count.group(1)) if len(count.groups()) > 0 else 1)
                      break
                  if self.data[item:'reset'] is not None and self.data[item:'reset'].search(line):
                      self.data[item] = self.data[item:'start']
                      break
  
Support file globbing for log processor since names could be dynamic (based on hostname, etc.).
## Code Before:
import re
import snmpy

class log_processor(snmpy.plugin):
    def create(self):
        for k, v in sorted(self.conf['objects'].items()):
            extra = {
                'count':  re.compile(v['count']),
                'reset':  re.compile(v['reset']) if 'reset' in v else None,
                'start':  int(v['start']) if 'start' in v else 0,
                'rotate': bool(v['rotate']) if 'rotate' in v else False
            }

            self.data['1.%s' % k] = 'string', v['label']
            self.data['2.%s' % k] = 'integer', extra['start'], extra

        self.tail()

    @snmpy.plugin.task
    def tail(self):
        for line in snmpy.plugin.tail(self.conf['file_name'], True):
            if line is True:
                for item in self.data['2.0':]:
                    if self.data[item:'rotate'] and line is True:
                        self.data[item] = self.data[item:'start']
                continue

            for item in self.data['2.0':]:
                count = self.data[item:'count'].search(line)
                if count:
                    self.data[item] = self.data[item:True] + (int(count.group(1)) if len(count.groups()) > 0 else 1)
                    break
                if self.data[item:'reset'] is not None and self.data[item:'reset'].search(line):
                    self.data[item] = self.data[item:'start']
                    break

## Instruction:
Support file globbing for log processor since names could be dynamic (based on hostname, etc.).
## Code After:
import glob
import re
import snmpy

class log_processor(snmpy.plugin):
    def create(self):
        for k, v in sorted(self.conf['objects'].items()):
            extra = {
                'count':  re.compile(v['count']),
                'reset':  re.compile(v['reset']) if 'reset' in v else None,
                'start':  int(v['start']) if 'start' in v else 0,
                'rotate': bool(v['rotate']) if 'rotate' in v else False
            }

            self.data['1.%s' % k] = 'string', v['label']
            self.data['2.%s' % k] = 'integer', extra['start'], extra

        self.tail()

    @snmpy.plugin.task
    def tail(self):
        for line in snmpy.plugin.tail(glob.glob(self.conf['file_name'])[0], True):
            if line is True:
                for item in self.data['2.0':]:
                    if self.data[item:'rotate'] and line is True:
                        self.data[item] = self.data[item:'start']
                continue

            for item in self.data['2.0':]:
                count = self.data[item:'count'].search(line)
                if count:
                    self.data[item] = self.data[item:True] + (int(count.group(1)) if len(count.groups()) > 0 else 1)
                    break
                if self.data[item:'reset'] is not None and self.data[item:'reset'].search(line):
                    self.data[item] = self.data[item:'start']
                    break
