]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/usr/bin/perl\r |
2 | #\r | |
3 | # SmoothWall CGIs\r | |
4 | #\r | |
5 | # This code is distributed under the terms of the GPL\r | |
6 | #\r | |
7 | # (c) The SmoothWall Team\r | |
8 | #\r | |
9 | # $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $\r | |
10 | #\r | |
11 | \r | |
12 | use strict;\r | |
13 | \r | |
14 | # enable only the following on debugging purpose\r | |
15 | #use warnings;\r | |
16 | #use CGI::Carp 'fatalsToBrowser';\r | |
17 | \r | |
18 | require 'CONFIG_ROOT/general-functions.pl';\r | |
19 | require "${General::swroot}/lang.pl";\r | |
20 | require "${General::swroot}/header.pl";\r | |
21 | \r | |
22 | my %cgiparams=();\r | |
23 | my %pppsettings=();\r | |
24 | my %netsettings=();\r | |
25 | my @cgigraphs=();\r | |
26 | my @graphs=();\r | |
27 | my $iface='';\r | |
28 | \r | |
29 | &Header::showhttpheaders();\r | |
30 | \r | |
31 | my $graphdir = "/home/httpd/html/graphs";\r | |
32 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);\r | |
33 | \r | |
34 | $ENV{'QUERY_STRING'} =~ s/&//g;\r | |
35 | @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});\r | |
36 | $cgigraphs[1] = '' unless defined $cgigraphs[1];\r | |
37 | \r | |
38 | if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED)/) {\r | |
39 | &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');\r | |
40 | } else {\r | |
41 | &Header::openpage($Lang::tr{'system graphs'}, 1, '');\r | |
42 | }\r | |
43 | &Header::openbigbox('100%', 'left');\r | |
44 | \r | |
45 | if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|cpu|memory|swap|disk)/) {\r | |
46 | my $graph = $cgigraphs[1];\r | |
47 | my $graphname = ucfirst(lc($cgigraphs[1]));\r | |
48 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");\r | |
49 | \r | |
50 | if (-e "$graphdir/${graph}-day.png") {\r | |
51 | my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);\r | |
52 | print "<center>";\r | |
53 | print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";\r | |
54 | print "<img src='/graphs/${graph}-day.png' border='0' /><hr />";\r | |
55 | print "<img src='/graphs/${graph}-week.png' border='0' /><hr />";\r | |
56 | print "<img src='/graphs/${graph}-month.png' border='0' /><hr />";\r | |
57 | print "<img src='/graphs/${graph}-year.png' border='0' />";\r | |
58 | } else {\r | |
59 | print $Lang::tr{'no information available'};\r | |
60 | }\r | |
61 | &Header::closebox();\r | |
62 | print "<div align='center'><table width='80%'><tr><td align='center'>";\r | |
63 | if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED)/) {\r | |
64 | print "<a href='/cgi-bin/graphs.cgi?graph=network'>";\r | |
65 | } else {\r | |
66 | print "<a href='/cgi-bin/graphs.cgi'>";\r | |
67 | }\r | |
68 | print "$Lang::tr{'back'}</a></td></tr></table></div>\n";\r | |
69 | ;\r | |
70 | } elsif ($cgigraphs[1] =~ /network/) {\r | |
71 | push (@graphs, ('GREEN'));\r | |
72 | if ($netsettings{'BLUE_DEV'}) {\r | |
73 | push (@graphs, ('BLUE')); }\r | |
74 | if ($netsettings{'ORANGE_DEV'}) {\r | |
75 | push (@graphs, ('ORANGE')); }\r | |
76 | push (@graphs, ("RED"));\r | |
77 | \r | |
78 | foreach my $graphname (@graphs) {\r | |
79 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");\r | |
80 | \r | |
81 | if (-e "$graphdir/${graphname}-day.png") {\r | |
82 | my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);\r | |
83 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r | |
84 | print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";\r | |
85 | print "<img src='/graphs/${graphname}-day.png' border='0' />";\r | |
86 | print "</a>";\r | |
87 | } else {\r | |
88 | print $Lang::tr{'no information available'};\r | |
89 | }\r | |
90 | print "<br />\n";\r | |
91 | &Header::closebox();\r | |
92 | }\r | |
93 | } else {\r | |
94 | &Header::openbox('100%', 'center', "CPU $Lang::tr{'graph'}");\r | |
95 | if (-e "$graphdir/cpu-day.png") {\r | |
96 | my $ftime = localtime((stat("$graphdir/cpu-day.png"))[9]);\r | |
97 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r | |
98 | print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";\r | |
99 | print "<img src='/graphs/cpu-day.png' border='0' />";\r | |
100 | print "</a>";\r | |
101 | } else {\r | |
102 | print $Lang::tr{'no information available'};\r | |
103 | }\r | |
104 | print "<br />\n";\r | |
105 | &Header::closebox();\r | |
106 | \r | |
107 | &Header::openbox('100%', 'center', "Memory $Lang::tr{'graph'}");\r | |
108 | if (-e "$graphdir/memory-day.png") {\r | |
109 | my $ftime = localtime((stat("$graphdir/memory-day.png"))[9]);\r | |
110 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r | |
111 | print "<a href='/cgi-bin/graphs.cgi?graph=memory'>";\r | |
112 | print "<img src='/graphs/memory-day.png' border='0' />";\r | |
113 | print "</a>";\r | |
114 | } else {\r | |
115 | print $Lang::tr{'no information available'};\r | |
116 | }\r | |
117 | print "<br />\n";\r | |
118 | &Header::closebox();\r | |
119 | \r | |
120 | &Header::openbox('100%', 'center', "Swap $Lang::tr{'graph'}");\r | |
121 | if (-e "$graphdir/swap-day.png") {\r | |
122 | my $ftime = localtime((stat("$graphdir/swap-day.png"))[9]);\r | |
123 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r | |
124 | print "<a href='/cgi-bin/graphs.cgi?graph=swap'>";\r | |
125 | print "<img src='/graphs/swap-day.png' border='0' />";\r | |
126 | print "</a>";\r | |
127 | } else {\r | |
128 | print $Lang::tr{'no information available'};\r | |
129 | }\r | |
130 | print "<br />\n";\r | |
131 | &Header::closebox();\r | |
132 | \r | |
133 | &Header::openbox('100%', 'center', "Disk $Lang::tr{'graph'}");\r | |
134 | if (-e "$graphdir/disk-day.png") {\r | |
135 | my $ftime = localtime((stat("$graphdir/disk-day.png"))[9]);\r | |
136 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r | |
137 | print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";\r | |
138 | print "<img src='/graphs/disk-day.png' border='0' />";\r | |
139 | print "</a>";\r | |
140 | } else {\r | |
141 | print $Lang::tr{'no information available'};\r | |
142 | }\r | |
143 | print "<br />\n";\r | |
144 | &Header::closebox();\r | |
145 | }\r | |
146 | \r | |
147 | &Header::closebigbox();\r | |
148 | &Header::closepage();\r |