Merge branch 'master' of srvgitgnv:/gitstore/g_tr65/debian6500
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Tue, 24 Feb 2015 09:46:48 +0000 (10:46 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Tue, 24 Feb 2015 09:46:48 +0000 (10:46 +0100)
master/root/bin/conf_swm_integration.tcl
master/root/bin/cpumon_light [new file with mode: 0755]
master/root/bin/cpumon_lite [deleted file]

index a2e3a68bec2279f4003ba1b888fbe4808fd91362..0afda89da12db44cd489b906d04ca81b227ca431 100755 (executable)
@@ -31,7 +31,7 @@ expect -exact "#" { send "no shutdown\r" }
 expect -exact "#" { send "exit\r" }
 
 expect -exact "#" { send "ip route 192.168.$sub.0 255.255.255.0 Vlan192\r" }
-expect -exact "#" { send "ip route 192.168.$sub.160 255.255.255.255 Vlan1\r" }
+expect -exact "#" { send "ip route 192.168.$sub.160 255.255.255.255 10.133.28.160\r" }
 expect -exact "#" { send "ip route 192.168.$sub.101 255.255.255.255 Vlan10\r" }
 expect -exact "#" { send "ip route 192.168.0.0 255.255.255.0 192.168.$sub.230\r" }
 expect -exact "#" { send "exit\r" }
diff --git a/master/root/bin/cpumon_light b/master/root/bin/cpumon_light
new file mode 100755 (executable)
index 0000000..af635c1
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+use strict;
+
+my @cpu_stat_t0 = proc_stat();
+sleep 1;
+my @cpu_stat_t1 = proc_stat();
+my $total = 0;
+for (my $cpu_i = 0; $cpu_i < (scalar @cpu_stat_t0); $cpu_i++) {
+    my @stat_t0 = split /\s+/, $cpu_stat_t0[$cpu_i];
+    my @stat_t1 = split /\s+/, $cpu_stat_t1[$cpu_i];
+    my ($t0_idle, $t1_idle) = ($stat_t0[3], $stat_t1[3]);
+    my ($t0_total, $t1_total) = (0, 0);
+    $t0_total += $_ foreach @stat_t0;
+    $t1_total += $_ foreach @stat_t1;
+
+    my $load = ($t1_total - $t0_total == 0) ? 100:
+        int((100 * (($t1_total - $t0_total) - ($t1_idle - $t0_idle))/($t1_total - $t0_total)) + 0.5);
+    print " +" unless ($cpu_i == 0);
+    printf "% 5.1f%% ", $load;
+    $total += $load;
+}
+printf " = % 6.1f%%\n", $total;
+
+sub proc_stat() {
+    return grep {s/^cpu\d+\s//} read_file('/proc/stat');
+}
+
+sub read_file($) {
+    my ($file) = @_;
+    open FILE, "<$file";
+    my @content = <FILE>;
+    close FILE;
+    return @content;
+}
+
diff --git a/master/root/bin/cpumon_lite b/master/root/bin/cpumon_lite
deleted file mode 100755 (executable)
index e450952..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-INSTALL_DIR=$(dirname $0)
-
-$INSTALL_DIR/monitor_proc -s /proc/stat
-while true; do
-       sleep 1
-       $INSTALL_DIR/monitor_proc /proc/stat | \
-               awk '
-BEGIN { printf "cpu:" }
-/cpu[0-9]/ {
-       idle=$5
-       sum=0; for (i=2;i<=NF;i++) sum+=$(i)
-       load=(sum-idle)*100/sum
-       tot+=load
-       if (!not_first) not_first=1; else printf " +"
-       printf " % 5.1f%%", load
-}
-END { printf " = % 6.1f%%\n", tot }'
-done