Skip to content
Snippets Groups Projects
Forked from 713 / Warden / Warden
361 commits behind the upstream repository.
info.pl 2.56 KiB
#!/usr/bin/perl
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.  

use strict;
use warnings;

use FindBin qw($RealBin);
FindBin::again();

#------------------------------------------------------------------------------
# Warden 2.2 Client, Info, Example
#
# Simple use of warden-client Info functionality to receive information about
# client registered to Warden server. This code illustrates how to integrate
# warden-client info functionality into local applications.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# This code should developer add into his/her application.

# Load Warden client library and use main module
use lib "$RealBin/../lib";
use WardenClient;

# obtain information about already registered clients
my @clients = WardenClient::getClientInfo() or exit 1; # receive data or exit

print "+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n";
print "| Client ID      | Hostname                             | Registered          | Requestor                   | Service                | CT | Type            | ROE | Description tags                              | IP Net Client      |\n";
print "+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n";

foreach (@clients) {
  printf("| %-14s ", $_->{'client_id'} || "unknown");
  printf("| %-36s ", $_->{'hostname'} || "unknown");
  printf("| %19s ", $_->{'registered'}  || "unknown");
  printf("| %-27s ", $_->{'requestor'} || "unknown");
  printf("| %-22s ", $_->{'service'} || "-");
  printf("| %-1s ", $_->{'client_type'}  || "unknown");
  printf("| %-16s ", $_->{'type'} || "-");
  printf("| %-1s ", $_->{'receive_own_events'}  || "-");
  printf("| %-47s ", $_->{'description_tags'} || "-");
  printf("| %-18s |\n", $_->{'ip_net_client'} || "unknown");
}
print "+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n";
print "\n";
print "Current registered clients in: " . scalar localtime(time) . "\n";

exit 0;