Skip to content

Commit 7b707e5

Browse files
committed
Add example how to invoke "ssh" service from the command line
1 parent ebf787b commit 7b707e5

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ you an idea how to pass relevant information on the command line using JSON::
170170
# Launch "pushover" service plugin
171171
mqttwarn --plugin=pushover --options='{"title": "About", "message": "Hello world", "addrs": ["userkey", "token"], "priority": 6}'
172172

173+
# Launch "ssh" service plugin from the command line
174+
mqttwarn --plugin=ssh --config='{"host": "ssh.example.org", "port": 22, "user": "foo", "password": "bar"}' --options='{"addrs": ["command with substitution %s"], "payload": "{\"args\": \"192.168.0.1\"}"}'
175+
173176
# Launch "cloudflare_zone" service plugin from "mqttwarn-contrib", passing "--config" parameters via command line
174177
mqttwarn --plugin=mqttwarn_contrib.services.cloudflare_zone --config='{"auth-email": "foo", "auth-key": "bar"}' --options='{"addrs": ["0815", "www.example.org", ""], "message": "192.168.0.1"}'
175178

mqttwarn/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def level2number(self, level):
124124
def g(self, section, key, default=None):
125125
try:
126126
val = self.get(section, key)
127-
if val.upper() in self.specials:
127+
if isinstance(val, str) and val.upper() in self.specials:
128128
return self.specials[val.upper()]
129129
return ast.literal_eval(val)
130130
except NoOptionError:

mqttwarn/services/ssh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def plugin(srv, item):
6868
_, stdout, stderr = ssh.exec_command(command)
6969

7070
except Exception as e:
71-
srv.logging.warning("Cannot run command %s on host %s" % (command, host))
71+
srv.logging.warning("Cannot run command '%s' on host '%s'" % (command, host))
7272
srv.logging.warning("%s" % e)
7373
return False
7474

0 commit comments

Comments
 (0)