]> git.zerfleddert.de Git - upsgraph/blob - upsgraph.pl
e291cc73abe6f7efd6f014346e2e790e4d72bf65
[upsgraph] / upsgraph.pl
1 #!/usr/bin/perl -w
2
3 #Due to memory leak in Debian squeeze (Bug #545519)
4 my $use_rrds = 0;
5 my $rrd_result = 0;
6
7 if ((@ARGV != 1) && (@ARGV != 2)) {
8 print STDERR "Syntax: ${0} configfile [uid]\n";
9 exit(1);
10 }
11
12 use Net::SNMP;
13 use IO::Socket::INET;
14 use IO::Select;
15 use RRDs;
16 use File::Copy;
17 use Data::Dumper;
18
19 $UPSGRAPH::outdir = "";
20 $UPSGRAPH::daysCovered = 370;
21 $UPSGRAPH::step = 60;
22 $UPSGRAPH::stepsPerHour = (60 * 60) / $UPSGRAPH::step;
23 $UPSGRAPH::keep = ($UPSGRAPH::daysCovered*24*60*60)/$UPSGRAPH::step;
24 $UPSGRAPH::keepHours = ($UPSGRAPH::daysCovered*24*60*60)/$UPSGRAPH::stepsPerHour/$UPSGRAPH::step;
25 $UPSGRAPH::hosts = ();
26 $UPSGRAPH::regenerateOnStart = 1; #when set, regenerate graphs on script startup
27
28 do $ARGV[0] or die "can't read config: $!";
29
30 my $outdir = $UPSGRAPH::outdir;
31 my $step = $UPSGRAPH::step;
32 my $stepsPerHour = $UPSGRAPH::stepsPerHour;
33 my $keep = $UPSGRAPH::keep;
34 my $keepHours = $UPSGRAPH::keepHours;
35 my $hosts = $UPSGRAPH::hosts;
36
37 sub rrd_update(@) {
38 my @args = @_;
39 print "Updating: ". Dumper(\@_);
40 if ($use_rrds == 1) {
41 RRDs::update(@args);
42 $rrd_result = RRDs::error;
43 } else {
44 $rrd_result = system("rrdtool", "update", @args);
45 }
46 }
47
48 sub rrd_graph(@) {
49 my @args = @_;
50 my @rrd_out = ();
51 print "Graphing: " . Dumper(\@_);
52 if ($use_rrds == 1) {
53 @rrd_out = RRDs::graph(@args);
54 $rrd_result = RRDs::error;
55 } else {
56 my $rrd_stdout;
57
58 open(RRDFD, '-|', 'rrdtool', 'graph', @args);
59 while(<RRDFD>) {
60 chomp;
61 $rrd_stdout = $_;
62 }
63 close(RRDFD);
64 $rrd_result = $?;
65 if ($rrd_result == 0) {
66 push @rrd_out, 0;
67 push @rrd_out, split(/x/, $rrd_stdout);
68 }
69 }
70
71 return @rrd_out;
72 }
73
74 sub rrdcreate(@) {
75 my $newrrd = shift;
76 my $field = shift;
77 my $vars = shift;
78 my $start = shift;
79
80 my @cmd = ("${newrrd}", "--step=${step}");
81
82 if (defined($start)) {
83 push @cmd, "--start=${start}";
84 }
85
86 push @cmd, "DS:${field}:GAUGE:600:" .
87 $vars->{$field}->{'min'} . ":" .
88 $vars->{$field}->{'max'};
89
90 push @cmd, "RRA:AVERAGE:0.5:1:${keep}";
91 push @cmd, "RRA:MIN:0.4:${stepsPerHour}:${keepHours}";
92 push @cmd, "RRA:MAX:0.4:${stepsPerHour}:${keepHours}";
93
94 RRDs::create(@cmd);
95 if (RRDs::error) {
96 print "Error while creating: " . RRDs::error . "\n";
97 print Dumper(\@cmd);
98 exit 1;
99 }
100 }
101
102 sub fetch_snmp(@) {
103 my $address = shift;
104 my $community = shift;
105 my $oid = shift;
106
107 (my $session, my $error) = Net::SNMP->session(Hostname => $address,
108 Community => $community);
109
110 if (!$session) {
111 print STDERR "session error: $error";
112 return undef;
113 }
114
115 $session->translate(0);
116
117 my $result = $session->get_request($oid);
118
119 $session->close;
120
121 return undef if (!defined($result));
122
123 $result->{$oid};
124 }
125
126 sub fetch_tcp(@) {
127 my $address = shift;
128 my $port = shift;
129
130 my $sock = IO::Socket::INET->new(PeerAddr => $address,
131 PeerPort => $port,
132 Proto => 'tcp',
133 Timeout => 1);
134
135 return undef if (!$sock);
136
137 my $select = IO::Select->new($sock);
138
139 my $value = undef;
140
141 if ($select->can_read(1)) {
142 chomp($value) if (sysread($sock, $value, 4096) > 0);
143 }
144
145 close($sock);
146
147 if (!$value) {
148 return undef;
149 }
150
151 $value=~ s/\s//g;
152
153 $value;
154 }
155
156 sub fetch_tcp_multi(@) {
157 my $address = shift;
158 my $port = shift;
159 my $delimiter = shift;
160 my %values;
161
162 my $sock = IO::Socket::INET->new(PeerAddr => $address,
163 PeerPort => $port,
164 Proto => 'tcp',
165 Timeout => 1);
166
167 return undef if (!$sock);
168
169 my $select = IO::Select->new($sock);
170
171 while($select->can_read(1)) {
172 if (sysread($sock, my $buf, 16384) > 0) {
173 $buf=~s/\r//g;
174 foreach my $line (split(/\n/, $buf)) {
175 (my $key, my $value) = split(/${delimiter}/, $line);
176 $value=~ s/\s//g;
177 $values{$key} = $value;
178 }
179 } else {
180 last;
181 }
182 }
183
184 close($sock);
185
186 %values;
187 }
188
189 sub dayGraphFunc {
190 my $dataSrc = shift;
191 my $mode = shift;
192 my $color = shift;
193 my $label = shift;
194 my $dataPoints = shift;
195 my @args = ();
196 push @args, "CDEF:prev${mode}1=PREV(${dataSrc})";
197 for (my $i = 1; $i < $dataPoints - 1; ++$i) {
198 my $prev = $i;
199 my $next = $i+1;
200 push @args, "CDEF:prev${mode}${next}=PREV(prev${mode}${prev})";
201 }
202 my $dayCons = '';
203 my $consFunc = '';
204 for (my $i = 1; $i < $dataPoints; ++$i) {
205 $dayCons .= "prev${mode}${i},";
206 $consFunc .= ",${mode}";
207 }
208 push @args, "CDEF:day${mode}=${dayCons}${dataSrc}${consFunc}";
209 push @args, "CDEF:fillCalDay${mode}0=COUNT,${dataPoints},%,0,EQ,day${mode},UNKN,IF";
210 for (my $i = 1; $i < $dataPoints; ++$i) {
211 my $prev = $i-1;
212 my $next = $i;
213 push @args, "CDEF:fillCalDay${mode}${next}=PREV(fillCalDay${mode}${prev})";
214 }
215 my $fillPoint = '';
216 my $if = '';
217 for (my $i = 0; $i < $dataPoints; ++$i) {
218 $fillPoint .= "COUNT,${dataPoints},%,${i},EQ,fillCalDay${mode}${i},";
219 $if .= ",IF";
220 }
221 push @args, "CDEF:${mode}Curve=${fillPoint}UNKN${if}";
222 my $forwardShift = (24*60*60) * ($dataPoints - 1) / $dataPoints;
223 push @args, "SHIFT:${mode}Curve:-${forwardShift}";
224 push @args, "LINE1:${mode}Curve#${color}:${label}";
225 return \@args;
226 }
227
228 sub cfgToGraphDef {
229 my $cfg = shift;
230 my $varname = shift;
231 my $dpPerDay= shift;
232 my @graphDef = ();
233 foreach my $subGraph (@$cfg) {
234 if ($subGraph eq 'avg') {
235 push @graphDef, "LINE1:${varname}-avg#FF0000";
236 } elsif ($subGraph eq 'day-min') {
237 push @graphDef, @{dayGraphFunc("${varname}-min", 'MIN', '0000ff', 'Day Minimum Temperature', $dpPerDay)};
238 } elsif ($subGraph eq 'day-max') {
239 push @graphDef, @{dayGraphFunc("${varname}-max", 'MAX', '00ff00', 'Day Maximum Temperature', $dpPerDay)};
240 }
241 }
242 return \@graphDef;
243 }
244
245 if ($> == 0) {
246 if (@ARGV != 2) {
247 print STDERR "Running as root, please provide UID as 2th argument!\n";
248 exit(1);
249 }
250
251 print "Running as root, switching to ".$ARGV[1]."\n";
252 $< = $> = $ARGV[1];
253 }
254
255 foreach my $host (@$hosts) {
256 my $rrdfile = $host->{'rrdfile'};
257
258 foreach my $var (keys(%{$host->{'vars'}})) {
259 $host->{'vars'}->{$var}->{'min'} = 'U' if (!defined($host->{'vars'}->{$var}->{'min'}));
260 $host->{'vars'}->{$var}->{'max'} = 'U' if (!defined($host->{'vars'}->{$var}->{'max'}));
261 }
262
263 if (-e "${rrdfile}") {
264 print "Reading old ${rrdfile} to preserve data...\n";
265
266 my $rrdinfo = RRDs::info("${rrdfile}");
267 if (RRDs::error) {
268 print "Error while getting info: " . RRDs::error . "\n";
269 exit 1;
270 }
271
272 (my $start, my $ostep, my $names, my $data) =
273 RRDs::fetch("${rrdfile}",
274 "-s " . (time() - ($rrdinfo->{'rra[0].rows'} * $rrdinfo->{'step'})),
275 "AVERAGE");
276
277 if (RRDs::error) {
278 print "Error while fetching data: " . RRDs::error . "\n";
279 exit 1;
280 }
281
282 foreach my $field (@$names) {
283 if (! -e "${rrdfile}.${field}") {
284 rrdcreate("${rrdfile}.${field}",
285 "${field}",
286 $host->{'vars'},
287 (${start}-${ostep}));
288 }
289 }
290
291 my $pos = $start;
292 foreach my $line (@$data) {
293 foreach my $field (@$names) {
294 my $val = shift (@$line);
295 $val = 'U' if (!defined($val));
296
297 RRDs::update("${rrdfile}.${field}", "${pos}:${val}");
298 if (RRDs::error) {
299 print "Can't insert data: " . RRDs::error . "\n";
300 exit 1;
301 }
302
303 }
304
305 $pos += $ostep;
306
307 if ((($pos-$start)/$ostep) == $#$data) {
308 last;
309 }
310 }
311
312 rename("${rrdfile}", "${rrdfile}.old") or die "Can't rename old file: $!\n";
313 }
314
315 foreach my $field (@{$host->{'fields'}}) {
316 if (! -e "${rrdfile}.${field}") {
317 print "Creating ${rrdfile}.${field}...\n";
318 rrdcreate("${rrdfile}.${field}",
319 "${field}",
320 $host->{'vars'});
321 }
322
323 my $rrdinfo = RRDs::info("${rrdfile}.${field}");
324 if (RRDs::error) {
325 print "Error while getting info: " . RRDs::error . "\n";
326 exit 1;
327 }
328
329 my $limitsChanged = 0;
330 if (defined($rrdinfo->{"ds[${field}].min"})) {
331 if ($rrdinfo->{"ds[${field}].min"} ne $host->{'vars'}->{$field}->{'min'}) {
332 $limitsChanged = 1;
333 RRDs::tune("${rrdfile}.${field}","-i",$field.":".$host->{'vars'}->{$field}->{'min'});
334 }
335 } else {
336 if ($host->{'vars'}->{$field}->{'min'} ne 'U') {
337 $limitsChanged = 1;
338 RRDs::tune("${rrdfile}.${field}","-i",$field.":".$host->{'vars'}->{$field}->{'min'});
339 }
340 }
341
342 if (RRDs::error) {
343 print "Error while setting min: " . RRDs::error . "\n";
344 exit 1;
345 }
346
347 if (defined($rrdinfo->{"ds[${field}].max"})) {
348 if ($rrdinfo->{"ds[${field}].max"} ne $host->{'vars'}->{$field}->{'max'}) {
349 $limitsChanged = 1;
350 RRDs::tune("${rrdfile}.${field}","-a",$field.":".$host->{'vars'}->{$field}->{'max'});
351 }
352 } else {
353 if ($host->{'vars'}->{$field}->{'max'} ne 'U') {
354 $limitsChanged = 1;
355 RRDs::tune("${rrdfile}.${field}","-a",$field.":".$host->{'vars'}->{$field}->{'max'});
356 }
357 }
358
359 if (RRDs::error) {
360 print "Error while setting max: " . RRDs::error . "\n";
361 exit 1;
362 }
363
364 if ($rrdinfo->{'rra[0].rows'} != $keep ||
365 !defined($rrdinfo->{'rra[1].rows'}) || $rrdinfo->{'rra[1].rows'} != $keepHours ||
366 $limitsChanged == 1) {
367
368 print "Resizing ${rrdfile}.${field} from " . $rrdinfo->{'rra[0].rows'} .
369 " to ${keep} samples.\n";
370
371 (my $start, my $ostep, my $names, my $data) =
372 RRDs::fetch("${rrdfile}.${field}",
373 "-s " . (time() - ($rrdinfo->{'rra[0].rows'} * $rrdinfo->{'step'})),
374 "AVERAGE");
375
376 if (RRDs::error) {
377 print "Error while fetching data: " . RRDs::error . "\n";
378 exit 1;
379 }
380
381 rrdcreate("${rrdfile}.${field}.new",
382 "${field}",
383 $host->{'vars'},
384 (${start}-${ostep}));
385
386 print "Preserving data in file ${rrdfile}.${field} since " . localtime($start) . "\n";
387
388 my $pos = $start;
389 foreach my $line (@$data) {
390 my $vline = "${pos}";
391
392 foreach my $val (@$line) {
393 $val = 'U' if (!defined($val));
394 $vline .= ":${val}";
395 }
396 RRDs::update("${rrdfile}.${field}.new", $vline) or die "Can't insert data\n";
397
398 if (RRDs::error) {
399 print "Error while updating: " . RRDs::error . "\n";
400 exit 1;
401 }
402 $pos += $ostep;
403
404 if ((($pos-$start)/$ostep) == $#$data) {
405 last;
406 }
407 }
408
409 rename("${rrdfile}.${field}", "${rrdfile}.${field}.old") or die "Can't rename old file: $!\n";
410 rename("${rrdfile}.${field}.new", "${rrdfile}.${field}") or die "Can't rename new file: $!\n";
411
412 $rrdinfo = RRDs::info("${rrdfile}.${field}");
413 if (RRDs::error) {
414 print "Error while getting info: " . RRDs::error . "\n";
415 exit 1;
416 }
417
418 if ($rrdinfo->{'rra[0].rows'} != $keep) {
419 print "Failed!\n";
420 exit 1;
421 }
422 }
423 }
424 }
425
426 #my $child = fork();
427 #
428 #die "fork failed!" if (!defined($child));
429 #
430 #exit 0 if ($child != 0);
431
432 my $first = $UPSGRAPH::regenerateOnStart;
433 while(1) {
434 open(HTML, ">${outdir}/index.html.new");
435
436 print HTML '<html><head><meta http-equiv="refresh" content="60"/><meta http-equiv="cache-control" content="no-cache"/><meta http-equiv="pragma" content="no-cache"/><meta http_equiv="expires" content="Sat, 26 Jul 1997 05:00:00 GMT"/><title>Status</title></head>';
437 print HTML '<body bgcolor="#ffffff">';
438
439 foreach my $host (@$hosts) {
440 print HTML "[<a href=\"#".${host}->{'name'}."\">".${host}->{'name'}."</a>]&nbsp;";
441 }
442 print HTML "<br>\n";
443
444 foreach my $host (@$hosts) {
445 print HTML "<br>\n";
446 print HTML "<a name=\"".${host}->{'name'}."\"></a>\n";
447 my $vars = $host->{'vars'};
448 my $rrdfile = $host->{'rrdfile'};
449 my $hostname = $host->{'name'};
450 my %multi_values = ();
451
452 foreach my $var (@{$host->{'fields'}}) {
453 delete $vars->{$var}->{'value'};
454
455 my $result;
456
457 if ((!defined($vars->{$var}->{'proto'})) ||
458 ($vars->{$var}->{'proto'} eq '') ||
459 ($vars->{$var}->{'proto'} eq 'snmp')) {
460 $result = fetch_snmp($host->{'address'}, $host->{'community'}, $vars->{$var}->{'oid'});
461 } elsif ($vars->{$var}->{'proto'} eq 'tcp') {
462 $result = fetch_tcp($host->{'address'}, $vars->{$var}->{'port'});
463 } elsif ($vars->{$var}->{'proto'} eq 'tcp_multi') {
464 if (defined($multi_values{$vars->{$var}->{'multi_id'}})) {
465 $result = $multi_values{$vars->{$var}->{'multi_id'}}
466 } else {
467 my %values = fetch_tcp_multi($host->{'address'}, $vars->{$var}->{'port'}, $vars->{$var}->{'multi_delimiter'});
468 @multi_values{keys %values} = values %values;
469 $result = $multi_values{$vars->{$var}->{'multi_id'}};
470 }
471 }
472
473 next unless (defined $result);
474
475 $vars->{$var}->{'value'} = $result;
476 if (defined($vars->{$var}->{'factor'})) {
477 $vars->{$var}->{'value'} *= $vars->{$var}->{'factor'};
478 }
479 }
480
481 foreach my $var (@{$host->{'fields'}}) {
482 if (!(defined($vars->{$var}->{'value'}))) {
483 $vars->{$var}->{'value'} = 'U';
484 }
485 rrd_update("${rrdfile}.${var}", "N:" . $vars->{$var}->{'value'});
486 }
487 if ($rrd_result) {
488 print "Error while updating: " . $rrd_result . "\n";
489 }
490
491 foreach my $var (@{$host->{'fields'}}) {
492 my $graphWidth = 365 * 3;
493 my $graphConfig;
494 if (defined $vars->{$var}->{'graph'}) {
495 $graphConfig = $vars->{$var}->{'graph'};
496 foreach my $subGraph (qw(day week year)) {
497 if (!defined($graphConfig->{$subGraph})) {
498 $graphConfig->{$subGraph} = [ 'avg'];
499 }
500 }
501 } else {
502 $graphConfig = {
503 'day' => [ 'avg' ],
504 'week' => [ 'avg' ],
505 'year' => [ 'avg' ],
506 };
507 }
508
509 my @graphdef = ('-P', "-t", $hostname." - ".$vars->{$var}->{'name'});
510 push @graphdef, "--lazy" if !$first;
511
512 push @graphdef, "DEF:${var}-avg=${rrdfile}.${var}:${var}:AVERAGE";
513 push @graphdef, "DEF:${var}-min=${rrdfile}.${var}:${var}:MIN";
514 push @graphdef, "DEF:${var}-max=${rrdfile}.${var}:${var}:MAX";
515 push @graphdef, "LINE1:${var}-avg#FF0000";
516 push @graphdef, "VDEF:cur=${var}-avg,LAST";
517 push @graphdef, 'GPRINT:cur:Current\\: <span foreground="#FF0000">%.2lf</span>\\r';
518
519 my $mtime;
520 $mtime=(stat("${outdir}/${hostname}.${var}.png.work"))[9];
521
522 (my $averages, my $width, my $height) =
523 rrd_graph("${outdir}/${hostname}.${var}.png.work",
524 "-w", "720", @graphdef);
525
526 pop @graphdef;
527 pop @graphdef;
528 pop @graphdef;
529
530 if ($rrd_result) {
531 print "Error while graphing: " . $rrd_result . "\n";
532 } else {
533 my $newmtime=(stat("${outdir}/${hostname}.${var}.png.work"))[9];
534 if ((!defined($mtime)) || ($newmtime != $mtime)) {
535 copy("${outdir}/${hostname}.${var}.png.work", "${outdir}/${hostname}.${var}.png.new");
536 rename("${outdir}/${hostname}.${var}.png.new", "${outdir}/${hostname}.${var}.png");
537 }
538 }
539
540 print HTML "<a href=\"${hostname}.${var}.html\"><img src=\"${hostname}.${var}.png\" width=\"${width}\" height=\"${height}\" border=\"0\"></a><br>\n";
541
542 open (HTML2, ">${outdir}/${hostname}.${var}.html.new");
543 print HTML2 '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="refresh" content="60"/><meta http-equiv="cache-control" content="no-cache"/><meta http-equiv="pragma" content="no-cache"/><meta http_equiv="expires" content="Sat, 26 Jul 1997 05:00:00 GMT"/><title>' . $vars->{$var}->{'name'} . '</title></head>';
544 print HTML2 '<body bgcolor="#ffffff">';
545
546 push @graphdef, "VDEF:min=${var}-min,MINIMUM";
547 push @graphdef, "GPRINT:min:Minimum\\: %.2lf";
548
549 push @graphdef, "VDEF:avg=${var}-avg,AVERAGE";
550 push @graphdef, "GPRINT:avg:Average\\: %.2lf";
551
552 push @graphdef, "VDEF:max=${var}-max,MAXIMUM";
553 push @graphdef, "GPRINT:max:Maximum\\: %.2lf";
554
555 push @graphdef, "VDEF:cur=${var}-avg,LAST";
556 push @graphdef, "GPRINT:cur:Current\\: %.2lf";
557
558 my @dayGraphDef = @graphdef;
559 push @dayGraphDef, @{cfgToGraphDef($graphConfig->{'day'}, ${var}, 24)};
560
561 $mtime=(stat("${outdir}/${hostname}.${var}.long.png.work"))[9];
562 ($averages, $width, $height) =
563 rrd_graph("${outdir}/${hostname}.${var}.long.png.work",
564 "-w", $graphWidth, @dayGraphDef);
565
566 if ($rrd_result) {
567 print "Error while graphing: " . $rrd_result . "\n";
568 } else {
569 my $newmtime=(stat("${outdir}/${hostname}.${var}.long.png.work"))[9];
570 if ((!defined($mtime)) || ($newmtime != $mtime)) {
571 copy("${outdir}/${hostname}.${var}.long.png.work", "${outdir}/${hostname}.${var}.long.png.new");
572 rename("${outdir}/${hostname}.${var}.long.png.new", "${outdir}/${hostname}.${var}.long.png");
573 }
574 }
575
576 print HTML2 "<img src=\"${hostname}.${var}.long.png\" width=\"${width}\" height=\"${height}\"><br>\n";
577
578 $mtime=(stat("${outdir}/${hostname}.${var}.week.png.work"))[9];
579
580 my @weekGraphDef = @graphdef;
581 push @weekGraphDef, @{cfgToGraphDef($graphConfig->{'week'}, ${var}, 24)};
582
583 ($averages, $width, $height) =
584 rrd_graph("${outdir}/${hostname}.${var}.week.png.work",
585 "-w", "$graphWidth", "-e", "now", "-s", "00:00-8d", @weekGraphDef);
586
587 if ($rrd_result) {
588 print "Error while graphing: " . $rrd_result . "\n";
589 } else {
590 my $newmtime=(stat("${outdir}/${hostname}.${var}.week.png.work"))[9];
591 if ((!defined($mtime)) || ($newmtime != $mtime)) {
592 copy("${outdir}/${hostname}.${var}.week.png.work", "${outdir}/${hostname}.${var}.week.png.new");
593 rename("${outdir}/${hostname}.${var}.week.png.new", "${outdir}/${hostname}.${var}.week.png");
594 }
595 }
596
597 print HTML2 "<img src=\"${hostname}.${var}.week.png\" width=\"${width}\" height=\"${height}\"><br>\n";
598
599 $mtime=(stat("${outdir}/${hostname}.${var}.year.png.work"))[9];
600
601 my @yearGraphDef = @graphdef;
602 push @yearGraphDef, @{cfgToGraphDef($graphConfig->{'year'}, ${var}, 3)};
603
604 ($averages, $width, $height) =
605 rrd_graph("${outdir}/${hostname}.${var}.year.png.work",
606 "-w", "$graphWidth", "-e", "00:00", "-s", "end-365d", @yearGraphDef);
607
608 if ($rrd_result) {
609 print "Error while graphing: " . $rrd_result . "\n";
610 } else {
611 my $newmtime=(stat("${outdir}/${hostname}.${var}.year.png.work"))[9];
612 if ((!defined($mtime)) || ($newmtime != $mtime)) {
613 copy("${outdir}/${hostname}.${var}.year.png.work", "${outdir}/${hostname}.${var}.year.png.new");
614 rename("${outdir}/${hostname}.${var}.year.png.new", "${outdir}/${hostname}.${var}.year.png");
615 }
616 }
617
618 print HTML2 "<img src=\"${hostname}.${var}.year.png\" width=\"${width}\" height=\"${height}\"><br>\n";
619
620 print HTML2 "</body></html>\n";
621 close(HTML2);
622 rename("${outdir}/${hostname}.${var}.html.new", "${outdir}/${hostname}.${var}.html");
623 }
624 }
625
626 print HTML "</body></html>\n";
627 print HTML "<br>Generated on: " . localtime(time());
628 print HTML ' by <a href="http://git.zerfleddert.de/cgi-bin/gitweb.cgi/upsgraph">upsgraph</a>.';
629
630 close(HTML);
631
632 rename("${outdir}/index.html.new", "${outdir}/index.html");
633
634 sleep(${step}/2);
635 $first = 0;
636 }
Impressum, Datenschutz