Hallo Gemeinde
Ich schlage mich seit Tagen an meinem Rechner mit vnstat herum.
vnstat in der Konsole funktioniert.
Es werden Werte angezeigt. So wie es soll.
Nun versuche ich, das Ganze im Browser darzustellen.
Dazu benutze ich das "vnStat PHP frontend 1.5.1".
Installiert habe ich es so, wie z. B. hier
https://www.tecmint.com/vnstat-php-frontend-for-monitoring-network-bandwidth/
oder hier
https://www.itzgeek.com/how-tos/linux/centos-how-tos/vnstat-php-frontend-web-based-interface-for-monitoring-network.html
beschrieben.
Der Browser zeigt zwar die Seite richtig an aber leider ohne Daten.
Ich habe hier die Datei "config.php", die im Verzeichnis "/srv/http/" liegt:
<?php
//
// vnStat PHP frontend (c)2006-2010 Bjorge Dijkstra (bjd@jooz.net)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
// see file COPYING or at http://www.gnu.org/licenses/gpl.html
// for more information.
//
error_reporting(E_ALL | E_NOTICE);
//
// configuration parameters
//
// edit these to reflect your particular situation
//
$locale = 'de_DE.UTF-8';
$language = 'de';
// list of network interfaces monitored by vnStat
$iface_list = array('wlp5s0');
//
// optional names for interfaces
// if there's no name set for an interface then the interface identifier
// will be displayed instead
//
$iface_title['wlp5s0'] = 'Wireless';
#$iface_title['sixxs'] = 'SixXS IPv6';
//
// There are two possible sources for vnstat data. If the $vnstat_bin
// variable is set then vnstat is called directly from the PHP script
// to get the interface data.
//
// The other option is to periodically dump the vnstat interface data to
// a file (e.g. by a cronjob). In that case the $vnstat_bin variable
// must be cleared and set $data_dir to the location where the dumps
// are stored. Dumps must be named 'vnstat_dump_$iface'.
//
// You can generate vnstat dumps with the command:
// vnstat --dumpdb -i $iface > /path/to/data_dir/vnstat_dump_$iface
//
$vnstat_bin = '/usr/bin/vnstat';
$data_dir = './dumps';
# $data_dir = '/var/lib/vnstat';
// graphics format to use: svg or png
$graph_format='svg';
// Font to use for PNG graphs
define('GRAPH_FONT',dirname(__FILE__).'/VeraBd.ttf');
// Font to use for SVG graphs
define('SVG_FONT', 'Verdana');
// Default theme
define('DEFAULT_COLORSCHEME', 'light');
?>
Auch wenn ich das hier "$data_dir = '/var/lib/vnstat';" aktiviere ändert sich nichts.
Hier ist die Datei "vnstat.conf" aus dem Verzeichnis /etc/:
# vnStat 2.0 config file
##
# default interface
# Interface "eth0"
Interface "wlp5s0"
# location of the database directory
DatabaseDir "/var/lib/vnstat"
# locale (LC_ALL) ("-" = use system locale)
Locale "-"
# date output formats for -d, -m, -t and -w
DayFormat "%Y-%m-%d"
MonthFormat "%Y-%m"
TopFormat "%Y-%m-%d"
# characters used for visuals
RXCharacter "%"
TXCharacter ":"
RXHourCharacter "r"
TXHourCharacter "t"
# how units are prefixed when traffic is shown
# 0 = IEC standard prefixes (KiB/MiB/GiB...)
# 1 = old style binary prefixes (KB/MB/GB...)
# 2 = SI decimal prefixes (kB/MB/GB...)
UnitMode 0
# used rate unit (0 = bytes, 1 = bits)
RateUnit 1
# how units are prefixed when traffic rate is shown in bits
# 0 = IEC binary prefixes (Kibit/s...)
# 1 = SI decimal prefixes (kbit/s...)
RateUnitMode 1
# output style
# 0 = minimal & narrow, 1 = bar column visible
# 2 = same as 1 except rate in summary
# 3 = rate column visible
OutputStyle 3
# number of decimals to use in outputs
DefaultDecimals 2
HourlyDecimals 1
# spacer for separating hourly sections (0 = none, 1 = '|', 2 = '][', 3 = '[ ]')
HourlySectionStyle 2
# how many seconds should sampling for -tr take by default
Sampletime 5
# default query mode
# 0 = normal, 1 = days, 2 = months, 3 = top, 5 = short
# 7 = hours, 8 = xml, 9 = one line, 10 = json
QueryMode 0
# default list output entry count (0 = all)
List5Mins 24
ListHours 24
ListDays 30
ListMonths 12
ListYears 0
ListTop 10
# vnstatd
##
# switch to given user when started as root (leave empty to disable)
DaemonUser ""
# switch to given user when started as root (leave empty to disable)
DaemonGroup ""
# try to detect interface maximum bandwidth, 0 = disable feature
# MaxBandwidth will be used as fallback value when enabled
BandwidthDetection 1
# maximum bandwidth (Mbit) for all interfaces, 0 = disable feature
# (unless interface specific limit is given)
MaxBandwidth 1000
# interface specific limits
# example 8Mbit limit for eth0 (remove # to activate):
#MaxBWeth0 8
# data retention durations (-1 = unlimited, 0 = feature disabled)
5MinuteHours 48
HourlyDays 4
DailyDays 62
MonthlyMonths 25
YearlyYears -1
TopDayEntries 20
# how often (in seconds) interface data is updated
UpdateInterval 30
# how often (in seconds) interface status changes are checked
PollInterval 5
# how often (in minutes) data is saved to database
SaveInterval 5
# how often (in minutes) data is saved when all interface are offline
OfflineSaveInterval 30
# on which day should months change
MonthRotate 1
MonthRotateAffectsYears 0
# filesystem disk space check (1 = enabled, 0 = disabled)
CheckDiskSpace 1
# how much the boot time can variate between updates (seconds)
BootVariation 15
# create database entries even when there is no traffic (1 = enabled, 0 = disabled)
TrafficlessEntries 1
# how many minutes to wait during daemon startup for system clock to
# sync time if most recent database update appears to be in the future
TimeSyncWait 5
# how often (in minutes) bandwidth detection is done when
# BandwidthDetection is enabled (0 = disabled)
BandwidthDetectionInterval 5
# force data save when interface status changes (1 = enabled, 0 = disabled)
SaveOnStatusChange 1
# enable / disable logging (0 = disabled, 1 = logfile, 2 = syslog)
UseLogging 2
# create dirs if needed (1 = enabled, 0 = disabled)
CreateDirs 1
# update ownership of files if needed (1 = enabled, 0 = disabled)
UpdateFileOwner 1
# file used for logging if UseLogging is set to 1
LogFile "/var/log/vnstat/vnstat.log"
# file used as daemon pid / lock file
PidFile "/var/run/vnstat/vnstat.pid"
# vnstati
##
# title timestamp format
HeaderFormat "%Y-%m-%d %H:%M"
# show hours with rate (1 = enabled, 0 = disabled)
HourlyRate 1
# show rate in summary (1 = enabled, 0 = disabled)
SummaryRate 1
# transparent background (1 = enabled, 0 = disabled)
TransparentBg 0
# image colors
CBackground "FFFFFF"
CEdge "AEAEAE"
CHeader "606060"
CHeaderTitle "FFFFFF"
CHeaderDate "FFFFFF"
CText "000000"
CLine "B0B0B0"
CLineL "-"
CRx "92CF00"
CTx "606060"
CRxD "-"
CTxD "-"
Hier die Datei "/var/log/httpd/error_log", die geschrieben wird, so bald ich die index.php in /srv/http/ mit 127.0.0.1/index.php im Browser aufrufe:
[Wed Nov 14 16:12:18.336257 2018] [mpm_prefork:notice] [pid 420] AH00163: Apache/2.4.37 (Unix) PHP/7.2.12 configured -- resuming normal operations
[Wed Nov 14 16:12:18.337510 2018] [core:notice] [pid 420] AH00094: Command line: '/usr/bin/httpd -D FOREGROUND'
[Wed Nov 14 16:12:56.740373 2018] [php7:notice] [pid 460] [client 127.0.0.1:48770] PHP Notice: Undefined index: totalrx in /srv/http/index.php on line 81
[Wed Nov 14 16:12:56.740451 2018] [php7:notice] [pid 460] [client 127.0.0.1:48770] PHP Notice: Undefined index: totalrxk in /srv/http/index.php on line 81
[Wed Nov 14 16:12:56.740477 2018] [php7:notice] [pid 460] [client 127.0.0.1:48770] PHP Notice: Undefined index: totaltx in /srv/http/index.php on line 82
[Wed Nov 14 16:12:56.740493 2018] [php7:notice] [pid 460] [client 127.0.0.1:48770] PHP Notice: Undefined index: totaltxk in /srv/http/index.php on line 82
[Wed Nov 14 16:12:56.740525 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: Illegal string offset 'rx' in /srv/http/index.php on line 89
[Wed Nov 14 16:12:56.740536 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: Illegal string offset 'tx' in /srv/http/index.php on line 90
[Wed Nov 14 16:12:56.740546 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: Illegal string offset 'rx' in /srv/http/index.php on line 94
[Wed Nov 14 16:12:56.740553 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: Illegal string offset 'tx' in /srv/http/index.php on line 95
[Wed Nov 14 16:12:56.740562 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: Illegal string offset 'rx' in /srv/http/index.php on line 99
[Wed Nov 14 16:12:56.740569 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: Illegal string offset 'tx' in /srv/http/index.php on line 100
[Wed Nov 14 16:12:56.740593 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 74
[Wed Nov 14 16:12:56.740620 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 74
[Wed Nov 14 16:12:56.740632 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 131
[Wed Nov 14 16:12:56.740640 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 131
[Wed Nov 14 16:12:56.740655 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 74
[Wed Nov 14 16:12:56.740667 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 74
[Wed Nov 14 16:12:56.740679 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 131
[Wed Nov 14 16:12:56.740688 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 131
[Wed Nov 14 16:12:56.740703 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 74
[Wed Nov 14 16:12:56.740712 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 74
[Wed Nov 14 16:12:56.740719 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 131
[Wed Nov 14 16:12:56.740726 2018] [php7:warn] [pid 460] [client 127.0.0.1:48770] PHP Warning: A non-numeric value encountered in /srv/http/index.php on line 131
Und zuletzt noch den Inhalt des Verzeichnisses /var/lib/vnstat/, in dem die Daten liegen.
[hanshiasl@arch vnstat]$ ls -la
insgesamt 120
drwxr-xr-x 2 root root 4096 14. Nov 16:17 .
drwxr-xr-x 33 root root 4096 14. Nov 16:12 ..
-rw-r--r-- 1 root root 2792 23. Okt 06:19 .enp4s0
-rw-r--r-- 1 root root 2792 23. Okt 06:19 enp4s0
-rw-r--r-- 1 root root 98304 14. Nov 16:17 vnstat.db
-rw-r--r-- 1 root root 2792 23. Okt 06:19 .wlp5s0
-rw-r--r-- 1 root root 2792 23. Okt 06:19 wlp5s0
.
Kann mir da jemand auf die Sprünge helfen, wie ich die Daten im Bowser sichtbar machen kann?
Ich finde leider den Fehler nicht.
Auf meinem NAS mit Ubuntu Server 16.04 funktioniert es einwandfrei.