MonitorSensorOutput: sensormc.cgi

File sensormc.cgi, 2.7 KB (added by human, 3 years ago)

SensorMultiColumn? for widescreen panels

Line 
1#!/usr/bin/perl
2#
3# slightly modified by Freek Reedeker 2009
4#
5# copyright Martin Pot 2003
6# http://martybugs.net/linux/hddtemp.cgi
7#
8# sensormc.cgi
9
10my @graphs;
11my $numberOfColumns, $currentColumn;
12$numberOfColumns = 2;
13
14my ($name, $descr);
15# Get available daily graphs
16# If a daily graph exists in the currrent directory it will be shown.
17# To remove a daily graph go to the /usr/local/bin/lmsensor.pl script
18# If you comment the sensor out of the "to monitor" list, its daily graph
19# will be deleted 
20my $availableGraphs = `ls *-day.png`;
21# Push them on @graphs array
22while($availableGraphs =~ m/\G(.*)-.*.png\n/g) 
23{
24        push (@graphs, $1);     
25#       print "<!--$1-->"."\n";
26}
27
28# get the server name (or you could hard code some description here)
29my $svrname = $ENV{'SERVER_NAME'};
30
31# get url parameters
32my @values = split(/&/, $ENV{'QUERY_STRING'});
33foreach my $i (@values) 
34{
35        ($varname, $mydata) = split(/=/, $i);
36        if ($varname eq 'trend')
37        {
38                $name = $mydata;
39        }
40}
41
42if ($name eq '')
43{ 
44        $descr = "summary"; 
45}
46else
47{ 
48        $descr = " ".$name." ";
49        # replace %20 codes with <space> in name
50        $descr =~ s/%20/ /g;
51}
52
53print "Content-type: text/html;\n\n";
54print <<END
55<html>
56<head>
57  <TITLE>$svrname Sensors :: $descr</TITLE>
58  <META HTTP-EQUIV="Refresh" CONTENT="300">
59  <META HTTP-EQUIV="Cache-Control" content="no-cache">
60  <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
61  <style>
62    body { font-family: Verdana,Tahoma,Arial,Helvetica; font-size:9pt}
63    .header { font-size: 16pt; font-weight: 900; }
64  </style>
65</head>
66<body bgcolor="#ffffff" topMargin='5'>
67
68<span class='header'>$svrname Sensors :: $descr</span>
69<br><br>
70END
71;
72
73if ($name eq '')
74{
75        print "Daily Graphs (5 minute averages)";
76        print "<br>";
77        $currentColumn = 1;
78        #print start of table
79        print "<table border='0'>";
80        #print start of table row
81        print "<tr>";
82        foreach $graph (@graphs)
83        {
84                print "<td>";
85                print "<a href='?trend=$graph'><img src='$graph-day.png' border='1'></a>";
86                #print "<br>";
87                #print "<br>";
88                print "</td>";
89                # Check for last column, continue on next row.
90                if ($currentColumn++ == $numberOfColumns){
91                        $currentColumn = 1;             
92                        print "</tr><tr>";
93                }               
94        }
95        # fill the remaining cells of the last row with empty data     
96        while (($currentColumn-1) % $numberOfColumns){
97                        $currentColumn++;               
98                        print "<td></td>";
99        }       
100        print "</tr>";
101        print "</table>";       
102}
103else
104{
105        print <<END
106Daily Graph (5 minute averages)
107<br>
108<img src='$name-day.png'>
109<br>
110Weekly Graph (30 minute averages)
111<br>
112<img src='$name-week.png'>
113<br>
114Monthly Graph (2 hour averages)
115<br>
116<img src='$name-month.png'>
117<br>
118Yearly Graph (12 hour averages)
119<br>
120<img src='$name-year.png'>
121END
122;
123}
124
125print <<END
126<br><br>
127<a
128href='http://oss.oetiker.ch/rrdtool/'>
129 <img src='http://oss.oetiker.ch/rrdtool/.pics/rrdtool.gif'
130border='0'></a>
131</body>
132</html>
133END
134;
135
136

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.