File: second.lua

package info (click to toggle)
ntopng 2.4%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,888 kB
  • ctags: 8,091
  • sloc: cpp: 21,442; ansic: 10,999; sh: 1,627; makefile: 423; pascal: 312; ruby: 34; exp: 4
file content (52 lines) | stat: -rw-r--r-- 1,633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--
-- (C) 2013-16 - ntop.org
--

dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path

if (ntop.isPro()) then
  package.path = dirs.installdir .. "/pro/scripts/callbacks/?.lua;" .. package.path
end

require "lua_utils"
require "graph_utils"

-- Toggle debug
local enable_second_debug = 0

ifnames = interface.getIfNames()

for _,ifname in pairs(ifnames) do
   a = string.ends(ifname, ".pcap")
   if(not(a)) then
      interface.select(ifname)
      ifstats = aggregateInterfaceStats(interface.getStats())

      dirs = ntop.getDirs()
      basedir = fixPath(dirs.workingdir .. "/" .. ifstats.id .. "/rrd")

      --io.write(basedir.."\n")
      if(not(ntop.exists(basedir))) then
	 if(enable_second_debug == 1) then io.write('Creating base directory ', basedir, '\n') end
	 ntop.mkdir(basedir)
      end

      interface.setSecondTraffic()

      -- Traffic stats
      makeRRD(basedir, ifname, "bytes", 1, ifstats.bytes)
      makeRRD(basedir, ifname, "packets", 1, ifstats.packets)
      makeRRD(basedir, ifname, "drops", 1, ifstats.drops)

      -- General stats
      makeRRD(basedir, ifname, "num_hosts", 1, ifstats.hosts)
      makeRRD(basedir, ifname, "num_flows", 1, ifstats.flows)
      makeRRD(basedir, ifname, "num_http_hosts", 1, ifstats.http_hosts)

      -- TCP stats
      makeRRD(basedir, ifname, "tcp_retransmissions", 1, ifstats.tcpPacketStats.retransmissions)
      makeRRD(basedir, ifname, "tcp_ooo", 1, ifstats.tcpPacketStats.out_of_order)
      makeRRD(basedir, ifname, "tcp_lost", 1, ifstats.tcpPacketStats.lost)
   end
end -- for _,ifname in pairs(ifnames) do