-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral_report.pl
70 lines (37 loc) · 1020 Bytes
/
general_report.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/local/bin/perl -wT
use strict;
use warnings;
my $REPORTS_DIRECTORY = '/tmp/cron_services_list/';
my $GENERAL_REPORTS_DIRECTORY = "/tmp/cron_general/";
my %scripts_hash = summary();
foreach my $script (keys %scripts_hash){
chomp $script;
if($script eq '' ){
next;
}
if( -f $script){
open (FH,'>>',$GENERAL_REPORTS_DIRECTORY."general_report_$$.txt") or die $!;
print FH $script."\n";
}else{
open (FH,'>>',$GENERAL_REPORTS_DIRECTORY."ne_general_report_$$.txt") or die $!;
print FH $script."\n";
}
close FH;
}
print STDERR '[' . scalar (localtime) . ']' . " REPORT FINISHED!\n";
sub summary {
my %scripts_hash = ();
opendir my $dh, $REPORTS_DIRECTORY or die $!;
my @reports = readdir $dh;
foreach my $report (@reports){
if($report eq '.' or $report eq '..'){
next;
}
open(FH,'<',$REPORTS_DIRECTORY.$report ) or die $!;
while (my $script = <FH>){
$scripts_hash{$script} = $script;
}
close FH;
}
return %scripts_hash;
}