-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of baltig.sandia.gov:scot/SCOT
- Loading branch information
Showing
445 changed files
with
47,501 additions
and
13,369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ scot-ui/build/static/js/ | |
scot-ui/build/ | ||
.vscode/ | ||
emailapi.cfg.pl | ||
local/ | ||
**/*.log | ||
**/foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env perl | ||
|
||
use lib '../lib'; | ||
use lib '/opt/scot/lib'; | ||
use Data::Dumper; | ||
use Scot::Env; | ||
use v5.16; | ||
|
||
my $env = Scot::Env->new(config_file=>'/opt/scot/etc/scot.cfg.pl'); | ||
my $mongo = $env->mongo; | ||
|
||
my $agcol = $mongo->collection('Alertgroup'); | ||
my $acol = $mongo->collection('Alert'); | ||
|
||
my $start = $ARGV[0]; | ||
my $end = $ARGV[1]; | ||
|
||
if ( !defined $start or !defined $end ) { | ||
die "usage error: $0 start_id end_id"; | ||
} | ||
|
||
if ( $start > $end ) { | ||
my $tmp = $start; | ||
$start = $end; | ||
$end = $tmp; | ||
} | ||
|
||
my $agcursor = $agcol->find({ | ||
'$and' => [ | ||
{ id => { '$gte' => $start + 0 } }, | ||
{ id => { '$lte' => $end + 0 }}, | ||
], | ||
}); | ||
|
||
while ( my $ag = $agcursor->next ) { | ||
|
||
my $agid = $ag->id + 0; | ||
|
||
print "Bulk closing Alertgroup $agid\n"; | ||
|
||
my $acursor = $acol->find({alertgroup => $agid}); | ||
my $count = 0; | ||
while (my $alert = $acursor->next) { | ||
|
||
print " closing alert ".$alert->id."\n"; | ||
|
||
$alert->update({ | ||
'$set' => { status => 'closed' }, | ||
}); | ||
$count++; | ||
|
||
} | ||
print " updating alertgroup stats\n"; | ||
$ag->update({ | ||
'$set' => { | ||
status => 'closed', | ||
closed_count => $count, | ||
open_count => 0, | ||
promoted_count => 0, | ||
updated => time(), | ||
}, | ||
}); | ||
|
||
print " sending mq message to browsers\n"; | ||
$env->mq->send("/topic/scot", { | ||
action => 'updated', | ||
data => { | ||
who => 'scot-admin', | ||
type => 'alertgroup', | ||
id => $agid, | ||
}, | ||
}); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env perl | ||
|
||
use lib '../lib'; | ||
use lib '/opt/scot/lib'; | ||
use Data::Dumper; | ||
use Scot::Env; | ||
use File::Slurp; | ||
|
||
my $env = Scot::Env->new(config_file=>'/opt/scot/etc/scot.cfg.pl'); | ||
my $mongo = $env->mongo; | ||
my $csvfile = "/tmp/bulk.csv"; | ||
|
||
my @lines = read_file($csvfile); | ||
|
||
foreach my $line (@lines) { | ||
|
||
my @row = split(',',$line); | ||
|
||
my $ipaddr = $row[0]; | ||
my $subnet = $row[1]; | ||
my $machine = $row[2]; | ||
my $make = $row[3]; | ||
my $site = $row[4]; | ||
my $area = $row[5]; | ||
my $building = $row[6]; | ||
my $room = $row[7]; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use lib '../lib'; | ||
|
||
use Scot::Env; | ||
use Scot::Email::Processor; | ||
|
||
my $config = "/opt/scot/etc/email_processing.cfg.pl"; | ||
my $env = Scot::Env->new(config_file => $config); | ||
my $processor = Scot::Email::Processor->new({env => $env}); | ||
|
||
my $flag = $ARGV[0]; | ||
|
||
unless ($flag) { | ||
$processor->run(); | ||
} | ||
|
||
if ( $flag eq "-d" ) { | ||
$processor->dump_messages() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env perl | ||
|
||
# start a Scot::Email::Responder to watch a queue | ||
# first argument is the responder type. eg: | ||
# to start Scot::Email::Responder::Dispatch the | ||
# first arg is "dispatch" | ||
|
||
use strict; | ||
use warnings; | ||
use lib '../lib'; | ||
use Scot::Env; | ||
use Module::Runtime qw(require_module); | ||
use Try::Tiny; | ||
|
||
my $config = "/opt/scot/etc/email_processing.cfg.pl"; | ||
my $env = Scot::Env->new(config_file => $config); | ||
|
||
my $resptype = $ARGV[0]; | ||
|
||
if ( ! defined $resptype ) { | ||
$env->log->logdie("Failed to provide command line argument 0: Responder type"); | ||
} | ||
|
||
my $class = "Scot::Email::Responder::$resptype"; | ||
|
||
try { | ||
require_module($class); | ||
} | ||
catch { | ||
$env->log->logdie("$_. Failed to load Module $class! Ensure module name patched a responder in /opt/scot/lib/Scot/Email/Responder."); | ||
}; | ||
|
||
my $queue = $env->responders->{$class}->{queue}; | ||
|
||
|
||
my $responder = $class->new({env => $env, queue => $queue}); | ||
$responder->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env perl | ||
|
||
use lib '../lib'; | ||
use lib '../../Scot-Internal-Modules/lib'; | ||
use Scot::Env; | ||
use Data::Dumper; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
my $env = Scot::Env->new(config_file => '/opt/scot/etc/scot.cfg.pl'); | ||
my $mongo = $env->mongo; | ||
|
||
my $col = $mongo->collection('Entity'); | ||
my $cursor = $col->find(); | ||
$cursor->immortal(1); | ||
|
||
while (my $entity = $cursor->next) { | ||
my $id = $entity->id; | ||
my $data = $entity->data; | ||
if ( defined $data->{splunk} ) { | ||
if (defined $data->{splunkit}) { | ||
printf "%10d SplunkIt present, deleting splunk button\n",$id; | ||
delete $data->{splunk}; | ||
$entity->update({'$set' => { data => $data }}); | ||
} | ||
else { | ||
my $orig = delete $data->{splunk}; | ||
my $title = $orig->{data}->{title}; | ||
my $url = $orig->{data}->{url}; | ||
|
||
(my $newtitle = $title) =~ s/Splunk/SplunkIt/g; | ||
(my $newurl = $url) =~ s/splunk/splunkit/g; | ||
|
||
print "$id Changing Data => \n"; | ||
print " $newtitle\n"; | ||
print " $newurl\n"; | ||
|
||
$orig->{data} = { | ||
title => $newtitle, | ||
url => $newurl, | ||
}; | ||
|
||
$data->{splunkit} = $orig; | ||
|
||
$entity->update({'$set' => { data => $data }}); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use lib '../lib'; | ||
use lib '../../lib'; | ||
use lib '../../Scot-Internal-Modules/lib'; | ||
use lib '/opt/scot/lib'; | ||
# use Scot::Flair::Worker; | ||
use Scot::Flair::Worker; | ||
use Scot::Env; | ||
use Data::Dumper; | ||
use utf8::all; | ||
use Carp qw(cluck longmess shortmess); | ||
use feature qw(say); | ||
|
||
my $env = Scot::Env->new(config_file => '/opt/scot/etc/flair.cfg.pl'); | ||
my $log = $env->log; | ||
|
||
die unless defined $env and ref($env) eq "Scot::Env"; | ||
|
||
$SIG{__DIE__} = sub { our @reason =@_}; | ||
|
||
END { | ||
our @reason; | ||
if (@reason) { | ||
say "Flair Diead because: @reason"; | ||
$env->log->error("Flair died because: ", {filter => \&Dumper, value =>\@reason}); | ||
} | ||
} | ||
|
||
|
||
my $loop = Scot::Flair::Worker->new(env => $env); | ||
$loop->run(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env perl | ||
|
||
use lib '../lib'; | ||
use lib '/opt/scot/lib'; | ||
use strict; | ||
use warnings; | ||
|
||
use Data::Dumper; | ||
use Scot::Env; | ||
use Scot::Email::Scheduler; | ||
|
||
my $dry = $ARGV[0]; | ||
my $pidfile = '/var/run/inbox.pid'; | ||
|
||
if ( -s $pidfile ) { | ||
die "$pidfile exists. Kill running $0 and delete $pidfile to continue"; | ||
} | ||
|
||
open my $pidfh, ">", $pidfile or die "Unable to create PID file $pidfile!"; | ||
print $pidfh "$$"; | ||
close $pidfh; | ||
|
||
# my $config = "../../Scot-Internal-Modules/etc/email.cfg.pl"; | ||
my $config = "/opt/scot/etc/inbox.cfg.pl"; | ||
my $env = Scot::Env->new(config_file => $config); | ||
|
||
my $options = { env => $env }; | ||
$options->{dry_run} = 1 if defined $dry; | ||
|
||
my $sched = Scot::Email::Scheduler->new($options); | ||
$sched->run(); | ||
|
||
system("rm -f $pidfile"); |
Oops, something went wrong.