]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/scripts/makegraphs
Corrected guardian
[people/pmueller/ipfire-2.x.git] / src / scripts / makegraphs
CommitLineData
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
25use strict;
26#use warnings;
27
28use RRDs;
986e08d9 29require "/var/ipfire/general-functions.pl";
cd1a2927
MT
30require "${General::swroot}/lang.pl";
31
32my (%settings, @ipacsum, $iface, $ERROR);
33&General::readhash("${General::swroot}/ethernet/settings", \%settings);
52345790
MT
34my %mbmon_settings = ();
35&General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings);
36
cd1a2927
MT
37# Added for conversion of utf-8 characters
38use Encode 'from_to';
39my %tr=();
40
de53a053
CS
41system("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
46if((${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
60my $rrdlog = "/var/log/rrd";
fd0763dc 61my $graphs = "/srv/web/ipfire/html/graphs";
cd1a2927 62$ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
60cbd6e7 63my $hdd_device = "/dev/harddisk";
a68fedca 64my $temp = '';
52345790
MT
65my %mbmon_values = ();
66my $key;
67my $value;
68my @args = ();
69my $count = 0;
70my $ERROR;
71my $dbg = 0;
52345790 72my $path_smartctl = "/usr/sbin/smartctl";
e3a8510a 73my $path_hddtemp = "/usr/sbin/hddtemp";
52345790 74
4b4aec3a
CS
75my %color = ();
76my %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
80open(MBMON_OUT, ">/var/log/mbmon-values");
81open(FD, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ;
82
eecaf145 83while( $_ = <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}
92close(FD);
93close(MBMON_OUT);
cd1a2927 94
eecaf145 95sub 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