[vlma-devel] commit: Notify when CPU load and other metrics are higher than a defined threshold . (Adrien Grand )

git version control git at videolan.org
Wed Oct 1 23:18:21 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed Oct  1 23:17:35 2008 +0200| [581e7d02ff66915bd28d4d87c8e45e849fcad73e] | committer: Adrien Grand 

Notify when CPU load and other metrics are higher than a defined threshold.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=581e7d02ff66915bd28d4d87c8e45e849fcad73e
---

 .../java/org/videolan/vlma/VLMaServiceImpl.java    |   13 ++++++++++++-
 vlma-daemon/src/main/resources/config.properties   |    3 +++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java b/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
index 16eaa78..25a5f7c 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/VLMaServiceImpl.java
@@ -201,7 +201,18 @@ public class VLMaServiceImpl implements VLMaService {
                 if(Data.TRAFFIC_IN.equals(data) || Data.TRAFFIC_OUT.equals(data)) {
                     sample.setValue(data.name().toLowerCase(), Long.parseLong(value.trim()));
                 } else {
-                    sample.setValue(data.name().toLowerCase(), Double.parseDouble(value.trim()));
+                    double maxCpuLoad = configuration.getDouble("vlma.notification.cpu_load.threshold");
+                    double maxVlcCpu = configuration.getDouble("vlma.notification.vlc_cpu.threshold");
+                    double maxVlcMem = configuration.getDouble("vlma.notification.vlc_mem.threshold");
+                    double doubleValue = Double.parseDouble(value.trim());
+                    if(Data.CPU_LOAD.equals(data) && doubleValue >= maxCpuLoad) {
+                        sendNotification("Warning: CPU load of " + server.getName() + " is " + doubleValue);
+                    } else if(Data.VLC_CPU.equals(data) && doubleValue >= maxVlcCpu) {
+                        sendNotification("Warning: CPU usage of VLC is " + doubleValue + "% on " + server.getName());
+                    } else if(Data.VLC_MEM.equals(data) && doubleValue >= maxVlcMem) {
+                        sendNotification("Warning: Memory usage of VLC is " + doubleValue + "% on " + server.getName());
+                    }
+                    sample.setValue(data.name().toLowerCase(), doubleValue);
                 }
             } catch (Exception e) {
                 if (e instanceof NumberFormatException)
diff --git a/vlma-daemon/src/main/resources/config.properties b/vlma-daemon/src/main/resources/config.properties
index 6e57718..8cb33a6 100644
--- a/vlma-daemon/src/main/resources/config.properties
+++ b/vlma-daemon/src/main/resources/config.properties
@@ -31,6 +31,9 @@ vlma.notification.mail.host = localhost
 vlma.notification.mail.sender = VideoLAN Manager <root at localhost>
 vlma.notification.msn.login =
 vlma.notification.msn.pass =
+vlma.notification.cpu_load.threshold = 5.0
+vlma.notification.vlc_cpu.threshold = 80.0
+vlma.notification.vlc_mem.threshold = 80.0
 vlma.streaming.http.port = 8001
 vlma.streaming = UDP_MULTICAST
 vlma.streaming.udp.ipbank.min = 239.255.0.1



More information about the vlma-devel mailing list