From 72b9d9556503dc5caeab55534fa06c62a72ad06a Mon Sep 17 00:00:00 2001
From: Tomas Plesnik <plesnik@ics.muni.cz>
Date: Fri, 20 Mar 2015 10:55:22 +0100
Subject: [PATCH] rozdeleno tisknuti pouze validnich a vsech klientu

---
 src/warden-server/bin/getClients.pl | 17 ++++++++++++-----
 src/warden-server/doc/README        |  5 +++--
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/warden-server/bin/getClients.pl b/src/warden-server/bin/getClients.pl
index 1649ed2..96f9e40 100755
--- a/src/warden-server/bin/getClients.pl
+++ b/src/warden-server/bin/getClients.pl
@@ -35,13 +35,14 @@ WardenCommon::loadConf($conf_file);
 #				FUNCTIONS
 ################################################################################
 sub usage {
-  print "Usage: $RealScript (without parameters) [-h -V]\n";
+  print "Usage: $RealScript [-a -h -V]\n";
   exit 1;
 }
 
 
 sub help {
-  print "$RealScript (without parameters) [-h -V]\n";
+  print "$RealScript [-a -h -V]\n";
+  print "-a     print all clients (invalid clients included)\n";
   print "-h     print this text and exit\n";
   print "-V     print version and exit\n";
   exit 0;
@@ -57,9 +58,10 @@ sub version {
 ################################################################################
 #                               MAIN
 ################################################################################
-our ($opt_h, $opt_V);
+our ($opt_a, $opt_h, $opt_V);
 
-die usage unless getopts("hV");
+die usage unless getopts("ahV");
+my $all			= $opt_a;
 my $help		= $opt_h;
 my $script_version	= $opt_V;
 
@@ -77,7 +79,12 @@ if ($script_version) {
 my $dbh = WardenCommon::connectDB;
 
 # obtain data from DB
-my $sth = $dbh->prepare("SELECT * FROM clients ORDER BY client_id ASC;") or die "Cannot prepare statement: " . $dbh->errstr;
+my $sth;
+if ($all) {
+  $sth = $dbh->prepare("SELECT * FROM clients ORDER BY client_id ASC;") or die "Cannot prepare statement: " . $dbh->errstr;
+} else {
+  $sth = $dbh->prepare("SELECT * FROM clients WHERE valid='t' ORDER BY client_id ASC;") or die "Cannot prepare statement: " . $dbh->errstr;
+}
 $sth->execute or die "Cannot execute statement: " . $sth->errstr;
 my $hash_ref = $sth->fetchall_hashref("client_id");
 
diff --git a/src/warden-server/doc/README b/src/warden-server/doc/README
index 8077c15..1c2d6cd 100644
--- a/src/warden-server/doc/README
+++ b/src/warden-server/doc/README
@@ -368,8 +368,9 @@ H. Status Info
 
   2. Get Clients
 
-     Function getClients is accessible via getClients.pl. Function has no input
-     parameters and returns detailed information about all registered clients.
+     Function getClients is accessible via getClients.pl. Function returns detailed
+     information about valid or all (-a) registered clients. Parameter -a returns
+     valid and invalid clients together.
 
 --------------------------------------------------------------------------------
 I. Warden Watchdog
-- 
GitLab