refs #1853 ping ogcore from the OS as well

ping3
Natalia Serrano 2025-04-10 11:31:47 +02:00
parent 0e113ecd49
commit 16554e5d93
3 changed files with 24 additions and 7 deletions

View File

@ -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

View File

@ -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):

View File

@ -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)