Skip to content

Commit

Permalink
Merge pull request #9 from wirenboard/feature/41500-unix-socket
Browse files Browse the repository at this point in the history
  • Loading branch information
KraPete authored Sep 23, 2022
2 parents 28b2712 + ed0a48c commit 7c79986
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
buildDebArchAll()
buildDebSbuild defaultTargets: 'bullseye-host'
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-diag-collect (1.4.0) stable; urgency=medium

* Support connection to Mosquitto through unix socket

-- Petr Krasnoshchekov <petr.krasnoshchekov@wirenboard.ru> Tue, 20 Sep 2022 15:05:48 +0500

wb-diag-collect (1.3.0) stable; urgency=medium

* Add enum with "OK","OPERATION_ERROR","USER_INPUT_ERROR" result codes
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ X-Python3-Version: >= 3.2
Package: python3-wb-diag-collect
Section: python
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends}, python3-yaml, python3-mqttrpc, python3-paho-mqtt, python3-wb-mcu-fw-updater, emmcparm (>= 5.0.0)
Depends: ${python3:Depends}, ${misc:Depends}, python3-yaml, python3-mqttrpc, python3-paho-mqtt, python3-paho-socket, python3-wb-mcu-fw-updater, emmcparm (>= 5.0.0)
Description: python3 library for one-click diagnostic data
collector for Wiren Board

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='wb-diag-collect',
version='1.0',
version='1.4.0',
description='Diagnostic collector',
author='Sokolov Semen',
author_email='s.sokolov@wirenboard.ru',
Expand Down
3 changes: 1 addition & 2 deletions wb-diag-collect.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mqtt:
broker: '127.0.0.1'
port: 1883
broker: 'unix:///var/run/mosquitto/mosquitto.sock'

journald_logs:
lines_number: 1000
Expand Down
20 changes: 15 additions & 5 deletions wb/diag/rpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import signal
import subprocess
from contextlib import contextmanager
import urllib.parse

from mqttrpc import MQTTRPCResponseManager, dispatcher
from paho.mqtt import client as mqttclient
import paho_socket

from wb.diag import collector

Expand All @@ -20,11 +22,19 @@ def __init__(self, options, dispatcher, logger):
self.dispatcher.add_method(self.diag)
self.dispatcher.add_method(self.status)

self.client = mqttclient.Client("wb-diag-collect")
self.client.on_message = self.on_message

logger.debug("Connecting to broker %s:%s", options["broker"], options["port"])
self.client.connect(options["broker"], options["port"])
broker = options["broker"]
url = urllib.parse.urlparse(broker)
if url.scheme == 'unix':
logger.debug("Connecting to broker %s", broker)
self.client = paho_socket.Client("wb-diag-collect")
self.client.on_message = self.on_message
self.client.sock_connect(url.path)
else:
port = options["port"]
logger.debug("Connecting to broker %s:%s", broker, port)
self.client = mqttclient.Client("wb-diag-collect")
self.client.on_message = self.on_message
self.client.connect(broker, port)

self.run = True

Expand Down

0 comments on commit 7c79986

Please sign in to comment.