|
@@ -1,4 +1,4 @@
|
|
-#!/usr/bin/env python
|
|
|
|
|
|
+#!/usr/bin/env python3
|
|
|
|
|
|
import os
|
|
import os
|
|
import re
|
|
import re
|
|
@@ -10,7 +10,7 @@ allowed = [
|
|
##### System informations
|
|
##### System informations
|
|
r'^/usr/bin/lsb_release\s+-d$', # Linux
|
|
r'^/usr/bin/lsb_release\s+-d$', # Linux
|
|
r'^/(usr/)?bin/uname\s+-mrs$', # Linux, BSD & others
|
|
r'^/(usr/)?bin/uname\s+-mrs$', # Linux, BSD & others
|
|
- r'''^/(usr/)?s?bin/awk -F'"' -e '/PRETTY_NAME/{ print \$2; }' /etc/os-release''', # Linux: /etc/os-release via awk for get_os.py
|
|
|
|
|
|
+ r'''^/(usr/)?s?bin/awk -F'"' (-e\s*)?'/PRETTY_NAME/{ print \$2; }' /etc/os-release''', # Linux: /etc/os-release via awk for get_os.py
|
|
|
|
|
|
##### Complete command lines (Monitoring-Plugins on Debian)
|
|
##### Complete command lines (Monitoring-Plugins on Debian)
|
|
r'^/usr/lib/nagios/plugins/check_disk -w \d+% -c \d+% -p /[/a-z]*$',
|
|
r'^/usr/lib/nagios/plugins/check_disk -w \d+% -c \d+% -p /[/a-z]*$',
|
|
@@ -33,7 +33,7 @@ allowed = [
|
|
|
|
|
|
cmdline = os.getenv('SSH_ORIGINAL_COMMAND')
|
|
cmdline = os.getenv('SSH_ORIGINAL_COMMAND')
|
|
if not cmdline:
|
|
if not cmdline:
|
|
- print 'This is just a wrapper, no command specified!'
|
|
|
|
|
|
+ print('This is just a wrapper, no command specified!')
|
|
sys.exit(3)
|
|
sys.exit(3)
|
|
|
|
|
|
for maybe in allowed:
|
|
for maybe in allowed:
|
|
@@ -42,13 +42,13 @@ for maybe in allowed:
|
|
|
|
|
|
try:
|
|
try:
|
|
cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
|
|
cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
|
|
- except Exception, exc:
|
|
|
|
- print 'Could not execute plugin ("%s"): %s' % (' '.join(cmdline), exc)
|
|
|
|
|
|
+ except Exception as exc:
|
|
|
|
+ print('Could not execute plugin ("%s"): %s' % (' '.join(cmdline), exc))
|
|
sys.exit(3)
|
|
sys.exit(3)
|
|
else:
|
|
else:
|
|
- print cmd.communicate()[0].rstrip()
|
|
|
|
|
|
+ print(cmd.communicate()[0].rstrip().decode('utf-8'))
|
|
sys.exit(cmd.returncode)
|
|
sys.exit(cmd.returncode)
|
|
|
|
|
|
-print '%s: No allowed command found!' % sys.argv[0]
|
|
|
|
|
|
+print('%s: No allowed command found!' % sys.argv[0])
|
|
sys.exit(3)
|
|
sys.exit(3)
|
|
|
|
|