From c417c12436e7fc40df04bce25e1e3c5260ae8284 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Fri, 21 Aug 2015 20:03:51 +0530
Subject: [PATCH] xmpp: Implement diagnostics
- Mostly moved from freedombox-setup.
---
actions/xmpp | 2 +-
plinth/modules/xmpp/__init__.py | 16 ++++++++++++++++
plinth/modules/xmpp/templates/xmpp.html | 5 +++--
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/actions/xmpp b/actions/xmpp
index ab9e0b286..06e5af08e 100755
--- a/actions/xmpp
+++ b/actions/xmpp
@@ -22,10 +22,10 @@ Configuration helper for the ejabberd service
"""
import argparse
-import subprocess
import os
import shutil
import socket
+import subprocess
import re
import yaml
diff --git a/plinth/modules/xmpp/__init__.py b/plinth/modules/xmpp/__init__.py
index 4ce2e2988..aa0a14f07 100644
--- a/plinth/modules/xmpp/__init__.py
+++ b/plinth/modules/xmpp/__init__.py
@@ -20,6 +20,7 @@ Plinth module to configure XMPP server
"""
from gettext import gettext as _
+import json
from plinth import actions
from plinth import action_utils
@@ -101,3 +102,18 @@ def on_domainname_change(sender, old_domainname, new_domainname, **kwargs):
['change-domainname',
'--domainname', new_domainname],
async=True)
+
+
+def diagnose():
+ """Run diagnostics and return the results."""
+ results = []
+
+ results.append(action_utils.diagnose_port_listening(5222, 'tcp4'))
+ results.append(action_utils.diagnose_port_listening(5222, 'tcp6'))
+ results.append(action_utils.diagnose_port_listening(5269, 'tcp4'))
+ results.append(action_utils.diagnose_port_listening(5269, 'tcp6'))
+ results.append(action_utils.diagnose_port_listening(5280, 'tcp4'))
+ results.append(action_utils.diagnose_port_listening(5280, 'tcp6'))
+ results.extend(action_utils.diagnose_url_on_all('http://{host}/jwchat'))
+
+ return results
diff --git a/plinth/modules/xmpp/templates/xmpp.html b/plinth/modules/xmpp/templates/xmpp.html
index 112236b0f..999b11dfa 100644
--- a/plinth/modules/xmpp/templates/xmpp.html
+++ b/plinth/modules/xmpp/templates/xmpp.html
@@ -31,18 +31,19 @@
any other
XMPP client .
- Launch web
+ Launch web
client
Status
-
+
{% if status.is_running %}
ejabberd is running
{% else %}
ejabberd is not running
{% endif %}
+{% include "diagnostics_button.html" with module="xmpp" %}
Configuration