Skip to content
Snippets Groups Projects
Commit 510098a2 authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

Zacisteni kodu serveru portovaneho na Apache; doplneni komentaru a hlavicek...

Zacisteni kodu serveru portovaneho na Apache; doplneni komentaru a hlavicek funkci; oprava drobnych chyb; presun autoru do separatniho souboru AUTHORS
parent 971c6a6e
Branches
Tags
No related merge requests found
Showing
with 354 additions and 978 deletions
...@@ -3,39 +3,14 @@ ...@@ -3,39 +3,14 @@
# getClients.pl # getClients.pl
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use File::Basename; use File::Basename;
our $VERSION = "0.1"; our $VERSION = "2.0";
my $warden_path = '/opt/warden-server'; my $warden_path = '/opt/warden-server';
require $warden_path . '/lib/WardenStatus.pm'; require $warden_path . '/lib/WardenStatus.pm';
......
...@@ -3,39 +3,14 @@ ...@@ -3,39 +3,14 @@
# getStatus.pl # getStatus.pl
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use File::Basename; use File::Basename;
our $VERSION = "0.1"; our $VERSION = "2.0";
my $warden_path = '/opt/warden-server'; my $warden_path = '/opt/warden-server';
require $warden_path . '/lib/WardenStatus.pm'; require $warden_path . '/lib/WardenStatus.pm';
...@@ -102,29 +77,27 @@ my @server_status = @$server_status_ref; ...@@ -102,29 +77,27 @@ my @server_status = @$server_status_ref;
print "Warden server variables:\n"; print "Warden server variables:\n";
print "========================\n"; print "========================\n";
print "SERVER_VERSION:\t\t$server_status[0]\n"; print "SERVER_VERSION:\t\t$server_status[0]\n";
#print "ADDRESS:\t\t$server_status[1]\n"; print "HOSTNAME:\t\t$server_status[1]\n";
#print "PORT:\t\t\t$server_status[2]\n"; print "IP_ADDRESS:\t\t$server_status[2]\n";
#print "LOGDIR:\t\t\t$server_status[3]\n"; print "PORT:\t\t\t$server_status[3]\n";
#print "PIDDIR:\t\t\t$server_status[4]\n"; print "DB_NAME:\t\t$server_status[4]\n";
#print "VARDIR:\t\t\t$server_status[5]\n"; print "DB_USER:\t\t$server_status[5]\n";
#print "SSL_KEY_FILE:\t\t$server_status[6]\n"; print "DB_HOST:\t\t$server_status[6]\n";
#print "SSL_CERT_FILE:\t\t$server_status[7]\n"; print "SYSLOG_FACILITY:\t$server_status[7]\n";
#print "SSLCA_FILE:\t\t$server_status[8]\n";
print "SYSLOG_FACILITY:\t$server_status[9]\n";
print "\n"; print "\n";
print "Warden server status:\n"; print "Warden server status:\n";
print "=====================\n"; print "=====================\n";
print "Database size:\t\t\t$server_status[10]\n"; print "Database size:\t\t\t$server_status[8]\n";
print "Count of saved events:\t\t$server_status[11]\n"; print "Count of saved events:\t\t$server_status[9]\n";
print "Last ID in events table:\t$server_status[12]\n"; print "Last ID in events table:\t$server_status[10]\n";
print "Time of first inserted event:\t$server_status[13] (UTC)\n"; print "Time of first inserted event:\t$server_status[11] (UTC)\n";
print "Time of latest inserted event:\t$server_status[14] (UTC)\n"; print "Time of latest inserted event:\t$server_status[12] (UTC)\n";
print "Count of registered clients:\t$server_status[15]\n"; print "Count of registered clients:\t$server_status[13]\n";
print "\n"; print "\n";
# check if sum of registered client isn't 0 # check if sum of registered client isn't 0
if ($server_status[15] != 0) { if ($server_status[13] != 0) {
print "Statistics of registered senders:\n"; print "Statistics of registered senders:\n";
print "+-----------------------------------------------------------------------------------------------------------+\n"; print "+-----------------------------------------------------------------------------------------------------------+\n";
print "| Client ID | Hostname | Service | Stored events | Last insertion (UTC) |\n"; print "| Client ID | Hostname | Service | Stored events | Last insertion (UTC) |\n";
......
...@@ -5,10 +5,24 @@ DB_USER=`cat /opt/warden-server/etc/warden-server.conf | grep DB_USER | sed 's/[ ...@@ -5,10 +5,24 @@ DB_USER=`cat /opt/warden-server/etc/warden-server.conf | grep DB_USER | sed 's/[
DB_PASS=`cat /opt/warden-server/etc/warden-server.conf | grep DB_PASS | sed 's/[";]//g' |awk '{print $3}'` DB_PASS=`cat /opt/warden-server/etc/warden-server.conf | grep DB_PASS | sed 's/[";]//g' |awk '{print $3}'`
DB_HOST=`cat /opt/warden-server/etc/warden-server.conf | grep DB_HOST | sed 's/[";]//g' |awk '{print $3}'` DB_HOST=`cat /opt/warden-server/etc/warden-server.conf | grep DB_HOST | sed 's/[";]//g' |awk '{print $3}'`
echo "SELECT FROM_UNIXTIME( UNIX_TIMESTAMP( received ) - ( UNIX_TIMESTAMP( received ) % ( 60 ) ) ) AS t, COUNT( id ) FROM events GROUP BY t" | mysql -h $DB_HOST -u $DB_USER $DB_NAME echo "DB_NAME: $DB_NAME"
echo "DB_USER: $DB_USER"
echo "DB_PASS: $DB_PASS"
echo "DB_HOST: $DB_HOST"
echo
echo "DB status:"
echo "----------"
echo "SELECT FROM_UNIXTIME( UNIX_TIMESTAMP( received ) - ( UNIX_TIMESTAMP( received ) % ( 60 ) ) ) AS t, COUNT( id ) FROM events GROUP BY t" | mysql -h $DB_HOST --user=$DB_USER $DB_NAME --password='w4rd3n&r00t'
echo
echo "apache2ctl status:"
echo "------------------"
apache2ctl status apache2ctl status
echo -n "" echo
echo "uptime:"
echo "-------"
uptime uptime
echo -n klientu: ; netstat -nlpa | grep :443 | grep ESTA |wc -l; echo
#echo -n klientu: ; netstat -nlpa | grep :443 | grep ESTA | wc -l;
echo -n FIN:; netstat | grep WAIT2 | wc -l echo -n FIN:; netstat | grep WAIT2 | wc -l
...@@ -3,40 +3,15 @@ ...@@ -3,40 +3,15 @@
# registerReceiver.pl # registerReceiver.pl
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use Switch; use Switch;
use File::Basename; use File::Basename;
our $VERSION = "0.1"; our $VERSION = "2.0";
my $warden_path = '/opt/warden-server'; my $warden_path = '/opt/warden-server';
require $warden_path . '/lib/WardenReg.pm'; require $warden_path . '/lib/WardenReg.pm';
......
...@@ -3,40 +3,15 @@ ...@@ -3,40 +3,15 @@
# registerSender.pl # registerSender.pl
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use Switch; use Switch;
use File::Basename; use File::Basename;
our $VERSION = "0.1"; our $VERSION = "2.0";
my $warden_path = '/opt/warden-server'; my $warden_path = '/opt/warden-server';
require $warden_path . '/lib/WardenReg.pm'; require $warden_path . '/lib/WardenReg.pm';
......
...@@ -3,40 +3,15 @@ ...@@ -3,40 +3,15 @@
# unregisterClient.pl # unregisterClient.pl
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use Switch; use Switch;
use File::Basename; use File::Basename;
our $VERSION = "0.1"; our $VERSION = "2.0";
my $warden_path = '/opt/warden-server'; my $warden_path = '/opt/warden-server';
require $warden_path . '/lib/WardenReg.pm'; require $warden_path . '/lib/WardenReg.pm';
......
AUTHORS AND MAINTAINERS :
MAIN DEVELOPERS:
Tomas Plesnik <plesnik@ics.muni.cz>
Jan Soukal <soukal@ics.muni.cz>
Michal Kostenec <kostenec@civ.zcu.cz>
CONTRIBUTORS:
Vit Slama <slama@cis.vutbr.cz>
Martin Drasar <drasar@ics.muni.cz>
TESTING:
Jakub Cegan <cegan@ics.muni.cz>
DEVELOPMENT MANAGER:
Jan Vykopal <vykopal@ics.muni.cz>
PROJECT MANAGERS:
Pavel Kacha <ph@cesnet.cz>
Andrea Kropacova <andrea@cesnet.cz>
COMMUNITY:
Radoslav Bodo <bodik@civ.zcu.cz>
Radomir Orkac <orkac@cesnet.cz>
...@@ -10,7 +10,6 @@ Content ...@@ -10,7 +10,6 @@ Content
D. Miscellaneous D. Miscellaneous
E. Registration of Clients E. Registration of Clients
F. Status Info F. Status Info
G. Authors
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
A. Overall Information A. Overall Information
...@@ -319,12 +318,5 @@ F. Status Info ...@@ -319,12 +318,5 @@ F. Status Info
parameters and returns detailed information about all registered clients. parameters and returns detailed information about all registered clients.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
G. Authors
Development: Tomas PLESNIK <plesnik@ics.muni.cz>
Jan SOUKAL <soukal@ics.muni.cz>
Copyright (C) 2011-2012 Cesnet z.s.p.o Copyright (C) 2011-2012 Cesnet z.s.p.o
Special thanks go to Martin Drasar from CSIRT-MU for his help and support
in the development of Warden system.
warden-server-0.1.0 warden-server-2.0.0
#DumpIOInput On #
#DumpIOOutput On # warden-apache.conf - configuration file for the Apache server
#DumpIOLogLevel warn #
SSLEngine on SSLEngine on
...@@ -10,13 +10,9 @@ ...@@ -10,13 +10,9 @@
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile server-cert.pem SSLCertificateFile /etc/ssl/certs/warden-dev.cesnet.cz.pem
SSLCertificateKeyFile server-key.pem SSLCertificateKeyFile /opt/warden-client/etc/warden-dev.cesnet.cz.key
SSLCACertificateFile ca-cert.pem SSLCACertificateFile /etc/ssl/certs/tcs-ca-bundle.pem
#Mozno umistit jeste pred samotny <VirtualHost>
#http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_
#Create a new parent Perl interpreter for the given VirtualHost and give it its own interpreter pool
PerlOptions +Parent PerlOptions +Parent
PerlSwitches -I/opt/warden-server/lib PerlSwitches -I/opt/warden-server/lib
...@@ -26,4 +22,3 @@ ...@@ -26,4 +22,3 @@
PerlHandler Warden::ApacheDispatch PerlHandler Warden::ApacheDispatch
SSLOptions +StdEnvVars SSLOptions +StdEnvVars
</Location> </Location>
...@@ -2,52 +2,33 @@ ...@@ -2,52 +2,33 @@
# warden-server.conf - configuration file for Warden server # warden-server.conf - configuration file for Warden server
# #
#-------------------------------------------------------------------------------
# ADDRESS - IP address of warden server
#-------------------------------------------------------------------------------
$ADDRESS = "warden-dev.cesnet.cz";
#-------------------------------------------------------------------------------
# PORT - used TCP port for Warden server
#-------------------------------------------------------------------------------
$PORT = "443";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# BASEDIR - base directory of Warden server # BASEDIR - base directory of Warden server
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$BASEDIR = "/opt/warden-server"; $BASEDIR = "/opt/warden-server";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# VARDIR - var directory # FACILITY - syslog facility
#-------------------------------------------------------------------------------
$VARDIR = "$BASEDIR/var/";
#-------------------------------------------------------------------------------
# LOGDIR - logging directory
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$LOGDIR = "/var/log/"; $FACILITY = "local7";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# PIDDIR - process ID directory # DB_NAME - database name of Warden server
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$PIDDIR = "/var/run/"; $DB_NAME = "warden";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# SSL_KEY_FILE - path to server SSL certificate key file # DB_USER - user of Warden server database
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$SSL_KEY_FILE = "/etc/ssl/private/warden-dev.cesnet.cz.key"; $DB_USER = "root";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# SSL_CERT_FILE - path to server SSL certificate file # DB_PASS - password of Warden server database
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$SSL_CERT_FILE = "/etc/ssl/certs/warden-dev.cesnet.cz.pem"; $DB_PASS = "w4rd3n&r00t";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# SSL_CA_FILE - path to CA ceritificate file # DB_HOST - what IP address to listen on of Warden server
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
$SSL_CA_FILE = "/etc/ssl/certs/tcs-ca-bundle.pem"; $DB_HOST = "localhost";
#-------------------------------------------------------------------------------
# FACILITY - syslog facility
#-------------------------------------------------------------------------------
$FACILITY = "local7";
This diff is collapsed.
#!/usr/bin/perl -w
#
# ApacheDispatch.pm
#
# Copyright (C) 2011-2012 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
package Warden::ApacheDispatch; package Warden::ApacheDispatch;
use strict;
use SOAP::Transport::HTTP; use SOAP::Transport::HTTP;
our $VERSION = "2.0";
# set server dispatch_to
my $server = SOAP::Transport::HTTP::Apache->dispatch_to('.','Warden'); my $server = SOAP::Transport::HTTP::Apache->dispatch_to('.','Warden');
#-------------------------------------------------------------------------------
# handler - call handler for Warden server
#-------------------------------------------------------------------------------
sub handler { sub handler {
$server->handler(@_) $server->handler(@_)
} }
1; 1;
...@@ -3,40 +3,14 @@ ...@@ -3,40 +3,14 @@
# WardenConf.pm # WardenConf.pm
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
# #
# Use of this source is governed by a BSD-style license, see LICENSE file.
package WardenConf; package WardenConf;
use strict; use strict;
our $VERSION = "0.1"; our $VERSION = "2.0";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# loadConf - load variables from configuration file # loadConf - load variables from configuration file
......
...@@ -3,43 +3,17 @@ ...@@ -3,43 +3,17 @@
# WardenReg.pm # WardenReg.pm
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
package WardenReg; package WardenReg;
use strict; use strict;
use SOAP::Lite; use SOAP::Lite;
use IO::Socket::SSL qw(debug1); use IO::Socket::SSL qw(debug1);
#use SOAP::Transport::TCP;
use SOAP::Transport::HTTP; use SOAP::Transport::HTTP;
our $VERSION = "0.1"; our $VERSION = "2.0";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -55,47 +29,6 @@ sub errMsg ...@@ -55,47 +29,6 @@ sub errMsg
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# c2s - connect to server, send request and receive response # c2s - connect to server, send request and receive response
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#sub c2s
#{
# my $uri = shift;
# my $ssl_key_file = shift;
# my $ssl_cert_file = shift;
# my $ssl_ca_file = shift;
# my $method = shift;
# my $data = shift;
#
# my $client;
# my ($server, $port, $service) = $uri =~ /https:\/\/(.+)\:(\d+)\/(.+)/;
# if (!($client = SOAP::Transport::TCP::Client->new(
# PeerAddr => $server,
# PeerPort => $port,
# Proto => 'tcp',
# SSL_use_cert => 1,
# SSL_verify_mode => 0x02,
# SSL_key_file => $ssl_key_file,
# SSL_cert_file => $ssl_cert_file,
# SSL_ca_file => $ssl_ca_file,
# ))) {errMsg("Sorry, unable to create socket: " . &SOAP::Transport::TCP::Client::errstr)}
#
# # setting of URI and serialize SOAP envelope and data object
# my $soap = SOAP::Lite->uri($uri);
# my $envelope = $soap->serializer->envelope(method => $method, $data);
#
# # setting of TCP URI and send serialized SOAP envelope and data
# my $tcp_uri = "tcp://$server:$port/$service";
# my $result = $client->send_receive(envelope => $envelope, endpoint => $tcp_uri);
#
# # check server response
# if (!defined $result) {
# errMsg("Error: server returned empty response." . "\n" . "Problem with used SSL ceritificates or Warden server at $server:$port is down.");
# } else {
# # deserialized response from server -> create SOAP envelope and data object
# my $response = $soap->deserializer->deserialize($result);
# # check SOAP fault status
# $response->fault ? errMsg("Server sent error message:: " . $response->faultstring) : return 1;
# }
#}
#
sub c2s sub c2s
{ {
my $uri = shift; my $uri = shift;
...@@ -104,19 +37,12 @@ sub c2s ...@@ -104,19 +37,12 @@ sub c2s
my $ssl_ca_file = shift; my $ssl_ca_file = shift;
my $method = shift; my $method = shift;
my $data = shift; my $data = shift;
my $client; my $client;
my ($server, $port, $service) = $uri =~ /https:\/\/(.+)\:(\d+)\/(.+)/; my ($server, $port, $service) = $uri =~ /https:\/\/(.+)\:(\d+)\/(.+)/;
if (!($client = SOAP::Transport::HTTP::Client->new( if (!($client = SOAP::Transport::HTTP::Client->new())) {
# ssl_opts => { errMsg("Sorry, unable to create socket: " . &SOAP::Transport::HTTP::Client::errstr)
# verify_hostname => 0, }
# SSL_use_cert => 1,
# SSL_verify_mode => 0x02,
# SSL_key_file => $ssl_key_file,
# SSL_cert_file => $ssl_cert_file,
# SSL_ca_file => $ssl_ca_file
#}
))) {errMsg("Sorry, unable to create socket: " . &SOAP::Transport::HTTP::Client::errstr)}
$client->ssl_opts( verify_hostname => 1, $client->ssl_opts( verify_hostname => 1,
SSL_use_cert => 1, SSL_use_cert => 1,
SSL_verify_mode => 0x02, SSL_verify_mode => 0x02,
...@@ -124,13 +50,13 @@ sub c2s ...@@ -124,13 +50,13 @@ sub c2s
SSL_cert_file => $ssl_cert_file, SSL_cert_file => $ssl_cert_file,
SSL_ca_file => $ssl_ca_file); SSL_ca_file => $ssl_ca_file);
# setting of URI and serialize SOAP envelope and data object # set URI and serialize SOAP envelope and data object
my $soap = SOAP::Lite->uri($service)->proxy($uri); my $soap = SOAP::Lite->uri($service)->proxy($uri);
my $envelope = $soap->serializer->envelope(method => $method, $data); my $envelope = $soap->serializer->envelope(method => $method, $data);
# setting of TCP URI and send serialized SOAP envelope and data # set URI and send serialized SOAP envelope and data
my $tcp_uri = "https://$server:$port/$service"; my $server_uri = "https://$server:$port/$service";
my $result = $client->send_receive(envelope => $envelope, endpoint => $tcp_uri); my $result = $client->send_receive(envelope => $envelope, endpoint => $server_uri);
# check server response # check server response
if (!defined $result) { if (!defined $result) {
...@@ -144,8 +70,6 @@ sub c2s ...@@ -144,8 +70,6 @@ sub c2s
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# registerSender - register new warden sender # registerSender - register new warden sender
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
......
...@@ -3,43 +3,17 @@ ...@@ -3,43 +3,17 @@
# WardenStatus.pm # WardenStatus.pm
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # Copyright (C) 2011-2012 Cesnet z.s.p.o
# Author(s): Tomas PLESNIK <plesnik@ics.muni.cz>
# Jan SOUKAL <soukal@ics.muni.cz>
# #
# Redistribution and use in source and binary forms, with or without # Use of this source is governed by a BSD-style license, see LICENSE file.
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Cesnet z.s.p.o nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the Cesnet z.s.p.o or contributors be liable for
# any direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
package WardenStatus; package WardenStatus;
use strict; use strict;
use SOAP::Lite; use SOAP::Lite;
use IO::Socket::SSL qw(debug1); use IO::Socket::SSL qw(debug1);
#use SOAP::Transport::TCP;
use SOAP::Transport::HTTP; use SOAP::Transport::HTTP;
#use Data::Dumper;
our $VERSION = "0.1"; our $VERSION = "2.0";
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -55,45 +29,6 @@ sub errMsg ...@@ -55,45 +29,6 @@ sub errMsg
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# c2s - connect to server, send request and receive response # c2s - connect to server, send request and receive response
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#sub c2s
#{
# my $uri = shift;
# my $ssl_key_file = shift;
# my $ssl_cert_file = shift;
# my $ssl_ca_file = shift;
# my $method = shift;
#
# my $client;
# my ($server, $port, $service) = $uri =~ /https:\/\/(.+)\:(\d+)\/(.+)/;
# if (!($client = SOAP::Transport::TCP::Client->new(
# PeerAddr => $server,
# PeerPort => $port,
# Proto => 'tcp',
# SSL_use_cert => 1,
# SSL_verify_mode => 0x02,
# SSL_key_file => $ssl_key_file,
# SSL_cert_file => $ssl_cert_file,
# SSL_ca_file => $ssl_ca_file,
# ))) {errMsg("Sorry, unable to create socket: " . &SOAP::Transport::TCP::Client::errstr)}
#
# # setting of URI and serialize SOAP envelope and data object
# my $soap = SOAP::Lite->uri($uri);
# my $envelope = $soap->serializer->envelope(method => $method);
#
# # setting of TCP URI and send serialized SOAP envelope and data
# my $tcp_uri = "tcp://$server:$port/$service";
# my $result = $client->send_receive(envelope => $envelope, endpoint => $tcp_uri);
#
# # check server response
# if (!defined $result) {
# errMsg("Error: server returned empty response." . "\n" . "Problem with used SSL ceritificates or Warden server at $server:$port is down.");
# } else {
# # deserialized response from server -> create SOAP envelope and data object
# my $response = $soap->deserializer->deserialize($result);
# # check SOAP fault status
# $response->fault ? errMsg("Server sent error message:: " . $response->faultstring) : return $response;
# }
#}
sub c2s sub c2s
{ {
my $uri = shift; my $uri = shift;
...@@ -102,19 +37,12 @@ sub c2s ...@@ -102,19 +37,12 @@ sub c2s
my $ssl_ca_file = shift; my $ssl_ca_file = shift;
my $method = shift; my $method = shift;
my $data = shift; my $data = shift;
my $client; my $client;
my ($server, $port, $service) = $uri =~ /https:\/\/(.+)\:(\d+)\/(.+)/; my ($server, $port, $service) = $uri =~ /https:\/\/(.+)\:(\d+)\/(.+)/;
if (!($client = SOAP::Transport::HTTP::Client->new( if (!($client = SOAP::Transport::HTTP::Client->new())) {
# ssl_opts => { errMsg("Sorry, unable to create socket: " . &SOAP::Transport::HTTP::Client::errstr)
# verify_hostname => 0, }
# SSL_use_cert => 1,
# SSL_verify_mode => 0x02,
# SSL_key_file => $ssl_key_file,
# SSL_cert_file => $ssl_cert_file,
# SSL_ca_file => $ssl_ca_file
#}
))) {errMsg("Sorry, unable to create socket: " . &SOAP::Transport::HTTP::Client::errstr)}
$client->ssl_opts(verify_hostname => 1, $client->ssl_opts(verify_hostname => 1,
SSL_use_cert => 1, SSL_use_cert => 1,
SSL_verify_mode => 0x02, SSL_verify_mode => 0x02,
...@@ -122,13 +50,13 @@ sub c2s ...@@ -122,13 +50,13 @@ sub c2s
SSL_cert_file => $ssl_cert_file, SSL_cert_file => $ssl_cert_file,
SSL_ca_file => $ssl_ca_file); SSL_ca_file => $ssl_ca_file);
# setting of URI and serialize SOAP envelope and data object # set URI and serialize SOAP envelope and data object
my $soap = SOAP::Lite->uri($service)->proxy($uri); my $soap = SOAP::Lite->uri($service)->proxy($uri);
my $envelope = $soap->serializer->envelope(method => $method); my $envelope = $soap->serializer->envelope(method => $method);
# setting of TCP URI and send serialized SOAP envelope and data # setting of TCP URI and send serialized SOAP envelope and data
my $tcp_uri = "https://$server:$port/$service"; my $server_uri = "https://$server:$port/$service";
my $result = $client->send_receive(envelope => $envelope, endpoint => $tcp_uri); my $result = $client->send_receive(envelope => $envelope, endpoint => $server_uri);
# check server response # check server response
if (!defined $result) { if (!defined $result) {
...@@ -157,39 +85,31 @@ sub getClients ...@@ -157,39 +85,31 @@ sub getClients
my $conf_file = $etcdir . "warden-client.conf"; my $conf_file = $etcdir . "warden-client.conf";
my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file) = WardenConf::loadConf($conf_file); my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file) = WardenConf::loadConf($conf_file);
# call method getClients on the Warden server
my $response = c2s($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, "getClients"); my $response = c2s($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, "getClients");
# match getClients functions response
$response->match('/Envelope/Body/getClientsResponse/');
my $i = 1; # parse returned SOAP data object with clients
my ($client_id, $hostname, $registered, $requestor, $service, $client_type, $type, $receive_own_events, $description_tags, $ip_net_client);
my @clients; my @clients;
my $response_data = $response->valueof("[$i]"); my ($client_id, $hostname, $registered, $requestor, $service, $client_type, $type, $receive_own_events, $description_tags, $ip_net_client);
my @response_list = $response->valueof('/Envelope/Body/getClientsResponse/client/');
# parse returned data object while (scalar @response_list) {
while (defined $response_data) { my $response_data = shift(@response_list);
# inicialization of temporal client array
my @client; my @client;
# parse items of one client
$client_id = $response_data->{'CLIENT_ID'} ; $client_id = $response_data->{'CLIENT_ID'} ;
$hostname = $response_data->{'HOSTNAME'}; $hostname = $response_data->{'HOSTNAME'};
$registered = $response_data->{'REGISTERED'}; $registered = $response_data->{'REGISTERED'};
$requestor = $response_data->{'REQUESTOR'}; $requestor = $response_data->{'REQUESTOR'};
$service = $response_data->{'SERVICE'}; $service = defined $response_data->{'SERVICE'} ? $response_data->{'SERVICE'} : "-";
$client_type = $response_data->{'CLIENT_TYPE'}; $client_type = $response_data->{'CLIENT_TYPE'};
$type = defined $response_data->{'TYPE'} ? $response_data->{'TYPE'} : ""; $type = defined $response_data->{'TYPE'} ? $response_data->{'TYPE'} : "-";
$receive_own_events = defined $response_data->{'RECEIVE_OWN_EVENTS'} ? $response_data->{'RECEIVE_OWN_EVENTS'} : ""; $receive_own_events = defined $response_data->{'RECEIVE_OWN_EVENTS'} ? $response_data->{'RECEIVE_OWN_EVENTS'} : "-";
$description_tags = defined $response_data->{'DESCRIPTION_TAGS'} ? $response_data->{'DESCRIPTION_TAGS'} : ""; $description_tags = defined $response_data->{'DESCRIPTION_TAGS'} ? $response_data->{'DESCRIPTION_TAGS'} : "-";
$ip_net_client = $response_data->{'IP_NET_CLIENT'}; $ip_net_client = $response_data->{'IP_NET_CLIENT'};
# push received clients from warden server into @clients which is returned # push received clients from warden server into @clients which is returned
@client = ("$client_id", "$hostname", "$registered", "$requestor", "$service", "$client_type", "$type", "$receive_own_events", "$description_tags", "$ip_net_client"); @client = ($client_id, $hostname, $registered, $requestor, $service, $client_type, $type, $receive_own_events, $description_tags, $ip_net_client);
push (@clients,\@client); push (@clients,\@client);
# go to the next received client
$i++;
$response_data = $response->valueof("[$i]");
} }
return @clients; return @clients;
} # End of getClients } # End of getClients
...@@ -210,25 +130,21 @@ sub getStatus ...@@ -210,25 +130,21 @@ sub getStatus
my $conf_file = $etcdir . "warden-client.conf"; my $conf_file = $etcdir . "warden-client.conf";
my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file) = WardenConf::loadConf($conf_file); my ($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file) = WardenConf::loadConf($conf_file);
# call method getStatus on Warden server
my $response = c2s($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, "getStatus"); my $response = c2s($uri, $ssl_key_file, $ssl_cert_file, $ssl_ca_file, "getStatus");
# match getStatus functions response #-----------------------------------------------------------------------------
$response->match('/Envelope/Body/getStatusResponse/'); # parse returned SOAP object with server status
my @status; my @response_list = $response->valueof('/Envelope/Body/getStatusResponse/server_status/');
my $i = 1; my $response_data = shift(@response_list);
# get first value from SOAP data object
my $response_data = $response->valueof("[$i]");
# parse items of server status
my $version = $response_data->{'VERSION'}; my $version = $response_data->{'VERSION'};
#my $address = $response_data->{'ADDRESS'}; my $server_hostname = $response_data->{'HOSTNAME'};
#my $port = $response_data->{'PORT'}; my $ip_address = $response_data->{'IP_ADDRESS'};
my $logdir = $response_data->{'LOGDIR'}; my $port = $response_data->{'PORT'};
#my $piddir = $response_data->{'PIDDIR'}; my $db_name = $response_data->{'DB_NAME'};
my $vardir = $response_data->{'VARDIR'}; my $db_user = $response_data->{'DB_USER'};
#my $ssl_key_file_server = $response_data->{'SSL_KEY_FILE'}; my $db_host = $response_data->{'DB_HOST'};
#my $ssl_cert_file_server = $response_data->{'SSL_CERT_FILE'};
#my $ssl_ca_file_server = $response_data->{'SSL_CA_FILE'};
my $facility = $response_data->{'FACILITY'}; my $facility = $response_data->{'FACILITY'};
my $db_size = $response_data->{'DB_SIZE'}; my $db_size = $response_data->{'DB_SIZE'};
my $events_sum = $response_data->{'EVENTS_SUM'}; my $events_sum = $response_data->{'EVENTS_SUM'};
...@@ -237,24 +153,26 @@ sub getStatus ...@@ -237,24 +153,26 @@ sub getStatus
my $events_last_timestamp = $response_data->{'EVENTS_LAST_TIMESTAMP'}; my $events_last_timestamp = $response_data->{'EVENTS_LAST_TIMESTAMP'};
my $clients_sum = $response_data->{'CLIENTS_SUM'}; my $clients_sum = $response_data->{'CLIENTS_SUM'};
#my @server_status = ("$version", "$address", "$port", "$logdir", "$piddir", "$vardir", "$ssl_key_file_server", "$ssl_cert_file_server", "$ssl_ca_file_server", "$facility", "$db_size", "$events_sum", "$events_last_id", "$events_first_timestamp", "$events_last_timestamp", "$clients_sum"); my @server_status = ($version, $server_hostname, $ip_address, $port, $db_name, $db_user, $db_host, $facility, $db_size, $events_sum, $events_last_id, $events_first_timestamp, $events_last_timestamp, $clients_sum);
my @server_status = ("$version", undef, undef, undef, undef, undef, undef, undef, undef, "$facility", "$db_size", "$events_sum", "$events_last_id", "$events_first_timestamp", "$events_last_timestamp", "$clients_sum"); my @status;
push(@status, \@server_status); push(@status, \@server_status);
$i++; #-----------------------------------------------------------------------------
$response_data = $response->valueof("[$i]"); # parse returned SOAP object with client status
while (defined $response_data) { @response_list = $response->valueof('/Envelope/Body/getStatusResponse/client_status/');
my ($client_id, $hostname, $service, $count, $timestamp);
while (scalar @response_list) {
my $response_data = shift(@response_list);
my @client_status; my @client_status;
# parse SOAP data object
my $client_id = $response_data->{'CLIENT_ID'}; my $client_id = $response_data->{'CLIENT_ID'};
my $hostname = $response_data->{'HOSTNAME'}; my $hostname = $response_data->{'HOSTNAME'};
my $service = $response_data->{'SERVICE'}; my $service = $response_data->{'SERVICE'};
my $count = $response_data->{'COUNT'}; my $count = $response_data->{'COUNT'};
my $timestamp = $response_data->{'TIMESTAMP'}; my $timestamp = $response_data->{'TIMESTAMP'};
@client_status = ("$client_id", "$hostname", "$service", "$count", "$timestamp");
@client_status = ($client_id, $hostname, $service, $count, $timestamp);
push(@status, \@client_status); push(@status, \@client_status);
$i++;
$response_data = $response->valueof("[$i]");
} }
return @status; return @status;
} # End of getStatus } # End of getStatus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment