]> git.pld-linux.org Git - packages/cacti-template-lighttpd.git/blame - fixes.patch
- fix help doc part
[packages/cacti-template-lighttpd.git] / fixes.patch
CommitLineData
74be4dde
ER
1--- lighttpd_stats_1.0/ss_lighttpd_stats.php 2008-10-05 17:59:04.134098093 +0300
2+++ lighttpd_stats_1.0/ss_lighttpd_stats.php 2008-10-05 18:07:11.707053483 +0300
c821d0f8
ER
3@@ -1,3 +1,4 @@
4+#!/usr/bin/php
5 <?php
6 //
7 // +----------------------------------------------------------------------+
5ec3f4f4
ER
8@@ -17,7 +17,7 @@
9 // ss_lighttpd_stats.php <hostname>
10 //
11 // As a script server object:
12-// ss_lighttpd_stats.php ss_apache_stats <hostname>
13+// ss_lighttpd_stats.php ss_lighttpd_stats <hostname>
14 //
15 //
16
c821d0f8
ER
17@@ -21,9 +22,6 @@
18 //
19 //
20
21-/* display no errors */
22-error_reporting(0);
23-
24 if (!isset($called_by_script_server)) {
25 include_once(dirname(__FILE__) . "/../include/config.php");
26 array_shift($_SERVER["argv"]);
74be4dde
ER
27@@ -47,8 +45,8 @@
28 $status = lighttpdStatus::getStatus($host);
29 $return = '';
30
31- foreach($variables as $status_var => $cacti_var){
32- if(isset($status[$status_var])){
33+ foreach ($variables as $status_var => $cacti_var){
34+ if (isset($status[$status_var])) {
35 $return .= sprintf('%s:%s ', $cacti_var, $status[$status_var]);
36 }
37 }
38@@ -84,7 +82,7 @@
39 throw new Exception('Host not found');
40 }
41
42- $fh = @fsockopen($address, 80, $errno, $errstr, self::QUERY_TIMEOUT);
43+ $fh = fsockopen($address, 80, $errno, $errstr, self::QUERY_TIMEOUT);
44
45 if(!$fh || !is_resource($fh)){
46 throw new Exception($errstr, $errno);
47@@ -112,20 +110,24 @@
48 throw new Exception('');
49 }
50
51- $lines = explode("\n", $status);
52+ list($headers, $body) = explode("\r\n\r\n", $status);
53+ $headers = explode("\r\n", $headers);
54
55 // check response code
56 // should be "HTTP/1.1 200 OK"
57- if(trim($lines[0]) != 'HTTP/1.1 200 OK'){
58- throw new Exception($lines[0]);
59+ // can be also "HTTP/1.0 200 OK" if routed via proxy
60+ $http_status = trim($headers[0]);
61+ if ($http_status != 'HTTP/1.0 200 OK' && $http_status != 'HTTP/1.1 200 OK'){
62+ throw new Exception($http_status);
63 }
64
65 $vars = array();
66
67- foreach($lines as $line){
68+ $body = explode("\n", $body);
69+ foreach($body as $line){
70 $line = trim($line);
71
72- if(preg_match('/(.+): (.+)/', $line, $matches)){
73+ if (preg_match('/^(.+): (.+)/', $line, $matches)){
74 $vars[$matches[1]] = intval($matches[2]);
75 }
76 }
77@@ -140,2 +141,0 @@
78-
79-?>
This page took 0.080667 seconds and 4 git commands to generate.