Perl コードによる Swatchdog の柔軟なアクションのための基底クラス (Base class for flexible action of Swatchdog by perl code)
Filename | Tamanho | Hora | Download count |
Swatchdog-Actions-Perl-0.1.tar.gz | 13.14 k | 2016-04-09 15:46:24 | 48 |
NAME Swatchdog::Actions::Perl - perl object for Swatchdog action INSTALLATION To install this module type the following: perl Makefile.PL make test sudo make install SYNOPSIS In your perl module file: package Swatchdog::Actions::Perl::Login; use threads; use threads::shared; use Swatchdog::Actions::Perl; use vars qw( @ISA %TrustedUser ); @ISA = qw(Swatchdog::Actions::Perl); %TrustedUser = (); share(%TrustedUser); sub new($@) { my $class = shift; my $self = Swatchdog::Actions::Perl->new(@_); bless $self, $class; return $self; } sub logEventOccurred($) { my $self = shift; $self->logInfo('The use %s has logged in a %s manner from %s.', $self->{property}->{user}, $self->{property}->{secure} ? 'secure' : 'non-secure', $self->{property}->{from} ); } sub mustEventBeDealtWith($) { my $self = shift; my $value; $self->logTrace('BEGIN %s', (caller 0)[3]); $value = exists $TrustedUser{$self->{property}->{user}} && $self->{property}->{secure} ; $self->logInfo('The user %s from %s %s a trusted user.', $self->{property}->{user}, $self->{property}->{from}, $self->{property}->{secure} ? 'is' : "isn't" ); $self->logTrace('END %s', (caller 0)[3]); return $value; } sub dealWithEvent($) { my $self = shift; $self->logDebug('BEGIN %s', (caller 0)[3]); AddTrustedClientHost($self->{property}->{from}); $self->logDebug('END %s', (caller 0)[3]); } sub AddTrustedClientHost($) { # Do something. } In the configuration file of Swatchdog: perlcode 0 use Swatchdog::Actions::Perl::Login; perlcode 0 $Swatchdog::Actions::Perl::Login::TrustedUser{john} = 1; perlcode 0 $Swatchdog::Actions::Perl::Login::TrustedUser{mark} = 1; perlcode 0 $Swatchdog::Actions::Perl::Login::TrustedUser{becky} = 1; perlcode 0 my $Login = Swatchdog::Actions::Perl::Login->new(); watchfor /^\w{3}\s+\d{1-2} \d{2}:\d{2}:\d{2} \S+ sshd\[\d+\]: Accepted publickey for (\w+) from: (\S+) port / perlcode 2 $Login->onEventOccurred( perlcode 2 user => $1, from => $2, perlcode 2 secure => 1 perlcode 2 ); DESCRIPTION This module is a base class, which provides Swatchdog actions. In the configuration file of Swatchdog, to run a complex process in a exec action, you need to create a command. By using this module, you will be able to define the action in the perl code instead of the command. VERSION 0.1 AUTHOR Yuji Okamura <okamura[at]users.osdn.me> COPYRIGHT Copyright (C) 2015 Yuji OKamura. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Rev. | Hora | Autor | Mensagem RSS |
7fc34baa | 2016-04-09 15:37:09 | Yuji Okamura | Fixed the version. |
a94bf883 | 2016-04-09 15:09:48 | Yuji Okamura | PODs and etc. are modified. |
8e18d90a | 2016-04-08 20:55:05 | Yuji Okamura | original version |