perun.proxy.utils 2.7.4__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/PKG-INFO +3 -1
  2. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/README.md +2 -0
  3. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/run_probes.py +40 -6
  4. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/separate_oidc_logs.py +4 -3
  5. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/separate_ssp_logs.py +4 -3
  6. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun.proxy.utils.egg-info/PKG-INFO +3 -1
  7. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/setup.cfg +1 -1
  8. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/LICENSE +0 -0
  9. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/__init__.py +0 -0
  10. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/metadata_expiration.py +0 -0
  11. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/__init__.py +0 -0
  12. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_custom_command.py +0 -0
  13. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_dockers.py +0 -0
  14. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_exabgp_propagation.py +0 -0
  15. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_ldap.py +0 -0
  16. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_ldap_syncrepl.py +0 -0
  17. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_mongodb.py +0 -0
  18. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_nginx.py +0 -0
  19. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_oidc_login.py +0 -0
  20. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_pgsql.py +0 -0
  21. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_php_syntax.py +0 -0
  22. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_privacyidea.py +0 -0
  23. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_rpc_status.py +0 -0
  24. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_saml.py +0 -0
  25. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/check_user_logins.py +0 -0
  26. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/nagios/webserver_availability.py +0 -0
  27. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/oracle2postgresql.py +0 -0
  28. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/print_docker_versions.py +0 -0
  29. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/run_version_script.py +0 -0
  30. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun/proxy/utils/sync_usable_token_types.py +0 -0
  31. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun.proxy.utils.egg-info/SOURCES.txt +0 -0
  32. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun.proxy.utils.egg-info/dependency_links.txt +0 -0
  33. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun.proxy.utils.egg-info/entry_points.txt +0 -0
  34. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun.proxy.utils.egg-info/requires.txt +0 -0
  35. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/perun.proxy.utils.egg-info/top_level.txt +0 -0
  36. {perun.proxy.utils-2.7.4 → perun.proxy.utils-3.1.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: perun.proxy.utils
3
- Version: 2.7.4
3
+ Version: 3.1.0
4
4
  Summary: Utilities and monitoring probes for Perun ProxyIdP
5
5
  Home-page: https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils.git
6
6
  Requires-Python: >=3.9
@@ -55,6 +55,8 @@ There are several extras which are required only for some scripts:
55
55
  - script designed to execute multiple monitoring probes
56
56
  - output is compatible with CheckMK
57
57
  - it is required to put configuration file to `/etc/run_probes_cfg.yaml`
58
+ - default timeout in seconds for all checks is set by `default_timeout` in the config, and each check can optionally have its own `timeout` setting overriding the default one.
59
+
58
60
 
59
61
  For usage instructions, run:
60
62
 
@@ -25,6 +25,8 @@ There are several extras which are required only for some scripts:
25
25
  - script designed to execute multiple monitoring probes
26
26
  - output is compatible with CheckMK
27
27
  - it is required to put configuration file to `/etc/run_probes_cfg.yaml`
28
+ - default timeout in seconds for all checks is set by `default_timeout` in the config, and each check can optionally have its own `timeout` setting overriding the default one.
29
+
28
30
 
29
31
  For usage instructions, run:
30
32
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/python3
2
+ import argparse
2
3
  import re
3
4
  import subprocess
4
5
  import sys
@@ -41,7 +42,7 @@ def get_metrics_and_new_output(output):
41
42
  return None, output
42
43
 
43
44
 
44
- def run_probe(probe_name, command):
45
+ def run_probe(probe_name, command, timeout):
45
46
  """
46
47
  Runs nagios monitoring probe and prints output in following formats:
47
48
  1) return_code probe_name metrics output
@@ -50,9 +51,17 @@ def run_probe(probe_name, command):
50
51
  metrics output format:
51
52
  metric1=val;|metric2=val2|metric3=val3;val3;;;|metric4=val4
52
53
  """
53
- result = subprocess.run(
54
- command, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
55
- )
54
+ try:
55
+ result = subprocess.run(
56
+ command,
57
+ text=True,
58
+ stdout=subprocess.PIPE,
59
+ stderr=subprocess.STDOUT,
60
+ timeout=timeout,
61
+ )
62
+ except subprocess.TimeoutExpired:
63
+ print(f"3 {probe_name} - probe TIMED OUT after {timeout}s")
64
+ return 3
56
65
  output = re.sub("[ \t\n]+", " ", result.stdout)
57
66
  search = re.search(r" - .*", output)
58
67
  if search:
@@ -65,18 +74,43 @@ def run_probe(probe_name, command):
65
74
  return result.returncode
66
75
 
67
76
 
77
+ def parse_arguments():
78
+ parser = argparse.ArgumentParser()
79
+ parser.add_argument(
80
+ "-p",
81
+ "--probes",
82
+ nargs="+",
83
+ default=[],
84
+ help="Optional list of probes to run from the config."
85
+ "If not specified, all probes will be run.",
86
+ )
87
+ args = parser.parse_args()
88
+ return args
89
+
90
+
68
91
  def main():
92
+ args = parse_arguments()
93
+ probes_to_run = args.probes
94
+
69
95
  config_filepath = "/etc/run_probes_cfg.yaml"
70
96
  config = yaml.safe_load(open_file(config_filepath))
97
+
71
98
  if not config:
72
99
  return
73
100
 
74
- for _, options in config.items():
101
+ global_timeout = config["default_timeout"]
102
+ for _, options in config["checks"].items():
75
103
  module = options["module"]
76
104
  for name, args in options.get("runs").items():
105
+ if probes_to_run and name not in probes_to_run:
106
+ continue
77
107
  command = ["python3", "-m", module]
108
+ timeout = global_timeout
78
109
  if args is not None:
79
110
  for arg_name, arg_val in args.items():
111
+ if arg_name == "timeout":
112
+ timeout = arg_val
113
+ continue
80
114
  if len(arg_name) == 1:
81
115
  arg_name = "-" + arg_name
82
116
  else:
@@ -88,7 +122,7 @@ def main():
88
122
  command.append(arg_name)
89
123
  if arg_val is not None:
90
124
  command.append(str(arg_val))
91
- Thread(target=run_probe, args=[name, command]).start()
125
+ Thread(target=run_probe, args=[name, command, timeout]).start()
92
126
 
93
127
 
94
128
  if __name__ == "__main__":
@@ -69,9 +69,10 @@ def main():
69
69
  final_log_file.close()
70
70
 
71
71
  # Zip old log file
72
- with open(full_log_absolute_name, "rb") as f_in, gzip.open(
73
- full_log_absolute_name + ".gz", "wb"
74
- ) as f_out:
72
+ with (
73
+ open(full_log_absolute_name, "rb") as f_in,
74
+ gzip.open(full_log_absolute_name + ".gz", "wb") as f_out,
75
+ ):
75
76
  shutil.copyfileobj(f_in, f_out)
76
77
 
77
78
  # Remove unzip file
@@ -79,9 +79,10 @@ def main():
79
79
  final_log_file.close()
80
80
 
81
81
  # Zip old log file
82
- with open(full_log_absolute_name, "rb") as f_in, gzip.open(
83
- full_log_absolute_name + ".gz", "wb"
84
- ) as f_out:
82
+ with (
83
+ open(full_log_absolute_name, "rb") as f_in,
84
+ gzip.open(full_log_absolute_name + ".gz", "wb") as f_out,
85
+ ):
85
86
  shutil.copyfileobj(f_in, f_out)
86
87
 
87
88
  # Remove unzip file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: perun.proxy.utils
3
- Version: 2.7.4
3
+ Version: 3.1.0
4
4
  Summary: Utilities and monitoring probes for Perun ProxyIdP
5
5
  Home-page: https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils.git
6
6
  Requires-Python: >=3.9
@@ -55,6 +55,8 @@ There are several extras which are required only for some scripts:
55
55
  - script designed to execute multiple monitoring probes
56
56
  - output is compatible with CheckMK
57
57
  - it is required to put configuration file to `/etc/run_probes_cfg.yaml`
58
+ - default timeout in seconds for all checks is set by `default_timeout` in the config, and each check can optionally have its own `timeout` setting overriding the default one.
59
+
58
60
 
59
61
  For usage instructions, run:
60
62
 
@@ -1,5 +1,5 @@
1
1
  [metadata]
2
- version = 2.7.4
2
+ version = 3.1.0
3
3
  license_files = LICENSE
4
4
  long_description = file: README.md
5
5
  long_description_content_type = text/markdown