Newer
Older
Jan Soukal
committed
#!/usr/bin/perl -w
#
# Copyright (C) 2011-2013 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
use strict;
#------------------------------------------------------------------------------
# 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.
# Path to warden-client directory
my $warden_path = '/home/soukal/pokus/warden/warden-client/';
# Inclusion of warden-client receiving functionality
require $warden_path . '/lib/WardenClientCommon.pm';
my @clients = WardenClientCommon::getClientsInfo($warden_path) or exit 1; # receive data or exit
Jan Soukal
committed
print "+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n";
print "| Client ID | Hostname | Registered | Requestor | Service | CT | Type | ROE | Description tags | IP Net Client |\n";
print "+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n";
Jan Soukal
committed
Jan Soukal
committed
foreach (@clients) {
printf("| %-10s ", $_->{'client_id'} || "NULL");
printf("| %-30s ", $_->{'hostname'} || "NULL");
printf("| %19s ", $_->{'registered'} || "NULL");
printf("| %-23s ", $_->{'requestor'} || "NULL");
printf("| %-25s ", $_->{'service'} || "NULL");
printf("| %-2s ", $_->{'client_type'} || "NULL");
printf("| %-15s ", $_->{'type'} || "NULL");
printf("| %-4s ", $_->{'receive_own_events'} || "NULL");
printf("| %-50s ", $_->{'description_tags'} || "NULL");
printf("| %-18s |\n", $_->{'ip_net_client'} || "NULL");
Jan Soukal
committed
}
print "+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n";
print "\n";
print "Current registered clients in: " . scalar localtime(time) . "\n";
exit 0;