import re
import snmpy.plugin
import subprocess

class value_cmd(snmpy.plugin.ValuePlugin):
    CDEF_FUNCS = {
        'min': min,
        'max': max,
        'len': len,
        'sum': sum,
        'len': len,
        'avg': lambda l: 0 if len(l) == 0 else sum(l) / len(l),
    }

    def update(self):
        text = subprocess.Popen(self.conf['object'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
        for item in self:
            find = re.findall(self[item].regex, text)

            if find:
                if self[item:'cdef'] in self.CDEF_FUNCS:
                    self[item] = self.CDEF_FUNCS[self[item].cdef](self[item].native(i) for i in find)
                else:
                    self[item] = self[item].native(self[item:'join':''].join(find))

@@ -275,16 +275,194 @@
 %0A    %7D%0A%0A
+    def __init__(self, conf):%0A        self.item_attributes = %7B%0A            'cdef': None,%0A            'join': '',%0A        %7D%0A        snmpy.plugin.ValuePlugin.__init__(self, conf)%0A%0A
     def 
@@ -471,24 +471,24 @@
 date(self):%0A
-
         text
@@ -741,16 +741,14 @@
 item
-:'
+%5D.
 cdef
-'%5D
  in 
@@ -952,19 +952,14 @@
 item
-:'
+%5D.
 join
-':''%5D
 .joi

Convert value_cmd to new plugin data model.