# Path: simplemonitor/Monitors/monitor.py
# class Monitor:
# class MonitorFail(Monitor):
# class MonitorNull(Monitor):
#     def __init__(
#         self, name: str = "unnamed", config_options: Optional[dict] = None
#     ) -> None:
#     def get_config_option(
#         self,
#         key: str,
#         *,
#         default: Any = None,
#         required: bool = False,
#         required_type: str = "str",
#         allowed_values: Any = None,
#         allow_empty: bool = True,
#         minimum: Optional[Union[int, float]] = None,
#         maximum: Optional[Union[int, float]] = None,
#     ) -> Any:
#     def dependencies(self) -> List[str]:
#     def dependencies(self, dependency_list: List[str]) -> None:
#     def remaining_dependencies(self) -> List[str]:
#     def is_remote(self) -> bool:
#     def run_test(self) -> Union[NoReturn, bool]:
#     def virtual_fail_count(self) -> int:
#     def test_success(self) -> bool:
#     def first_failure(self) -> bool:
#     def state(self) -> MonitorState:
#     def get_result(self) -> str:
#     def reset_dependencies(self) -> None:
#     def dependency_succeeded(self, dependency: str) -> None:
#     def log_result(self, name: str, logger: Any) -> None:
#     def get_params(self) -> Tuple:
#     def set_mon_refs(self, mmm: Any) -> None:
#     def minimum_gap(self) -> int:
#     def minimum_gap(self, gap: int) -> None:
#     def describe(self) -> str:
#     def is_windows(allow_cygwin: bool = True) -> bool:
#     def _add_unavailable_seconds(self) -> None:
#     def record_fail(self, message: str = "") -> bool:
#     def record_success(self, message: str = "") -> bool:
#     def record_skip(self, which_dep: Optional[str]) -> bool:
#     def uptime(self) -> Optional[datetime.timedelta]:
#     def skipped(self) -> bool:
#     def get_success_count(self) -> int:
#     def all_better_now(self) -> bool:
#     def availability(self) -> float:
#     def first_failure_time(self) -> Optional[arrow.Arrow]:
#     def notify(self) -> bool:
#     def notify(self, value: bool) -> None:
#     def urgent(self) -> bool:
#     def urgent(self, value: Union[bool, int]) -> None:
#     def was_skipped(self) -> bool:
#     def should_run(self) -> bool:
#     def last_virtual_fail_count(self) -> int:
#     def attempt_recover(self) -> None:
#     def run_recovered(self) -> None:
#     def post_config_setup(self) -> None:
#     def __getstate__(self) -> dict:
#     def __setstate__(self, state: dict) -> None:
#     def _set_monitor_logger(self) -> None:
#     def to_python_dict(self) -> dict:
#     def from_python_dict(
#         cls: Any, load_dict: dict
#     ) -> "Monitor":  # can't return Monitor type as flake8 gets cross
#     def get_downtime(self) -> UpDownTime:
#     def get_wasdowntime(self) -> UpDownTime:
#     def get_uptime(self) -> UpDownTime:
#     def state_dict(self) -> dict:
#     def __str__(self) -> str:
#     def __init__(self, name: str, config_options: dict):
#     def run_test(self) -> bool:
#     def describe(self) -> str:
#     def get_params(self) -> Tuple:
#     def run_test(self) -> bool:
#     def get_params(self) -> Tuple:


import fnmatch
import os
import platform
import re
import subprocess
import time
import psutil
    import pydbus
from typing import Any, List, Optional, Tuple, cast
from .monitor import Monitor, register
        return self.record_success()

    def describe(self) -> str:
        """Explains what this instance is checking"""
        return "checking for service called %s in state %s" % (
            self.service_name,
            self.want_state,
        )

    def get_params(self) -> Tuple:
        return (self.host, self.service_name, self.want_state)


