diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b68880..2d57d18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.0] - 2025-04-10 + +### Added + +- Operating system: periodically ping ogcore + ## [3.1.0] - 2025-04-07 ### Added diff --git a/src/opengnsys/modules/server/OpenGnSys/__init__.py b/src/opengnsys/modules/server/OpenGnSys/__init__.py index 259544a..ade870f 100644 --- a/src/opengnsys/modules/server/OpenGnSys/__init__.py +++ b/src/opengnsys/modules/server/OpenGnSys/__init__.py @@ -30,7 +30,6 @@ @author: Ramón M. Gómez, ramongomez at us dot es """ - import base64 import os import random @@ -102,6 +101,20 @@ class OpenGnSysWorker(ServerWorker): exec_level = None # Execution level (permitted operations) jobmgr = JobMgr() + ## pings ogcore + def mon (self): + n = 0 + while True: + time.sleep (1) + n += 1 + if not n % 10: + body = { + "iph": self.interface.ip, + "timestamp": int (time.time()), + } + logger.debug (f'about to send ping ({body})') + self.REST.sendMessage ('clients/status/webhook', body) + def onActivation(self): """ Sends OGAgent activation notification to OpenGnsys server @@ -189,6 +202,8 @@ class OpenGnSysWorker(ServerWorker): if os.path.isfile(new_hosts_file): shutil.copyfile(new_hosts_file, hosts_file) + threading.Thread (name='monitoring_thread', target=self.mon, daemon=True).start() + logger.debug ('onActivation ok') def onDeactivation(self): diff --git a/src/opengnsys/workers/oglive_worker.py b/src/opengnsys/workers/oglive_worker.py index 6586bc7..0347dad 100644 --- a/src/opengnsys/workers/oglive_worker.py +++ b/src/opengnsys/workers/oglive_worker.py @@ -241,12 +241,8 @@ class ogLiveWorker(ServerWorker): n += 1 if not n % 10: body = { - "iph": self.IPlocal, - "ido": self.idordenador, - "npc": self.nombreordenador, - "idc": self.idcentro, - "ida": self.idaula, - "timestamp": int (time.time()), + 'iph': self.IPlocal, + 'timestamp': int (time.time()), } logger.debug (f'about to send ping ({body})') self.REST.sendMessage ('clients/status/webhook', body)