Hallo,
Ich würde gerne die Network Traffic Daten in zabbix sammeln und verwerten.
Hat vielleicht schon jemand eventuell eine Importmöglichkeit für Daten aus dem Linuxtool vnstat realisiert?
Wenn nicht, hat jemand das Vermögen und die Lust dies zu tun? Meine Dankbarkeit und ein Trinkgeld wäre demjenigen sicher.
vnstat ( http://humdi.net/vnstat/ ) bietet ja die Möglichkeit die Daten sich als xml oder in ";" separierten Style, ausgeben zu lassen. Eine Möglichkeit wäre ja nun via z.B. xml2/sed script+cronjob und zabbix_sender die Daten auf einen Zabbix Server zu pushen.
Beispieldaten (XML output):
";" Style
Alternativ, kennt jemand einen entsprechenden allgemein gültigen XML2zabbix Converter oder ähnliches?
Vielleicht ergibt sich ja was, Danke schonmal!
Schöne Grüße
Forseti
Ich würde gerne die Network Traffic Daten in zabbix sammeln und verwerten.
Hat vielleicht schon jemand eventuell eine Importmöglichkeit für Daten aus dem Linuxtool vnstat realisiert?
Wenn nicht, hat jemand das Vermögen und die Lust dies zu tun? Meine Dankbarkeit und ein Trinkgeld wäre demjenigen sicher.

vnstat ( http://humdi.net/vnstat/ ) bietet ja die Möglichkeit die Daten sich als xml oder in ";" separierten Style, ausgeben zu lassen. Eine Möglichkeit wäre ja nun via z.B. xml2/sed script+cronjob und zabbix_sender die Daten auf einen Zabbix Server zu pushen.
Beispieldaten (XML output):
--xml Show database content for selected interface or all interfaces in xml format. All traffic values in the output are in KiB.
Code:
<vnstat version="1.11" xmlversion="1">
<interface id="eth2">
<id>eth2</id>
<nick>eth2</nick>
<created><date><year>2015</year><month>10</month><day>15</day></date></created>
<updated><date><year>2015</year><month>10</month><day>15</day></date><time><hour>18</hour><minute>27</minute></time></updated>
<traffic>
<total><rx>0</rx><tx>0</tx></total>
<days>
<day id="0"><date><year>2015</year><month>10</month><day>15</day></date><rx>0</rx><tx>0</tx></day>
</days>
<months>
<month id="0"><date><year>2015</year><month>10</month></date><rx>0</rx><tx>0</tx></month>
</months>
<tops>
</tops>
<hours>
<hour id="16"><date><year>2015</year><month>10</month><day>15</day></date><rx>0</rx><tx>0</tx></hour>
<hour id="17"><date><year>2015</year><month>10</month><day>15</day></date><rx>0</rx><tx>0</tx></hour>
<hour id="18"><date><year>2015</year><month>10</month><day>15</day></date><rx>0</rx><tx>0</tx></hour>
</hours>
</traffic>
</interface>
<interface id="eth0">
<id>eth0</id>
<nick>eth0</nick>
<created><date><year>2015</year><month>10</month><day>15</day></date></created>
<updated><date><year>2015</year><month>10</month><day>15</day></date><time><hour>18</hour><minute>27</minute></time></updated>
<traffic>
<total><rx>9685</rx><tx>180</tx></total>
<days>
<day id="0"><date><year>2015</year><month>10</month><day>15</day></date><rx>9685</rx><tx>180</tx></day>
</days>
<months>
<month id="0"><date><year>2015</year><month>10</month></date><rx>9685</rx><tx>180</tx></month>
</months>
<tops>
</tops>
<hours>
<hour id="16"><date><year>2015</year><month>10</month><day>15</day></date><rx>471</rx><tx>32</tx></hour>
<hour id="17"><date><year>2015</year><month>10</month><day>15</day></date><rx>4962</rx><tx>97</tx></hour>
<hour id="18"><date><year>2015</year><month>10</month><day>15</day></date><rx>4252</rx><tx>51</tx></hour>
</hours>
</traffic>
</interface>
<interface id="eth1">
<id>eth1</id>
<nick>eth1</nick>
<created><date><year>2015</year><month>10</month><day>15</day></date></created>
<updated><date><year>2015</year><month>10</month><day>15</day></date><time><hour>18</hour><minute>27</minute></time></updated>
<traffic>
<total><rx>1989</rx><tx>6359</tx></total>
<days>
<day id="0"><date><year>2015</year><month>10</month><day>15</day></date><rx>1989</rx><tx>6359</tx></day>
</days>
<months>
<month id="0"><date><year>2015</year><month>10</month></date><rx>1989</rx><tx>6359</tx></month>
</months>
<tops>
</tops>
<hours>
<hour id="16"><date><year>2015</year><month>10</month><day>15</day></date><rx>715</rx><tx>637</tx></hour>
<hour id="17"><date><year>2015</year><month>10</month><day>15</day></date><rx>856</rx><tx>5380</tx></hour>
<hour id="18"><date><year>2015</year><month>10</month><day>15</day></date><rx>418</rx><tx>342</tx></hour>
</hours>
</traffic>
</interface>
</vnstat>
Instead of showing the database with a formated output, this output will dump the whole database in a format that should be easy to parse with most script languages. Use this for example with PHP, Perl or Python to
make a custom webpage. The dump uses ; as field delimeter.
active;1 activity status
interface;eth0 name for the interface
nick;inet nick (if given)
created;1023895272 creation date in Unix time
updated;1065467100 when the database was updated
totalrx;569605 all time total received MiB
totaltx;2023708 all time total transmitted MiB
currx;621673719 latest rx value in /proc
curtx;981730184 latest tx value in /proc
totalrxk;644 total rx KiB counter
totaltxk;494 total tx KiB counter
btime;1059414541 system boot time in Unix time
Then follows 30 lines like the following
d;0;1078696800;559;7433;68;557;1
where d = days, 0 = day number in database (0 is today), 1077314401 date in Unix time, 559 = rx MiB, 7433 = tx MiB, 68 = rx KiB, 557 = tx KiB and 1 tells that vnStat has filled this value and it is in use.
m;0;1078092000;48649;139704;527;252;1 (x12)
t;0;1078351200;5979;47155;362;525;1 (x10)
h;0;1078699800;118265;516545 (x24)
m = months, t = top10 and h = hours, all other fields are in the same order as in days except hours that doesn't have a separate KiB value. For hours the forth and fifth fields have values in KiB.
make a custom webpage. The dump uses ; as field delimeter.
active;1 activity status
interface;eth0 name for the interface
nick;inet nick (if given)
created;1023895272 creation date in Unix time
updated;1065467100 when the database was updated
totalrx;569605 all time total received MiB
totaltx;2023708 all time total transmitted MiB
currx;621673719 latest rx value in /proc
curtx;981730184 latest tx value in /proc
totalrxk;644 total rx KiB counter
totaltxk;494 total tx KiB counter
btime;1059414541 system boot time in Unix time
Then follows 30 lines like the following
d;0;1078696800;559;7433;68;557;1
where d = days, 0 = day number in database (0 is today), 1077314401 date in Unix time, 559 = rx MiB, 7433 = tx MiB, 68 = rx KiB, 557 = tx KiB and 1 tells that vnStat has filled this value and it is in use.
m;0;1078092000;48649;139704;527;252;1 (x12)
t;0;1078351200;5979;47155;362;525;1 (x10)
h;0;1078699800;118265;516545 (x24)
m = months, t = top10 and h = hours, all other fields are in the same order as in days except hours that doesn't have a separate KiB value. For hours the forth and fifth fields have values in KiB.
Code:
version;3 active;1 interface;eth0 nick;eth0 created;1444918036 updated;1444926770 totalrx;9 totaltx;0 currx;53255561 curtx;1188420 totalrxk;511 totaltxk;189 btime;1444901992 d;0;1444918036;9;0;511;189;1 d;1;0;0;0;0;0;0 d;2;0;0;0;0;0;0 d;3;0;0;0;0;0;0 d;4;0;0;0;0;0;0 d;5;0;0;0;0;0;0 d;6;0;0;0;0;0;0 d;7;0;0;0;0;0;0 d;8;0;0;0;0;0;0 d;9;0;0;0;0;0;0 d;10;0;0;0;0;0;0 d;11;0;0;0;0;0;0 d;12;0;0;0;0;0;0 d;13;0;0;0;0;0;0 d;14;0;0;0;0;0;0 d;15;0;0;0;0;0;0 d;16;0;0;0;0;0;0 d;17;0;0;0;0;0;0 d;18;0;0;0;0;0;0 d;19;0;0;0;0;0;0 d;20;0;0;0;0;0;0 d;21;0;0;0;0;0;0 d;22;0;0;0;0;0;0 d;23;0;0;0;0;0;0 d;24;0;0;0;0;0;0 d;25;0;0;0;0;0;0 d;26;0;0;0;0;0;0 d;27;0;0;0;0;0;0 d;28;0;0;0;0;0;0 d;29;0;0;0;0;0;0 m;0;1444918036;9;0;511;189;1 m;1;0;0;0;0;0;0 m;2;0;0;0;0;0;0 m;3;0;0;0;0;0;0 m;4;0;0;0;0;0;0 m;5;0;0;0;0;0;0 m;6;0;0;0;0;0;0 m;7;0;0;0;0;0;0 m;8;0;0;0;0;0;0 m;9;0;0;0;0;0;0 m;10;0;0;0;0;0;0 m;11;0;0;0;0;0;0 t;0;0;0;0;0;0;0 t;1;0;0;0;0;0;0 t;2;0;0;0;0;0;0 t;3;0;0;0;0;0;0 t;4;0;0;0;0;0;0 t;5;0;0;0;0;0;0 t;6;0;0;0;0;0;0 t;7;0;0;0;0;0;0 t;8;0;0;0;0;0;0 t;9;0;0;0;0;0;0 h;0;0;0;0 h;1;0;0;0 h;2;0;0;0 h;3;0;0;0 h;4;0;0;0 h;5;0;0;0 h;6;0;0;0 h;7;0;0;0 h;8;0;0;0 h;9;0;0;0 h;10;0;0;0 h;11;0;0;0 h;12;0;0;0 h;13;0;0;0 h;14;0;0;0 h;15;0;0;0 h;16;1444921190;471;32 h;17;1444924790;4962;97 h;18;1444926770;4294;60 h;19;0;0;0 h;20;0;0;0 h;21;0;0;0 h;22;0;0;0 h;23;0;0;0
Vielleicht ergibt sich ja was, Danke schonmal!
Schöne Grüße
Forseti
Comment