Warn if interval is short

This commit is contained in:
Jose Gracia 2024-02-07 14:06:53 +01:00
parent c7c4460196
commit 8543446b91

View file

@ -204,8 +204,23 @@ class App:
self.config = config self.config = config
self.db = MonitoringDB(self.config.verbose) self.db = MonitoringDB(self.config.verbose)
@staticmethod
def warnings(config):
warn = ""
if config.interval < 5:
warn += '# Warning: interval<5 is very small and may lead to data gaps.'
return warn
def run_all(self): def run_all(self):
header = f"# {config.datetime}: {config.cmd}\n#\n" warnings = self.warnings(self.config)
if warnings:
print(warnings)
header = f"# {config.datetime}: {config.cmd}\n"
if warnings:
header += f"{warnings}\n"
header += "#\n"
for jobid in self.config.jobid: for jobid in self.config.jobid:
try: try:
power = Power.from_db(self.db, jobid, self.config.interval) power = Power.from_db(self.db, jobid, self.config.interval)