upraveno logování a pridana metoda pro nahrani probe do konstruktoru

verze3
Michal 2026-08-29 16:14:23 +02:00
parent 72bffeebd9
commit 4c4b29259a
1 changed files with 5 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import jnet.lib.LogFile;
public class SnmpProbeManager implements AutoCloseable {
private Snmp snmp = null;
@ -55,6 +56,8 @@ public class SnmpProbeManager implements AutoCloseable {
} catch (IOException ex) {
System.getLogger(SnmpProbeManager.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
}
loadTask();
}
public void loadTask() {
@ -95,7 +98,7 @@ public class SnmpProbeManager implements AutoCloseable {
SnmpMonitorTask task = new SnmpMonitorTask(cfg.id, snmp, target, oid, identifier, listeners);
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(task, 0, cfg.interval, TimeUnit.SECONDS);
tasks.put(cfg.id, new TaskEntry(cfg, future, task));
// System.out.println("[Manager] Přidána úloha " + cfg);
LogFile.printDebug("[NodeProbe Manager] Přidána úloha " + cfg);
}
/**
@ -105,7 +108,7 @@ public class SnmpProbeManager implements AutoCloseable {
TaskEntry entry = tasks.remove(id);
if (entry != null) {
entry.future.cancel(false);
System.out.println("[Manager] Odebrána úloha ID " + id);
LogFile.printDebug("[NodeProbe Manager] Odebrána úloha ID " + id);
return true;
}
return false;