use warnings;
-# Disable warnings of unjoinded threads when stopping guardian.
+# Disable warnings of unjoined threads when stopping guardian.
no warnings 'threads';
# Define version.
print "Guardian $version \n";
print "Usage: guardian <optional arguments>\n";
print " -c, --config\t\tspecifiy a configuration file other than the default (/etc/guardian/guardian.conf)\n";
- print " -f, --foreground\trun in the foreground (doesn't fork, any output goes to STDOUT)\n";
+ print " -f, --foreground\turn in the foreground (doesn't fork, any output goes to STDOUT)\n";
print " -h, --help\t\tshows this help\n";
print " -v, --version\t\tdisplay programm version and exit.\n";
exit;
# Check if another instance of guardian is allready running.
if (&Guardian::Daemon::IsRunning()) {
- die "Another instance of Guardian is allready running...\n";
+ die "Another instance of Guardian is already running...\n";
}
# Read-in the configuration file and store the settings.
## with huge logfiles, at initialization time of the worker process, the file will
## be opened once and the cursor position of the end of file (EOF) get stored. When
## reading any newly added lines from the file, we directly can jump to the last
-## known position and get these lines. Afterwards, we store the current curser position
+## known position and get these lines. Afterwards, we store the current cursor position
## again, so we can do it in this way over and over again.
#
## All read lines get stored in an array, which will be passed to the Parser.
#
-## If any response (action) from the parser get recieved, it will be put into the
+## If any response (action) from the parser is received, it will be put into the
## shared event queue.
#
sub Worker ($) {
my $file = $_[0];
- # Obtain the parser name which should be used to parser any
+ # Obtain the parser name which should be used to parse any
# messages of this file.
my $parser = $monitored_files{$file};
# Infinite loop.
while(1) {
- # Check if the workers should pause or perform it's desired work.
+ # Check if the workers should pause or perform their desired work.
if ($workers_pause) {
# Wait 1 second until the next check.
sleep(1);
## Socket function.
#
## This function uses the Socket module to create and listen to an UNIX socket.
-## It automatically accepts all incomming connections and pass the recieved
+## It automatically accepts all incoming connections and pass the received
## data messages to the the Message_Parser function which is also part of the
## socket module.
#
# Log successfull creation of socket.
$logger->Log("debug", "Listening to Socket...");
- # Accept incomming connections from the socket.
+ # Accept incoming connections from the socket.
while (my $connection = $server->accept()) {
# Autoflush the socket after the data
- # has been recieved.
+ # has been received.
$connection->autoflush(1);
# Gather all data from the connection.
# Remove any newlines.
chomp($message);
- # Log recieved socket command.
+ # Log received socket command.
$logger->Log("debug", "Socket - Recieved message: $message");
- # Send the recieved data message to the
+ # Send the received data message to the
# socket parser.
my $action = &Guardian::Socket::Message_Parser($message);
## Function for capturing process signals.
#
## This function captures any sent process signals and will call various
-## actions, basend on the captured signal.
+## actions, based on the captured signal.
#
sub SignalHandler {
$SIG{INT} = \&Shutdown;
# Loop through the hash which contains the monitored files and start
# a worker thread for each single one.
foreach my $file (keys %monitored_files) {
- # Check if an worker allready is running for this file.
+ # Check if an worker is already running for this file.
# If not, start the worker.
unless (exists($running_workers{$file})) {
$logger->Log("debug", "Starting worker thread for $file");
# Loop through all running workers.
foreach my $worker (keys %running_workers) {
# Determine if the worker should be stopped.
- # This happen if the file should not be longer monitored.
+ # This happens if the file should not be longer monitored.
unless(exists($monitored_files{$worker})) {
$logger->Log("debug", "Stopping worker thread for $worker");
#
sub PauseWorkers() {
# Set workers_pause variable to "1".
- # All workers will be sleep until the variable has been set to "0".
+ # All workers will sleep until the variable has been set to "0".
$workers_pause = 1;
# Log paused workers.
#
## Reload function.
#
-## This function will get called if the signal handler recieves a "SIGHUP" signal,
+## This function will get called if the signal handler receives a "SIGHUP" signal,
## or the reload command will be sent via socket connection. It is responsible for
## reloading all configure options and stopping/starting the worker threads.
#
#
## ReloadIgnoreList function.
#
-## This function will be called if the signal handler recieves a "SIGUSR1" signal,
+## This function will be called if the signal handler receives a "SIGUSR1" signal,
## or the reload-ignore-list command will be sent via the socket connection. It just
## performs a simple check if an ignore file has been configured and calls the responsible
## function on the events module.
#
## This function only get called when the logrotate command will be sent via
## the socket connection. It is responsible for validating and altering the current
-## curser positions of the monitored files and stopping/starting the worker threads.
+## cursor positions of the monitored files and stopping/starting the worker threads.
#
sub Logrotate () {
# Stop all running workers.
## Shutdown function.
#
## This function is used to do a clean shutdown of guardian. It will be called
-## by the signal handler when recieving INT (2), QUIT (3) and TERM (15) signals.
+## by the signal handler when receiving INT (2), QUIT (3) and TERM (15) signals.
#
sub Shutdown () {
# Log shutdown.