Index: pkg-nagios-plugins-contrib/check_graphite/check_graphite.py
===================================================================
--- pkg-nagios-plugins-contrib.orig/check_graphite/check_graphite.py
+++ pkg-nagios-plugins-contrib/check_graphite/check_graphite.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 check_graphite.py
 ~~~~~~~
@@ -9,8 +9,8 @@ check_graphite.py
 
 import json
 import optparse
-import urllib
-import urllib2
+import urllib.request, urllib.parse, urllib.error
+import urllib.request, urllib.error, urllib.parse
 import sys
 
 from numbers import Real
@@ -34,7 +34,7 @@ class Graphite(object):
             [('until', self._until)] +\
             [('format', 'json')]
         self.full_url = self.url + '/render?' +\
-            urllib.urlencode(params)
+            urllib.parse.urlencode(params)
 
     def check_datapoints(self, datapoints, check_func, **kwargs):
         """Find alerting datapoints
@@ -56,19 +56,19 @@ class Graphite(object):
             return [x for x in datapoints if isinstance(x, Real) and check_func(x, kwargs['threshold'])]
         elif 'bounds' in kwargs:
             if 'compare' in kwargs:
-              return [datapoints[x] for x in xrange(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x], kwargs['compare'][x]]) and check_func(datapoints[x] / kwargs['bounds'][x], kwargs['beyond']) and check_func(datapoints[x], kwargs['compare'][x])]
+              return [datapoints[x] for x in range(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x], kwargs['compare'][x]]) and check_func(datapoints[x] / kwargs['bounds'][x], kwargs['beyond']) and check_func(datapoints[x], kwargs['compare'][x])]
             else:
-                return [datapoints[x] for x in xrange(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x]]) and check_func(datapoints[x], kwargs['bounds'][x])]
+                return [datapoints[x] for x in range(len(datapoints)) if all([datapoints[x], kwargs['bounds'][x]]) and check_func(datapoints[x], kwargs['bounds'][x])]
 
     def fetch_metrics(self):
         try:
-            response = urllib2.urlopen(self.full_url)
+            response = urllib.request.urlopen(self.full_url)
 
             if response.code != 200:
                 return None
             else:
                 return json.loads(response.read())
-        except urllib2.URLError, TypeError:
+        except urllib.error.URLError as TypeError:
             return None
 
     def generate_output(self, datapoints, *args, **kwargs):
@@ -210,7 +210,7 @@ if __name__ == '__main__':
             warn = float(options.warning)
             crit = float(options.critical)
         except ValueError:
-            print 'ERROR: WARNING or CRITICAL threshold is not a number\n'
+            print('ERROR: WARNING or CRITICAL threshold is not a number\n')
             parser.print_help()
             sys.exit(NAGIOS_STATUSES['UNKNOWN'])
 
@@ -234,7 +234,7 @@ if __name__ == '__main__':
                 kwargs['compare'] = [x[0] for x in metric_data[3].get('datapoints', [])][from_slice:]
 
                 if not graphite.has_numbers(kwargs['compare']):
-                    print 'CRITICAL: No compare target output from Graphite!'
+                    print('CRITICAL: No compare target output from Graphite!')
                     sys.exit(NAGIOS_STATUSES['CRITICAL'])
 
             if graphite.has_numbers(actual) and graphite.has_numbers(kwargs['bounds']):
@@ -245,13 +245,13 @@ if __name__ == '__main__':
                                                                      target=target_name)
 
             else:
-                print 'CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets)
+                print('CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets))
                 sys.exit(NAGIOS_STATUSES['CRITICAL'])
         else:
             for target in metric_data:
                 datapoints = [x[0] for x in target.get('datapoints', []) if isinstance(x[0], Real)]
                 if not graphite.has_numbers(datapoints) and not options.empty_ok:
-                    print 'CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets)
+                    print('CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets))
                     sys.exit(NAGIOS_STATUSES['CRITICAL'])
 
                 crit_oob = graphite.check_datapoints(datapoints, check_func, threshold=crit)
@@ -265,13 +265,13 @@ if __name__ == '__main__':
                                                                           critical=crit)
     else:
         if options.empty_ok and isinstance(metric_data, list):
-            print 'OK: No output from Graphite for target(s): %s' % ', '.join(targets)
+            print('OK: No output from Graphite for target(s): %s' % ', '.join(targets))
             sys.exit(NAGIOS_STATUSES['OK'])
 
-        print 'CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets)
+        print('CRITICAL: No output from Graphite for target(s): %s' % ', '.join(targets))
         sys.exit(NAGIOS_STATUSES['CRITICAL'])
 
-    for target, messages in check_output.iteritems():
+    for target, messages in check_output.items():
         if messages['CRITICAL']:
             exit_code = NAGIOS_STATUSES['CRITICAL']
         elif messages['WARNING']:
@@ -281,6 +281,6 @@ if __name__ == '__main__':
 
         for status_code in ['CRITICAL', 'WARNING', 'OK']:
             if messages[status_code]:
-                print '\n'.join(['%s: %s' % (status_code, status) for status in messages[status_code]])
+                print('\n'.join(['%s: %s' % (status_code, status) for status in messages[status_code]]))
 
     sys.exit(exit_code)
