cokemine / ServerStatus-goclient

The client of ServerStatus-Hotaru written in Go
MIT License
74 stars 27 forks source link

fix(vnstat): panic when not enough data available #14

Closed cubercsl closed 2 years ago

cubercsl commented 2 years ago

When using vnstat first time or without persistent data (such as openwrt with data stored in flash), the output of the command vnstat --oneline at startup will be:

# vnstat --oneline
 enp2s0: Not enough data available yet.

and the indexing operation in the code will cause panic.

And the man page of vnstat says "The output contains 15 fields with ; used as field delimiter".

  --oneline [mode]
      Show traffic summary for selected interface using one line with a parsable format. The output contains 15 fields with ; used as field delimiter.