LP#1711194 osrf_config --diagnostic reports max-children
authorBill Erickson <berickxx@gmail.com>
Wed, 16 Aug 2017 18:10:13 +0000 (14:10 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 18 Aug 2017 16:34:18 +0000 (12:34 -0400)
--diagnostic output shows the maximum number of allowed drones per
service along with the active drone count.  Additionally, a usage
percentage value is displayed.

E.g.

$ /openils/bin/osrf_control -l --diagnostic

* open-ils.acq   [1581] uptime=00:35 cputime=00:00:00 #drones=1/15 6%
* open-ils.actor [1629] uptime=00:35 cputime=00:00:00 #drones=2/15 13%

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

bin/opensrf-perl.pl.in

index e1c7efc..021f00e 100755 (executable)
@@ -65,6 +65,7 @@ my $opt_ignore_orphans = 0;
 my $sclient;
 my @perl_services;
 my @nonperl_services;
+my %max_children_map;
 my $hostname = $ENV{OSRF_HOSTNAME} || hostfqdn();
 
 GetOptions(
@@ -264,7 +265,10 @@ sub do_diagnostic {
                 msg($str);
             } else {
                 my @drones = `pgrep -f "Drone \\[$svc\\]"`;
-                $str .= "#drones=".scalar(@drones);
+                my $dcount = scalar(@drones);
+                my $dmax = $max_children_map{$svc};
+                $str .= "#drones=$dcount/$dmax ";
+                $str .= sprintf('%3d%%', (int(($dcount / $dmax) * 100)));
                 msg($str);
                 msg("\tERR $svc has no running drones.") unless @drones;
             }
@@ -332,6 +336,10 @@ sub do_init {
                 next;
             }
             my $lang = $sclient->config_value('apps', $app, 'language') || '';
+
+            $max_children_map{$app} = $sclient->config_value(
+                'apps', $app, 'unix_config', 'max_children');
+
             if ($lang =~ /perl/i) {
                 push(@perl_services, $app);
             } else {