@register
class MonitorRC(Monitor):
    """Monitor a service handled by an rc.d script.

    This monitor checks the return code of /usr/local/etc/rc.d/<name>
    and reports failure if it's non-zero by default.
    """

    monitor_type = "rc"

    def __init__(self, name: str, config_options: dict) -> None:
        """Initialise the class.
        Change script path to /etc/rc.d/ to monitor base system services. If the
        script path ends with /, the service name is appended."""
        super().__init__(name, config_options)
        self.service_name = cast(str, self.get_config_option("service", required=True))
        self.script_path = cast(

# Path: simplemonitor/Monitors/monitor.py
# class Monitor:
# class MonitorFail(Monitor):
# class MonitorNull(Monitor):
#     def __init__(
#         self, name: str = "unnamed", config_options: Optional[dict] = None
#     ) -> None:
#     def get_config_option(
#         self,
#         key: str,
#         *,
#         default: Any = None,
#         required: bool = False,
#         required_type: str = "str",
#         allowed_values: Any = None,
#         allow_empty: bool = True,
#         minimum: Optional[Union[int, float]] = None,
#         maximum: Optional[Union[int, float]] = None,
#     ) -> Any:
#     def dependencies(self) -> List[str]:
#     def dependencies(self, dependency_list: List[str]) -> None:
#     def remaining_dependencies(self) -> List[str]:
#     def is_remote(self) -> bool:
#     def run_test(self) -> Union[NoReturn, bool]:
#     def virtual_fail_count(self) -> int:
#     def test_success(self) -> bool:
#     def first_failure(self) -> bool:
#     def state(self) -> MonitorState:
#     def get_result(self) -> str:
#     def reset_dependencies(self) -> None:
#     def dependency_succeeded(self, dependency: str) -> None:
#     def log_result(self, name: str, logger: Any) -> None:
#     def get_params(self) -> Tuple:
#     def set_mon_refs(self, mmm: Any) -> None:
#     def minimum_gap(self) -> int:
#     def minimum_gap(self, gap: int) -> None:
#     def describe(self) -> str:
#     def is_windows(allow_cygwin: bool = True) -> bool:
#     def _add_unavailable_seconds(self) -> None:
#     def record_fail(self, message: str = "") -> bool:
#     def record_success(self, message: str = "") -> bool:
#     def record_skip(self, which_dep: Optional[str]) -> bool:
#     def uptime(self) -> Optional[datetime.timedelta]:
#     def skipped(self) -> bool:
#     def get_success_count(self) -> int:
#     def all_better_now(self) -> bool:
#     def availability(self) -> float:
#     def first_failure_time(self) -> Optional[arrow.Arrow]:
#     def notify(self) -> bool:
#     def notify(self, value: bool) -> None:
#     def urgent(self) -> bool:
#     def urgent(self, value: Union[bool, int]) -> None:
#     def was_skipped(self) -> bool:
#     def should_run(self) -> bool:
#     def last_virtual_fail_count(self) -> int:
#     def attempt_recover(self) -> None:
#     def run_recovered(self) -> None:
#     def post_config_setup(self) -> None:
#     def __getstate__(self) -> dict:
#     def __setstate__(self, state: dict) -> None:
#     def _set_monitor_logger(self) -> None:
#     def to_python_dict(self) -> dict:
#     def from_python_dict(
#         cls: Any, load_dict: dict
#     ) -> "Monitor":  # can't return Monitor type as flake8 gets cross
#     def get_downtime(self) -> UpDownTime:
#     def get_wasdowntime(self) -> UpDownTime:
#     def get_uptime(self) -> UpDownTime:
#     def state_dict(self) -> dict:
#     def __str__(self) -> str:
#     def __init__(self, name: str, config_options: dict):
#     def run_test(self) -> bool:
#     def describe(self) -> str:
#     def get_params(self) -> Tuple:
#     def run_test(self) -> bool:
#     def get_params(self) -> Tuple:


# Path: simplemonitor/Monitors/service.py
import fnmatch
import os
import platform
import re
import subprocess
import time
import psutil
    import pydbus
from typing import Any, List, Optional, Tuple, cast
from .monitor import Monitor, register

        return self.record_success()

    def describe(self) -> str:
        """Explains what this instance is checking"""
        return "checking for service called %s in state %s" % (
            self.service_name,
            self.want_state,
        )

    def get_params(self) -> Tuple:
        return (self.host, self.service_name, self.want_state)


@register
class MonitorRC(Monitor):
    """Monitor a service handled by an rc.d script.

    This monitor checks the return code of /usr/local/etc/rc.d/<name>
    and reports failure if it's non-zero by default.
    """

    monitor_type = "rc"

    def __init__(self, name: str, config_options: dict) -> None:
        """Initialise the class.
        Change script path to /etc/rc.d/ to monitor base system services. If the
        script path ends with /, the service name is appended."""
        super().__init__(name, config_options)
        self.service_name = cast(str, self.get_config_option("service", required=True))
        self.script_path = cast(

            str, self.get_config_option("path", default="/usr/local/etc/rc.d/")