View | Details | Raw Unified | Return to bug 251054 | Differences between
and this patch

Collapse All | Expand All

(-)bin/flow-rpt2rrd (-11 / +10 lines)
Lines 4-10 Link Here
4
import os
4
import os
5
import rrdtool
5
import rrdtool
6
import sys
6
import sys
7
import string
8
7
9
#
8
#
10
# flow-rpt2rrd - convert flow-report output to rrd format
9
# flow-rpt2rrd - convert flow-report output to rrd format
Lines 28-34 Link Here
28
    keys.append(line)
27
    keys.append(line)
29
    line = f.readline().strip()
28
    line = f.readline().strip()
30
  f.close()
29
  f.close()
31
  return string.join(keys, ',')
30
  return keys.join(',')
32
31
33
#
32
#
34
# Class: ftsym
33
# Class: ftsym
Lines 117-129 Link Here
117
116
118
  def set_use_fields(self,f):
117
  def set_use_fields(self,f):
119
    self.use_fields = {}
118
    self.use_fields = {}
120
    for i in string.split(f, ','):
119
    for i in f.split(','):
121
      self.use_fields[i] = 1
120
      self.use_fields[i] = 1
122
    
121
    
123
  def set_use_key_names(self,f):
122
  def set_use_key_names(self,f):
124
    self.use_key_names = {}
123
    self.use_key_names = {}
125
    self.use_key_names_special = {}
124
    self.use_key_names_special = {}
126
    for i in string.split(f, ','):
125
    for i in f.split(','):
127
      if i[:6] == 'total_':
126
      if i[:6] == 'total_':
128
        self.use_key_names_special[i] = 1
127
        self.use_key_names_special[i] = 1
129
      else:
128
      else:
Lines 141-147 Link Here
141
140
142
  def setrrd(self, storage, path, postfix):
141
  def setrrd(self, storage, path, postfix):
143
    (self.rrd_5min, self.rrd_30min, self.rrd_2hr, self.rrd_1day) = \
142
    (self.rrd_5min, self.rrd_30min, self.rrd_2hr, self.rrd_1day) = \
144
      string.split(storage,':')
143
      storage.split(':')
145
    self.rrd_path = path
144
    self.rrd_path = path
146
    self.rrd_postfix = postfix
145
    self.rrd_postfix = postfix
147
146
Lines 179-185 Link Here
179
178
180
      rrdtool.create(rrdFile, *rrdParams)
179
      rrdtool.create(rrdFile, *rrdParams)
181
      if self.debug:
180
      if self.debug:
182
        print >>sys.stderr, string.join(rrdParams,' ')
181
        print >>sys.stderr, rrdParams.join(' ')
183
182
184
    # foreach value
183
    # foreach value
185
184
Lines 208-221 Link Here
208
      if (not self.in_data) :
207
      if (not self.in_data) :
209
208
210
        if line[:13] == '# first-flow:':
209
        if line[:13] == '# first-flow:':
211
          self.start_time = (string.split(line[14:]))[0]
210
          self.start_time = line[14:].split()[0]
212
211
213
        # handle the totals record differently
212
        # handle the totals record differently
214
        if line[:53] == '# rec1: records,ignores,flows,octets,packets,duration':
213
        if line[:53] == '# rec1: records,ignores,flows,octets,packets,duration':
215
          tmp = string.split(line[8:], ',')
214
          tmp = line[8:].split(',')
216
          line = f.readline().strip()
215
          line = f.readline().strip()
217
          tmp_use_fields_index = {}
216
          tmp_use_fields_index = {}
218
          tmp_splt = string.split(line, ',')
217
          tmp_splt = line.split(',')
219
          x = 0
218
          x = 0
220
          ds = 0
219
          ds = 0
221
          for i in tmp:
220
          for i in tmp:
Lines 232-238 Link Here
232
          self.in_data = 1
231
          self.in_data = 1
233
    
232
    
234
          # foreach element in field names
233
          # foreach element in field names
235
          for i in string.split(line[8:],','):
234
          for i in line[8:].split(','):
236
    
235
    
237
            # remove key designators
236
            # remove key designators
238
            if i[-1:] == '*':
237
            if i[-1:] == '*':
Lines 267-273 Link Here
267
        # if in the data area and not a comment, store it
266
        # if in the data area and not a comment, store it
268
        if self.in_data and line [:1] != '#':
267
        if self.in_data and line [:1] != '#':
269
    
268
    
270
          splt = string.split(line, ',')
269
          splt = line.split(',')
271
270
272
          # combine the key fields to form one key
271
          # combine the key fields to form one key
273
          k = ''
272
          k = ''

Return to bug 251054