Add services docu
authorHeinz Junkes <junkes@fhi-berlin.mpg.de>
Fri, 19 Jan 2018 16:05:31 +0100
changeset 10 f7c1eb1e5733
parent 9 526bf7695cbd
child 12 d0f2a667d9d5
Add services docu
FEL/index.rst
FEL/services/channelFinder.rst
FEL/services/findPVs
FEL/services/scanServer.rst
--- a/FEL/index.rst	Wed Jan 17 17:33:45 2018 +0100
+++ b/FEL/index.rst	Fri Jan 19 16:05:31 2018 +0100
@@ -14,17 +14,16 @@
    intro/features
    intro/license
 
-Using the Q-Cluster 
-=====================
+Services 
+========
 
 .. toctree::
    :maxdepth: 2
 
-   user/accounts
-   user/markups
-   user/search
-   user/namespaces
-   user/subscriptions
+   services/channelFinder
+   services/scanServer
+   services/logServer
+   services/alarmHandler
 
 Administrating Q-Cluster 
 ========================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FEL/services/channelFinder.rst	Fri Jan 19 16:05:31 2018 +0100
@@ -0,0 +1,52 @@
+=============
+Channelfinder
+=============
+
+Channel finder service
+----------------------
+
+Channelfinder run's on fel02. Fel02 is a VM running on a DELL R530 server
+(Bld. E, Groundfloor, Server room, labeld FEL0X) as part of a esx-cluster.
+It gives an overview of all PV's, IOC's used at the FEL experiment. PV'a are
+searchable. Based on a mongodb database.
+
+.. uml::
+
+   @startuml
+
+   node FEL0X <<esx host>> {
+     node fel02 {
+       [eth0] <<141.14.134.176>>
+       [eth1] <<10.0.0.16>>
+     }
+   }
+   @enduml
+
+User 'channel' in /home/channel (Password:ch...r)
+
+Source files can be found in /var/www/html/channelfinder::
+
+ channel@fel02:/var/www/html/channelfinder$ ls -l
+ total 24
+ -rw-r--r-- 1 root root 6413 Apr  2  2015 channelfinder.php
+ -rw-r--r-- 1 root root   48 Mar 29  2015 index.php
+ -rw-r--r-- 1 root root 1735 Mar 28  2015 lall
+ -rw-r--r-- 1 root root  889 Mar 29  2015 searchPV.php
+ -rw-r--r-- 1 root root 1692 Mar 30  2015 showPVs.php
+
+To collect al PVs from all known (ioc list is hardcoded in findPVs) IOCs the
+script 'findPVs' must be run. It can not be used in a cron job. If some PV's
+are not available it might hang. On all requested IOC's fel02's ssh key must be
+registered (.ssh/authorized_keys).
+
+The script reads the /srv/ioc/log/Database/$IOC.dbl file which gets written on
+IOC reboot (on load of db files).
+
+findPVs:
+
+.. include:: findPVs
+
+How to use
+----------------------
+
+Access: http://fel02.rz-berlin.mpg.de/channelfinder/channelfinder.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FEL/services/findPVs	Fri Jan 19 16:05:31 2018 +0100
@@ -0,0 +1,163 @@
+#!/usr/bin/perl
+use lib '/home/channel/EPICS/base/lib/perl/';
+use MongoDB;
+use MongoDB::Timestamp;
+
+use CA;
+
+my $hostname = "localhost";
+my $port = 27017;
+
+my $conn = MongoDB::Connection->new( "host" => "$hostname", 
+                                     "port" => $port );
+my $db = $conn->get_database( 'channelfinder' );
+my $ioc_stats = $db->get_collection( 'ioc_stats' );
+my $pv_stats = $db->get_collection( 'pv_stats' );
+
+$path="/srv/ioc/log/Database";
+
+@hosts = qw(ioc160 ioc161 ioc162 ioc163 ioc164 ioc165 ioc167 ioc168 agrajag zoot bacnet-gw resume fel03 mprot fel04);
+
+
+my $dt   = DateTime->now;   # Stores current date and time as datetime object
+my $date = $dt->ymd;   # Retrieves date as a string in 'yyyy-mm-dd' format
+my $time = $dt->hms;   # Retrieves time as a string in 'hh:mm:ss' format
+my $dtString = $date ." ".$time;
+
+%iocs = ();
+foreach $host(@hosts) {
+  open (SSH,"/usr/bin/ssh epics\@$host ls $path/* |") or die "$!\n";
+  while (<SSH>) {
+    $name = $_;
+    $name =~ s{.*/}{};
+    $name =~ s{\.[^.]+$}{};
+    $iocs{ $name } = $host;
+  }
+  close SSH;
+}
+
+  while ( my ($name, $host) = each(%iocs) ) {
+    $ioc_stats->remove({name => $name});
+    $ioc_stats->insert({name => $name, 
+			host => $host, 
+			type => 'ioc', 
+			dt => $dtString });
+  }
+$cnt = $ioc_stats->count();
+printf("Info:  $cnt iocs\n");
+
+sub readDesc ()
+{
+my ($chan, $status, $data) = @_;
+$desc = $data;
+#print "Desc in callback : $desc\n";
+}
+
+sub readVal ()
+{
+my ($chan, $status, $data) = @_;
+$val = $data;
+#print "Val in callback : $val\n";
+}
+
+sub readDisa ()
+{
+my ($chan, $status, $data) = @_;
+$disa = $data;
+#print "DISA in callback : $disa\n";
+}
+
+while ( my ($ioc, $host) = each(%iocs) ) {
+print " ............ $ioc on $host ..................\n";
+  open (SSH,"/usr/bin/ssh epics\@$host cat $path/$ioc.dbl |") or die "$!\n";
+  while (<SSH>) {
+    $pv=$_;
+    chomp($pv);
+    print "PV: $pv ... ";
+    $pv_stats->remove({name => $pv});
+
+    my $pv_desc = $pv . ".DESC";
+    my $pv_disa = $pv . ".DISA";
+
+    $pv_chan = CA->new($pv_desc);
+eval { CA->pend_io(1); };
+if ($@) {
+    if ($@ =~ m/^ECA_TIMEOUT/) {
+        print "Channel $pv_chan->name connect timed out.\n";
+    } else {
+        die $@;
+    }
+} else {
+ printf "    Host:          %s\n", $pv_chan->host_name;
+ $host = $pv_chan->host_name;
+}
+
+if($pv_chan->is_connected) {
+
+    $pv_chan->get_callback (\&readDesc,1);
+eval { CA->pend_io(2); };
+if ($@) {
+    if ($@ =~ m/^ECA_TIMEOUT/) {
+        print "Channel $pv_chan->name connect timed out.\n";
+    } else {
+        die $@;
+    }
+}
+print " DESC : $desc ... ";
+
+    $pv_chan = CA->new($pv);
+eval { CA->pend_io(2); };
+if ($@) {
+    if ($@ =~ m/^ECA_TIMEOUT/) {
+        print "Channel $pv_chan->name connect timed out.\n";
+    } else {
+        die $@;
+    }
+}
+    $pv_chan->get_callback (\&readVal,1);
+eval { CA->pend_io(2); };
+if ($@) {
+    if ($@ =~ m/^ECA_TIMEOUT/) {
+        print "Channel $pv_chan->name connect timed out.\n";
+    } else {
+        die $@;
+    }
+}
+
+print " VAL : $val ... ";
+
+    $pv_chan = CA->new($pv_disa);
+eval { CA->pend_io(2); };
+if ($@) {
+    if ($@ =~ m/^ECA_TIMEOUT/) {
+        print "Channel $pv_chan->name connect timed out.\n";
+    } else {
+        die $@;
+    }
+}
+    $pv_chan->get_callback (\&readDisa,1);
+eval { CA->pend_io(2); };
+if ($@) {
+    if ($@ =~ m/^ECA_TIMEOUT/) {
+        print "Channel $pv_chan->name connect timed out.\n";
+    } else {
+        die $@;
+    }
+}
+
+print " DISA : $disa ...\n";
+
+    $pv_stats->insert({	name => $pv, 
+			ioc => $ioc, 
+			host => $host, 
+			desc => $desc,
+                        val => $val,
+			disa => $disa,
+			type => "toBeDef", 
+			dt => $dtString });
+  }
+}
+  close SSH;
+}
+$cnt = $pv_stats->count();
+print ("Info:  $cnt PVs \n");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FEL/services/scanServer.rst	Fri Jan 19 16:05:31 2018 +0100
@@ -0,0 +1,33 @@
+==========
+ScanServer
+==========
+
+Scan server  service
+----------------------
+
+ScanServer run's on fel01. Fel01 is a VM running on a DELL R530 server
+(Bld. E, Groundfloor, Server room, labeld FEL0X) as part of a esx-cluster.
+xxxx
+
+.. uml::
+
+   @startuml
+
+   node FEL0X <<esx host>> {
+     node fel01 {
+       [eth0] <<141.14.134.111>>
+       [eth1] <<10.0.0.2>>
+     }
+   }
+   @enduml
+
+How to use
+----------------------
+
+Access (Scan Server REST Interface): http://fel01.rz-berlin.mpg.de:4810/index.html
+
+
+ScanServer console on port 4809
+PVs FHI:ScanServer:
+
+