1

Temat: Vnstat nie zapisuje danych

Zainstalowałem pakiet vnstat i przy każdym restarcie routera zapisuje dane od nowa a chciałbym by jednak te dane były zapisane na stałe. Do modemu mam włożoną kartę SD na która przeniosłem bazę danych, edytując pozycje DatabaseDir  na "/tmp/extroot/". Niestety  nic to nie daje, nie za bardzo wiem gdzie tkwi problem?

2

Odp: Vnstat nie zapisuje danych

Ponieważ:
- musisz zamontować gdzieś nośnik (/tmp/extroot!)
- uruchomić vnstat PO zamontowaniu nośnika

Zrobiłeś obie rzeczy?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: Vnstat nie zapisuje danych

ok, przez interfejs luci zamontowałem  kartę SD i jest widoczna w katalogu /tmp/extroot czyli rozumiem że mam  zamontować ten nośnik w innym katalogu np /mnt ???

4

Odp: Vnstat nie zapisuje danych

Montuj gdzie chcesz, może być i w /tmp. Byle by był tam zamontowany

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

5

Odp: Vnstat nie zapisuje danych

Nośnik jest zamontowany. Kiedy przechodzę do katalogu /tmp/extroot  widzę że jednak vnstat zapisuje  dane na karcie SD.  Ale jednak to nie działa tak jak powinno.

6

Odp: Vnstat nie zapisuje danych

Co nie działa? Zrestartuj router, nie rób nic więcej tylko zaloguj się przez ssh i pokaż wyniki poleceń:

uci show fstab
mount
uci show vnstat
cat /etc/vnstat.conf
ps
Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

7

Odp: Vnstat nie zapisuje danych

root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].enabled='1'
fstab.@mount[0].device='/dev/sda1'
fstab.@mount[0].target='/'
root@OpenWrt:~# 
root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/ubi0_1 on /overlay type ubifs (rw,noatime,ubi=0,vol=1)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
root@OpenWrt:~# 
root@OpenWrt:~# uci show vnstat
vnstat.@vnstat[0]=vnstat
vnstat.@vnstat[0].interface='br-lan' 'eth0.2'
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/vnstat.conf
# vnStat 1.18 config file
##

# default interface
Interface "eth0"

# location of the database directory
DatabaseDir "/tmp/extroot/"

# locale (LC_ALL) ("-" = use system locale)
Locale "-"

# on which day should months change
MonthRotate 1

# date output formats for -d, -m, -t and -w
# see 'man date' for control codes
DayFormat    "%d-%m-%Y"
MonthFormat  "%d-%m-%Y"
TopFormat    "%x"

# 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/TiB)
# 1 = old style binary prefixes (KB/MB/GB/TB)
UnitMode 0

# how units are prefixed when traffic rate is shown
# 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 and weekly
# 3 = rate column visible
OutputStyle 3

# used rate unit (0 = bytes, 1 = bits)
RateUnit 1

# number of decimals to use in outputs
DefaultDecimals 2
HourlyDecimals 1

# spacer for separating hourly sections (0 = none, 1 = '|', 2 = '][', 3 = '[ ]')
HourlySectionStyle 2

# 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 'ethnone':
MaxBWethnone 8

# how many seconds should sampling for -tr take by default
Sampletime 5

# default query mode
# 0 = normal, 1 = days, 2 = months, 3 = top10
# 4 = exportdb, 5 = short, 6 = weeks, 7 = hours
QueryMode 0

# filesystem disk space check (1 = enabled, 0 = disabled)
CheckDiskSpace 1

# database file locking (1 = enabled, 0 = disabled)
UseFileLocking 1

# how much the boot time can variate between updates (seconds)
BootVariation 15

# log days without traffic to daily list (1 = enabled, 0 = disabled)
TrafficlessDays 1


# 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 ""

# 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 seconds) interface data is updated
UpdateInterval 60

# how often (in seconds) interface status changes are checked
PollInterval 30

# how often (in minutes) data is saved to file
SaveInterval 15

# how often (in minutes) data is saved when all interface are offline
OfflineSaveInterval 30

# how often (in minutes) bandwidth detection is redone 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 "%x %H:%M"

# show hours with rate (1 = enabled, 0 = disabled)
HourlyRate 1

# show rate in summary (1 = enabled, 0 = disabled)
SummaryRate 1
root@OpenWrt:~# cat /etc/vnstat.conf
# vnStat 1.18 config file
##

# default interface
Interface "eth0"

# location of the database directory
DatabaseDir "/tmp/extroot/"

# locale (LC_ALL) ("-" = use system locale)
Locale "-"

# on which day should months change
MonthRotate 1

# date output formats for -d, -m, -t and -w
# see 'man date' for control codes
DayFormat    "%d-%m-%Y"
MonthFormat  "%d-%m-%Y"
TopFormat    "%x"

# 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/TiB)
# 1 = old style binary prefixes (KB/MB/GB/TB)
UnitMode 0

# how units are prefixed when traffic rate is shown
# 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 and weekly
# 3 = rate column visible
OutputStyle 3

# used rate unit (0 = bytes, 1 = bits)
RateUnit 1

# number of decimals to use in outputs
DefaultDecimals 2
HourlyDecimals 1

# spacer for separating hourly sections (0 = none, 1 = '|', 2 = '][', 3 = '[ ]')
HourlySectionStyle 2

# 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 'ethnone':
MaxBWethnone 8

# how many seconds should sampling for -tr take by default
Sampletime 5

# default query mode
# 0 = normal, 1 = days, 2 = months, 3 = top10
# 4 = exportdb, 5 = short, 6 = weeks, 7 = hours
QueryMode 0

# filesystem disk space check (1 = enabled, 0 = disabled)
CheckDiskSpace 1

# database file locking (1 = enabled, 0 = disabled)
UseFileLocking 1

# how much the boot time can variate between updates (seconds)
BootVariation 15

# log days without traffic to daily list (1 = enabled, 0 = disabled)
TrafficlessDays 1


# 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 ""

# 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 seconds) interface data is updated
UpdateInterval 60

# how often (in seconds) interface status changes are checked
PollInterval 30

# how often (in minutes) data is saved to file
SaveInterval 15

# how often (in minutes) data is saved when all interface are offline
OfflineSaveInterval 30

# how often (in minutes) bandwidth detection is redone 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 "%x %H:%M"

# show hours with rate (1 = enabled, 0 = disabled)
HourlyRate 1

# show rate in summary (1 = enabled, 0 = disabled)
SummaryRate 1

# layout of summary (1 = with monthly, 0 = without monthly)
SummaryLayout 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            "-"
root@OpenWrt:~# ps
  PID USER       VSZ STAT COMMAND
    1 root      1568 S    /sbin/procd
    2 root         0 SW   [kthreadd]
    3 root         0 IW   [kworker/0:0]
    4 root         0 IW<  [kworker/0:0H]
    5 root         0 IW   [kworker/u4:0]
    6 root         0 IW<  [mm_percpu_wq]
    7 root         0 SW   [ksoftirqd/0]
    8 root         0 IW   [rcu_sched]
    9 root         0 IW   [rcu_bh]
   10 root         0 SW   [migration/0]
   11 root         0 SW   [cpuhp/0]
   12 root         0 SW   [cpuhp/1]
   13 root         0 SW   [migration/1]
   14 root         0 SW   [ksoftirqd/1]
   15 root         0 IW   [kworker/1:0]
   16 root         0 IW<  [kworker/1:0H]
   17 root         0 RW   [kworker/u4:1]
   57 root         0 IW   [kworker/0:1]
  115 root         0 IW   [kworker/1:1]
  128 root         0 SW   [oom_reaper]
  129 root         0 IW<  [writeback]
  131 root         0 SW   [kcompactd0]
  132 root         0 IW<  [crypto]
  134 root         0 IW<  [kblockd]
  166 root         0 IW<  [watchdogd]
  188 root         0 SW   [kswapd0]
  247 root         0 IW<  [pencrypt]
  249 root         0 IW<  [pdecrypt]
  348 root         0 IW<  [ipv6_addrconf]
  360 root         0 SW   [ubi_bgt0d]
  365 root         0 IW<  [kworker/1:1H]
  366 root         0 IW<  [kworker/0:1H]
  371 root         0 IW   [kworker/u4:2]
  490 root         0 IW   [kworker/0:2]
  502 root         0 SW   [ubifs_bgt0_1]
  600 root      1220 S    /sbin/ubusd
  618 root       924 S    /sbin/askfirst /usr/libexec/login.sh
  688 root      1028 S    /sbin/urngd
  837 root         0 IW<  [cfg80211]
 1189 root         0 SW   [scsi_eh_0]
 1190 root         0 IW<  [scsi_tmf_0]
 1191 root         0 SW   [usb-storage]
 1197 root         0 SW   [scsi_eh_1]

8

Odp: Vnstat nie zapisuje danych

Widzisz przecież że nie masz w fstabie montowania niczego w /tmp/extroot.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

9

Odp: Vnstat nie zapisuje danych

Udało mi się ustawić, teraz po restarcie wszytko działa i dane są zapisywane.

root@OpenWrt:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='7e30e612-f3d6-4a53-927b-c9ce819f65f3'
fstab.@mount[0].enabled='1'
root@OpenWrt:~#