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

presunuto nacitani konfiguracniho souboru; zmena formatovani if podminek

parent 47ecccca
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,18 @@ use WardenCommon;
our $VERSION = "2.2";
my $etc = "$FindBin::RealBin/../etc";
# read config file
my $conf_file = "$etc/warden-server.conf";
our $DB_NAME = undef;
our $DB_USER = undef;
our $DB_PASS = undef;
our $DB_HOST = undef;
unless (do $conf_file) {
die("Errors in config file '$conf_file': $@") if $@;
die("Can't read config file '$conf_file': $!") unless defined $_;
# if $_ defined, it's retvalue of last statement of conf, for which we don't care
}
################################################################################
......@@ -43,22 +55,14 @@ die usage unless getopts("h");
my $help = $opt_h;
# catch help param
if ($help) {usage}
if ($help) {
usage;
}
# superuser controle
my $UID = $<;
if ($UID != 0) {WardenCommon::errMsg("You must be root for running this script!")}
# read config file
my $conf_file = "$etc/warden-server.conf";
our $DB_NAME = undef;
our $DB_USER = undef;
our $DB_PASS = undef;
our $DB_HOST = undef;
unless (do $conf_file) {
die("Errors in config file '$conf_file': $@") if $@;
die("Can't read config file '$conf_file': $!") unless defined $_;
# if $_ defined, it's retvalue of last statement of conf, for which we don't care
if ($UID != 0) {
WardenCommon::errMsg("You must be root for running this script!");
}
# connect to DB
......
......@@ -23,6 +23,23 @@ use WardenCommon;
our $VERSION = "2.2";
my $etc = "$FindBin::RealBin/../etc";
# read config file
my $conf_file = "$etc/warden-server.conf";
our $BASEDIR = undef
our $SYSLOG = undef;
our $SYSLOG_VERBOSE = undef;
our $SYSLOG_FACILITY = undef;
our $DB_NAME = undef;
our $DB_USER = undef;
our $DB_PASS = undef;
our $DB_HOST = undef;
our $MAX_EVENTS_LIMIT = undef;
unless (do $conf_file) {
die("Errors in config file '$conf_file': $@") if $@;
die("Can't read config file '$conf_file': $!") unless defined $_;
# if $_ defined, it's retvalue of last statement of conf, for which we don't care
}
################################################################################
......@@ -44,27 +61,14 @@ die usage unless getopts("h");
my $help = $opt_h;
# catch help param
if ($help) {usage}
if ($help) {
usage;
}
# superuser controle
my $UID = $<;
if ($UID != 0) {WardenCommon::errMsg("You must be root for running this script!")}
# read config file
my $conf_file = "$etc/warden-server.conf";
our $BASEDIR = undef
our $SYSLOG = undef;
our $SYSLOG_VERBOSE = undef;
our $SYSLOG_FACILITY = undef;
our $DB_NAME = undef;
our $DB_USER = undef;
our $DB_PASS = undef;
our $DB_HOST = undef;
our $MAX_EVENTS_LIMIT = undef;
unless (do $conf_file) {
die("Errors in config file '$conf_file': $@") if $@;
die("Can't read config file '$conf_file': $!") unless defined $_;
# if $_ defined, it's retvalue of last statement of conf, for which we don't care
if ($UID != 0) {
WardenCommon::errMsg("You must be root for running this script!");
}
# connect to DB
......@@ -103,61 +107,81 @@ my $db_size = defined $size ? Format::Human::Bytes::base10($size) : "none";
$sth = $DBH->prepare("SELECT count(*) FROM events WHERE valid = 't';") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_sum = $sth->fetchrow();
if (!defined $events_sum) {$events_sum = "none"}
if (!defined $events_sum) {
$events_sum = "none";
}
# sum of records in table events (with invalid)
$sth = $DBH->prepare("SELECT count(*) FROM events;") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_sum_inv = $sth->fetchrow();
if (!defined $events_sum_inv) {$events_sum_inv = "none"}
if (!defined $events_sum_inv) {
$events_sum_inv = "none";
}
# id of last record in table events
$sth = $DBH->prepare("SELECT max(id) FROM events WHERE valid = 't';") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_last_id = $sth->fetchrow();
if (!defined $events_last_id) {$events_last_id = "none"}
if (!defined $events_last_id) {
$events_last_id = "none";
}
# id of last record in table events (with invalid)
$sth = $DBH->prepare("SELECT max(id) FROM events;") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_last_id_inv = $sth->fetchrow();
if (!defined $events_last_id_inv) {$events_last_id_inv = "none"}
if (!defined $events_last_id_inv) {
$events_last_id_inv = "none";
}
# timestamp of first record in table events
$sth = $DBH->prepare("SELECT received FROM events WHERE id = (SELECT min(id) FROM events WHERE valid = 't');") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_first_timestamp = $sth->fetchrow();
if (!defined $events_first_timestamp) {$events_first_timestamp = "none"}
if (!defined $events_first_timestamp) {
$events_first_timestamp = "none";
}
# timestamp of first record in table events (with invalid)
$sth = $DBH->prepare("SELECT received FROM events WHERE id = (SELECT min(id) FROM events);") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_first_timestamp_inv = $sth->fetchrow();
if (!defined $events_first_timestamp_inv) {$events_first_timestamp_inv = "none"}
if (!defined $events_first_timestamp_inv) {
$events_first_timestamp_inv = "none";
}
# timestamp of last record in table events
$sth = $DBH->prepare("SELECT received FROM events WHERE id = (SELECT max(id) FROM events WHERE valid = 't');") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_last_timestamp = $sth->fetchrow();
if (!defined $events_last_timestamp) {$events_last_timestamp = "none"}
if (!defined $events_last_timestamp) {
$events_last_timestamp = "none";
}
# timestamp of last record in table events (with invalid)
$sth = $DBH->prepare("SELECT received FROM events WHERE id = (SELECT max(id) FROM events);") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $events_last_timestamp_inv = $sth->fetchrow();
if (!defined $events_last_timestamp_inv) {$events_last_timestamp_inv = "none"}
if (!defined $events_last_timestamp_inv) {
$events_last_timestamp_inv = "none";
}
# sum of records in table clients
$sth = $DBH->prepare("SELECT count(*) FROM clients WHERE valid = 't';") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $clients_sum = $sth->fetchrow();
if (!defined $clients_sum) {$clients_sum = "none"}
if (!defined $clients_sum) {
$clients_sum = "none";
}
# sum of records in table clients (with invalid)
$sth = $DBH->prepare("SELECT count(*) FROM clients;") or die "Cannot prepare statement: " . $DBH->errstr;
$sth->execute or die "Cannot execute statement: " . $sth->errstr;
my $clients_sum_inv = $sth->fetchrow();
if (!defined $clients_sum_inv) {$clients_sum_inv = "none"}
if (!defined $clients_sum_inv) {
$clients_sum_inv = "none";
}
#-------------------------------------------------------------------------------
# Statistics of active registered senders
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment