Created
August 19, 2020 13:54
-
-
Save DD-ScottBeamish/e7b3c9dc7859877fd6ba607ad2ca0ab7 to your computer and use it in GitHub Desktop.
Custom Action - Remote SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time,paramiko | |
| from checks import AgentCheck | |
| class remoteSSHCheck(AgentCheck): | |
| def check(self, instance): | |
| client = paramiko.SSHClient() | |
| #client.load_system_host_keys() | |
| #client.connect(instance['host']) | |
| client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
| client.connect(instance['host'],username=instance['username'],password=instance['password']) | |
| stdin, stdout, stderr = client.exec_command(instance['cmd']) | |
| self.gauge(instance['metric'], stdout.read(), tags=instance['tags'], hostname=instance['host']) | |
| client.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| init_config: | |
| instances: | |
| - host: ScottsMPBeamish | |
| cmd: ps -A -o %cpu,%mem | awk '{ cpu += $1; mem += $2} END {print cpu}' | |
| tags: ["os:osx"] | |
| metric: remote.system.cpu.system | |
| username: <username> | |
| password: <password> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment