--- generate-overview.pl 2003/05/24 12:21:42 1.10 +++ generate-overview.pl 2003/11/03 10:30:48 1.16 @@ -27,6 +27,9 @@ # Target can be skipped in overview report with skip-overview +my $path; +my $gBaseURL; + BEGIN { # $gInstallRoot = (($0 =~ m:^(.*/):)[0] || "./") . "."; require '/etc/cricket/cricket-conf.pl'; @@ -36,7 +39,7 @@ # $gBaseURL = "http://localhost/~cricket/grapher.cgi"; my $hostname = `hostname -f`; chomp($hostname); - $gBaseURL = "http://$hostname/cgi-bin/cricket/grapher.cgi"; + $gBaseURL = "/cgi-bin/cricket/grapher.cgi"; # change this to destination directory $path = "/data/mon/"; @@ -44,6 +47,7 @@ #use lib "$gInstallRoot/../lib"; use lib "$Common::global::gInstallRoot/lib"; +use strict; use File::Basename; use LWP::UserAgent; @@ -67,7 +71,7 @@ initConst(); $Common::global::gCT = new ConfigTree::Cache; -$gCT = $Common::global::gCT; +my $gCT = $Common::global::gCT; $gCT->Base($Common::global::gConfigRoot); $gCT->Warn(\&Warn); @@ -116,14 +120,15 @@ print OUT "$key"; print OUT ' ' if ($filename =~ m/Daily/i); - print OUT <<'HTMLEND' if ($dynamic_js); + print OUT ''; + my $html=<<'HTMLEND'; HTMLEND + if ($dynamic_js) { + my $cookie_name = $key; + $cookie_name =~ s/[^a-zA-Z0-9]//g; + $html =~ s/##cookie_name##/$cookie_name/g; + print OUT $html; + } + print OUT ""; close(OUT); @@ -251,10 +282,10 @@ my ($desc,$url,$img) = @_; if ($dynamic_js) { my $html =<<'HTMLEND'; - -##desc## + +##desc## - + HTMLEND @@ -272,11 +303,15 @@ sub localHandleTargetInstance { my($Name, $target) = @_; - $targetpath = $target->{'auto-target-path'}; - $targetname = $target->{'auto-target-name'}; + my $targetpath = $target->{'auto-target-path'}; + my $targetname = $target->{'auto-target-name'}; - if (! defined($target->{'skip-overview'})) - { + my @skip_views = split(/[\s,]+/,$target->{'skip-view'}) if ($target->{'skip-view'}); +print "### ",join("|",@skip_views),"\n"; + + if (defined($target->{'skip-overview'})) { + Info("Skipping target $targetname."); + } else { Info("Working on target $targetname."); my($reqRanges,@ranges); @@ -295,7 +330,7 @@ foreach $range (@ranges) { - $rangeLabel = rangeToLabel($range); + my $rangeLabel = rangeToLabel($range); my($paramtarget) = "$targetpath/$targetname"; @@ -312,18 +347,21 @@ # find the ds names based on the target type my($ttype) = lc($target->{'target-type'}); - my($ttRef) = $main::gCT->configHash($Name, 'targettype', $ttype, $target); + my($ttRef) = $gCT->configHash($Name, 'targettype', $ttype, $target); # If there are views defined, then we generate graphs # for each view. my($dslist); - if (defined($ttRef->{'view'})) - { + if (defined($ttRef->{'view'})) { my($v); - foreach $v (split(/\s*,\s*/, $ttRef->{'view'})) - { + foreach $v (split(/\s*,\s*/, $ttRef->{'view'})) { + my ($view_name,undef) = split(/\s*:\s*/,$v); + if (grep(/$view_name/,@skip_views)) { + Info("Skip view $v"); + next; + } # views are like this: "cpu: cpu1load cpu5load" my($vname, $dss) = split(/\s*:\s*/, $v, 2); @@ -331,7 +369,7 @@ $dslist =~ s/\s*$//; $dslist =~ s/\s+/,/g; - $URL = "$gBaseURL?type=png&target=$paramtarget"; + my $URL = "$gBaseURL?type=png&target=$paramtarget"; $URL .= "&dslist=$dslist&range=$paramrange"; my $desc = "$paramtarget $vname"; $desc .= " ".$target->{'short-desc'}."" if (defined $target->{'short-desc'}); @@ -341,7 +379,7 @@ Info("Retrieving graph for $desc"); # getURL($URL,"$path/$name-$vname-$rangeLabel.png"); - $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname"; + my $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname"; $html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL); } } else { @@ -349,7 +387,7 @@ # squeeze out any extra spaces $dslist = join(',', split(/\s*,\s*/, $dslist)); - $URL = "$gBaseURL?type=png&target=$paramtarget"; + my $URL = "$gBaseURL?type=png&target=$paramtarget"; $URL .= "&dslist=$dslist&range=$paramrange"; my $desc ="$paraminst $rangeLabel"; $desc .= " ".$target->{'short-desc'}."" if (defined $target->{'short-desc'}); @@ -360,7 +398,7 @@ Info("Retrieving graph for $desc"); # getURL($URL,"$path/$name-$rangeLabel.png"); - $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y"; + my $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y"; $html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL); } }