forked from lausser/check_logfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
winconfig.pl
executable file
·127 lines (123 loc) · 4.64 KB
/
winconfig.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
use strict;
use File::Basename;
use Getopt::Long qw(:config no_ignore_case getopt_compat);
# --with-seekfiles-dir=PATH sets directory for the state files (default=/tmp)
# --with-protocols-dir=PATH sets directory for the protocol files (default=/tmp)
# --with-trusted-path=PATH sets trusted path for executables called by scripts (default=/bin:/sbin:/usr/bin:/usr/sbin)
# --with-perl=PATH sets path to perl executable
# --with-gzip=PATH sets path to gzip executable
my($opt_with_seekfiles_dir, $opt_with_protocols_dir, $opt_with_trusted_path,
$opt_with_perl, $opt_with_gzip);
my $release = "";
open CFGAC, "configure.ac";
while (<CFGAC>) {
$release = $1 if /^AC_INIT\(.*,([\d\.]+)\)/;
}
close CFGAC;
if (! GetOptions(
"with-seekfiles-dir=s" => \$opt_with_seekfiles_dir,
"with-protocols-dir=s" => \$opt_with_protocols_dir,
"with-trusted-path=s" => \$opt_with_trusted_path,
"with-perl=s" => \$opt_with_perl,
"with-gzip=s" => \$opt_with_gzip,
)) {
printf "nonono\n";
exit;
}
$opt_with_seekfiles_dir = 'C:\TEMP' if ! $opt_with_seekfiles_dir;
$opt_with_protocols_dir = 'C:\TEMP' if ! $opt_with_protocols_dir;
$opt_with_trusted_path = '' if ! $opt_with_trusted_path;
$opt_with_perl = 'C:\strawberry\perl\bin\perl' if ! $opt_with_perl;
$opt_with_gzip = '' if ! $opt_with_gzip;
if (open CHECKLOGFILES, ">./plugins-scripts/check_logfiles") {
printf CHECKLOGFILES "#! %s -w\n", $opt_with_perl;
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/Tivoli/Config/Logfile.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/CheckLogfiles.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/CheckLogfiles/Search/Psloglist.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/CheckLogfiles/Search/Dumpel.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/CheckLogfiles/Search/Eventlog.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/CheckLogfiles/Search/Wevtutil.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPM, './plugins-scripts/Nagios/CheckLogfiles/Search/Dummy.pm') {
while(<CHECKLOGFILESPM>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPM;
}
if (open CHECKLOGFILESPL, './plugins-scripts/check_logfiles.pl') {
while(<CHECKLOGFILESPL>) {
s/^1;//g;
s/#SEEKFILES_DIR#/$opt_with_seekfiles_dir/g;
s/#PROTOCOLS_DIR#/$opt_with_protocols_dir/g;
s/#TRUSTED_PATH#/$opt_with_trusted_path/g;
s/#PACKAGE_VERSION#/$release/g;
printf CHECKLOGFILES "%s", $_;
}
close CHECKLOGFILESPL;
}
close CHECKLOGFILES;
}