From 4372fe5fe9dc01a066169ec545da35b244aa6cd6 Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Thu, 9 Apr 2015 17:43:48 +0000 Subject: [PATCH] [enh] Add check STMP outgoing port --- lib/yunohost/monitor.py | 12 +++++++++++- locales/en.json | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/yunohost/monitor.py b/lib/yunohost/monitor.py index 8c8d87ee8..51f3ee16a 100644 --- a/lib/yunohost/monitor.py +++ b/lib/yunohost/monitor.py @@ -32,10 +32,13 @@ import subprocess import xmlrpclib import os.path import errno +import os import cPickle as pickle +from subprocess import Popen, PIPE from urllib import urlopen from datetime import datetime, timedelta + from moulinette.core import MoulinetteError glances_uri = 'http://127.0.0.1:61209' @@ -151,6 +154,12 @@ def monitor_network(units=None, human_readable=False): glances = _get_glances_api() result = {} + cmd_check_smtp = os.system('/bin/nc -z -w1 yunohost.org 25') + if cmd_check_smtp == 0: + smtp_check = m18n.n('network_check_smtp_ok') + else: + smtp_check = m18n.n('network_check_smtp_ko') + if units is None: units = ['usage', 'infos'] @@ -201,7 +210,8 @@ def monitor_network(units=None, human_readable=False): result[u] = { 'public_ip': p_ip, 'local_ip': l_ip, - 'gateway': gateway + 'gateway': gateway, + 'smtp_check' : smtp_check } else: raise MoulinetteError(errno.EINVAL, m18n.n('unit_unknown', u)) diff --git a/locales/en.json b/locales/en.json index eff603015..ce2cd74eb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -116,6 +116,9 @@ "service_no_log" : "No log to display for service '{:s}'", "service_cmd_exec_failed" : "Unable to execute command '{:s}'", + "network_check_smtp_ok" : "Outbound mail (SMTP port 25) is not blocked", + "network_check_smtp_ko" : "Outbound mail (SMTP port 25) seems to be blocked by your network", + "ldap_initialized" : "LDAP successfully initialized", "admin_password_change_failed" : "Unable to change password", "admin_password_changed" : "Administration password successfully changed",