Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use of socket.fqdn to implement simple status publishing

  • Loading branch information...
commit 2489052c71f2980bf4f5194bc1fe16bbeaddf9af 1 parent cb0b1d9
Kyle Gordon authored

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. +3 2 mqtt-republisher.py
5 mqtt-republisher.py
@@ -9,6 +9,7 @@
9 9 import logging
10 10 import signal
11 11 import time
  12 +import socket
12 13
13 14 import mosquitto
14 15
@@ -37,7 +38,7 @@ def cleanup(signum, frame):
37 38 in the event of a SIGTERM or SIGINT.
38 39 """
39 40 logging.info("Disconnecting from broker")
40   - mqttc.publish("/status" + socket.fqdn(), "Offline")
  41 + mqttc.publish("/status/" + socket.getfqdn, "Offline")
41 42 mqttc.disconnect()
42 43 logging.info("Exiting on signal %d", signum)
43 44
@@ -57,7 +58,7 @@ def on_connect(result_code):
57 58 ## FIXME - needs fleshing out http://mosquitto.org/documentation/python/
58 59 if result_code == 0:
59 60 logging.info("Connected to broker")
60   - mqttc.publish("/status" + socket.fqdn(), "Online")
  61 + mqttc.publish("/status/" + socket.getfqdn, "Online")
61 62 else:
62 63 logging.warning("Something went wrong")
63 64 cleanup()

0 comments on commit 2489052

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