Subversion Repositories ALCASAR

Rev

Rev 1675 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1675 Rev 2589
Line 93... Line 93...
93
    function get_vnstat_data($use_label=true)
93
    function get_vnstat_data($use_label=true)
94
    {
94
    {
95
        global $iface, $vnstat_bin, $data_dir;
95
        global $iface, $vnstat_bin, $data_dir;
96
        global $hour,$day,$month,$top,$summary;
96
        global $hour,$day,$month,$top,$summary;
97
 
97
 
-
 
98
	$vnstat_data = array();
98
        if (!isset($vnstat_bin) || $vnstat_bin == '')
99
        if (!isset($vnstat_bin) || $vnstat_bin == '')
99
        {
100
        {
100
	    if (file_exists("$data_dir/vnstat_dump_$iface"))
101
	    if (file_exists("$data_dir/vnstat_dump_$iface"))
101
	    {
102
	    {
102
        	$vnstat_data = file("$data_dir/vnstat_dump_$iface");
103
        	$vnstat_data = file("$data_dir/vnstat_dump_$iface");
103
	    }
104
	    }
104
	    else
-
 
105
	    {
-
 
106
		$vnstat_data = array();
-
 
107
	    }
-
 
108
        }
105
        }
109
        else
106
        else
110
        {
107
        {
111
            $fd = popen("$vnstat_bin --dumpdb -i $iface", "r");
108
            $fd = popen("$vnstat_bin --dumpdb -i $iface", "r");
-
 
109
            if (is_resource($fd))
-
 
110
            {
112
            $buffer = '';
111
            	$buffer = '';
113
            while (!feof($fd)) {
112
            	while (!feof($fd)) {
114
                $buffer .= fgets($fd);
113
                	$buffer .= fgets($fd);
-
 
114
            	}
-
 
115
            	$vnstat_data = explode("\n", $buffer);
-
 
116
            	pclose($fd);
115
            }
117
            }
116
            $vnstat_data = explode("\n", $buffer);
-
 
117
            pclose($fd);
-
 
118
        }
118
        }
119
 
119
 
120
 
120
 
121
        $day = array();
121
        $day = array();
122
        $hour = array();
122
        $hour = array();
123
        $month = array();
123
        $month = array();
124
        $top = array();
124
        $top = array();
125
 
125
 
126
        if (strpos($vnstat_data[0], 'Error') !== false) {
126
        if (isset($vnstat_data[0]) && strpos($vnstat_data[0], 'Error') !== false) {
127
          return;
127
          return;
128
        }
128
        }
129
 
129
 
130
        //
130
        //
131
        // extract data
131
        // extract data