special_agent.py 800 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env python3
  2. from collections.abc import Iterable, Sequence
  3. from pydantic import BaseModel
  4. from cmk.server_side_calls.v1 import HostConfig, SpecialAgentCommand, SpecialAgentConfig
  5. from cmk.server_side_calls.v1._utils import Secret
  6. class _Params(BaseModel):
  7. ldap_uri: str
  8. user: str
  9. password: Secret
  10. def _commands_function(params: _Params, host_config: HostConfig) -> Iterable[SpecialAgentCommand]:
  11. command_arguments: list[str | Secret] = [
  12. params.ldap_uri,
  13. params.user,
  14. params.password.unsafe(),
  15. ]
  16. yield SpecialAgentCommand(command_arguments=command_arguments)
  17. special_agent_edirectory_monitor = SpecialAgentConfig(
  18. name="edirectory_monitor",
  19. parameter_parser=_Params.model_validate,
  20. commands_function=_commands_function,
  21. )