]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/usr/bin/perl |
2 | ||
3 | ############################################################################ | |
4 | # # | |
5 | # This file is part of the IPCop Firewall. # | |
6 | # # | |
7 | # IPCop 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 2 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # IPCop 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. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with IPCop; if not, write to the Free Software # | |
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
20 | # # | |
21 | # Copyright (C) 2004-01-19 Mark Wormgoor <mark@wormgoor.com>. # | |
22 | # # | |
23 | ############################################################################ | |
60cbd6e7 | 24 | |
cd1a2927 MT |
25 | use strict; |
26 | #use warnings; | |
27 | ||
28 | use RRDs; | |
986e08d9 | 29 | require "/var/ipfire/general-functions.pl"; |
cd1a2927 MT |
30 | require "${General::swroot}/lang.pl"; |
31 | ||
32 | my (%settings, @ipacsum, $iface, $ERROR); | |
33 | &General::readhash("${General::swroot}/ethernet/settings", \%settings); | |
52345790 MT |
34 | my %mbmon_settings = (); |
35 | &General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings); | |
36 | ||
cd1a2927 MT |
37 | # Added for conversion of utf-8 characters |
38 | use Encode 'from_to'; | |
39 | my %tr=(); | |
40 | ||
de53a053 CS |
41 | system("chmod 777 /srv/web/ipfire/html/graphs"); |
42 | ||
cd1a2927 | 43 | # Force language back to English (ugly hack!) |
eecaf145 | 44 | # Modified to only force if we are unable to convert charset |
cd1a2927 | 45 | # from utf-8 |
375c0b3b CS |
46 | if((${Lang::language} eq 'el') || |
47 | (${Lang::language} eq 'fa') || | |
48 | (${Lang::language} eq 'ru') || | |
49 | (${Lang::language} eq 'th') || | |
50 | (${Lang::language} eq 'vi') || | |
51 | (${Lang::language} eq 'zh') || | |
52 | (${Lang::language} eq 'zt')) { | |
53 | eval `/bin/cat "${General::swroot}/langs/en.pl"`; | |
cd1a2927 | 54 | } else { |
dc5c65a5 | 55 | #use translated version for other languages |
375c0b3b | 56 | %tr=%Lang::tr; |
cd1a2927 MT |
57 | } |
58 | ||
59 | # Settings | |
60 | my $rrdlog = "/var/log/rrd"; | |
fd0763dc | 61 | my $graphs = "/srv/web/ipfire/html/graphs"; |
cd1a2927 | 62 | $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; |
60cbd6e7 | 63 | my $hdd_device = "/dev/harddisk"; |
a68fedca | 64 | my $temp = ''; |
52345790 MT |
65 | my %mbmon_values = (); |
66 | my $key; | |
67 | my $value; | |
68 | my @args = (); | |
69 | my $count = 0; | |
70 | my $ERROR; | |
71 | my $dbg = 0; | |
52345790 | 72 | my $path_smartctl = "/usr/sbin/smartctl"; |
e3a8510a | 73 | my $path_hddtemp = "/usr/sbin/hddtemp"; |
52345790 | 74 | |
4b4aec3a CS |
75 | my %color = (); |
76 | my %mainsettings = (); | |
77 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
78 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
52345790 MT |
79 | |
80 | open(MBMON_OUT, ">/var/log/mbmon-values"); | |
81 | open(FD, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ; | |
82 | ||
eecaf145 | 83 | while( $_ = <FD> ) |
52345790 | 84 | { |
375c0b3b CS |
85 | next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ; |
86 | $key = $1 ; | |
87 | $value = $2 ; | |
88 | $key =~ y/A-Z/a-z/ ; | |
89 | $mbmon_values{$key} = $value; | |
90 | print(MBMON_OUT "$key=$value\n"); | |
52345790 MT |
91 | } |
92 | close(FD); | |
93 | close(MBMON_OUT); | |
cd1a2927 | 94 | |
eecaf145 | 95 | sub updatehdddata |
60cbd6e7 | 96 | { |
375c0b3b CS |
97 | my $disk = $_[0]; |
98 | my $standby; | |
99 | my @array = split(/\//,$disk); | |
100 | ||
101 | if ( ! -e "$rrdlog/hddshutdown-".$array[$#array].".rrd"){ | |
102 | # database did not exist -> create | |
103 | RRDs::create ("$rrdlog/hddshutdown-".$array[$#array].".rrd", "--step=300", | |
104 | "DS:standby:GAUGE:600:0:1", | |
105 | "RRA:AVERAGE:0.5:1:576", | |
106 | "RRA:AVERAGE:0.5:6:672", | |
107 | "RRA:AVERAGE:0.5:24:732", | |
108 | "RRA:AVERAGE:0.5:144:1460"); | |
109 | $ERROR = RRDs::error; | |
110 | print "Error in RRD::create for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR; | |
471a46f7 | 111 | } |
375c0b3b CS |
112 | |
113 | if (-e "/tmp/hddshutdown-".$array[$#array]) {$standby = 1;} | |
114 | else {$standby = 0;} | |
115 | ||
116 | RRDs::update ("$rrdlog/hddshutdown-".$array[$#array].".rrd", "-t", "standby", "N:$standby"); | |
117 | $ERROR = RRDs::error; | |
118 | print "Error in RRD::update for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR; | |
119 | ||
120 | if ( ! -e "$rrdlog/hddtemp-".$array[$#array].".rrd"){ | |
121 | # database did not exist -> create | |
122 | RRDs::create ("$rrdlog/hddtemp-".$array[$#array].".rrd", "--step=300", | |
123 | "DS:temperature:GAUGE:600:0:100", | |
124 | "RRA:AVERAGE:0.5:1:576", | |
125 | "RRA:AVERAGE:0.5:6:672", | |
126 | "RRA:AVERAGE:0.5:24:732", | |
127 | "RRA:AVERAGE:0.5:144:1460"); | |
128 | $ERROR = RRDs::error; | |
129 | print "Error in RRD::create for hdd-".$array[$#array].": $ERROR\n" if $ERROR; | |
471a46f7 | 130 | } |
375c0b3b CS |
131 | |
132 |