]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/hardwaregraphs.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2005-2011 IPFire Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require "${General::swroot}/graphs.pl";
34 my %mainsettings = ();
35 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
36 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
38 my %sensorsettings = ();
40 my @sensorsgraphs = ();
41 my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/`;
42 foreach (@sensorsdir){
46 push(@sensorsgraphs,$_);
50 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
51 $querry[0] = '' unless defined $querry[0];
52 $querry[1] = 'hour' unless defined $querry[1];
54 if ( $querry[0] =~ "hwtemp"){
55 print "Content-type: image/png\n\n";
57 &Graphs
::updatehwtempgraph
($querry[1]);
58 }elsif ( $querry[0] =~ "hwfan"){
59 print "Content-type: image/png\n\n";
61 &Graphs
::updatehwfangraph
($querry[1]);
62 }elsif ( $querry[0] =~ "hwvolt"){
63 print "Content-type: image/png\n\n";
65 &Graphs
::updatehwvoltgraph
($querry[1]);
66 }elsif ( $querry[0] =~ "thermaltemp"){
67 print "Content-type: image/png\n\n";
69 &Graphs
::updatethermaltempgraph
($querry[1]);
70 }elsif ( $querry[0] =~ "sd?" ){
71 print "Content-type: image/png\n\n";
73 &Graphs
::updatehddgraph
($querry[0],$querry[1]);
74 }elsif ( $querry[0] =~ "nvme?" ){
75 print "Content-type: image/png\n\n";
77 &Graphs
::updatehddgraph
($querry[0],$querry[1]);
79 &Header
::showhttpheaders
();
80 &Header
::openpage
($Lang::tr
{'hardware graphs'}, 1, '');
81 &Header
::openbigbox
('100%', 'left');
83 &Header
::getcgihash
(\
%sensorsettings);
85 if ( $sensorsettings{'ACTION'} eq $Lang::tr
{'save'} ) {
86 foreach(@sensorsgraphs){
88 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
89 my $label = $2.$3;$label=~ s/-//g;
90 if ( $sensorsettings{'LINE-'.$label} ne "on" ){
91 $sensorsettings{'LINE-'.$label} = 'off';
92 } elsif ($sensorsettings{'LINE-'.$label} eq "on" ){
93 $sensorsettings{'LINE-'.$label} = 'checked';
95 $sensorsettings{'LABEL-'.$label} =~ s/\W//g;
97 &General
::writehash
("${General::swroot}/sensors/settings", \
%sensorsettings);
100 my @disks = `ls -1 /sys/block | grep -E '^sd|^nvme' | sort | uniq`;
105 my @array = split(/\//,$disk);
107 &Header
::openbox
('100%', 'center', "$array[$#array] $Lang::tr{'graph'}");
108 &Graphs
::makegraphbox
("hardwaregraphs.cgi",$array[$#array],"day");
112 if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null` ) {
113 &Header
::openbox
('100%', 'center', "ACPI Thermal-Zone Temp $Lang::tr{'graph'}");
114 &Graphs
::makegraphbox
("hardwaregraphs.cgi","thermaltemp","day");
118 if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/temperature-* 2>/dev/null` ) {
119 &Header
::openbox
('100%', 'center', "hwtemp $Lang::tr{'graph'}");
120 &Graphs
::makegraphbox
("hardwaregraphs.cgi","hwtemp","day");
124 if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/fanspeed-* 2>/dev/null` ) {
125 &Header
::openbox
('100%', 'center', "hwfan $Lang::tr{'graph'}");
126 &Graphs
::makegraphbox
("hardwaregraphs.cgi","hwfan","day");
130 if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/voltage-* 2>/dev/null` ) {
131 &Header
::openbox
('100%', 'center', "hwvolt $Lang::tr{'graph'}");
132 &Graphs
::makegraphbox
("hardwaregraphs.cgi","hwvolt","day");
136 if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-* 2>/dev/null` ) {
139 &Header
::closebigbox
();
140 &Header
::closepage
();
146 &Header
::openbox
('100%', 'center', "$Lang::tr{'mbmon settings'}");
149 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
150 <table width='100%' border='0' cellspacing='5' cellpadding='0' align='center'>
152 <td align='right' width='40%'><b>$Lang::tr{'mbmon display'}</b></td>
153 <td align='left'><b>$Lang::tr{'mbmon label'}</b></td>
158 foreach (@sensorsgraphs){
159 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
160 my $label = $2.$3;$label=~ s/-//g;
161 $sensorsettings{'LABEL-'.$label}="$label";
162 $sensorsettings{'LINE-'.$label}="checked";
163 &General
::readhash
("${General::swroot}/sensors/settings", \
%sensorsettings);
164 print("<tr><td align='right'><input type='checkbox' name='LINE-$label' $sensorsettings{'LINE-'.$label} /></td>");
165 print("<td><input type='text' name='LABEL-$label' value='$sensorsettings{'LABEL-'.$label}' size='25' /></td></tr>\n");
170 <td align='center' colspan='2' ><input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td>