Skip to content

Commit

Permalink
mrtg-2.17.7 (#12)
Browse files Browse the repository at this point in the history
* Update to HTML 5 template in bin/mrtg, corrected style

* version 2.17.7
  • Loading branch information
moxsh authored and oetiker committed Jul 12, 2018
1 parent 741a657 commit b51d650
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 32 deletions.
8 changes: 7 additions & 1 deletion src/CHANGES
@@ -1,3 +1,10 @@
Changes 2.17.7, 2018-07-12
--------------------------
From: Martin Sechny, shenk.sk
* update to HTML 5 template in bin/mrtg, checked by HTML+CSS W3C validator
* corrected style in HTML template: color with background-color
(workaround for missing text color property in mrtg.cfg)

Changes 2.17.6, 2014-12-02
--------------------------
From: tobi
Expand All @@ -13,7 +20,6 @@ Changes 2.17.5, 2012-04-26
From: Pavel Gulchouck <gul@gul.kiev.ua>
* fix for kmg option coredump


Changes 2.17.4, 2012-01-12
--------------------------
From: tobi
Expand Down
68 changes: 37 additions & 31 deletions src/bin/mrtg
Expand Up @@ -2,7 +2,7 @@
# -*- mode: cperl -*-

###################################################################
# MRTG 2.17.4 Multi Router Traffic Grapher
# MRTG 2.17.7 Multi Router Traffic Grapher
###################################################################
# Created by Tobias Oetiker <tobi@oetiker.ch>
# and Dave Rand <dlr@bungi.com>
Expand Down Expand Up @@ -1592,32 +1592,31 @@ sub writehtml {
my $dirrel = "../" x ($$rcfg{'directory_web'}{$router} =~ tr|/|/|);

$Today=&$LOC(datestr(time));
$VERSION = "2.17.4";
$VERSION = "2.17.7";
open (HTML,">$$cfg{'htmldir'}$$rcfg{'directory'}{$router}$router.$$rcfg{'extension'}{$router}") ||
do { warn ("$NOW: WARNING: Writing $router.$$rcfg{'extension'}{$router}: $!");
next };
# this unforutnately confuses IE greatly ... so we have to comment
# this unforutnately confuses old IE greatly ... so we have to comment
# it out for now ... :-(
# print HTML '<?xml version="1.0" encoding="' . &$LOC('iso-8859-1') . '"?>' . "\n";
print HTML '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/dtd/xhtml11.dtd">' . "\n";
print HTML "<html>\n";
# print HTML '<?xml version="1.0" encoding="' . &$LOC('UTF-8') . '"?>' . "\n";
print HTML '<!DOCTYPE html>' . "\n";
print HTML '<html lang="en">' . "\n";
my $interval =$$cfg{'interval'};
my $expiration = &expistr($interval);
my $refresh = defined $$cfg{'refresh'} ? $$cfg{'refresh'} : 300;
my $namestring = &$LOC("the device");
print HTML "<!-- Begin Head -->\n";
print HTML <<"TEXT";
<head>
<title>$$rcfg{'title'}{$router}</title>
<meta http-equiv="refresh" content="$refresh" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="$expiration" />
<meta http-equiv="generator" content="MRTG $VERSION" />
<meta http-equiv="date" content="$expiration" />
TEXT
print HTML "\t\t" . '<meta http-equiv="content-type" content="text/html; charset='.&$LOC('iso-8859-1') . "\" />\n";

my $namestring = &$LOC("the device");
print HTML '<!-- MRTG ' . "$VERSION" . ' -->' . "\n";
print HTML '<!-- Begin Head -->' . "\n";
print HTML "\t" . '<head>' . "\n";
print HTML "\t\t" . '<meta charset="' . &$LOC('UTF-8') . '" />' . "\n";
print HTML "\t\t" . '<meta http-equiv="refresh" content="' . "$refresh" . '" />' . "\n";
# Not functional in HTML file in modern web browsers - use HTTP header instead
# <meta http-equiv="pragma" content="no-cache" />
# <meta http-equiv="cache-control" content="no-cache" />
# <meta http-equiv="expires" content="$expiration" />
# <meta http-equiv="generator" content="MRTG $VERSION" />
# <meta http-equiv="date" content="$expiration" />
print HTML "\t\t" . '<title>' . "$$rcfg{'title'}{$router}" . '</title>' . "\n";
foreach $peri (qw(d w m y)) {
print HTML <<"TEXT";
<!-- maxin $peri $$maxin{$peri}{$router} -->
Expand All @@ -1637,7 +1636,6 @@ TEXT
<!-- avpercent $peri $$avpercent{$peri}{$router} -->
TEXT
}

print HTML "<!-- cuin $peri $$cuin{$peri}{$router} -->\n"
if defined $$cuin{$peri}{$router};
print HTML "<!-- cuout $peri $$cuout{$peri}{$router} -->\n"
Expand Down Expand Up @@ -1666,10 +1664,16 @@ TEXT
$$rcfg{'rgb5'}{$router} = "" unless defined $$rcfg{'rgb5'}{$router};
$$rcfg{'rgb6'}{$router} = "" unless defined $$rcfg{'rgb6'}{$router};

print HTML "
<style type=\"text/css\">
print HTML " <style>
body {
background-color: $$rcfg{'backgc'}{$router};
";
if($$rcfg{'backgc'}{$router} eq '#ffffff') {
print HTML " color: #000000;";
} else {
print HTML " color: #ffffff;";
}
print HTML "
}
div {
border-bottom: 2px solid #aaa;
Expand All @@ -1696,7 +1700,7 @@ TEXT
color: $$rcfg{'rgb2'}{$router};
}";

print HTML "
print HTML "
div table .inpeak th {
color: $$rcfg{'rgb3'}{$router};
}
Expand Down Expand Up @@ -1749,11 +1753,13 @@ TEXT

$$rcfg{addhead}{$router} =~ s/\\n/\n/g if defined $$rcfg{addhead}{$router};

print HTML "
$$rcfg{'addhead'}{$router}
print HTML "$$rcfg{'addhead'}{$router}
</head>
<!-- End Head -->";
print HTML "
$$rcfg{bodytag}{$router}
$$rcfg{'pagetop'}{$router}";
$$rcfg{'pagetop'}{$router}
";
print HTML "<p>";
if (defined $$rcfg{'timezone'}{$router}){
print HTML
Expand All @@ -1767,8 +1773,7 @@ $$rcfg{'pagetop'}{$router}";
",<br />\n".
&$LOC("at which time $namestring had been up for <strong>$uptime</strong>.")
}
print HTML "</p>\n<!-- End Head -->";

print HTML "</p>";
my %sample= ('d' => "`Daily' Graph (".$interval.' Minute',
'w' => "`Weekly' Graph (30 Minute",
'm' => "`Monthly' Graph (2 Hour",
Expand Down Expand Up @@ -1911,7 +1916,8 @@ print HTML "
print HTML "
</table>
</div>
<!-- End Legend -->";
<!-- End Legend -->
";
}

if (!(defined $$rcfg{'options'}{'nobanner'}{$router})) {
Expand Down Expand Up @@ -1976,7 +1982,7 @@ TEXT
print HTML <<TEXT
</address>
</div>
<!-- End MRTG Block -->
<!-- End MRTG Block -->
TEXT
}

Expand Down

0 comments on commit b51d650

Please sign in to comment.