Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Conversation

@georgehansper
Copy link

For python 2.4/2.6 compatability

  • added the class Dummy_argparse for Python 2.4/2.6 compatibility
  • check if class sys has the attribute maxsize, use constant 2^32-1 if not
  • Performance data now outputs raw counters
  • Performance data only put the warn/crit levels in the 1st set of values
  • changed name of /var/tmp file to check_iftraffic_nrpe_stats.dat

George Hansper added 2 commits November 28, 2014 05:26
…nce output is now the raw counters, Performance data only includes warning/critical levels on 1st set of values
…e' to allow argparse to be installed as a module
@SamK
Copy link
Owner

SamK commented Dec 5, 2014

Hello George, thank's a lot for this great pull request.
I do however have a few questions here and there.

@stromnet
Copy link

Hi,

the performance data is indeed broken in master. Opsview generate no graphs, when the gauge value is sent as a counter.

However, this change will break the status checking, as that is made on the .value.
An alternative approach, including the status-fix from 27-no-warnings-nor-criticals

@@ -241,6 +241,7 @@ class NagiosService(object):
     def __init__(self):
         self.label = None
         self.value = None
+        self.raw_value = None
         self.min_level = 0
         self.max_level = None
         self.warn_level = None
@@ -254,13 +255,13 @@ class NagiosService(object):
                '%(min_level)s;' \
                '%(max_level)s' % \
                {'label': self.label,
-                'value': self.value,
+                'value': self.raw_value,
                 'warn_level': self.warn_level,
                 'crit_level': self.crit_level,
                 'min_level': self.min_level,
                 'max_level': self.max_level}

-    def status(self, value):
+    def status(self):
         """Returns the string defining the Nagios status of the value"""
         if self.value >= self.crit_level:
             return 'CRITICAL'
@@ -325,7 +326,7 @@ class NagiosResult(object):
     def add(self, new_service):
         """ Add a NagiosService object in the Nagios results
         """
-        self.status = self.worst(self.status, new_service.status)
+        self.status = self.worst(self.status, new_service.status())
         self._services.append(new_service)


@@ -591,6 +592,7 @@ def main(default_values):
                 # Define service values
                 #

+                nagios_service.raw_value = if_data1[counter['name']]
                 nagios_service.value = traffic_value
                 nagios_service.max_level = float(args.bandwidth)
                 # convert percent levels given by user into real values

@stromnet
Copy link

An addition to my above patch, in order to get performance counters in the desired value.

                     # convert to desired unit if asked
                     nagios_service.value = convert_bytes(nagios_service.value,
                                                          args.unit)
+                    nagios_service.raw_value = convert_bytes(nagios_service.raw_value,
+                                                         args.unit)

                 nagios_result.add(nagios_service)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants