From 52345790a3bef3e0bb2a404153a7c0d1c8767e13 Mon Sep 17 00:00:00 2001 From: ms Date: Mon, 17 Jul 2006 15:36:55 +0000 Subject: [PATCH] =?utf8?q?Hinzugef=C3=BCgt:=20=20=20*=20Hddtemp=20war=20ni?= =?utf8?q?cht=20in=20der=20ISO...=20=20=20*=20Smartmontools=20f=C3=BCr=20H?= =?utf8?q?DD-=C3=9Cberwachung.=20=20=20*=20MBMon=20zur=20Temperatur-=20und?= =?utf8?q?=20Drehzahl-=C3=9Cberwachung.=20=20=20*=20./make.sh=20build-only?= =?utf8?q?=20=20Anmerkung:=20=20=20*=20Die=20Graphen=20sind=20noch=20?= =?utf8?q?nicht=20ganz=20implementiert.=20=20=20=20=20Muss=20nochmal=20auf?= =?utf8?q?ger=C3=A4umt=20und=20vor=20allem=20die=20Sprach-=20=20=20=20=20b?= =?utf8?q?ezeichnungen=20m=C3=BCssen=20angepasst=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@210 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/cfgroot/mbmon-settings | 4 + html/cgi-bin/hddgraph.cgi | 261 +++++++++++++++++++++++++++--- langs/de/cgi-bin/de.pl | 10 ++ langs/en/cgi-bin/en.pl | 10 ++ lfs/configroot | 3 +- lfs/hddtemp | 5 +- lfs/mbmon | 80 +++++++++ lfs/smartmontools | 79 +++++++++ make.sh | 7 + src/ROOTFILES.i386 | 39 +++++ src/scripts/makegraphs | 296 +++++++++++++++++++++++++++++++--- 11 files changed, 748 insertions(+), 46 deletions(-) create mode 100644 config/cfgroot/mbmon-settings create mode 100644 lfs/mbmon create mode 100644 lfs/smartmontools diff --git a/config/cfgroot/mbmon-settings b/config/cfgroot/mbmon-settings new file mode 100644 index 0000000000..c36c2ee04a --- /dev/null +++ b/config/cfgroot/mbmon-settings @@ -0,0 +1,4 @@ +GRAPH_HDD=1 +GRAPH_TEMP=1 +GRAPH_FAN=1 +GRAPH_VOLT=1 diff --git a/html/cgi-bin/hddgraph.cgi b/html/cgi-bin/hddgraph.cgi index 71cfef014f..3ccd93867a 100644 --- a/html/cgi-bin/hddgraph.cgi +++ b/html/cgi-bin/hddgraph.cgi @@ -6,27 +6,17 @@ # # (c) The SmoothWall Team # -# $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $ -# -# 2006-02-23 modified by weizen_42 for hddgraphs -# -# 2006-02-xx weizen_42 several modifications -# 2006-03-31 weizen_42 link to homepage -# 2006-04-22 weizen_42 v0.1.1 install below proxygraphs in status menu -# use strict; # enable only the following on debugging purpose -#use warnings; -#use CGI::Carp 'fatalsToBrowser'; +# use warnings; +# use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -my $version = 'v0.1.1'; - my %cgiparams=(); my @cgigraphs=(); my @graphs=(); @@ -35,32 +25,263 @@ my @graphs=(); my $graphdir = "/home/httpd/html/graphs"; +&Header::getcgihash(\%cgiparams); + $ENV{'QUERY_STRING'} =~ s/&//g; @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'}); $cgigraphs[1] = '' unless defined $cgigraphs[1]; +my %mbmon_settings = (); +my %mbmon_values = (); +&General::readhash("/var/log/mbmon-values", \%mbmon_values); +my $key; + +if ( $cgiparams{'ACTION'} eq $Lang::tr{'save'} ) +{ + $mbmon_settings{'GRAPH_TEMP'} = ($cgiparams{'TEMP'} eq 'on'); + $mbmon_settings{'GRAPH_FAN'} = ($cgiparams{'FAN'} eq 'on'); + $mbmon_settings{'GRAPH_VOLT'} = ($cgiparams{'VOLT'} eq 'on'); + $mbmon_settings{'GRAPH_HDD'} = ($cgiparams{'HDD'} eq 'on'); + + foreach my $line (sort keys %cgiparams) + { + if ( index($line, "LINE-") != -1 ) + { + $mbmon_settings{$line} = 'on'; + } + + if ( index($line, "LABEL-") != -1 ) + { + $mbmon_settings{$line} = $cgiparams{$line}; + } + } + + &General::writehash("${General::swroot}/mbmon/settings", \%mbmon_settings); +} +else +{ + &General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings); +} + +my $selected_temp = ''; +my $selected_fan = ''; +my $selected_volt = ''; +my $selected_hdd = ''; + +$selected_temp = "checked='checked'" if ( $mbmon_settings{'GRAPH_TEMP'} == 1 ); +$selected_fan = "checked='checked'" if ( $mbmon_settings{'GRAPH_FAN'} == 1 ); +$selected_volt = "checked='checked'" if ( $mbmon_settings{'GRAPH_VOLT'} == 1 ); +$selected_hdd = "checked='checked'" if ( $mbmon_settings{'GRAPH_HDD'} == 1 ); + +my %mbmon_graphs = (); +foreach $key ( sort(keys %mbmon_values) ) +{ + $mbmon_graphs{$key} = "checked='checked'" if ( $mbmon_settings{'LINE-'.$key} eq 'on' ); + if ( !defined($mbmon_settings{'LABEL-'.$key}) ) + { + $mbmon_settings{'LABEL-'.$key} = $key; + } +} + &Header::openpage($Lang::tr{'harddisk temperature graphs'}, 1, ''); &Header::openbigbox('100%', 'left'); - &Header::openbox('100%', 'center', $Lang::tr{'harddisk temperature'}); +############### +# DEBUG DEBUG +#&Header::openbox('100%', 'left', 'DEBUG'); +#my $debugCount = 0; +#foreach my $line (sort keys %cgiparams) { +# print "$line = $cgiparams{$line}
\n"; +# $debugCount++; +#} +#print " Count: $debugCount\n"; +#&Header::closebox(); +# DEBUG DEBUG +############### - if (-e "$graphdir/hddtemp-day.png") +if ($cgigraphs[1] =~ /(temp|fan|volt)/) +{ + my $graph = $cgigraphs[1]; + my $graphname = $Lang::tr{"mbmon $cgigraphs[1]"}; + &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); + + if (-e "$graphdir/mbmon-${graph}-day.png") { - my $ftime = localtime((stat("$graphdir/hddtemp-day.png"))[9]); + my $ftime = localtime((stat("$graphdir/mbmon-${graph}-day.png"))[9]); print "
"; print "$Lang::tr{'the statistics were last updated at'}: $ftime


\n"; - print "
"; - print "
"; - print "
"; - print ""; + print "
"; + print "
"; + print "
"; + print ""; } else { print $Lang::tr{'no information available'}; } - &Header::closebox(); + print "
"; + print ""; + print "$Lang::tr{'back'}
\n"; +} +elsif ($cgigraphs[1] =~ /(hdd)/) +{ + my $graph = $cgigraphs[1]; + my $graphname = $Lang::tr{"harddisk temperature"}; + &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); + + if (-e "$graphdir/hddtemp-day.png") + { + my $ftime = localtime((stat("$graphdir/hddtemp-day.png"))[9]); + print "
"; + print "$Lang::tr{'the statistics were last updated at'}: $ftime


\n"; + print "
"; + print "
"; + print "
"; + print ""; + if ( -e "/var/log/hddgraph_smartctl_out" ) + { + my $output = `/bin/cat /var/log/hddgraph_smartctl_out`; + $output = &Header::cleanhtml($output); + print "
$output
\n"; + } + } + else + { + print $Lang::tr{'no information available'}; + } + &Header::closebox(); + print "
"; + print ""; + print "$Lang::tr{'back'}
\n"; +} +else +{ + if ( $mbmon_settings{'GRAPH_TEMP'} == 1 ) + { + &Header::openbox('100%', 'center', "$Lang::tr{'mbmon temp'} $Lang::tr{'graph'}"); + if (-e "$graphdir/mbmon-temp-day.png") + { + my $ftime = localtime((stat("$graphdir/mbmon-temp-day.png"))[9]); + print "
$Lang::tr{'the statistics were last updated at'}: $ftime

\n"; + print ""; + print ""; + print ""; + } + else + { + print $Lang::tr{'no information available'}; + } + print "
\n"; + &Header::closebox(); + } + + if ( $mbmon_settings{'GRAPH_FAN'} == 1 ) + { + &Header::openbox('100%', 'center', "$Lang::tr{'mbmon fan'} $Lang::tr{'graph'}"); + if (-e "$graphdir/mbmon-fan-day.png") + { + my $ftime = localtime((stat("$graphdir/mbmon-fan-day.png"))[9]); + print "
$Lang::tr{'the statistics were last updated at'}: $ftime

\n"; + print ""; + print ""; + print ""; + } + else + { + print $Lang::tr{'no information available'}; + } + print "
\n"; + &Header::closebox(); + } + + if ( $mbmon_settings{'GRAPH_VOLT'} == 1 ) + { + &Header::openbox('100%', 'center', "$Lang::tr{'mbmon volt'} $Lang::tr{'graph'}"); + if (-e "$graphdir/mbmon-volt-day.png") + { + my $ftime = localtime((stat("$graphdir/mbmon-volt-day.png"))[9]); + print "
$Lang::tr{'the statistics were last updated at'}: $ftime

\n"; + print ""; + print ""; + print ""; + } + else + { + print $Lang::tr{'no information available'}; + } + print "
\n"; + &Header::closebox(); + } + + if ( $mbmon_settings{'GRAPH_HDD'} == 1 ) + { + &Header::openbox('100%', 'center', $Lang::tr{'harddisk temperature'}); + if (-e "$graphdir/hddtemp-day.png") + { + my $ftime = localtime((stat("$graphdir/hddtemp-day.png"))[9]); + print "
"; + print "$Lang::tr{'the statistics were last updated at'}: $ftime


\n"; + print ""; + print "
"; + print "
"; + } + else + { + print $Lang::tr{'no information available'}; + } + print "
\n"; + &Header::closebox(); + } + + &Header::openbox('100%', 'center', $Lang::tr{'settings'}); +print < + + + + + +
 $Lang::tr{'mbmon temp'} $Lang::tr{'graph'}
 $Lang::tr{'mbmon fan'} $Lang::tr{'graph'}
 $Lang::tr{'mbmon volt'} $Lang::tr{'graph'}
 $Lang::tr{'harddisk temperature'}-$Lang::tr{'graph'}
+
+ + +END +; + +my $i = 0; +foreach $key ( sort(keys %mbmon_values) ) +{ + if ( $i % 2 ) + { + print(""); + } + else + { + print(""); + } + $mbmon_settings{'LABEL-'.$key} = &Header::cleanhtml($mbmon_settings{'LABEL-'.$key}); + print(""); + print("\n"); + print("\n"); + $i++; +} + +print < + +
$Lang::tr{'mbmon display'} $Lang::tr{'mbmon value'}$Lang::tr{'mbmon label'}
$key$mbmon_values{$key} 
+ +
 
+ + +END +; + &Header::closebox(); +} + +&Header::closebox(); &Header::closebigbox(); &Header::closepage(); diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index e127c395e5..66ba324779 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -1476,6 +1476,16 @@ 'urlfilter update information' => 'Eine aktualisierte Version steht zum Download bereit. Besuchen Sie http://www.urlfilter.net für weitere Informationen.', 'display webinterface effects' => 'Überblendeffekte einschalten', 'outgoing firewall' => 'Ausgehende Firewall', +'mbmon graphs' => 'mbmon-Diagramme', +'mbmon settings' => 'mbmongraph Einstellungen', +'mbmon display' => 'Anzeigen', +'mbmon value' => 'Wert', +'mbmon label' => 'Label', +'mbmon fan' => 'Fan Speed', +'mbmon fan in' => 'Fan Speed in', +'mbmon temp' => 'Temperature', +'mbmon temp in' => 'Temperature in', +'mbmon volt' => 'Voltage', ); diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index ae7f14a9e8..c1bdf3ab68 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -1509,5 +1509,15 @@ 'urlfilter update information' => 'There is an updated version available for download. Visit http://www.urlfilter.net for more information.', 'display webinterface effects' => 'Activate effects', 'outgoing firewall' => 'Outgoing Firewall', +'mbmon graphs' => 'mbmon Graphs', +'mbmon settings' => 'mbmongraph Settings', +'mbmon display' => 'Display', +'mbmon value' => 'Value', +'mbmon label' => 'Label', +'mbmon fan' => 'Fan Speed', +'mbmon fan in' => 'Fan Speed in', +'mbmon temp' => 'Temperature', +'mbmon temp in' => 'Temperature in', +'mbmon volt' => 'Voltage', ); diff --git a/lfs/configroot b/lfs/configroot index ac117420da..c34a4d090a 100644 --- a/lfs/configroot +++ b/lfs/configroot @@ -51,7 +51,7 @@ $(TARGET) : # Create all directories for i in addon-lang alcatelusb auth backup backup/sets ca certs cnx_pci crls ddns dhcp dhcpc dmzholes \ - eagle-usb eciadsl ethernet isdn key langs logging main modem net-traffic nfs optionsfw outgoing patches pakfire portfw \ + eagle-usb eciadsl ethernet isdn key langs logging main mbmon modem net-traffic nfs optionsfw outgoing patches pakfire portfw \ ppp private proxy/advanced qos/bin red remote snort time urlfilter/autoupdate urlfilter/bin vpn wireless xtaccess ; do \ mkdir -p $(CONFIG_ROOT)/$$i; \ done @@ -77,6 +77,7 @@ $(TARGET) : cp $(DIR_SRC)/config/cfgroot/backup-include $(CONFIG_ROOT)/backup/include.system cp $(DIR_SRC)/config/cfgroot/backup-exclude.hardware $(CONFIG_ROOT)/backup/exclude.hardware cp $(DIR_SRC)/config/cfgroot/advoptions-list $(CONFIG_ROOT)/dhcp/advoptions-list + cp $(DIR_SRC)/config/cfgroot/mbmon-settings $(CONFIG_ROOT)/mbmon/settings cp $(DIR_SRC)/config/cfgroot/modem-defaults $(CONFIG_ROOT)/modem/defaults cp $(DIR_SRC)/config/cfgroot/modem-settings $(CONFIG_ROOT)/modem/settings cp $(DIR_SRC)/config/cfgroot/net-traffic-lib.pl $(CONFIG_ROOT)/net-traffic/net-traffic-lib.pl diff --git a/lfs/hddtemp b/lfs/hddtemp index 930202cd18..f18e44a7df 100644 --- a/lfs/hddtemp +++ b/lfs/hddtemp @@ -55,9 +55,6 @@ download :$(patsubst %,$(DIR_DL)/%,$(objects)) md5 : $(subst %,%_MD5,$(objects)) -dist: - make-packages.sh hddtemp $(THISAPP) - ############################################################################### # Downloading, checking, md5sum ############################################################################### @@ -79,7 +76,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && cp -fv $(DIR_DL)/hddtemp.db /etc/hddtemp.db - cd $(DIR_APP) && ./configure --with-db-path=/etc/hddtemp.db + cd $(DIR_APP) && ./configure --prefix=/usr --with-db-path=/etc/hddtemp.db cd $(DIR_APP) && make && make install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/mbmon b/lfs/mbmon new file mode 100644 index 0000000000..57bffccee5 --- /dev/null +++ b/lfs/mbmon @@ -0,0 +1,80 @@ +############################################################################### +# This file is part of the IPCop Firewall. # +# # +# IPCop is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPCop is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPCop; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Makefiles are based on LFSMake, which is # +# Copyright (C) 2002 Rod Roard # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 205 + +THISAPP = xmbmon$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = ab6614c785f5b653fcc69fb9c02058f0 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && ./configure --prefix=/usr + cd $(DIR_APP) && make PROGRAM=mbmon + cd $(DIR_APP) && install -o root -g wheel -m 4555 -c -p mbmon /usr/bin + cd $(DIR_APP) && install -o root -g wheel -m 444 -c -p mbmon.1 /usr/man/man1 + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/lfs/smartmontools b/lfs/smartmontools new file mode 100644 index 0000000000..bf394c9e45 --- /dev/null +++ b/lfs/smartmontools @@ -0,0 +1,79 @@ +############################################################################### +# This file is part of the IPCop Firewall. # +# # +# IPCop is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPCop is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPCop; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Makefiles are based on LFSMake, which is # +# Copyright (C) 2002 Rod Roard # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 5.36 + +THISAPP = smartmontools-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = 2e424f2d35efa38a29ebca419c1dbe3c + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && ./configure --prefix=/usr + cd $(DIR_APP) && make + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index 86c9dbaba2..c8c4adeafd 100644 --- a/make.sh +++ b/make.sh @@ -741,6 +741,7 @@ buildipcop() { ipcopmake portmap ipcopmake nfs ipcopmake nmap + ipcopmake mbmon ipcopmake iftop ipcopmake ncftp ipcopmake cftp @@ -1211,6 +1212,12 @@ pub-paks) echo -e "There was an error while uploading the packages to the ftp server." fi ;; +build-only) + rm -f $BASEDIR/log/$2* + BUILDMACHINE=`uname -m` + prepareenv + ipcopmake $2 + ;; *) echo "Usage: $0 {build|changelog|check|checkclean|clean|commit|diff|dist|gettoolchain|make|newpak|prefetch|pub-iso|pub-paks|shell|sync|toolchain|update}" cat doc/make.sh-usage diff --git a/src/ROOTFILES.i386 b/src/ROOTFILES.i386 index 7e87429855..53bf0df38d 100644 --- a/src/ROOTFILES.i386 +++ b/src/ROOTFILES.i386 @@ -27204,6 +27204,10 @@ usr/lib/liblzo2.so.2.0.0 usr/bin/wget usr/etc/wgetrc ## +## xmbmon205 +/usr/bin/mbmon +## +## ## mc ## usr/bin/mc @@ -27736,3 +27740,38 @@ usr/lib/libgthread-2.0.so.0.902.4 #usr/share/man/man1/glib-gettextize.1 #usr/share/man/man1/glib-mkenums.1 #usr/share/man/man1/gobject-query.1 +## +## hddtemp +## +etc/hddtemp.db +usr/sbin/hddtemp +#usr/share/locale/fr/LC_MESSAGES/hddtemp.mo +#usr/share/locale/ru/LC_MESSAGES/hddtemp.mo +#usr/share/man/man8/hddtemp.8 +## +## smartmontools-5.36 +## +#usr/etc/rc.d +#usr/etc/rc.d/init.d +#usr/etc/rc.d/init.d/smartd +#usr/etc/smartd.conf +usr/sbin/smartctl +#usr/sbin/smartd +#usr/share/doc/smartmontools-5.36 +#usr/share/doc/smartmontools-5.36/AUTHORS +#usr/share/doc/smartmontools-5.36/CHANGELOG +#usr/share/doc/smartmontools-5.36/COPYING +#usr/share/doc/smartmontools-5.36/INSTALL +#usr/share/doc/smartmontools-5.36/NEWS +#usr/share/doc/smartmontools-5.36/README +#usr/share/doc/smartmontools-5.36/TODO +#usr/share/doc/smartmontools-5.36/WARNINGS +#usr/share/doc/smartmontools-5.36/examplescripts +#usr/share/doc/smartmontools-5.36/examplescripts/Example1 +#usr/share/doc/smartmontools-5.36/examplescripts/Example2 +#usr/share/doc/smartmontools-5.36/examplescripts/Example3 +#usr/share/doc/smartmontools-5.36/examplescripts/README +#usr/share/doc/smartmontools-5.36/smartd.conf +#usr/share/man/man5/smartd.conf.5 +#usr/share/man/man8/smartctl.8 +#usr/share/man/man8/smartd.8 diff --git a/src/scripts/makegraphs b/src/scripts/makegraphs index ba0f7891d5..bcac55346d 100644 --- a/src/scripts/makegraphs +++ b/src/scripts/makegraphs @@ -31,6 +31,10 @@ require "${General::swroot}/lang.pl"; my (%settings, @ipacsum, $iface, $ERROR); &General::readhash("${General::swroot}/ethernet/settings", \%settings); +my %mbmon_settings = (); +&General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings); + + # Added for conversion of utf-8 characters use Encode 'from_to'; @@ -57,6 +61,41 @@ my $graphs = "/home/httpd/html/graphs"; $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; my $hdd_device = "/dev/harddisk"; my $temp = ''; +my %mbmon_values = (); +my $key; +my $value; +my @args = (); +my $count = 0; +my $ERROR; +my $dbg = 0; +my $path_rrd = "/var/log/rrd"; +my $path_graphs = "/home/httpd/html/graphs"; +my $path_smartctl = "/usr/sbin/smartctl"; + +my %colors = (); +$colors{"1"} = "#0000FF"; +$colors{"2"} = "#00FF00"; +$colors{"3"} = "#FF0000"; +$colors{"4"} = "#FFD700"; +$colors{"5"} = "#CCCCCC"; +$colors{"6"} = "#40E0D0"; +$colors{"7"} = "#90EE90"; +$colors{"8"} = "#F4A460"; + +open(MBMON_OUT, ">/var/log/mbmon-values"); +open(FD, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ; + +while( $_ = ) +{ + next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ; + $key = $1 ; + $value = $2 ; + $key =~ y/A-Z/a-z/ ; + $mbmon_values{$key} = $value; + print(MBMON_OUT "$key=$value\n"); +} +close(FD); +close(MBMON_OUT); sub gettraffic { my $interface = $_[0]; @@ -676,10 +715,10 @@ sub updatelqgraph { sub updatehdddata { - if ( ! -e "$rrdlog/hddtemp.rrd") + if ( ! -e "$path_rrd/hddtemp.rrd") { # database did not exist -> create - RRDs::create ("$rrdlog/hddtemp.rrd", "--step=300", + RRDs::create ("$path_rrd/hddtemp.rrd", "--step=300", "DS:temperature:GAUGE:600:0:100", "RRA:AVERAGE:0.5:1:576", "RRA:AVERAGE:0.5:6:672", @@ -689,35 +728,60 @@ sub updatehdddata print "Error in RRD::create for hdd: $ERROR\n" if $ERROR; } - my $hdd_output = `/usr/sbin/hddtemp -qn $hdd_device`; - - # I know 4 response possible responses: - # - # /dev/harddisk: harddisk type: S.M.A.R.T. not available - # /dev/harddisk: harddisk type: no sensor - # /dev/harddisk: harddisk type: 37°C or °F - # 37 + $temp = 0; + my $hdd_output = ''; + my $smart_output = ''; - if ( index($hdd_output, "S.M.A.R.T.") != -1 ) + if ( -e "$path_smartctl" ) { - $temp = 0; + system("$path_smartctl -iHA $hdd_device > /var/log/hddgraph_smartctl_out"); } - elsif ( index($hdd_output, "no sensor") != -1 ) + + if ( -e "$path_hddtemp" ) { - $temp = 1; + $hdd_output = `$path_hddtemp -qn $hdd_device`; + + # I know 4 response possible responses: + # + # /dev/harddisk: harddisk type: S.M.A.R.T. not available + # /dev/harddisk: harddisk type: no sensor + # /dev/harddisk: harddisk type: 37°C or °F + # 37 + + if ( index($hdd_output, "S.M.A.R.T.") != -1 ) + { + $temp = 0; + } + elsif ( index($hdd_output, "no sensor") != -1 ) + { + $temp = 1; + } + elsif ( index($hdd_output, "$hdd_device") != -1 ) + { + $hdd_output =~ /.*:.*:\s*(\d+).*\s/; + $temp = $1; + } + else + { + $hdd_output =~ /(\d+)\s/; + $temp = $1; + } } - elsif ( index($hdd_output, "$hdd_device") != -1 ) + elsif ( -e "/var/log/hddgraph_smartctl_out" ) { - $hdd_output =~ /.*:.*:\s*(\d+).*\s/; - $temp = $1; + $hdd_output = `cat /var/log/hddgraph_smartctl_out | grep Temperature_`; + my @t = split(/\s+/,$hdd_output); + $temp = $t[9]; } else { - $hdd_output =~ /(\d+)\s/; - $temp = $1; + $temp = 0; } - RRDs::update ("$rrdlog/hddtemp.rrd", "-t", "temperature", "N:$temp"); +# print "hdd $hdd_output \n"; +# print "temp $temp \n"; + + RRDs::update ("$path_rrd/hddtemp.rrd", "-t", "temperature", "N:$temp"); $ERROR = RRDs::error; print "Error in RRD::update for hdd: $ERROR\n" if $ERROR; @@ -743,6 +807,173 @@ sub updatehddgraph { print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; } +sub updatembmondata +{ + if ( ! -e "$path_rrd/mbmon.rrd" ) + { + # database did not exist -> create + + @args = ("$path_rrd/mbmon.rrd"); + + push(@args, "--step=300"); + foreach $key ( sort(keys %mbmon_values) ) + { + push(@args, "DS:$key:GAUGE:600:U:U"); + } + push(@args, "RRA:AVERAGE:0.5:1:576"); + push(@args, "RRA:AVERAGE:0.5:6:672"); + push(@args, "RRA:AVERAGE:0.5:24:732"); + push(@args, "RRA:AVERAGE:0.5:144:1460"); + + print("create ". join( ", ", @args)) if ( $dbg ); + + RRDs::create (@args); + $ERROR = RRDs::error; + print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR; + } + + my @ds; + my @val; + my $template; + + foreach $key ( sort(keys %mbmon_values) ) + { + push(@ds, $key); + push(@val, $mbmon_values{$key}); + } + + $template = join(':', @ds); + $value = "N:".join(':', @val); + + print("update template = '$template'\n") if ( $dbg ); + print("update value = '$value'\n") if ( $dbg ); + + RRDs::update("$path_rrd/mbmon.rrd", "-t", $template, $value); + $ERROR = RRDs::error; + print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR; +} + +sub updatetempgraph +{ + my $type = "temp"; + my $period = $_[0]; + + @args = ("$path_graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale", + "--color", "SHADEA#EAE9EE", + "--color", "SHADEB#EAE9EE", + "--color", "BACK#EAE9EE", + "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" ); + + $count = 1; + foreach $key ( sort(keys %mbmon_values) ) + { + if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') ) + { + if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) + { + $mbmon_settings{'LABEL-'.$key} = $key; + } + + push(@args, "DEF:$key=$path_rrd/mbmon.rrd:$key:AVERAGE"); + push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon temp in'} °C"); + push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.1lf °C"); + push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.1lf °C"); + push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.1lf °C\\j"); + + $count++; + } + } + + if ( $count > 1 ) + { + RRDs::graph ( @args ); + $ERROR = RRDs::error; + print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; + } +} + +sub updatefangraph +{ + my $type = "fan"; + my $period = $_[0]; + + @args = ("$path_graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale", + "--color", "SHADEA#EAE9EE", + "--color", "SHADEB#EAE9EE", + "--color", "BACK#EAE9EE", + "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" ); + + $count = 1; + foreach $key ( sort(keys %mbmon_values) ) + { + if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') ) + { + if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) + { + $mbmon_settings{'LABEL-'.$key} = $key; + } + + push(@args, "DEF:$key=$path_rrd/mbmon.rrd:$key:AVERAGE"); + push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} $tr{'mbmon fan in'} rpm"); + push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.0lf rpm"); + push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.0lf rpm"); + push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.0lf rpm\\j"); + + $count++; + } + } + + if ( $count > 1 ) + { + RRDs::graph ( @args ); + $ERROR = RRDs::error; + print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; + } +} + +sub updatevoltgraph +{ + my $type = "volt"; + my $period = $_[0]; + + @args = ("$path_graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale", + "--color", "SHADEA#EAE9EE", + "--color", "SHADEB#EAE9EE", + "--color", "BACK#EAE9EE", + "-t $tr{'mbmon temp'} ($tr{'graph per'} $tr{$period})" ); + + $count = 1; + foreach $key ( sort(keys %mbmon_values) ) + { + my $v = substr($key,0,1); + if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') ) + { + if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) + { + $mbmon_settings{'LABEL-'.$key} = $key; + } + + push(@args, "DEF:$key=$path_rrd/mbmon.rrd:$key:AVERAGE"); + push(@args, "LINE2:$key$colors{$count}:$mbmon_settings{'LABEL-'.$key} V"); + push(@args, "GPRINT:$key:MAX:$tr{'maximal'}\\:%5.2lf V"); + push(@args, "GPRINT:$key:AVERAGE:$tr{'average'}\\:%5.2lf V"); + push(@args, "GPRINT:$key:LAST:$tr{'current'}\\:%5.2lf V\\j"); + + $count++; + } + } + + if ( $count > 1 ) + { + RRDs::graph ( @args ); + $ERROR = RRDs::error; + print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; + } +} + ## Update ipac logs system ('/usr/sbin/fetchipac'); sleep 8; @@ -929,6 +1160,30 @@ updatehddgraph ("week"); updatehddgraph ("month"); updatehddgraph ("year"); +updatembmondata(); + +if ( $mbmon_settings{'GRAPH_TEMP'} == 1 ) +{ + updatetempgraph ("day"); + updatetempgraph ("week"); + updatetempgraph ("month"); + updatetempgraph ("year"); +} +if ( $mbmon_settings{'GRAPH_TEMP'} == 1 ) +{ + updatefangraph ("day"); + updatefangraph ("week"); + updatefangraph ("month"); + updatefangraph ("year"); +} +if ( $mbmon_settings{'GRAPH_VOLT'} == 1 ) +{ + updatevoltgraph ("day"); + updatevoltgraph ("week"); + updatevoltgraph ("month"); + updatevoltgraph ("year"); +} + ### ### Network Graphs ### @@ -971,7 +1226,6 @@ if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ && -e "$rrdlog/BLUE.rrd") { updateifgraph ("BLUE", "year"); } -#chmod 777 /home/httpd/html/{graphs,sgraph} -R system("chmod -R 0777 /home/httpd/html/graphs"); system("chmod -R 0777 /home/httpd/html/sgraph"); -- 2.39.2