view release on metacpan or search on metacpan
output in a specific format.
filter raw
==========
this filter will just dump the output as it is provided by the worker process. no
formatting will be done.
format:
HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
filter async
============
this filter dumps the worker process output unsynchronized in the following format. unsynchronised
means, that output lines from the different worker processes are printed at the same time they are
generated.
format:
HOSTNAME: OUTPUT
filter sync
============
this filter dumps the worker process output synchronised in the following format. synchronized
means, that the complete output for a single hosts will be dumped at once when the worker proces
has finished execution.
format:
HOSTNAME: OUTPUT
filter result
=============
this filter will only print the exit codes for the worker processes.
format:
HOSTNAME: exit code CODE
a filter reads the raw output generated by the worker processes and prints this
output in a filter specific format.
=head2 filter raw
this filter will just dump the output as it is provided by the worker process. no
formatting will be done.
format:
HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
=head2 filter async
this filter dumps the worker process output unsynchronized in the following format. unsynchronised
means, that output lines from the different worker processes are printed at the same time they are
generated.
format:
HOSTNAME: OUTPUT
=head2 filter sync
this filter dumps the worker process output synchronised in the following format. synchronized
means, that the complete output for a single hosts will be dumped at once when the worker proces
has finished execution.
format:
HOSTNAME: OUTPUT
=head2 filter result
this filter will only print the exit codes for the worker processes.
format:
HOSTNAME: exit code CODE
=head1 LOGGERS
a filter reads the raw output generated by the worker processes and prints this
output in a filter specific format.
=head2 filter raw
this filter will just dump the output as it is provided by the worker process. no
formatting will be done.
format:
HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
=head2 filter async
this filter dumps the worker process output unsynchronized in the following format. unsynchronised
means, that output lines from the different worker processes are printed at the same time they are
generated.
format:
HOSTNAME: OUTPUT
=head2 filter sync
this filter dumps the worker process output synchronised in the following format. synchronized
means, that the complete output for a single hosts will be dumped at once when the worker proces
has finished execution.
format:
HOSTNAME: OUTPUT
=head2 filter result
this filter will only print the exit codes for the worker processes.
format:
HOSTNAME: exit code CODE
=head1 LOGGERS
lib/NRun/Check.pm view on Meta::CPAN
# derived modules must implement the following subs's
#
# - init($cfg) - $cfg->{hostname} will be set
# - execute()
#
# a derived module must call register() in BEGIN{}, otherwise it will not
# be available.
#
# any output generated by the check modules must match the following format:
#
# HOSTNAME;stderr;PID;n/a;error;"OUTPUT"
#
# additionally the exit code must be printed on any error:
#
# HOSTNAME;stdout;PID;n/a;exit;"exit code CODE"
###
package NRun::Check;
use strict;
use warnings;
lib/NRun/Checks/CheckNs.pm view on Meta::CPAN
my $_cfg = shift;
$_self->{hostname} = $_cfg->{hostname};
}
###
# execute the check on $_self->{hostname}.
#
# on error, the following string will be printed on stderr:
#
# HOSTNAME;stderr;PID;n/a;error;"OUTPUT"
#
# <- 1 on success and 0 on error
sub execute {
my $_self = shift;
if (not gethostbyname($_self->{hostname})) {
print STDERR "$_self->{hostname};stderr;" . time() . ";$$;n/a;error;\"dns entry is missing for $_self->{hostname}\"\n";
print STDOUT "$_self->{hostname};stdout;" . time() . ";$$;n/a;exit;\"exit code $NRun::Constants::CHECK_FAILED_NS\"\n";
lib/NRun/Checks/CheckNull.pm view on Meta::CPAN
my $_cfg = shift;
$_self->{hostname} = $_cfg->{hostname};
}
###
# execute the check on $_self->{hostname}.
#
# on error, the following string will be printed on stderr:
#
# HOSTNAME;stderr;PID;n/a;error;"OUTPUT"
#
# <- 1 on success and 0 on error
sub execute {
my $_self = shift;
return 1;
}
1;
lib/NRun/Checks/CheckPing.pm view on Meta::CPAN
my $_cfg = shift;
$_self->{hostname} = $_cfg->{hostname};
}
###
# execute the check on $_self->{hostname}.
#
# on error, the following string will be printed on stderr:
#
# HOSTNAME;stderr;PID;n/a;error;"OUTPUT"
#
# <- 1 on success and 0 on error
sub execute {
my $_self = shift;
if (not Net::Ping->new()->ping($_self->{hostname})) {
print STDERR "$_self->{hostname};stderr;" . time() . ";$$;n/a;error;\"no ping reply from $_self->{hostname}\"\n";
print STDOUT "$_self->{hostname};stdout;" . time() . ";$$;n/a;exit;\"exit code $NRun::Constants::CHECK_FAILED_PING\"\n";
lib/NRun/Checks/CheckRscd.pm view on Meta::CPAN
my $_cfg = shift;
$_self->{hostname} = $_cfg->{hostname};
}
###
# execute the check on $_self->{hostname}.
#
# on error, the following string will be printed on stderr:
#
# HOSTNAME;stderr;PID;n/a;error;"OUTPUT"
#
# <- 1 on success and 0 on error
sub execute {
my $_self = shift;
my $out = `agentinfo $_self->{hostname} 2>&1`;
if ($? != 0) {
lib/NRun/Filter.pm view on Meta::CPAN
# - stderr($data)
# - stdout($data)
#
# a derived module must call register() in BEGIN{}, otherwise it will not
# be available.
#
# the output (which is generated by the worker processes, collected by the
# sink object and passed to the filter/logger modules) is expected to match
# the following format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
###
package NRun::Filter;
use strict;
use warnings;
use File::Basename;
###
lib/NRun/Filters/FilterAsync.pm view on Meta::CPAN
sub init {
my $_self = shift;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Filters/FilterAsync.pm view on Meta::CPAN
print STDOUT "$data[0]: $message\n";
}
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Filters/FilterExitCode.pm view on Meta::CPAN
sub init {
my $_self = shift;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Filters/FilterExitCode.pm view on Meta::CPAN
print STDOUT "$data[0]: $message\n" if (defined($message));
}
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
}
1;
lib/NRun/Filters/FilterNull.pm view on Meta::CPAN
my $_self = shift;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
}
1;
lib/NRun/Filters/FilterRaw.pm view on Meta::CPAN
my $_self = shift;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
print STDOUT $_data;
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
print STDERR $_data;
}
lib/NRun/Filters/FilterSync.pm view on Meta::CPAN
sub init {
my $_self = shift;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Filters/FilterSync.pm view on Meta::CPAN
$_self->end($data[0]);
}
}
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Logger.pm view on Meta::CPAN
# - stderr($data)
# - stdout($data)
#
# a derived module must call register() in BEGIN{}, otherwise it will not
# be available.
#
# the output (which is generated by the worker processes, collected by the
# sink object and passed to the filter/logger modules) is expected to match
# the following format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
###
package NRun::Logger;
use strict;
use warnings;
use File::Basename;
###
lib/NRun/Loggers/LoggerExitCode.pm view on Meta::CPAN
open(LOG, ">>$_self->{logfile}") or die("$_self->{logfile}: $!");
$_self->{LOG} = \*LOG;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Loggers/LoggerExitCode.pm view on Meta::CPAN
print {$_self->{LOG}} "$data[0]: $code\n" if (defined($code));
}
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
}
DESTROY {
lib/NRun/Loggers/LoggerNull.pm view on Meta::CPAN
sub init {
my $_self = shift;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
}
1;
lib/NRun/Loggers/LoggerOutput.pm view on Meta::CPAN
open(LOG, ">>$_self->{logfile}") or die("$_self->{logfile}: $!");
$_self->{LOG} = \*LOG;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Loggers/LoggerOutput.pm view on Meta::CPAN
$_self->end($data[0]);
}
}
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
my @data = split(/;/, $_data);
my ($message) = ($_data =~ m/[^"]"(.*)"[^"]*/);
lib/NRun/Loggers/LoggerRaw.pm view on Meta::CPAN
open(LOG, ">>$_self->{logfile}") or die("$_self->{logfile}: $!");
$_self->{LOG} = \*LOG;
}
###
# handle one line of data written on stdout.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stdout {
my $_self = shift;
my $_data = shift;
print {$_self->{LOG}} "$_data";
}
###
# handle one line of data written on stderr.
#
# expected data format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_data - the data to be handled
sub stderr {
my $_self = shift;
my $_data = shift;
print {$_self->{LOG}} "$_data";
}
lib/NRun/Worker.pm view on Meta::CPAN
#
# a derived module must call register() in BEGIN{}, otherwise it will not
# be available.
#
# a derived module must always write to $_self->{E} (STDERR) and
# $_self->{O} (STDOUT).
#
# all output produced by the derived worker modules must match the
# following format:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# this is the string which will be passed to the logger/filter implementations.
###
package NRun::Worker;
use strict;
use warnings;
use File::Basename;
lib/NRun/Worker.pm view on Meta::CPAN
print {$$_self->{O}} "$$_self->{hostname};stdout;" . time() . ";$$;$$_self->{pid};exit;\"exit code $NRun::Constants::CODE_SIGALRM;\"\n";
print {$$_self->{E}} "$$_self->{hostname};stderr;" . time() . ";$$;$$_self->{pid};error;\"SIGALRM received\"\n";
}
###
# execute $_cmd.
#
# command output will be formatted the following way, line by line:
#
# HOSTNAME;[stdout|stderr];TSTAMP;PID;PID(CHILD);[debug|error|exit|output|end];"OUTPUT"
#
# $_cmd - the command to be executed
# <- the return code
sub do {
my $_self = shift;
my $_cmd = shift;
chomp($_cmd);