summaryrefslogtreecommitdiffstats
path: root/lib/ASM
diff options
context:
space:
mode:
authorLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2016-01-21 16:46:34 -0700
committerLibravatarWilliam Heimbigner <william.heimbigner@gmail.com>2016-01-21 16:46:34 -0700
commita73ccb8276861dab3fcba34c2783122655947844 (patch)
tree1823287054c36c65de0f43963a180788d082570c /lib/ASM
parent939891b050a6c0c5f44acf6ef43a30ee76719a16 (diff)
Have the Inspect/opalert routines print a backlog to an incident-specific logfile, rather than a single file, and include a shortlink to this logfile when generating alerts
Diffstat (limited to 'lib/ASM')
-rw-r--r--lib/ASM/Commander.pm5
-rw-r--r--lib/ASM/Inspect.pm5
-rw-r--r--lib/ASM/Log.pm7
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm
index 6d194d2..0098d32 100644
--- a/lib/ASM/Commander.pm
+++ b/lib/ASM/Commander.pm
@@ -7,6 +7,8 @@ use IO::All;
use POSIX qw(strftime);
use Data::Dumper;
use URI::Escape;
+use ASM::Shortener;
+
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
my $cmdtbl = {
@@ -880,9 +882,10 @@ sub cmd_ops {
if ((time-$::sc{$tgt}{users}{lc $event->{nick}}{jointime}) > 90) {
$txtz .= " ($msg) $hilite !att-$tgt-opalert";
}
+ my $uuid = $::log->incident($tgt, "$tgt: $event->{nick} requested op attention\n");
+ $txtz = $txtz . ' ' . ASM::Shortener->shorturl($::settings->{web}->{detectdir} . $uuid . '.txt');
my @tgts = ASM::Util->getAlert($tgt, 'opalert', 'msgs');
ASM::Util->sendLongMsg($conn, \@tgts, $txtz);
- $::log->incident($tgt, "$tgt: $event->{nick} requested op attention\n");
} else {
unless (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})) {
my @tgts = ASM::Util->getAlert($tgt, 'opalert', 'msgs');
diff --git a/lib/ASM/Inspect.pm b/lib/ASM/Inspect.pm
index 3d44729..e18572d 100644
--- a/lib/ASM/Inspect.pm
+++ b/lib/ASM/Inspect.pm
@@ -6,6 +6,8 @@ use strict;
use Data::Dumper;
use String::Interpolate qw(interpolate);
use HTTP::Request;
+use ASM::Shortener;
+
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
%::ignored = ();
@@ -128,6 +130,8 @@ sub inspect {
"\x02$event->{nick}\x02 - ${nicereason}; ping ";
$txtz = $txtz . ASM::Util->commaAndify(ASM::Util->getAlert(lc $chan, $dct{$id}{risk}, 'hilights')) if (ASM::Util->getAlert(lc $chan, $dct{$id}{risk}, 'hilights'));
$txtz = $txtz . ' !att-' . $chan . '-' . $dct{$id}{risk};
+ my $uuid = $::log->incident($chan, "$chan: $dct{$id}{risk} risk: $event->{nick} - $nicereason\n");
+ $txtz = $txtz . ' ' . ASM::Shortener->shorturl($::settings->{web}->{detectdir} . $uuid . '.txt');
if ($id eq 'last_measure_regex') { #TODO: Note that this is another example of things that shouldn't be hardcoded, but are.
}
@@ -140,7 +144,6 @@ sub inspect {
$conn->schedule(45, sub { delete($::ignored{$chan}) if $::ignored{$chan} == $::RISKS{$dct{$id}{risk}} });
$::ignored{$chan} = $::RISKS{$dct{$id}{risk}};
}
- $::log->incident($chan, "$chan: $dct{$id}{risk} risk: $event->{nick} - $nicereason\n");
}
}
}
diff --git a/lib/ASM/Log.pm b/lib/ASM/Log.pm
index a362b53..ef204f0 100644
--- a/lib/ASM/Log.pm
+++ b/lib/ASM/Log.pm
@@ -6,6 +6,8 @@ use strict;
use ASM::Util;
use POSIX qw(strftime);
+use Data::UUID;
+
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
sub new
@@ -16,6 +18,7 @@ sub new
$self->{CONFIG} = $::settings->{log};
$self->{backlog} = {};
$self->{CONN} = $conn;
+ $self->{UUID} = Data::UUID->new;
bless($self);
mkdir($self->{CONFIG}->{dir});
$conn->add_handler('public', sub { logg($self, @_); }, "before");
@@ -36,13 +39,15 @@ sub incident
my $self = shift;
my ($chan, $header) = @_;
$chan = lc $chan;
- open(FH, '>>', 'dctlog.txt');
+ my $uuid = $self->{UUID}->create_str();
+ open(FH, '>', $self->{CONFIG}->{detectdir} . $uuid . '.txt');
print FH $header;
if (defined($self->{backlog}->{$chan})) {
print FH join('', @{$self->{backlog}->{$chan}});
}
print FH "\n\n";
close(FH);
+ return $uuid;
}
#writes out the backlog to a file which correlates to ASM's SQL actionlog table