diff --git a/iotronic_lightningrod/lightningrod.py b/iotronic_lightningrod/lightningrod.py index 13acbd0..e78854e 100644 --- a/iotronic_lightningrod/lightningrod.py +++ b/iotronic_lightningrod/lightningrod.py @@ -789,7 +789,7 @@ def wampConnect(wamp_conf): LOG.warning("WAMP Connection Failure timer: EXPIRED") lr_utils.LR_restart() - global connFailure + global connFailure # da valutare la rimozione connFailure = Timer(CONF.connection_failure_timer, timeout) connFailure.start() LOG.warning("WAMP Connection Failure timer: STARTED") diff --git a/iotronic_lightningrod/modules/service_manager.py b/iotronic_lightningrod/modules/service_manager.py index 5da5297..3b676dc 100644 --- a/iotronic_lightningrod/modules/service_manager.py +++ b/iotronic_lightningrod/modules/service_manager.py @@ -1142,8 +1142,8 @@ class ServiceManager(Module.Module): else: message = rpc_name + " result: " + s_uuid \ + " already removed!" - LOG.error(" - " + message) - w_msg = WM.WampError(msg=message, req_id=req_id) + LOG.warning(" - " + message) + w_msg = WM.WampSuccess(msg=message, req_id=req_id) except Exception as err: message = "Updating services.json error: " + str(err) diff --git a/utils/docker/arm/Dockerfile b/utils/docker/arm/Dockerfile index d1f9a39..5e4315a 100755 --- a/utils/docker/arm/Dockerfile +++ b/utils/docker/arm/Dockerfile @@ -17,7 +17,7 @@ RUN sed -i 's/# server_names_hash_bucket_size 64;/server_names_hash_bucket_size RUN rm -rf /var/lib/apt/lists/* -RUN npm install -g --unsafe @mdslab/wstun@1.0.10 && npm cache --force clean +RUN npm install -g --unsafe @mdslab/wstun@1.0.11 && npm cache --force clean RUN pip3 install iotronic-lightningrod @@ -26,6 +26,7 @@ RUN sed -i "s|80 default_server;|50000 default_server;|g" /etc/nginx/sites-avail COPY data/lr_configure /usr/local/bin/lr_configure COPY data/lr_install /usr/local/bin/lr_install +COPY data/lr_checks /usr/local/bin/lr_checks COPY data/startLR /usr/local/bin/startLR RUN /usr/local/bin/lr_install diff --git a/utils/docker/arm/data/lr_checks b/utils/docker/arm/data/lr_checks new file mode 100755 index 0000000..60e1daa --- /dev/null +++ b/utils/docker/arm/data/lr_checks @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +# lr_checks v1.0.1 + +import psutil +import subprocess + +start_checks=True + +print( + "\n###############################\n" + " Lightning-rod checks v1.0.1\n" + "###############################\n") + +""" CONNECTIONS """ +try: + res_pid = subprocess.Popen("ps aux | grep '/bin/lightning-rod' |grep -v grep| awk '{print $2}'", shell=True, stdout=subprocess.PIPE) + lr_pid = res_pid.communicate()[0].decode("utf-8").split("\n")[0] + if(lr_pid == ""): + start_checks = False + print(" - LR not running") + else: + print("\nLR PID: " + str(lr_pid)) + +except Exception as e: + print("LR pid error: " + str(e)) + start_checks = False + + +if start_checks: + + lr_socket = None + proc = psutil.Process(int(lr_pid)) + conn_list = proc.connections() + #print(str(conn_list)) + print("\nLR open connections:") + check=False + for socks in conn_list: + print(" - " + str(socks)) + #print(socks.raddr, socks.fd) + if socks.raddr != () : + if socks.raddr.port == 8181: + #print(socks.raddr.port, socks.fd) + #break; + check=True + lr_socket = [socks.raddr.port, socks.fd] + + if check: + print("\nLR WAMP socket:" + " port[" +str(lr_socket[0]) + "] - FD[" + str(lr_socket[1]) + "]") + + + """ LSOF """ + res_lsof = subprocess.Popen("lsof -i -n -P | grep '8080\|8181'| grep -v grep", shell=True, stdout=subprocess.PIPE) + sockets = res_lsof.communicate()[0].decode("utf-8").split("\n") + print("\nS4T sockets opened: ") + + for socks in sockets[:-1]: + print(" - " + str(socks)) + + + + """ PS """ + res_ps = subprocess.Popen("ps aux | grep 'wstun\|lightning' | grep -v grep", shell=True, stdout=subprocess.PIPE) + ps_s4t = res_ps.communicate()[0].decode("utf-8").split("\n") + print("\nS4T running processes: ") + + for socks in ps_s4t[:-1]: + print(" - " + str(socks)) diff --git a/utils/docker/x86_64/Dockerfile b/utils/docker/x86_64/Dockerfile index e883f77..fa839d0 100644 --- a/utils/docker/x86_64/Dockerfile +++ b/utils/docker/x86_64/Dockerfile @@ -19,7 +19,7 @@ RUN sed -i 's/# server_names_hash_bucket_size 64;/server_names_hash_bucket_size RUN rm -rf /var/lib/apt/lists/* -RUN npm install -g --unsafe @mdslab/wstun@1.0.10 && npm cache --force clean +RUN npm install -g --unsafe @mdslab/wstun@1.0.11 && npm cache --force clean RUN pip3 install iotronic-lightningrod @@ -28,6 +28,7 @@ RUN sed -i "s|80 default_server;|50000 default_server;|g" /etc/nginx/sites-avail COPY data/lr_configure /usr/local/bin/lr_configure COPY data/lr_install /usr/local/bin/lr_install +COPY data/lr_checks /usr/local/bin/lr_checks COPY data/startLR /usr/local/bin/startLR RUN /usr/local/bin/lr_install diff --git a/utils/docker/x86_64/data/lr_checks b/utils/docker/x86_64/data/lr_checks new file mode 100755 index 0000000..60e1daa --- /dev/null +++ b/utils/docker/x86_64/data/lr_checks @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +# lr_checks v1.0.1 + +import psutil +import subprocess + +start_checks=True + +print( + "\n###############################\n" + " Lightning-rod checks v1.0.1\n" + "###############################\n") + +""" CONNECTIONS """ +try: + res_pid = subprocess.Popen("ps aux | grep '/bin/lightning-rod' |grep -v grep| awk '{print $2}'", shell=True, stdout=subprocess.PIPE) + lr_pid = res_pid.communicate()[0].decode("utf-8").split("\n")[0] + if(lr_pid == ""): + start_checks = False + print(" - LR not running") + else: + print("\nLR PID: " + str(lr_pid)) + +except Exception as e: + print("LR pid error: " + str(e)) + start_checks = False + + +if start_checks: + + lr_socket = None + proc = psutil.Process(int(lr_pid)) + conn_list = proc.connections() + #print(str(conn_list)) + print("\nLR open connections:") + check=False + for socks in conn_list: + print(" - " + str(socks)) + #print(socks.raddr, socks.fd) + if socks.raddr != () : + if socks.raddr.port == 8181: + #print(socks.raddr.port, socks.fd) + #break; + check=True + lr_socket = [socks.raddr.port, socks.fd] + + if check: + print("\nLR WAMP socket:" + " port[" +str(lr_socket[0]) + "] - FD[" + str(lr_socket[1]) + "]") + + + """ LSOF """ + res_lsof = subprocess.Popen("lsof -i -n -P | grep '8080\|8181'| grep -v grep", shell=True, stdout=subprocess.PIPE) + sockets = res_lsof.communicate()[0].decode("utf-8").split("\n") + print("\nS4T sockets opened: ") + + for socks in sockets[:-1]: + print(" - " + str(socks)) + + + + """ PS """ + res_ps = subprocess.Popen("ps aux | grep 'wstun\|lightning' | grep -v grep", shell=True, stdout=subprocess.PIPE) + ps_s4t = res_ps.communicate()[0].decode("utf-8").split("\n") + print("\nS4T running processes: ") + + for socks in ps_s4t[:-1]: + print(" - " + str(socks))