]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
added script to ping all TRB
authorMichael Traxler <M.Traxler@gsi.de>
Thu, 6 Nov 2014 16:40:50 +0000 (17:40 +0100)
committerMichael Traxler <M.Traxler@gsi.de>
Thu, 6 Nov 2014 16:40:50 +0000 (17:40 +0100)
dmon/scripts/dmon_ping.pl [new file with mode: 0755]

diff --git a/dmon/scripts/dmon_ping.pl b/dmon/scripts/dmon_ping.pl
new file mode 100755 (executable)
index 0000000..de05b39
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use POSIX qw(strftime);
+use FileHandle;
+use lib "./code";
+use lib "../tools";
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use Dmon;
+use Net::Ping;
+
+my %config = Dmon::StartUp();
+
+
+my $ping = Net::Ping->new();
+while(1) {
+  my $found = 0;
+  my $notavail = 0;
+  my $list = "";
+  my $total = scalar @{$config{TrbIP}};
+  foreach my $p (@{$config{TrbIP}}) {
+    my $r = $ping->ping($p,1);
+    $found    += $r || 0;
+    $notavail += 1-($r||0);
+    $list .= " $p" unless $r;
+    }
+
+  my $title    = "Ping";
+  my $value    = sprintf("%i / %i",$found,$total);
+  my $longtext = sprintf("Total in list: %i. Boards reacting: %i. Boards not found: %s.",$total,$found,$list);
+  my $status   = Dmon::GetQAState('above',$found,($total,$total,$total-1));
+  Dmon::WriteQALog($config{flog},"ping",30,$status,$title,$value,$longtext,"");
+  
+  sleep(15);  
+  }
\ No newline at end of file