monitoringplugin.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. # -*- encoding: utf-8 -*-
  2. __version__ = '0.0.100802'
  3. __all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin']
  4. import optparse, os, re, sys
  5. try:
  6. import netsnmp
  7. except ImportError:
  8. pass
  9. class MonitoringPlugin(object):
  10. RETURNSTRINGS = { 0: "OK", 1: "WARNING", 2: "CRITICAL", 3: "UNKNOWN", 127: "UNKNOWN" }
  11. RETURNCODE = { 'OK': 0, 'WARNING': 1, 'CRITICAL': 2, 'UNKNOWN': 3 }
  12. returncode_priority = [2, 1, 3, 0]
  13. powers_binary = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']
  14. powers_binary_lower = [ p.lower() for p in powers_binary]
  15. powers_si = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']
  16. powers_si_lower = [ p.lower() for p in powers_si]
  17. def __init__(self, *args, **kwargs):
  18. self.__pluginname = kwargs.get('pluginname') or ''
  19. self.__version = kwargs.get('version') or None
  20. self.__tagforstatusline = kwargs.get('tagforstatusline') or ''
  21. self.__tagforstatusline = self.__tagforstatusline.replace('|', ' ')
  22. self.__description = kwargs.get('description') or None
  23. self.__output = []
  24. self.__multilineoutput = []
  25. self.__performancedata = []
  26. self.__returncode = []
  27. self.__brain_checks = []
  28. self.__brain_perfdata = []
  29. self.__brain_perfdatalabels = []
  30. self.__optparser = optparse.OptionParser(version=self.__version, description=self.__description)
  31. self._cmdlineoptions_parsed = False
  32. def add_cmdlineoption(self, shortoption, longoption, dest, help, **kwargs):
  33. self.__optparser.add_option(shortoption, longoption, dest=dest, help=help, **kwargs)
  34. def parse_cmdlineoptions(self):
  35. if self._cmdlineoptions_parsed:
  36. return
  37. # self.__optparser.add_option('-V', '--version', action='version', help='show version number and exit')
  38. self.__optparser.add_option('-v', '--verbose', dest='verbose', help='Verbosity, more for more ;-)', action='count')
  39. (self.options, self.args) = self.__optparser.parse_args()
  40. self._cmdlineoptions_parsed = True
  41. def range_to_limits(self, range):
  42. # Check if we must negate result
  43. if len(range) > 0 and range[0] == '@':
  44. negate = True
  45. range = range[1:]
  46. else:
  47. negate = False
  48. # Look for a ':'...
  49. if range.find(':') >= 0:
  50. # ... this is a range
  51. (low, high) = range.split(':')
  52. if not low:
  53. low = float(0.0)
  54. elif low[0] == '~':
  55. low = float('-infinity')
  56. else:
  57. low = float(low)
  58. if high:
  59. high = float(high)
  60. else:
  61. high = float('infinity')
  62. elif len(range) == 0:
  63. low = float('-infinity')
  64. high = float('infinity')
  65. else:
  66. # ... this is just a number
  67. low = float(0.0)
  68. high = float(range)
  69. return (low, high, negate)
  70. def value_in_range(self, value, range):
  71. if range not in ['', None]:
  72. (low, high, negate) = self.range_to_limits(range)
  73. else:
  74. return True
  75. if value < low or value > high:
  76. result = False
  77. else:
  78. result = True
  79. if negate:
  80. result = not result
  81. return result
  82. def value_wc_to_returncode(self, value, range_warn, range_crit):
  83. if not self.value_in_range(value, range_crit):
  84. return 2
  85. elif not self.value_in_range(value, range_warn):
  86. return 1
  87. return 0
  88. def is_float(self, string):
  89. try:
  90. float(string)
  91. return True
  92. except ValueError:
  93. return False
  94. def special_value_wc_to_returncode(self, value, warn, crit):
  95. # Special add on: WARN > CRIT
  96. if self.is_float(warn) and self.is_float(crit) and float(warn) > float(crit):
  97. # Test if value is *smaller* than thresholds
  98. warn = '@0:' + warn
  99. crit = '@0:' + crit
  100. return self.value_wc_to_returncode(value, warn, crit)
  101. def add_output(self, value):
  102. self.__output.append(value)
  103. def add_multilineoutput(self, value):
  104. self.__multilineoutput.append(value)
  105. def format_performancedata(self, label, value, unit, *args, **kwargs):
  106. label = label.lstrip().rstrip()
  107. if re.search('[=\' ]', label):
  108. label = '\'' + label + '\''
  109. perfdata = label + '=' + str(value)
  110. if unit:
  111. perfdata += str(unit).lstrip().rstrip()
  112. for key in ['warn', 'crit', 'min', 'max']:
  113. perfdata += ';'
  114. if key in kwargs and kwargs[key]!=None:
  115. perfdata += str(kwargs[key])
  116. return perfdata
  117. def add_performancedata(self, perfdata):
  118. self.__performancedata.append(perfdata)
  119. def format_add_performancedata(self, label, value, unit, *args, **kwargs):
  120. self.add_performancedata(self.format_performancedata(label, value, unit, *args, **kwargs))
  121. def add_returncode(self, value):
  122. self.__returncode.append(value)
  123. def tagtarget(self, tag, target):
  124. if target:
  125. return str(tag) + ':' + str(target)
  126. else:
  127. return str(tag)
  128. def remember_check(self, tag, returncode, output, multilineoutput=None, perfdata=None, target=None):
  129. check = {}
  130. check['tag'] = tag
  131. check['returncode'] = returncode
  132. check['output'] = output
  133. check['multilineoutout'] = multilineoutput
  134. check['perfdata'] = perfdata
  135. check['target'] = target
  136. self.remember_perfdata(perfdata)
  137. self.__brain_checks.append(check)
  138. return check
  139. def remember_perfdata(self, perfdata=None):
  140. if perfdata:
  141. for pd in perfdata:
  142. if pd['label'] in self.__brain_perfdatalabels:
  143. pdidx = self.__brain_perfdatalabels.index(pd['label'])
  144. self.__brain_perfdata[pdidx] = pd
  145. else:
  146. self.__brain_perfdata.append(pd)
  147. self.__brain_perfdatalabels.append(pd['label'])
  148. def dump_brain(self):
  149. return (self.__brain_checks, self.__brain_perfdata)
  150. def brain2output(self):
  151. out = [[], [], [], []]
  152. for check in self.__brain_checks:
  153. tagtarget = self.tagtarget(check['tag'], check.get('target'))
  154. returncode = check.get('returncode') or 0
  155. self.add_returncode(returncode)
  156. out[returncode].append(tagtarget)
  157. #if returncode == 0:
  158. # self.add_output(tagtarget)
  159. #else:
  160. # self.add_output(tagtarget + '(' + check.get('output') + ') ')
  161. self.add_multilineoutput(self.RETURNSTRINGS[returncode] + ' ' + tagtarget + ' - ' + check.get('output'))
  162. if check.get('multilineoutput'):
  163. self.add_multilineoutput(check.get('multilineoutput'))
  164. statusline = []
  165. for retcode in self.returncode_priority:
  166. if len(out[retcode]):
  167. statusline.append(str(len(out[retcode])) + ' ' + self.RETURNSTRINGS[retcode] + ': ' + ' '.join(out[retcode]))
  168. statusline = ', '.join(statusline)
  169. self.add_output(statusline)
  170. for pd in self.__brain_perfdata:
  171. self.format_add_performancedata(**pd)
  172. def value_to_human_binary(self, value, unit=''):
  173. for power in self.powers_binary:
  174. if value < 1024.0:
  175. return "%3.1f%s%s" % (value, power, unit)
  176. value /= 1024.0
  177. if float(value) not in [float('inf'), float('-inf')]:
  178. return "%3.1fYi%s" % (value, unit)
  179. else:
  180. return value
  181. def value_to_human_si(self, value, unit=''):
  182. for power in self.powers_si:
  183. if value < 1000.0:
  184. return "%3.1f%s%s" % (value, power, unit)
  185. value /= 1000.0
  186. if float(value) not in [float('inf'), float('-inf')]:
  187. return "%3.1fY%s" % (value, unit)
  188. else:
  189. return value
  190. def human_to_number(self, value, total=None):
  191. if total:
  192. if not self.is_float(total):
  193. total = self.human_to_number(total)
  194. if self.is_float(value):
  195. return float(value)
  196. elif value[-1] == '%':
  197. if total:
  198. return float(value[:-1])/100.0 * float(total)
  199. else:
  200. return float(value[:-1])
  201. elif value[-1].lower() in self.powers_si_lower:
  202. return 1000.0 ** self.powers_si_lower.index(value[-1].lower()) * float(value[:-1])
  203. elif value[-2:].lower() in self.powers_binary_lower:
  204. return 1024.0 ** self.powers_binary_lower.index(value[-2:].lower()) * float(value[:-2])
  205. else:
  206. return value
  207. def range_dehumanize(self, range, total=None):
  208. newrange = ''
  209. if len(range):
  210. if range[0] == '@':
  211. newrange += '@'
  212. range = range[1:]
  213. parts = range.split(':')
  214. newrange += ('%f' % self.human_to_number(parts[0], total)).rstrip('0').rstrip('.')
  215. if len(parts) > 1:
  216. newrange += ':' + ('%f' % self.human_to_number(parts[1], total)).rstrip('0').rstrip('.')
  217. if range != newrange:
  218. self.verbose(3, 'Changed range/thresold from "' + range + '" to "' + newrange + '"')
  219. return newrange
  220. else:
  221. return ''
  222. def verbose(self, level, output):
  223. if level <= self.options.verbose:
  224. print 'V' + str(level) + ': ' + output
  225. def max_returncode(self, returncodes):
  226. for rc in self.returncode_priority:
  227. if rc in returncodes:
  228. break
  229. return rc
  230. def exit(self):
  231. returncode = self.max_returncode(self.__returncode)
  232. self.back2nagios(returncode, statusline=self.__output, multiline=self.__multilineoutput, performancedata=self.__performancedata)
  233. def back2nagios(self, returncode, statusline=None, multiline=None, performancedata=None, subtag=None, exit=True):
  234. # FIXME: Make 'returncode' also accept strings
  235. # Build status line
  236. out = self.__tagforstatusline
  237. if subtag:
  238. out += '(' + subtag.replace('|', ' ') + ')'
  239. out += ' ' + self.RETURNSTRINGS[returncode]
  240. # Check if there's a status line text and build it
  241. if statusline:
  242. out += ' - '
  243. if type(statusline) == str:
  244. out += statusline
  245. elif type(statusline) in [list, tuple]:
  246. out += ', '.join(statusline).replace('|', ' ')
  247. # Check if we have multi line output and build it
  248. if multiline:
  249. if type(multiline) == str:
  250. out += '\n' + multiline.replace('|', ' ')
  251. elif type(multiline) in [list, tuple]:
  252. out += '\n' + '\n'.join(multiline).replace('|', ' ')
  253. # Check if there's perfdata
  254. if performancedata:
  255. out += '|'
  256. if type(performancedata) == str:
  257. out += performancedata
  258. elif type(performancedata) in [list, tuple]:
  259. out += ' '.join(performancedata).replace('|', ' ')
  260. # Exit program or return output line(s)
  261. if exit:
  262. print out
  263. sys.exit(returncode)
  264. else:
  265. return (returncode, out)
  266. ##############################################################################
  267. class SNMPMonitoringPlugin(MonitoringPlugin):
  268. def __init__(self, *args, **kwargs):
  269. # Same as "MonitoringPlugin.__init__(*args, **kwargs)" but a little bit more flexible
  270. #super(MonitoringPlugin, self).__init__(*args, **kwargs)
  271. MonitoringPlugin.__init__(self, *args, **kwargs)
  272. self.add_cmdlineoption('-H', '', 'host', 'Host to check', default='127.0.0.1')
  273. self.add_cmdlineoption('-P', '', 'snmpversion', 'SNMP protocol version', metavar='1', default='1')
  274. self.add_cmdlineoption('-C', '', 'snmpauth', 'SNMP v1/v2c community OR SNMP v3 quadruple', metavar='public', default='public')
  275. self.add_cmdlineoption('', '--snmpcmdlinepath', 'snmpcmdlinepath', 'Path to "snmpget" and "snmpwalk"', metavar='/usr/bin/', default='/usr/bin')
  276. # FIXME
  277. self.add_cmdlineoption('', '--nonetsnmp', 'nonetsnmp', 'Do not use NET-SNMP python bindings', action='store_true')
  278. # self.__optparser.add_option('', '--nonetsnmp', dest='nonetsnmp', help='Do not use NET-SNMP python bindings', action='store_true')
  279. self.__SNMP_Cache = {}
  280. self.__use_netsnmp = False
  281. self.__prepared_snmp = False
  282. def prepare_snmp(self):
  283. if not self._cmdlineoptions_parsed:
  284. self.parse_cmdlineoptions()
  285. if not self.options.nonetsnmp:
  286. try:
  287. import netsnmp
  288. self.__use_netsnmp = True
  289. except ImportError:
  290. pass
  291. if self.__use_netsnmp:
  292. self.verbose(1, 'Using NET-SNMP Python bindings')
  293. self.SNMPGET_wrapper = self.__SNMPGET_netsnmp
  294. self.SNMPWALK_wrapper = self.__SNMPWALK_netsnmp
  295. if self.options.snmpversion == '2c':
  296. self.options.snmpversion = '2'
  297. else:
  298. self.verbose(1, 'Using NET-SNMP command line tools')
  299. self.SNMPGET_wrapper = self.__SNMPGET_cmdline
  300. self.SNMPWALK_wrapper = self.__SNMPWALK_cmdline
  301. # Building command lines
  302. self.__CMDLINE_get = os.path.join(self.options.snmpcmdlinepath, 'snmpget') + ' -OqevtU '
  303. self.__CMDLINE_walk = os.path.join(self.options.snmpcmdlinepath, 'snmpwalk') + ' -OqevtU '
  304. if self.options.snmpversion in [1, 2, '1', '2', '2c']:
  305. if self.options.snmpversion in [2, '2']:
  306. self.options.snmpversion = '2c'
  307. self.__CMDLINE_get += ' -v' + str(self.options.snmpversion) + ' -c' + self.options.snmpauth + ' '
  308. self.__CMDLINE_walk += ' -v' + str(self.options.snmpversion) + ' -c' + self.options.snmpauth + ' '
  309. elif options.snmpversion == [3, '3']:
  310. # FIXME: Better error handling
  311. try:
  312. snmpauth = self.options.snmpauth.split(':')
  313. self.__CMDLINE_get += ' -v3 -l' + snmpauth[0] + ' -u' + snmpauth[1] + ' -a' + snmpauth[2] + ' -A' + snmpauth[3] + ' '
  314. self.__CMDLINE_walk += ' -v3 -l' + snmpauth[0] + ' -u' + snmpauth[1] + ' -a' + snmpauth[2] + ' -A' + snmpauth[3] + ' '
  315. except:
  316. self.back2nagios(3, 'Could not build SNMPv3 command line, need "SecLevel:SecName:AuthProtocol:AuthKey"')
  317. else:
  318. self.back2nagios(3, 'Unknown SNMP version "' + str(self.options.snmpversion) + '"')
  319. self.__CMDLINE_get += ' ' + self.options.host + ' %s 2>/dev/null'
  320. self.__CMDLINE_walk += ' ' + self.options.host + ' %s 2>/dev/null'
  321. self.verbose(3, 'Using commandline: ' + self.__CMDLINE_get)
  322. self.verbose(3, 'Using commandline: ' + self.__CMDLINE_walk)
  323. self.__prepared_snmp = True
  324. def find_index_for_value(self, list_indexes, list_values, wanted):
  325. self.verbose(2, 'Look for "' + str(wanted) + '"')
  326. index = None
  327. if len(list_indexes) != len(list_values):
  328. self.verbose(1, 'Length of index and value lists do not match!')
  329. return None
  330. try:
  331. index = list_values.index(wanted)
  332. index = list_indexes[index]
  333. except ValueError:
  334. pass
  335. if index:
  336. self.verbose(2, 'Found "' + str(wanted) +'" with index "' + str(index) + '"')
  337. else:
  338. self.verbose(2, 'Nothing found!')
  339. return index
  340. def find_in_table(self, oid_index, oid_values, wanted):
  341. self.verbose(2, 'Look for "' + str(wanted) + '" in "' + str(oid_values) +'"')
  342. index = None
  343. indexes = list(self.SNMPWALK(oid_index))
  344. values = list(self.SNMPWALK(oid_values))
  345. if len(indexes) != len(values):
  346. self.back2nagios(3, 'Different data from 2 SNMP Walks!')
  347. return self.find_index_for_value(indexes, values, wanted)
  348. def SNMPGET(self, baseoid, idx=None, exitonerror=True):
  349. if type(baseoid) in (list, tuple):
  350. if idx not in ['', None]:
  351. idx = '.' + str(idx)
  352. else:
  353. idx = ''
  354. if self.options.snmpversion in [1, '1']:
  355. value_low = long(self.SNMPGET_wrapper(baseoid[1] + idx, exitonerror=exitonerror))
  356. if value_low < 0L:
  357. value_low += 2 ** 32
  358. value_hi = long(self.SNMPGET_wrapper(baseoid[2] + idx, exitonerror=exitonerror))
  359. if value_hi < 0L:
  360. value_hi += 2 ** 32
  361. return value_hi * 2L ** 32L + value_low
  362. elif self.options.snmpversion in [2, 3, '2', '2c', '3']:
  363. return long(self.SNMPGET_wrapper(baseoid[0] + idx, exitonerror=exitonerror))
  364. elif type(baseoid) in (str, ) and idx != None:
  365. return self.SNMPGET_wrapper(baseoid + '.' + str(idx), exitonerror=exitonerror)
  366. else:
  367. return self.SNMPGET_wrapper(baseoid, exitonerror=exitonerror)
  368. def SNMPWALK(self, baseoid, exitonerror=True):
  369. return self.SNMPWALK_wrapper(baseoid, exitonerror=exitonerror)
  370. def __SNMPGET_netsnmp(self, oid, exitonerror=True):
  371. if not self.__prepared_snmp:
  372. self.prepare_snmp()
  373. if oid in self.__SNMP_Cache:
  374. self.verbose(2, "%40s -> (CACHED) %s" % (oid, self.__SNMP_Cache[oid]))
  375. return self.__SNMP_Cache[oid]
  376. result = netsnmp.snmpget(oid, Version=int(self.options.snmpversion), DestHost=self.options.host, Community=self.options.snmpauth)[0]
  377. if not result:
  378. if exitonerror:
  379. self.back2nagios(3, 'Timeout or no answer from "%s" looking for "%s"' % (self.options.host, oid))
  380. else:
  381. return None
  382. self.__SNMP_Cache[oid] = result
  383. self.verbose(2, "%40s -> %s" % (oid, result))
  384. return result
  385. def __SNMPWALK_netsnmp(self, oid, exitonerror=True):
  386. if not self.__prepared_snmp:
  387. self.prepare_snmp()
  388. if oid in self.__SNMP_Cache:
  389. self.verbose(2, "%40s -> (CACHED) %s" % (oid, self.__SNMP_Cache[oid]))
  390. return self.__SNMP_Cache[oid]
  391. result = netsnmp.snmpwalk(oid, Version=int(self.options.snmpversion), DestHost=self.options.host, Community=self.options.snmpauth)
  392. if not result:
  393. if exitonerror:
  394. self.back2nagios(3, 'Timeout or no answer from "%s" looking for "%s"' % (self.options.host, oid))
  395. else:
  396. return None
  397. self.__SNMP_Cache[oid] = result
  398. self.verbose(2, "%40s -> %s" % (oid, result))
  399. return result
  400. def __SNMPGET_cmdline(self, oid, exitonerror=True):
  401. if not self.__prepared_snmp:
  402. self.prepare_snmp()
  403. cmdline = self.__CMDLINE_get % oid
  404. self.verbose(2, cmdline)
  405. cmd = os.popen(cmdline)
  406. out = cmd.readline().rstrip().replace('"','')
  407. retcode = cmd.close()
  408. if retcode:
  409. if not exitonerror:
  410. return None
  411. if retcode == 256:
  412. self.back2nagios(3, 'Timeout - no SNMP answer from "' + self.options.host + '"')
  413. elif retcode ==512:
  414. self.back2nagios(3, 'OID "' + oid + '" not found')
  415. else:
  416. self.back2nagios(3, 'Unknown error code "' + str(retcode) + '" from command line utils')
  417. self.verbose(1, out)
  418. return out
  419. def __SNMPWALK_cmdline(self, oid, exitonerror=True):
  420. if not self.__prepared_snmp:
  421. self.prepare_snmp()
  422. cmdline = self.__CMDLINE_walk % oid
  423. self.verbose(2, cmdline)
  424. cmd = os.popen(cmdline)
  425. out = cmd.readlines()
  426. retcode = cmd.close()
  427. if retcode:
  428. if not exitonerror:
  429. return None
  430. if retcode == 256:
  431. self.back2nagios(3, 'Timeout - no SNMP answer from "' + self.options.host + '"')
  432. elif retcode ==512:
  433. self.back2nagios(3, 'OID "' + oid + '" not found')
  434. else:
  435. self.back2nagios(3, 'Unknown error code "' + str(retcode) + '" from command line utils')
  436. for line in range(0,len(out)):
  437. out[line] = out[line].rstrip().replace('"','')
  438. self.verbose(1, str(out))
  439. return out
  440. ##############################################################################
  441. def main():
  442. myplugin = MonitoringPlugin(pluginname='check_testplugin', tagforstatusline='TEST')
  443. from pprint import pprint
  444. pprint(myplugin.back2nagios(0, 'Nr. 01: Simple plugin', exit=False) )
  445. pprint(myplugin.back2nagios(0, 'Nr. 02: Simple plugin with sub tag', subtag='MySubTag', exit=False) )
  446. pprint(myplugin.back2nagios(0, 'Nr. 10: Exit Code OK', exit=False) )
  447. pprint(myplugin.back2nagios(1, 'Nr. 11: Exit Code WARNING', exit=False) )
  448. pprint(myplugin.back2nagios(2, 'Nr. 12: Exit Code CRITICAL', exit=False) )
  449. pprint(myplugin.back2nagios(3, 'Nr. 13: Exit Code UNKNOWN', exit=False) )
  450. ret = myplugin.back2nagios(0, 'Nr. 20: Plugin with string-based multiline output', 'Line 2\nLine 3\nLine4', exit=False)
  451. print ret[1]
  452. print 'Returncode: ' + str(ret[0])
  453. ret = myplugin.back2nagios(0, 'Nr. 21: Plugin with list-based multiline output', ['Line 2', 'Line 3', 'Line4'], exit=False)
  454. print ret[1]
  455. print 'Returncode: ' + str(ret[0])
  456. ret = myplugin.back2nagios(0, 'Nr. 22: Plugin with tuple-based multiline output', ('Line 2', 'Line 3', 'Line4'), exit=False)
  457. print ret[1]
  458. print 'Returncode: ' + str(ret[0])
  459. myplugin.add_performancedata('Val1', 42, '')
  460. myplugin.add_performancedata('Val2', 23, 'c', warn=10, crit=20, min=0, max=100)
  461. myplugin.add_performancedata('Val 3', '2342', 'c', warn=10, crit=20, min=0, max=100)
  462. pprint(myplugin.back2nagios(0, 'Nr. 30: With perfdatas', exit=False) )
  463. myplugin.back2nagios(0, 'Nr. 99: Exit test suite with OK')
  464. if __name__ == '__main__':
  465. main()
  466. #vim: ts=4 sw=4