Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../.././lib/svc/method/svc-apache-stats24
Real path: /lib/svc/method/svc-apache-stats24
Zurück
#!/usr/bin/python3.7 -Es import solaris.no_site_packages # # Copyright (c) 2016, 2023, Oracle and/or its affiliates. # # start and stop methods for the Apache stats provider import smf_include import subprocess import sys import os def start(): """start method gathers the config options and execs apache-stats""" fmri = os.getenv("SMF_FMRI") if fmri is None: # "cannot" happen print("SMF_FMRI is None: script must be invoked as SMF method", file=sys.stderr) return smf_include.SMF_EXIT_ERR_CONFIG # For now we are only getting the FMRI list from the properties try: instances = subprocess.check_output( ["/usr/bin/svcprop", "-g", "apache-instance", fmri]).splitlines() query_interval = subprocess.check_output( ["/usr/bin/svcprop", "-p", "config/query-interval", fmri]).splitlines()[0] except subprocess.CalledProcessError as err: print("Error occurred w/ svcprop: '{0}': '{1}'".format( fmri, err), file=sys.stderr) return smf_include.SMF_EXIT_ERR_FATAL # build argument list for apache-stats args = ["/usr/lib/apache-stats2.4/bin/apache-stats.py", query_interval] # Pass all fmris and config-paths to apache-stats process for line in instances: if line != "": # Arguments should be in config-path->fmri order by default args.append(line.split()[2]) # use check_call method to determine if degraded mode is necessary and # if so, the reason why try: subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr) except subprocess.CalledProcessError as err: if err.returncode == 3: # All provided logs used unsupported rotation program smf_include.smf_method_exit( smf_include.SMF_EXIT_ERR_FATAL, "no_valid_work_to_do", "All instances provided had unsupported apache configurations") elif err.returncode == 2: # Unsupported rotation scheme used smf_include.smf_method_exit( smf_include.SMF_EXIT_DEGRADED, "unsupported_configuration", "An unsupported configuration was detected") elif err.returncode == 1: # No valid instances to monitor smf_include.smf_method_exit( smf_include.SMF_EXIT_TEMP_DISABLE, "nothing_to_monitor", "No logs or server status pages were provided for monitoring") else: print("Internal Error while executing {0}: {1}".format(args, err), file=sys.stderr) return smf_include.SMF_EXIT_ERR_FATAL return smf_include.SMF_EXIT_OK smf_include.smf_main()