import base struct

This commit is contained in:
Arne Baeumler 2015-10-05 11:28:14 +02:00
commit ed39ebe568
11 changed files with 316 additions and 0 deletions

24
cgi-bin/graph.pl Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/perl
use strict;
use warnings;
use RRDs;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $TMPLpath = "/var/www/mrtg/tmpl";
my $cgi = new CGI;
my $graph = $cgi->param('graph');
$|++;
print $cgi->header(-type => "image/png");# unless($ARGV[0]);
if($graph) {
if(open(RRD,"<$TMPLpath/$graph.tmpl")) {
my @opts = <RRD>;
close(RRD);
chomp(@opts);
RRDs::graph("-",@opts) or die(RRDs::error);
}
}

31
config/nas.cfg Normal file
View File

@ -0,0 +1,31 @@
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
WorkDir: /var/www/mrtg/rrd
LogFormat: rrdtool
Target[nas.eth0]: #eth0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn:
Title[nas.eth0]: [nas] eth0
MaxBytes[nas.eth0]: 4294967295
Target[nas.tap0]: #tap0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn:
Title[nas.tap0]: [nas] tap0
MaxBytes[nas.tap0]: 4294967295
Target[nas.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn + ssCpuRawSystem.0&ssCpuRawSystem.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn + ssCpuRawNice.0&ssCpuRawNice.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn
Title[nas.cpu]: [nas] CPU Load
MaxBytes[nas.cpu]: 100
Options[nas.cpu]: gauge
Target[nas.memtotal]: ( .1.3.6.1.4.1.2021.4.5.0&.1.3.6.1.4.1.2021.4.5.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn ) - ( .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.6.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn )
Title[nas.memtotal]: [nas] Memory Usage
MaxBytes[nas.memtotal]: 409600
Options[nas.memtotal]: gauge
Target[nas.swap]:( .1.3.6.1.4.1.2021.4.3.0&.1.3.6.1.4.1.2021.4.3.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn ) - ( .1.3.6.1.4.1.2021.4.4.0&.1.3.6.1.4.1.2021.4.4.0:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn)
Title[nas.swap]: [nas] Swap Usage
MaxBytes[nas.swap]: 409600
Options[nas.swap]: gauge
Target[nas.temp]: .1.3.6.1.2.1.25.1.8&.1.3.6.1.2.1.25.1.8:jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn / 1000
Title[nas.temp]: [nas] CPU Temperature
MaxBytes[nas.temp]: 20000
Options[nas.temp]: gauge

14
config/nas.ok Normal file
View File

@ -0,0 +1,14 @@
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Descr eth0 2
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Descr lo 1
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Descr tap0 3
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Eth 1
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Eth b8-27-eb-8b-a7-b3 2
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Eth ba-0f-a1-41-fa-ed 3
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Ip 10.0.0.100 3
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Ip 127.0.0.1 1
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Ip 192.168.178.100 2
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Name eth0 2
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Name lo 1
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Name tap0 3
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Type 24 1
jai3hoiv6aiNg5eikaezie1aengeen7o@nas.vpn_ Type 6 Dup

1
config/oid-mib-cache.txt Normal file
View File

@ -0,0 +1 @@
ssCpuRawUser 1.3.6.1.4.1.2021.11.50

118
htdocs/index.html Normal file
View File

@ -0,0 +1,118 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>MRTG Index Page</TITLE>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-15" >
<META HTTP-EQUIV="Refresh" CONTENT="600" >
<META HTTP-EQUIV="Cache-Control" content="no-cache" >
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" >
<META HTTP-EQUIV="Expires" CONTENT="Thu, 24 Sep 2015 06:08:12 GMT" >
<LINK HREF="favicon.ico" rel="shortcut icon" >
<link rel="stylesheet" type="text/css" href="style.css"/>
</HEAD>
<BODY>
<H1>MRTG Index Page</H1>
<h2>br0tkasten.de</h2>
<div>
<div>
<B>[br0tkasten.de] eth0</B><br/>
<div><A HREF="br0tkasten.eth0.html"><IMG ALT="br0tkasten.eth0 Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.eth0"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] tap0</B><br/>
<div><A HREF="br0tkasten.tap0.html"><IMG ALT="br0tkasten.tap0 Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.tap0"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] Active CPU Load %</B><br/>
<div><A HREF="br0tkasten.cpu.html"><IMG ALT="br0tkasten.cpu Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.cpu"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] Memory Usage</B><br/>
<div><A HREF="br0tkasten.memtotal.html"><IMG ALT="br0tkasten.memtotal Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.memtotal"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] Swap Usage</B><br/>
<div><A HREF="br0tkasten.swap.html"><IMG ALT="br0tkasten.swap Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.swap"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] Process Statistics</B><br/>
<div><A HREF="br0tkasten.procs.html"><IMG ALT="br0tkasten.procs Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.procs"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] Established connections</B><br/>
<div><A HREF="br0tkasten.estconn.html"><IMG ALT="br0tkasten.estconn Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.estconn"></A></DIV>
</div>
<div>
<B>[br0tkasten.de] number of users</B><br/>
<div><A HREF="br0tkasten.users.html"><IMG ALT="br0tkasten.users Traffic Graph" SRC="/cgi-bin/graph.pl?graph=br0tkasten.users"></A></DIV>
</div>
</div>
<br/>
<h2>Kodi</h2>
<div>
<div>
<B>[kodi] eth0</B><br/>
<div><A HREF="kodi.eth0.html"><IMG ALT="kodi.eth0 Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.eth0"></A></DIV>
</div>
<div>
<B>[kodi] tap0</B><br/>
<div><A HREF="kodi.tap0.html"><IMG ALT="kodi.tap0 Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.tap0"></A></DIV>
</div>
<div>
<B>[kodi] Active CPU Load %</B><br/>
<div><A HREF="kodi.cpu.html"><IMG ALT="kodi.cpu Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.cpu"></A></DIV>
</div>
<div>
<B>[kodi] Memory Usage</B><br/>
<div><A HREF="kodi.memtotal.html"><IMG ALT="kodi.memtotal Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.memtotal"></A></DIV>
</div>
<div>
<B>[kodi] Swap Usage</B><br/>
<div><A HREF="kodi.swap.html"><IMG ALT="kodi.swap Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.swap"></A></DIV>
</div>
<div>
<B>[kodi] CPU Temperature</B><br/>
<div><A HREF="kodi.temp.html"><IMG ALT="kodi.temp Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.temp"></A></DIV>
</div>
<div>
<B>[kodi] TV on/off</B><br/>
<div><A HREF="kodi.tv.html"><IMG ALT="kodi.tv Traffic Graph" SRC="/cgi-bin/graph.pl?graph=kodi.tv"></A></DIV>
</div>
</div>
<br/>
<h2>NAS</h2>
<div>
<div>
<B>[nas] eth0</B><br/>
<div><A HREF="nas.eth0.html"><IMG ALT="nas.eth0 Traffic Graph" SRC="/cgi-bin/graph.pl?graph=nas.eth0"></A></DIV>
</div>
<div>
<B>[nas] tap0</B><br/>
<div><A HREF="nas.tap0.html"><IMG ALT="nas.tap0 Traffic Graph" SRC="/cgi-bin/graph.pl?graph=nas.tap0"></A></DIV>
</div>
<div>
<B>[nas] Active CPU Load %</B><br/>
<div><A HREF="nas.cpu.html"><IMG ALT="nas.cpu Traffic Graph" SRC="/cgi-bin/graph.pl?graph=nas.cpu"></A></DIV>
</div>
<div>
<B>[nas] Memory Usage</B><br/>
<div><A HREF="nas.memtotal.html"><IMG ALT="nas.memtotal Traffic Graph" SRC="/cgi-bin/graph.pl?graph=nas.memtotal"></A></DIV>
</div>
<div>
<B>[nas] Swap Usage</B><br/>
<div><A HREF="nas.swap.html"><IMG ALT="nas.swap Traffic Graph" SRC="/cgi-bin/graph.pl?graph=nas.swap"></A></DIV>
</div>
<div>
<B>[nas] CPU Temperature</B><br/>
<div><A HREF="nas.temp.html"><IMG ALT="nas.temp Traffic Graph" SRC="/cgi-bin/graph.pl?graph=nas.temp"></A></DIV>
</div>
</div>
</BODY>
</HTML>

