@@ -175,57 +175,41 @@ sub tinyproxy_update {
175
175
176
176
# print $data->toStringHTML();
177
177
178
- my $xpath = ' //tr//td' ;
179
- my @stats ;
180
-
181
- # This 'foreach' emulates the method 'to_literal_list' as it was
182
- # introduced in Perl-XML-LibXML version 2.0105 (2013-09-07), and
183
- # unfortunately not all systems have such a recent version.
184
- #
185
- # Some day in the future it should be changed by the line:
186
- # push(@stats, $_) foreach $data->findnodes($xpath)->to_literal_list;
187
- foreach ($data -> findnodes($xpath )-> get_nodelist()) {
188
- my $node ;
189
- ($node = $_ ) =~ s @ </?td>@@ g ;
190
- push (@stats , $node );
191
- }
192
- my %hstats = @stats ;
193
-
194
- for my $key (keys %hstats ) {
195
- if ($key eq " Number of open connections" ) {
178
+ foreach (split (' \n' , $data -> toStringHTML())) {
179
+ if (/ ^Number of open connections:\s +(\d +)/ ) {
196
180
$str = $e . " open" ;
197
- $ocon = $hstats { $key } - ($config -> {tinyproxy_hist }-> {$str } || 0);
198
- $ocon = 0 unless $ocon != $hstats { $key } ;
181
+ $ocon = $1 - ($config -> {tinyproxy_hist }-> {$str } || 0);
182
+ $ocon = 0 unless $ocon != $1 ;
199
183
$ocon /= 60;
200
- $config -> {tinyproxy_hist }-> {$str } = $hstats { $key } ;
184
+ $config -> {tinyproxy_hist }-> {$str } = $1 ;
201
185
}
202
- if ($key eq " Number of requests" ) {
186
+ if (/ Number of requests: \s +( \d +) / ) {
203
187
$str = $e . " reqs" ;
204
- $reqs = $hstats { $key } - ($config -> {tinyproxy_hist }-> {$str } || 0);
205
- $reqs = 0 unless $reqs != $hstats { $key } ;
188
+ $reqs = $1 - ($config -> {tinyproxy_hist }-> {$str } || 0);
189
+ $reqs = 0 unless $reqs != $1 ;
206
190
$reqs /= 60;
207
- $config -> {tinyproxy_hist }-> {$str } = $hstats { $key } ;
191
+ $config -> {tinyproxy_hist }-> {$str } = $1 ;
208
192
}
209
- if ($key eq " Number of bad connections" ) {
193
+ if (/ Number of bad connections: \s +( \d +) / ) {
210
194
$str = $e . " bcon" ;
211
- $bcon = $hstats { $key } - ($config -> {tinyproxy_hist }-> {$str } || 0);
212
- $bcon = 0 unless $bcon != $hstats { $key } ;
195
+ $bcon = $1 - ($config -> {tinyproxy_hist }-> {$str } || 0);
196
+ $bcon = 0 unless $bcon != $1 ;
213
197
$bcon /= 60;
214
- $config -> {tinyproxy_hist }-> {$str } = $hstats { $key } ;
198
+ $config -> {tinyproxy_hist }-> {$str } = $1 ;
215
199
}
216
- if ($key eq " Number of denied connections" ) {
200
+ if (/ Number of denied connections: \s +( \d +) / ) {
217
201
$str = $e . " dcon" ;
218
- $dcon = $hstats { $key } - ($config -> {tinyproxy_hist }-> {$str } || 0);
219
- $dcon = 0 unless $dcon != $hstats { $key } ;
202
+ $dcon = $1 - ($config -> {tinyproxy_hist }-> {$str } || 0);
203
+ $dcon = 0 unless $dcon != $1 ;
220
204
$dcon /= 60;
221
- $config -> {tinyproxy_hist }-> {$str } = $hstats { $key } ;
205
+ $config -> {tinyproxy_hist }-> {$str } = $1 ;
222
206
}
223
- if ($key eq " Number of refused connections due to high load" ) {
207
+ if (/ Number of refused connections due to high load: \s +( \d +) / ) {
224
208
$str = $e . " rcon" ;
225
- $rcon = $hstats { $key } - ($config -> {tinyproxy_hist }-> {$str } || 0);
226
- $rcon = 0 unless $rcon != $hstats { $key } ;
209
+ $rcon = $1 - ($config -> {tinyproxy_hist }-> {$str } || 0);
210
+ $rcon = 0 unless $rcon != $1 ;
227
211
$rcon /= 60;
228
- $config -> {tinyproxy_hist }-> {$str } = $hstats { $key } ;
212
+ $config -> {tinyproxy_hist }-> {$str } = $1 ;
229
213
}
230
214
}
231
215
0 commit comments