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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
|
#!/usr/bin/perl -Tw
# vim:syntax=perl
# $Id: lr_config.cgi.in,v 1.9 2001/11/28 11:15:53 bozuk Exp $
#
# Copyright (C) 2000-2001 Stichting LogReport Foundation LogReport@LogReport.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see COPYING); if not, check with
# http://www.gnu.org/copyleft/gpl.html or write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
#
# lr_config - interactively configure Lire
# inspiration: texconfig, configure-ntp, gpmconfig, paperconfig
use strict;
use POSIX;
use CGI ':all';
use CGI::Debug( report => 'errors' );
#use CGI qw/:all -nosticky/;
$ENV{PATH}='/usr/bin:/bin:/sbin:/usr/sbin';
my $use_gd=1;
eval { require GD::Graph;};
if ($@) {
$use_gd=0;
}
my $prefix="@prefix@";
my $exec_prefix="@prefix@";
my $debug=1;
my $KEEP_default="";
my $LR_SPOOLINTERVAL=300;
my $LR_SPOOLINTERVAL_default=10;
my $LR_MAX_MEMORY_default="40Megs";
# call it LR_TMPDIR for now. TMPDIR interferes with some sh's way
# to create here documents. This variable will be used as TMPDIR
# in the to be created config files.
my $TMPDIR_default="@prefix@/tmp";
my $DISCLAIMERFILE="@sysconfdir@/@PACKAGE@/disclaimer";
my $DISCLAIMERFILE_default="@sysconfdir@/@PACKAGE@/disclaimer.local";
my $LOGGING='stderr';
my $LOGGING_default='syslog';
my $DEBUG_default="";
my $from_default="LogReport Responder <log\@logreport.org>";
my $REPORTFILTERS_www_default="filter_pics filter_trackpage";
my $TRACKRE_www_filter_trackpage_default='/tar\.gz$/';
my $ITEMS_www_pagesperclienthost=30;
my $ITEMS_www_pagesperclienthost_default=60;
my $PAGES_www_pagesperclienthost=5;
my $PAGES_www_pagesperclienthost_default=10;
my @superservices=("dns", "email", "firewall", "ftp", "www", "print");
my %services;
$services{'apachemodgzip'}=["apachemodgzip"];
$services{'dns'}=["bind8","bind9"];
$services{'email'}=["exim","postfix", "qmail", "sendmail"];
$services{'www'}=["common", "combined","referer","modgzip","w3c_extended"];
$services{'print'}=["cups","lprng"];
$services{'ftp'}=["xferlog"];
$services{'firewall'}=["cisco", "ipchains", "ipfilter"];
my $to_default_all_all="postmaster";
my $subject_default_all_all="\`hostname\` \`date +%Y%m%d\`";
my $log_default = {
'apachemodgzip' => {
'apachemodgzip'=>'/var/log/apache/gzip.0'
},
'dns' => {
'bind8'=>"/var/log/named_querylog.0",
'bind9'=>"/var/log/named_querylog.0"
},
'email' => {
'exim'=>"/var/log/exim/mainlog.0",
'postfix'=>"/var/log/mail.log.0",
'qmail'=>"/service/qmail-send/log/main/current",
'sendmail'=>"/var/log/mail.log.0"
},
'www' => {
'combined'=>"/var/log/apache/combined.log.0",
'common'=>"/var/log/apache/common.log.0",
'referer'=>"/var/log/apache/referer.log.0",
'modgzip'=>"/var/log/apache/gzip.0",
'w3c_extended'=>'EMPTY'
},
'ftp' => {
'xferlog'=>"/var/log/xferlog.0"
},
'firewall' => {
'cisco'=>"/var/log/messages.0",
'ipchains'=>"/var/log/messages.0",
'ipfilter'=>"/var/log/ipflog.0.gz"
},
'print' => {
'cups'=>"/var/log/cups/page_log",
'lprng'=>"/var/log/lp-acct"
}
};
my $filter_default = {
'apachemodgzip' => {
'apachemodgzip'=>'/var/log/apache/gzip.0'
},
'dns' => {
'bind8'=>"cat",
'bind9'=>"cat"
},
'email' => {
'exim'=>"cat",
'postfix'=>"grep postfix",
'qmail'=>"tai64nfrac",
'sendmail'=>"grep sendmail"
},
'www' => {
'combined'=>"cat",
'common'=>"cat",
'referer'=>"cat",
'modgzip'=>"cat",
'w3c_extended'=>"cat"
},
'ftp' => {
'xferlog'=>"cat"
},
'firewall' => {
'cisco'=>"cat",
'ipchains'=>"grep 'Packet Log: '",
'ipfilter'=>"gzip -dc"
},
'print' => {
'cups'=>"cat",
'lprng'=>"cat"
}
};
my $localfile="@sysconfdir@/@PACKAGE@/defaults.local";
my $defaultsfile="@sysconfdir@/@PACKAGE@/defaults";
my $deffile="@sysconfdir@/@PACKAGE@/cron.defaults.local";
my $period="weekly";
my $date=asctime(localtime);
my $hostname=`hostname`;
print header,start_html(-title=>"Logreport config",-script=>{-language=>'JAVASCRIPT', -src=>'../lr_config.js'});
my $id=getuid;
my @a=getpwuid($id);
my $homedir=$a[7];
if ($id==0) {
print "Error: don't run me as root, but as the user who's supposed to run the Lire scripts";
exit;
}
my $LR_TMPDIR="$homedir/tmp";
# General introduction
my $step=param('step');
$step=1 if not defined $step;
$step++ if (defined(param('Next' )) and param('Next' ) ne '') ;
print h1({-align=>"center"},"Step $step"),br,br,hr,br;
param("step",$step);
if ($debug) {
print startform(-name=>'main',-method=>"GET");
}else{
print startform(-name=>'main',-method=>"POST");
}
print hidden(-name=>"step",-value=>$step);
print hidden("lr_keep");
print hidden("lr_responder");
print hidden("lr_spoolinterval");
print hidden("lr_tmpdir");
print hidden("lr_disclaimerfile");
print hidden("lr_logging");
print hidden("lr_debug");
print hidden("lr_defaults");
print hidden("lr_target_user");
print hidden("lr_user_level");
print hidden("lr_max_memory");
print hidden("lr_scale_bytes");
print hidden("lr_scale_sec");
print hidden("lr_scale_number");
print hidden("lr_disclamer");
print hidden("lr_include_images");
if (defined(param('lr_defaults')) and param('lr_defaults') eq 'Yes') {
print hidden("lr_subject");
print hidden("lr_to_all");
}
print hidden("lr_format");
my $lr_to_all=param("lr_to_all");
my $num_services=0;
for(@superservices){
my $s=$_;
my $svcs2=$services{$_};
print hidden("lr_collect_$s");
$num_services++ if defined(param("lr_collect_$s")) and param("lr_collect_$s") eq 'Yes';
for(@$svcs2) {
print hidden("lr_from_$s\_$_");
}
}
print hidden("lr_extra_subreports");
print hidden("lr_TRACKRE_www_filter_trackpage");
print hidden("lr_ITEMS_www_pagesperclienthost");
if (1==$step) {
print "This script enables you to configure your installation of LogReport's Lire
(see"
. a( {-href=>"http://www.logreport.org/"}," http://www.logreport.org/)").
". Lire converts various services' logfiles
to human readable reports. First I'll ask you some questions about
the systems preferred general setup, later I'll ask you about preferences
for specific services. I'll create local configuration files
under ${prefix}/etc/lire, and
save the answers in these files. These files are shellscripts; if needed,
you can give shellcode as answer to questions.
You should run this script as the user who's gonna run the Lire scripts.
This user should be able to read the logfiles you want to get processed.";
print br,hr,br,"Did you start this script as this user?";
print radio_group(-name=>"sameuser",-values=>['Yes','No']);
} elsif (2==$step) {
my $sameuser=param('sameuser');
if ($sameuser eq "No") {
print "Please run this script as the user who is going to run lire !" ;
print end_html;
exit;
}
my $testfile="${prefix}/etc/lire/foo.local";
my $r=open(IN,">$testfile");
if (not $r) {
print "Error: you can't create files in ${prefix}/etc/lire/ . Please".
" make sure you've got write access there, as well as in".
" ${prefix}/etc/lire/ 's subdirectories.";
goto endofscript;
}
close(IN);
if ( not unlink($testfile)) {
print "Error: you can't create files in ${prefix}/etc/lire/ . Please".
" make sure you've got write access there, as well as in".
" ${prefix}/etc/lire/ 's subdirectories.";
goto endofscript;
}
$r=opendir(DIR, "${prefix}/etc/lire");
if (not $r) {
print "Error: you can't read ${prefix}/etc/lire/ directory. Please".
" make sure you've got read access there !";
goto endofscript;
}
my @localfiles = grep { /\.local$/ } readdir(DIR);
closedir DIR;
if ($#localfiles > 0) {
print br;
print "There are local Lire configuration files on this system. This probably means",br,"
your Lire system is already configured. Move the files:",br,br;
map{print "${prefix}/etc/lire/$_",br} @localfiles;
print br,"out of the way if you want to reconfigure your system using this script.",br;
goto endofscript;
}
print br,hr,br,"Temporary files are by default not kept. Do you want to keep these files (e.g. for debugging purposes)?";
print radio_group(-name=>"lr_keep",-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'} );
print br,br,"Are you planning to run an online responder? (you need to manually tune your system to support this)";
print radio_group(-name=>"lr_responder",-values=>['Yes','No'], -onClick=>"clicked_single('lr_responder','lr_spoolinterval')" );
print br,br,"How many seconds should the system wait between
consecutive spoolruns? ",textfield(-name=>'lr_spoolinterval',-value=>$LR_SPOOLINTERVAL_default),br;
if ($use_gd) {
print br,br, "Lire can generate charts for some reports. Do you want charts
to be generated whenever possible ?";
print radio_group(-name=>"lr_include_images",-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'} );
}
print br,br, "Lire can scale bytes in reports to a more human readable form (22.1M, 10k, etc.). Do you want bytes fields to be scaled?",radio_group(-name=>'lr_scale_bytes',-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'});
print br,br, "Lire can scale seconds in reports to a more human readable form (1.1d, 5h, 30s, etc.). Do you want duration fields to be scaled?" ,radio_group(-name=>'lr_scale_sec',-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'});
print br,br,"Lire can scale numbers in reports to a more human readable form (5M, 3.1, etc.). Do you want numeric fields to be scaled?",radio_group(-name=>'lr_scale_number',-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'});
print br,br,"Lire can generate reports in several format :",br,
"In which format do you want to generate report by default?";
print radio_group(-name=>"lr_format",-values=>[' txt ', ' docbookx ', ' html ', ' xhtml ', ' pdf ', ' rtf ', ' logml ']);
print br,br,"Where should temporary files get stored? ",textfield(-name=>'lr_tmpdir',-value=>$LR_TMPDIR),br;
print br,br,"Do you want to sent a disclaimer with the generated reports? (In
case you're automatically sending generated reports by email.)";
print br,br,radio_group(-name=>"lr_disclaimer",-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'},-onClick=>"clicked_single('lr_disclaimer','lr_disclaimerfile')");
print br,br,"Where is the file containing the disclamer stored? ",textfield(-name=>'lr_disclaimerfile',-value=>$DISCLAIMERFILE_default),br;
print br,br,"By default, status and errormessages are sent to <B>$LOGGING</B>. Do you
want to change this to <B>$LOGGING_default</B>? (You need syslog's logger(1)
for this.)";
print radio_group(-name=>"lr_logging",-values=>['syslog','stderr'],-labels=>{syslog=>'Yes',stderr=>'No'});
print br,br,"By default, informative and debug messages are suppressed. Do you want
to run the system in debug mode? (The amount of debug messages is quite
impressive.)" ;
print radio_group(-name=>"lr_debug",-values=>['1','0'],-labels=>{1=>'Yes',0=>'No'});
print br,br,"Lire can tune its report's descriptions according to the report's reader profile. Currently, there are descriptions tailored for".br." <B>sysadmin</B> or <B>manager</B> types of user. For which kind of users are the reports intended ?";
print radio_group(-name=>"lr_target_user",-values=>['sysadmin','manager']),br;
print br,"Lire can tune the details in its report's descriptions according
to the reader's profile. Two level of details are supported :".br."
<B>normal</B> or <B>advanced</B>. Which level to you want ?";
print radio_group(-name=>"lr_user_level",-values=>['normal','advanced']),br;
print br,br,"Lire can tune its algorithm to generate reports according to the available memory and the size of the log size that is processed. What is the",br," maximum log file size that should be processed by the faster but memory hungry algorithm ? (You should set this to half your amount of available RAM.)";
print textfield(-name=>"lr_max_memory",-value=>$LR_MAX_MEMORY_default);
} elsif (3==$step) {
print hr,br,"We're done now with the general questions. We've reached the final part: I'll
ask you questions about the way various services' logfiles will get processed.
The services are categorised in 'superservices'. The superservices and their
services are:",br,br;
for(@superservices){
my $s=$_;
my $svcs2=$services{$_};
print "for superservice <B>$s</B>, services are",br,br;
map {print "<B>$_</B>",br} @$svcs2;
print hr,br;
}
print hr,br,"For each service, logfiles can get processed by a cronjob. Such a cronjob
converts a logfile to a report, and sends the report to some emailaddress.
I'm gonna build these cronjobs. (Don't worry, I'm not gonna activate them.
I'll tell you how to do that yourself later.) Therefore, I need to know
which services you're running, and I need to know the names of the logfiles.";
my $rc = open(IN,$deffile);
close (IN);
if ($rc) {
print br,"<B>Global defaults file $deffile already exists, not regenerating</B>";
print hidden("lr_defaults",'No');
} else {
print br,hr,br, "Do you want to use some default settings for all services, like the email address to send the report to?" ;
print radio_group(-name=>"lr_defaults",-values=>['Yes','No'],-onClick=>"clicked_single('lr_defaults','lr_to_all,lr_subject')");
print br,br,"Please enter your default to-address.",textfield(-name=>'lr_to_all',-value=>$to_default_all_all),br;
print br,br,"Please enter your default subject.",textfield(-name=>'lr_subject',-value=>$subject_default_all_all)," (A string like '[LogReport] www / apache report' will get added to this stem.)",br;
}
} elsif (4==$step){
for(@superservices){
my $s=$_;
my $svcs2s="";
my $svcs2=$services{$_};
map{$svcs2s.=$_.","} @$svcs2;
$svcs2s=~s/\,$//;
print br,br,"Are you collecting <B>$_</B> logfiles on this host ?",radio_group(-name=>"lr\_collect\_$s",-values=>['Yes','No'],-onCLick=>"clicked('$s','$svcs2s')");
print br,br,"Plase provide the from-address for each service: ";
for(@$svcs2) {
print br,br,"What from-address would you like to use for <B>$_</B> service ?",textfield(-name=>"lr_from_$s\_$_",-value=>$from_default),br;
}
print br,hr,br;
}
} elsif (5==$step){
for(@superservices){
my $s=$_;
my $svcs2=$services{$_};
if ($s eq "www"){
print "Do you want to generate extra subreports on specific webpages (This is only usefull if you're _not_ running a responder.)";
print radio_group(-name=>"lr_extra_subreports",-values=>['Yes','No']),br;
print br," Please specify which webpages you'd like to track. (You can give an egrep-style regexp here.)", textfield(-name=>"lr_TRACKRE_www_filter_trackpage",-value=>$TRACKRE_www_filter_trackpage_default),br,hr,br;
print br," Please specify the maximum number of lines in a 'requested pages per clienthost' subreport ";
print textfield(-name=>"lr_ITEMS_www_pagesperclienthost",-value=>$ITEMS_www_pagesperclienthost_default),br;
}
}
print br," Please specify the maximum number of pages per client, displayed in a 'requested pages per clienthost' subreport",textfield(-name=>"lr_PAGES_www_pagesperclienthost",-value=>$PAGES_www_pagesperclienthost_default);
} elsif ($step>=6 and $step<6+($num_services*2)){
my $substep=param('lr_substep');
my $subservice=param('lr_subservice');
my $i=int(($step-6)/2);
my $m=($step-6)%2;
my $s;
$subservice=0 if not defined(param('lr_subservice'));
for(@superservices){
if (param("lr_collect_$_") eq 'Yes' ){
if (0==$i) {
$s=$_;
if ($m==0){
$period='weekly';
} elsif ($m==1){
$period='daily';
}
last;
} else {
$i--;
}
}
}
my $svcs2=$services{$s};
if (not defined($substep)){
$substep=0 ;
}
if (defined(param('Next service')) and param('Next service') ne '') {
$subservice++;
}
my $s2=$_=$$svcs2[$subservice];
if (defined(param("Add file")) and param("Add file") ne '' ) {
if ( -r param("lr_$s\_$s2\_$substep\_$period")) {
$substep++;
} else {
if (param("lr_$s\_$s2\_$substep\_$period") ne '') {
print "<H1>You can't read: <B>[",param("lr_$s\_$s2\_$substep\_$period"),"]</B> file !</H1>",br,br;
} else {
print "<H1>Please first choose a file ! </H1>",br,br;
}
}
}
for (('daily','weekly')){
my $period=$_;
for (@superservices){
my $s1=$_;
my $svcs3=$services{$s1};
for (@$svcs3){
my $ss=param("lr\_substep\_$period\_$s1\_$_");
$ss=0 if not defined($ss);
$s2='' if not defined($s2);
if (($s1 ne $s) or ($s2 ne $_) or ($s2 eq '')){
print hidden("lr\_substep\_$period\_$s1\_$_") ;
}
for (my $i=0;$i<=$ss;$i++){
if (defined(param("lr_$s1\_$_\_$i\_$period")) and param("lr_$s1\_$_\_$i\_$period") ne ''){
if (-r param("lr_$s1\_$_\_$i\_$period") ) {
print hidden("lr_$s1\_$_\_$i\_$period") ;
print hidden("lr_logfiles_$s1\_$_\_$i\_$period\_filter") if param("lr_logfiles_$s1\_$_\_$i\_$period\_filter") ne '';
print hidden("lr_logfiles_$s1\_$_\_$i\_$period\_to") if param("lr_logfiles_$s1\_$_\_$i\_$period\_to") ne '';
print hidden("lr_logfiles_$s1\_$_\_$i\_$period\_subject") if param("lr_logfiles_$s1\_$_\_$i\_$period\_subject") ne '';
#print hidden("lr_logfiles_$s\_$_\_$i\_$period\_combined") if ($s1 eq 'www')
}
}
}
}
}
}
if (param("lr\_collect\_$s") eq 'Yes') {
$_=$$svcs2[$subservice];
if ( defined($_) and $_ ne '') {
param('lr_substep',$substep);
param("lr\_substep\_$period\_$s\_$_",$substep);
param('lr_subservice',$subservice);
print hidden(-name=>"lr\_substep_daily\_$s\_$_",-value=>$substep);
print hidden(-name=>"lr\_substep_weekly\_$s\_$_",-value=>$substep);
print hidden(-name=>"lr\_substep_daily\_$s\_$_",-value=>$substep);
print hidden(-name=>"lr\_substep_weekly\_$s\_$_",-value=>$substep);
print hidden(-name=>'lr_substep',-value=>$substep);
print hidden(-name=>'lr_subservice',-value=>$subservice);
print "\n\nIf any of your <B>$s</B> logfiles rotated $period ?",br;
print br,br,"Please specify <B>$_</B> logfiles that you want to collect",filefield(-name=>"lr_$s\_$_\_$substep\_$period",-default=>$$log_default{$s}->{$_}),br;
print br,br,"Filter",textfield(-name=>"lr_logfiles_$s\_$_\_$substep\_$period\_filter",-value=>'cat',-size=>180,-value=>$$filter_default{$s}->{$_}),br,hr,br,"\n\n";
print br,br,"To address",textfield(-name=>"lr_logfiles_$s\_$_\_$substep\_$period\_to",-value=>$lr_to_all,-size=>180),br,hr,br,"\n\n";
print br,br,"Subject",textfield(-name=>"lr_logfiles_$s\_$_\_$substep\_$period\_subject",-value=>$lr_to_all,-size=>80),br,hr,br,"\n\n";
#if ($s eq 'www') {
# if ($_ eq "boa" ){
# print hidden(-name=>"lr_logfiles_$s\_$_\_$substep\_$period\_combined",-value=>"common");
# }else{
# print br,br,"Type of log:",radio_group(-name=>"lr_logfiles_$s\_$_\_$substep\_$period\_combined",-values=>['combined','common']),br,br;
# }
#}
print submit(-name=>"Add file", -value=>"Add file");
print submit(-name=>"Next service", -value=>"Next Service");
} else {
print "There isn't more services in this class",br,br;
}
} else {
print br,br,h1("You choose not to collect $s logfiles on this host");
}
} elsif ($step==6+($num_services*2) ){
print br,br,h1("Creaing $localfile"),br;
if (not open(OUT,">$localfile" )){
print "Error: Cannot create file '$localfile'. Check if directory exists, and check permissions." ;
exit(1);
}
print OUT "\# $localfile - local settings for Lire\n\# system on:". $hostname.
"\# to be sourced by $defaultsfile\n". "\# automatically generated by lr_config.cgi on: ". $date;
# cannot get LR_TMPDIR in this loop, since what we call LR_TMPDIR gets
# called TMPDIR in $localfile
# KEEP LR_SPOOLINTERVAL FROM DISCLAIMERFILE LOGGING DEBUG DEFAULT_OUTPUT_FORMAT LR_TARGET_USER LR_USERLEVEL LR_MAX_MEMORY INCLUDEIMAGES
for ( "tmpdir","keep", "spoolinterval", "disclaimerfile", "logging", "debug" ,"target_user","user_level","max_memory","scale_bytes", "scale_number","scale_sec","include_images"){
if (defined(param("lr\_$_")) and param("lr\_$_") ne '' ) {
print OUT uc($_)."=",param("lr\_$_")."\n";
}
}
if (param('lr_defaults') eq 'Yes') {
if (open(DF, ">$deffile")) {
print DF 'subject="'.param('lr_subject').'"'."\n" ;
print DF 'to="'.param('lr_to_all').'"'."\n" ;
print br,h1("Wrote file '$deffile'.");
} else {
print br,br,h1("Error: Cannot create file '$deffile'. Check if directory exists, and check permissions.");
exit;
}
}
for ( ('weekly','daily')) {
my %jf;
$period=$_;
$jf{$period}='';
for(@superservices){
my $s=$_;
my $svcs2=$services{$_};
for(@$svcs2) {
if (param("lr_collect_$s") eq 'Yes') {
my $nf = param("lr_substep\_$period\_$s\_$_");
$nf=0 if not defined($nf);
for (my $i=0;$i<$nf;$i++) {
my $cf=param("lr_$s\_$_\_$i\_$period");
if (defined($cf) and $cf ne '') {
my $f="@sysconfdir@/@PACKAGE@/$s.$period.$_.$i.local";
if (open(F, ">$f")) {
$jf{$period}=$f.' ';
print F "# $f - $s $_ $period" ."\n".
"# cron config file" ."\n".
"# to be sourced by lr_cron(1)" ."\n".
"# automatically generated by lr_config(1) on ". $date ;
print F "superservice=$s\n".
"service=$_\n".
"log=".'"'.$cf.'"'."\n".
'filter="'.param("lr_logfiles_$s\_$_\_$i\_$period\_filter").'"'."\n".
'to="'.param("lr_logfiles_$s\_$_\_$i\_$period\_to").'"'."\n".
'subject="'.param("lr_logfiles_$s\_$_\_$i\_$period\_subject").'"'."\n";
if(0){
if (open(DF ,"<$deffile")){
while(<DF>){
chomp;
my @b=split(/=/,$_);
print F $b[0],"=";
if ($b[1]=~/\`/) {
my @cmd = $b[1]=~/"`(.*)`\s`(.*)`/g;
my $t='';
for (@cmd){
@a=`$_`;
chomp($a[0]);
$t.=$a[0].' ';
}
print F '"'.$t.'"',"\n";
} else {
print F $b[1],"\n";
}
}
}
}
print F "if test -r /usr/local/etc/lire/cron.defaults.local\n".
"then\n".
". /usr/local/etc/lire/cron.defaults.local\n".
"fi\n";
} else {
print br,br,h1("Error: Cannot create file '$f'. Check if directory exists, and check permissions.");
exit;
}
close(F);
}
}
}
}
}
print OUT "jobfiles_$period=".'"'.$jf{$period}.'"'."\n";
}
close(DF);
close(OUT);
print br,hr,br,h1("Congratulations, your Lire system is configured! To activate the system,"),
h1(" run"),br,
h1("{ echo '0 10 * * * ${exec_prefix}/bin/lr_cron daily'; echo '0 10 * * 0 ${exec_prefix}/bin/lr_cron weekly'; } | crontab -"),br,br,
" (that's one line). (I assume your crontab was empty untill now.) Once",br,
" activated like this, report(s) will be sent on a weekly and/or daily basis.",br,
" You can finetune your configuration, by editing the files I just wrote. Refer",br,
" to the Lire User Manual in user-manual.txt for information on syntax and",br,
" such, and for hints on how to set a whole bunch of report-specific parameters.",br,br,
" Have fun!",br,br
" The LogReport team mail to:", a({-href=>"mailto:logreport\@logreport.org"},"logreport\@logreport.org"),br,br,br;
}
print br,hr,br,submit("Next") if $step<14;
endofscript:
print end_form;
if ($debug) {
my $q=new CGI;
print hr,"DEBUG",br;
print br,$q->Dump,br;
}
print end_html;
|