Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Data::Dumper;
- use Switch;
- use 5.010;
- use File::Path qw( make_path rmtree );
- use File::Find;
- use File::Slurp qw( read_dir );
- use File::Spec::Functions qw( catfile catdir );
- my $dh; # handle
- while (1){
- our %threshold = ();
- my $path = "check";
- my @sub_dirs = grep { -d } map { catdir $path, $_ } read_dir $path;
- for my $subdir (@sub_dirs){
- if ( !opendir ($dh, $subdir)) {
- warn "Unable to open $subdir: $!\n";
- return;
- }
- my @files = grep { $_ ne '.' && $_ ne '..' } readdir($dh);
- my %readdir_map = map { $_ => 1 } @files;
- foreach (keys %threshold) {
- if (! exists $readdir_map{$_}) {
- delete $threshold{$_};
- my $site = "$_";
- # RVBDCC::hipchat::recover($config, $site);
- print "$_ has been deleted\n";
- }
- }
- my $count = scalar (@files);
- if ( $count > 0 ) {
- for my $file (@files) {
- $threshold{$file} +=1;
- # #$scm_config->{site} = $file;
- switch ($threshold{$file})
- {
- case 1 {print "Alert Detected for $file\n"}#{get_alert($file)}
- case 5 {print "Hipchat message for $file\n"} #{RVBDCC::hipchat::alert($config, $scm_config, $file)}
- case 10 {print "Sending mail notification for $file to rlaborius\@riverbed.com\n"}#{RVBDCC::email::mail($config, $scm_config, $file)}
- case 15 {print "Sending mail notification for $file to roc\@riverbed.com\n"}
- }
- sleep 1;
- }
- }
- else{
- #RVBDCC::hipchat::self_check($config);
- sleep 3;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement