Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use of socket.fqdn to implement simple status publishing

  • Loading branch information...
commit 2489052c71f2980bf4f5194bc1fe16bbeaddf9af 1 parent cb0b1d9
@kylegordon authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 mqtt-republisher.py
View
5 mqtt-republisher.py
@@ -9,6 +9,7 @@
import logging
import signal
import time
+import socket
import mosquitto
@@ -37,7 +38,7 @@ def cleanup(signum, frame):
in the event of a SIGTERM or SIGINT.
"""
logging.info("Disconnecting from broker")
- mqttc.publish("/status" + socket.fqdn(), "Offline")
+ mqttc.publish("/status/" + socket.getfqdn, "Offline")
mqttc.disconnect()
logging.info("Exiting on signal %d", signum)
@@ -57,7 +58,7 @@ def on_connect(result_code):
## FIXME - needs fleshing out http://mosquitto.org/documentation/python/
if result_code == 0:
logging.info("Connected to broker")
- mqttc.publish("/status" + socket.fqdn(), "Online")
+ mqttc.publish("/status/" + socket.getfqdn, "Online")
else:
logging.warning("Something went wrong")
cleanup()

0 comments on commit 2489052

Please sign in to comment.
Something went wrong with that request. Please try again.