96
htdocs/style.css Executable file
View File

@ -0,0 +1,96 @@
html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
body {
font-family: Verdana, Arial, sans-serif;
font-size: 12px;
background: #101010;
color: #E0E0E0;
margin: 0;
padding: 0;
height: 99%;
width: 100%;
}
hr {
border: 1px solid #B0B0B0;
width: 100%;
text-align: center;
}
input {
background-color: #FDFFEE;
border: 1px solid #2E1500;
color: #2E1500;
padding: 2px 3px;
}
p {
font-size:14px;
}
a {
text-decoration: none;
color: #A0A0A0;
font-weight: bold;
}
a:hover {
color: #E0E0E0;
font-weight: bold;
}
ul {
margin-left: 1em;
margin-bottom: 2px;
margin-top: 2px;
padding: 0px;
}
li {
margin-left: 1em;
}
h1 {
color: #E0E0E0;
font-size: 18px;
}
h2 {
color: #e0e0e0;
font-size: 16px;
width: 100%;
text-align: left;
border-bottom: 1px solid #cacaca;
margin-top: 3em;
margin-bottom: 0;
}
h3 {
color: #e0e0e0;
font-size: 14px;
}
h4 {
color: #e0e0e0;
font-size: 12px;
}
br {
clear: both;
}
hr {
clear: both;
}
div {
float: left;
background-color: #404040;
margin: 0.5em;
}

BIN
rrd/nas.tap0.rrd Normal file

Binary file not shown.

BIN
rrd/nas.temp.rrd Normal file

Binary file not shown.

10
run.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
MRTG="/usr/bin/mrtg"
CFGDIR="/var/www/mrtg/config"
for cfg in $CFGDIR/*.cfg;
do
LANG=C $MRTG "$cfg" &
done

12
tmpl/nas.tap0.tmpl Normal file
View File

@ -0,0 +1,12 @@
-v in/out
-t [nas] tap0
--color=BACK#909090
--color=CANVAS#C5C5C5
DEF:in=/var/www/mrtg/rrd/nas.tap0.rrd:ds0:AVERAGE
DEF:out=/var/www/mrtg/rrd/nas.tap0.rrd:ds1:AVERAGE
CDEF:invout=out,-1,*
AREA:in#25679F#7E99B0:Down
AREA:invout#25679F#7E99B0:Up
LINE1:in#040404
LINE1:invout#040404
LINE1:0#000000

10
tmpl/nas.temp.tmpl Normal file
View File

@ -0,0 +1,10 @@
-v Celsius
-t [nas] Temperature
--color=BACK#909090
--color=CANVAS#C5C5C5
DEF:in=/var/www/mrtg/rrd/nas.temp.rrd:ds0:AVERAGE
CDEF:red=in,54,GT,in,UNKN,IF
CDEF:green=in,54,GT,54,in,IF
AREA:red#FF0000
AREA:green#00FF00
LINE1:in#040404