StatsCollect 0.2.0.20110830 → 0.3.0.20120314

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -11,10 +11,10 @@ module StatsCollect
11
11
 
12
12
  # Send a given notification
13
13
  #
14
- # Parameters:
14
+ # Parameters::
15
15
  # * *iConf* (<em>map<Symbol,Object></em>): The notifier config
16
16
  # * *iMessage* (_String_): Message to send
17
- def sendNotification(iConf, iMessage)
17
+ def send_notification(iConf, iMessage)
18
18
  end
19
19
 
20
20
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -11,10 +11,10 @@ module StatsCollect
11
11
 
12
12
  # Send a given notification
13
13
  #
14
- # Parameters:
14
+ # Parameters::
15
15
  # * *iConf* (<em>map<Symbol,Object></em>): The notifier config
16
16
  # * *iMessage* (_String_): Message to send
17
- def sendNotification(iConf, iMessage)
17
+ def send_notification(iConf, iMessage)
18
18
  require 'mail'
19
19
  Mail.defaults do
20
20
  delivery_method(:smtp, iConf[:SMTP])
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -28,10 +28,10 @@ module StatsCollect
28
28
  def initialize
29
29
  # Parse for available Locations
30
30
  require 'rUtilAnts/Plugins'
31
- RUtilAnts::Plugins::initializePlugins
32
- parsePluginsFromDir('Locations', "#{File.expand_path(File.dirname(__FILE__))}/Locations", 'StatsCollect::Locations')
33
- parsePluginsFromDir('Backends', "#{File.expand_path(File.dirname(__FILE__))}/Backends", 'StatsCollect::Backends')
34
- parsePluginsFromDir('Notifiers', "#{File.expand_path(File.dirname(__FILE__))}/Notifiers", 'StatsCollect::Notifiers')
31
+ RUtilAnts::Plugins::install_plugins_on_object
32
+ parse_plugins_from_dir('Locations', "#{File.expand_path(File.dirname(__FILE__))}/Locations", 'StatsCollect::Locations')
33
+ parse_plugins_from_dir('Backends', "#{File.expand_path(File.dirname(__FILE__))}/Backends", 'StatsCollect::Backends')
34
+ parse_plugins_from_dir('Notifiers', "#{File.expand_path(File.dirname(__FILE__))}/Notifiers", 'StatsCollect::Notifiers')
35
35
 
36
36
  @Backend = nil
37
37
  @BackendInit = false
@@ -43,12 +43,12 @@ module StatsCollect
43
43
  @Options = OptionParser.new
44
44
  @Options.banner = 'StatsCollect.rb [--help] [--debug] --backend <Backend> --notifier <Notifier> --config <ConfigFile>'
45
45
  @Options.on( '--backend <Backend>', String,
46
- "<Backend>: Backend to be used. Available backends are: #{getPluginNames('Backends').join(', ')}",
46
+ "<Backend>: Backend to be used. Available backends are: #{get_plugins_names('Backends').join(', ')}",
47
47
  'Specify the backend to be used') do |iArg|
48
48
  @Backend = iArg
49
49
  end
50
50
  @Options.on( '--notifier <Notifier>', String,
51
- "<Notifier>: Notifier used to send notifications. Available notifiers are: #{getPluginNames('Notifiers').join(', ')}",
51
+ "<Notifier>: Notifier used to send notifications. Available notifiers are: #{get_plugins_names('Notifiers').join(', ')}",
52
52
  'Specify the notifier to be used') do |iArg|
53
53
  @Notifier = iArg
54
54
  end
@@ -63,7 +63,7 @@ module StatsCollect
63
63
  end
64
64
  @Options.on( '--debug',
65
65
  'Activate debug logs') do
66
- activateLogDebug(true)
66
+ activate_log_debug(true)
67
67
  end
68
68
 
69
69
  end
@@ -71,9 +71,9 @@ module StatsCollect
71
71
  # Check that the environment is correctly set.
72
72
  # This has to be called prior to calling collect, and exit should be made if error code is not 0.
73
73
  #
74
- # Parameters:
74
+ # Parameters::
75
75
  # * *iParams* (<em>list<String></em>): The parameters, as given in the command line
76
- # Return:
76
+ # Return::
77
77
  # * _Integer_: Error code (given to exit) (0 = no error)
78
78
  def setup(iParams)
79
79
  rErrorCode = 0
@@ -82,29 +82,29 @@ module StatsCollect
82
82
  begin
83
83
  lRemainingArgs = @Options.parse(iParams)
84
84
  if (!lRemainingArgs.empty?)
85
- logErr "Unknown arguments: #{lRemainingArgs.join(' ')}"
86
- logErr @Options
85
+ log_err "Unknown arguments: #{lRemainingArgs.join(' ')}"
86
+ log_err @Options
87
87
  rErrorCode = 1
88
88
  end
89
89
  rescue Exception
90
- logErr "Exception: #{$!}.\n#{$!.backtrace.join("\n")}"
90
+ log_err "Exception: #{$!}.\n#{$!.backtrace.join("\n")}"
91
91
  rErrorCode = 2
92
92
  end
93
93
  if (rErrorCode == 0)
94
94
  if (@DisplayHelp)
95
- logMsg @Options
95
+ log_msg @Options
96
96
  rErrorCode = 3
97
97
  elsif (@Backend == nil)
98
- logErr 'You must specify a backend.'
99
- logErr @Options
98
+ log_err 'You must specify a backend.'
99
+ log_err @Options
100
100
  rErrorCode = 4
101
101
  elsif (@Notifier == nil)
102
- logErr 'You must specify a notifier.'
103
- logErr @Options
102
+ log_err 'You must specify a notifier.'
103
+ log_err @Options
104
104
  rErrorCode = 5
105
105
  elsif (@ConfigFile == nil)
106
- logErr 'You must specify a config file.'
107
- logErr @Options
106
+ log_err 'You must specify a config file.'
107
+ log_err @Options
108
108
  rErrorCode = 6
109
109
  else
110
110
  @Conf = nil
@@ -114,30 +114,30 @@ module StatsCollect
114
114
  @Conf = eval(iFile.read)
115
115
  end
116
116
  rescue
117
- logErr "Invalid configuration file: #{@ConfigFile}"
117
+ log_err "Invalid configuration file: #{@ConfigFile}"
118
118
  rErrorCode = 7
119
119
  end
120
120
  if (rErrorCode == 0)
121
121
  # Get the corresponding notifier
122
122
  if (@Conf[:Notifiers][@Notifier] == nil)
123
- logErr "Notifier #{@Notifier} has no configuration set up in configuration file #{@ConfigFile}"
123
+ log_err "Notifier #{@Notifier} has no configuration set up in configuration file #{@ConfigFile}"
124
124
  rErrorCode = 8
125
125
  else
126
- @NotifierInstance, lError = getPluginInstance('Notifiers', @Notifier)
126
+ @NotifierInstance, lError = get_plugin_instance('Notifiers', @Notifier)
127
127
  if (@NotifierInstance == nil)
128
- logErr "Unable to instantiate notifier #{@Notifier}: #{lError}"
128
+ log_err "Unable to instantiate notifier #{@Notifier}: #{lError}"
129
129
  rErrorCode = 9
130
130
  else
131
131
  # Will we notify the user of the script execution ?
132
132
  @NotifyUser = true
133
133
  # Get the corresponding backend
134
134
  if (@Conf[:Backends][@Backend] == nil)
135
- logErr "Backend #{@Backend} has no configuration set up in configuration file #{@ConfigFile}"
135
+ log_err "Backend #{@Backend} has no configuration set up in configuration file #{@ConfigFile}"
136
136
  rErrorCode = 10
137
137
  else
138
- @BackendInstance, lError = getPluginInstance('Backends', @Backend)
138
+ @BackendInstance, lError = get_plugin_instance('Backends', @Backend)
139
139
  if (@BackendInstance == nil)
140
- logErr "Unable to instantiate backend #{@Backend}: #{lError}"
140
+ log_err "Unable to instantiate backend #{@Backend}: #{lError}"
141
141
  rErrorCode = 11
142
142
  end
143
143
  end
@@ -152,53 +152,53 @@ module StatsCollect
152
152
 
153
153
  # Execute the stats collection
154
154
  #
155
- # Return:
155
+ # Return::
156
156
  # * _Integer_: Error code (given to exit)
157
157
  def collect
158
158
  rErrorCode = 0
159
159
 
160
160
  require 'rUtilAnts/Misc'
161
- RUtilAnts::Misc::initializeMisc
162
- lMutexErrorCode = fileMutex('StatsCollect') do
161
+ RUtilAnts::Misc::install_misc_on_object
162
+ lMutexErrorCode = file_mutex('StatsCollect') do
163
163
  begin
164
164
  # The list of errors
165
165
  lLstErrors = []
166
- setLogErrorsStack(lLstErrors)
166
+ set_log_errors_stack(lLstErrors)
167
167
  # Collect statistics
168
- logInfo "[#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}] - Begin collecting stats (PID #{Process.pid})..."
168
+ log_info "[#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}] - Begin collecting stats (PID #{Process.pid})..."
169
169
  lFoundOrder = false
170
170
  lNbrErrors = 0
171
171
  setupBackend do
172
172
  # Get the stats orders to process
173
173
  lStatsOrdersProxy = StatsOrdersProxy.new
174
- @BackendInstance.getStatsOrders(lStatsOrdersProxy)
174
+ @BackendInstance.get_stats_orders(lStatsOrdersProxy)
175
175
  lFoundOrder = (!lStatsOrdersProxy.StatsOrders.empty?)
176
176
  # Process each stats order
177
177
  lStatsOrdersProxy.StatsOrders.each do |iLstIDs, iStatsOrderInfo|
178
178
  iTimeStamp, iLstLocations, iLstObjects, iLstCategories, iStatus = iStatsOrderInfo
179
- @BackendInstance.dequeueStatsOrders(iLstIDs)
180
- logInfo "Dequeued stats order: IDs: #{iLstIDs.join('|')}, Time: #{iTimeStamp}, Locations: #{iLstLocations.join('|')}, Objects: #{iLstObjects.join('|')}, Categories: #{iLstCategories.join('|')}, Status: #{iStatus}"
179
+ @BackendInstance.dequeue_stats_orders(iLstIDs)
180
+ log_info "Dequeued stats order: IDs: #{iLstIDs.join('|')}, Time: #{iTimeStamp}, Locations: #{iLstLocations.join('|')}, Objects: #{iLstObjects.join('|')}, Categories: #{iLstCategories.join('|')}, Status: #{iStatus}"
181
181
  begin
182
182
  lRecoverableOrders, lUnrecoverableOrders = processOrder(iLstObjects, iLstCategories, iLstLocations)
183
183
  # Add recoverable orders back
184
184
  lRecoverableOrders.each do |iOrderInfo|
185
185
  lNbrErrors += 1
186
186
  iLstRecoverableObjects, iLstRecoverableCategories, iLstRecoverableLocations = iOrderInfo
187
- logInfo "Enqueue recoverable order: Locations: #{iLstRecoverableLocations.join('|')}, Objects: #{iLstRecoverableObjects.join('|')}, Categories: #{iLstRecoverableCategories.join('|')}"
188
- @BackendInstance.putNewStatsOrder(DateTime.now + @Conf[:RecoverableErrorsRetryDelay]/86400.0, iLstRecoverableLocations, iLstRecoverableObjects, iLstRecoverableCategories, STATS_ORDER_STATUS_RECOVERABLE_ERROR)
187
+ log_info "Enqueue recoverable order: Locations: #{iLstRecoverableLocations.join('|')}, Objects: #{iLstRecoverableObjects.join('|')}, Categories: #{iLstRecoverableCategories.join('|')}"
188
+ @BackendInstance.put_new_stats_order(DateTime.now + @Conf[:RecoverableErrorsRetryDelay]/86400.0, iLstRecoverableLocations, iLstRecoverableObjects, iLstRecoverableCategories, STATS_ORDER_STATUS_RECOVERABLE_ERROR)
189
189
  end
190
190
  # Add unrecoverable orders back
191
191
  lUnrecoverableOrders.each do |iOrderInfo|
192
192
  lNbrErrors += 1
193
193
  iLstUnrecoverableObjects, iLstUnrecoverableCategories, iLstUnrecoverableLocations = iOrderInfo
194
- logInfo "Enqueue unrecoverable order: Locations: #{iLstUnrecoverableLocations.join('|')}, Objects: #{iLstUnrecoverableObjects.join('|')}, Categories: #{iLstUnrecoverableCategories.join('|')}"
195
- @BackendInstance.putNewStatsOrder(iTimeStamp, iLstUnrecoverableLocations, iLstUnrecoverableObjects, iLstUnrecoverableCategories, STATS_ORDER_STATUS_UNRECOVERABLE_ERROR)
194
+ log_info "Enqueue unrecoverable order: Locations: #{iLstUnrecoverableLocations.join('|')}, Objects: #{iLstUnrecoverableObjects.join('|')}, Categories: #{iLstUnrecoverableCategories.join('|')}"
195
+ @BackendInstance.put_new_stats_order(iTimeStamp, iLstUnrecoverableLocations, iLstUnrecoverableObjects, iLstUnrecoverableCategories, STATS_ORDER_STATUS_UNRECOVERABLE_ERROR)
196
196
  end
197
197
  @BackendInstance.commit
198
198
  rescue Exception
199
199
  lNbrErrors += 1
200
200
  @BackendInstance.rollback
201
- logErr "Exception while processing order #{iTimeStamp}, Locations: #{iLstLocations.join('|')}, Objects: #{iLstObjects.join('|')}, Categories: #{iLstCategories.join('|')}, Status: #{iStatus}: #{$!}.\n#{$!.backtrace.join("\n")}\n"
201
+ log_err "Exception while processing order #{iTimeStamp}, Locations: #{iLstLocations.join('|')}, Objects: #{iLstObjects.join('|')}, Categories: #{iLstCategories.join('|')}, Status: #{iStatus}: #{$!}.\n#{$!.backtrace.join("\n")}\n"
202
202
  rErrorCode = 14
203
203
  end
204
204
  end
@@ -206,16 +206,16 @@ module StatsCollect
206
206
  if (!lFoundOrder)
207
207
  @NotifyUser = false
208
208
  end
209
- setLogErrorsStack(nil)
209
+ set_log_errors_stack(nil)
210
210
  if (lNbrErrors > 0)
211
- logErr "#{lNbrErrors} orders were put in error during processing. Please check logs."
211
+ log_err "#{lNbrErrors} orders were put in error during processing. Please check logs."
212
212
  end
213
213
  if (!lLstErrors.empty?)
214
- logErr "#{lLstErrors.size} errors were reported. Check log for exact errors."
214
+ log_err "#{lLstErrors.size} errors were reported. Check log for exact errors."
215
215
  end
216
- logInfo "[#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}] - Stats collection finished."
216
+ log_info "[#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}] - Stats collection finished."
217
217
  rescue Exception
218
- logErr "Exception thrown while collecting stats: #{$!}.\n#{$!.backtrace.join("\n")}"
218
+ log_err "Exception thrown while collecting stats: #{$!}.\n#{$!.backtrace.join("\n")}"
219
219
  rErrorCode = 15
220
220
  @NotifyUser = true
221
221
  end
@@ -230,7 +230,7 @@ module StatsCollect
230
230
 
231
231
  # Send notifications of a file content if necessary
232
232
  #
233
- # Parameters:
233
+ # Parameters::
234
234
  # * *iFileName* (_String_): The file containing notifications to be sent
235
235
  def notify(iFileName)
236
236
  if (@NotifyUser)
@@ -242,19 +242,19 @@ module StatsCollect
242
242
  rescue Exception
243
243
  lMessage = "Error while reading log file #{iFileName}: #{$!}"
244
244
  end
245
- @NotifierInstance.sendNotification(@Conf[:Notifiers][@Notifier], lMessage)
245
+ @NotifierInstance.send_notification(@Conf[:Notifiers][@Notifier], lMessage)
246
246
  end
247
247
  end
248
248
 
249
249
  # Enqueue a new stats order
250
250
  #
251
- # Parameters:
251
+ # Parameters::
252
252
  # * *iLstLocations* (<em>list<String></em>): Locations list (can be empty for all locations)
253
253
  # * *iLstObjects* (<em>list<String></em>): Objects list (can be empty for all objects)
254
254
  # * *iLstCategories* (<em>list<String></em>): Categories list (can be empty for all categories)
255
255
  def pushStatsOrder(iLstLocations, iLstObjects, iLstCategories)
256
256
  setupBackend do
257
- @BackendInstance.putNewStatsOrder(DateTime.now, iLstLocations, iLstObjects, iLstCategories, STATS_ORDER_STATUS_TOBEPROCESSED)
257
+ @BackendInstance.put_new_stats_order(DateTime.now, iLstLocations, iLstObjects, iLstCategories, STATS_ORDER_STATUS_TOBEPROCESSED)
258
258
  end
259
259
  end
260
260
 
@@ -263,31 +263,31 @@ module StatsCollect
263
263
  # Call some code initializing backend before and ensuring it will be closed after.
264
264
  # This method is re-entrant.
265
265
  #
266
- # Parameters:
266
+ # Parameters::
267
267
  # * _CodeBlock_: the code to be called
268
268
  def setupBackend
269
269
  lBackendInitHere = false
270
270
  if (!@BackendInit)
271
- @BackendInstance.initSession(@Conf[:Backends][@Backend])
271
+ @BackendInstance.init_session(@Conf[:Backends][@Backend])
272
272
  @BackendInit = true
273
273
  lBackendInitHere = true
274
274
  end
275
275
  yield
276
276
  if (lBackendInitHere)
277
- @BackendInstance.closeSession
277
+ @BackendInstance.close_session
278
278
  @BackendInit = false
279
279
  end
280
280
  end
281
281
 
282
282
  # Process an order
283
283
  #
284
- # Parameters:
284
+ # Parameters::
285
285
  # * *iObjectsList* (<em>list<String></em>): List of objects to filter (can be empty for all)
286
286
  # * *iCategoriesList* (<em>list<String></em>): List of categories to filter (can be empty for all)
287
287
  # * *iLocationsList* (<em>list<String></em>): List of locations to filter (can be empty for all)
288
- # Return:
289
- # * <em>list<[list<String>,list<String>,list<String>]></em>: The list of orders (objects, categories, locations) that could not be performed due to recoverable errors
290
- # * <em>list<[list<String>,list<String>,list<String>]></em>: The list of orders (objects, categories, locations) that could not be performed due to unrecoverable errors
288
+ # Return::
289
+ # * <em>list< [list<String>,list<String>,list<String>] ></em>: The list of orders (objects, categories, locations) that could not be performed due to recoverable errors
290
+ # * <em>list< [list<String>,list<String>,list<String>] ></em>: The list of orders (objects, categories, locations) that could not be performed due to unrecoverable errors
291
291
  def processOrder(iObjectsList, iCategoriesList, iLocationsList)
292
292
  rRecoverableOrders = []
293
293
  rUnrecoverableOrders = []
@@ -295,7 +295,7 @@ module StatsCollect
295
295
  # For each location, call the relevant plugin
296
296
  lPlugins = []
297
297
  if (iLocationsList.empty?)
298
- lPlugins = getPluginNames('Locations')
298
+ lPlugins = get_plugins_names('Locations')
299
299
  else
300
300
  lPlugins = iLocationsList
301
301
  end
@@ -305,15 +305,15 @@ module StatsCollect
305
305
  if (@Conf[:Locations] != nil)
306
306
  lPluginConf = @Conf[:Locations][iPluginName]
307
307
  end
308
- lPlugin, lError = getPluginInstance('Locations', iPluginName)
308
+ lPlugin, lError = get_plugin_instance('Locations', iPluginName)
309
309
  if (lError == nil)
310
310
  # Ask the plugin to perform the order
311
311
  lStatsProxy = StatsProxy.new(iObjectsList, iCategoriesList, @BackendInstance, iPluginName)
312
- logInfo "===== Call Location plugin #{iPluginName} to perform order..."
312
+ log_info "===== Call Location plugin #{iPluginName} to perform order..."
313
313
  begin
314
314
  lPlugin.execute(lStatsProxy, lPluginConf, iObjectsList, iCategoriesList)
315
315
  rescue Exception
316
- logErr "Exception thrown during plugin #{iPluginName} execution: #{$!}.\n#{$!.backtrace.join("\n")}"
316
+ log_err "Exception thrown during plugin #{iPluginName} execution: #{$!}.\n#{$!.backtrace.join("\n")}"
317
317
  lErrorPlugins << iPluginName
318
318
  lError = true
319
319
  end
@@ -343,9 +343,9 @@ module StatsCollect
343
343
  end
344
344
  end
345
345
  end
346
- logInfo ''
346
+ log_info ''
347
347
  else
348
- logErr "Error while instantiating Location plugin #{iPluginName}: #{$!}."
348
+ log_err "Error while instantiating Location plugin #{iPluginName}: #{$!}."
349
349
  lErrorPlugins << iPluginName
350
350
  end
351
351
  end
@@ -360,10 +360,10 @@ module StatsCollect
360
360
  # Both lists can be empty to indicate all possible names.
361
361
  # This method returns the intersection of both lists.
362
362
  #
363
- # Parameters:
363
+ # Parameters::
364
364
  # * *iLst1* (<em>list<String></em>): The first list
365
365
  # * *iLst2* (<em>list<String></em>): The second list
366
- # Return:
366
+ # Return::
367
367
  # * <em>list<String></em>: The resulting list. Can be empty for all possible names, or nil for no name.
368
368
  def intersectLists(iLst1, iLst2)
369
369
  rLstIntersection = nil
@@ -398,8 +398,8 @@ module StatsCollect
398
398
  # Write stats in the database.
399
399
  # Apply some filter before.
400
400
  #
401
- # Parameters:
402
- # * *iStatsToAdd* (<em>list<[TimeStamp,Object,Category,Value]></em>): The stats to write in the DB
401
+ # Parameters::
402
+ # * *iStatsToAdd* (<em>list< [TimeStamp,Object,Category,Value] ></em>): The stats to write in the DB
403
403
  # * *iLstObjects* (<em>list<String></em>): The filtering objects to write (can be empty for all)
404
404
  # * *iLstCategories* (<em>list<String></em>): The filtering categories to write (can be empty for all)
405
405
  def writeStats(iStatsToAdd, iLstObjects, iLstCategories)
@@ -429,15 +429,15 @@ module StatsCollect
429
429
 
430
430
  # Write stats if there are some
431
431
  if (lStatsToBeCommitted.empty?)
432
- logInfo 'No stats to be written after filtering.'
432
+ log_info 'No stats to be written after filtering.'
433
433
  else
434
434
  # Get the current locations from the DB to know if our location exists
435
- lKnownLocations = @BackendInstance.getKnownLocations
435
+ lKnownLocations = @BackendInstance.get_known_locations
436
436
  # Get the list of categories, sorted by category name
437
- lKnownCategories = @BackendInstance.getKnownCategories
437
+ lKnownCategories = @BackendInstance.get_known_categories
438
438
  # Get the list of objects, sorted by object name
439
439
  # This map will eventually be completed if new objects are found among the stats to write.
440
- lKnownObjects = @BackendInstance.getKnownObjects
440
+ lKnownObjects = @BackendInstance.get_known_objects
441
441
  # Use the following to generate a RB file that can be used with RB plugin.
442
442
  if false
443
443
  lStrStats = []
@@ -455,8 +455,8 @@ module StatsCollect
455
455
  lLocationID = lKnownLocations[iLocation]
456
456
  if (lLocationID == nil)
457
457
  # First create the new location and get its ID
458
- logInfo "Creating new location: #{iLocation}"
459
- lLocationID = @BackendInstance.addLocation(iLocation)
458
+ log_info "Creating new location: #{iLocation}"
459
+ lLocationID = @BackendInstance.add_location(iLocation)
460
460
  lKnownLocations[iLocation] = lLocationID
461
461
  lCheckExistence = false
462
462
  end
@@ -464,9 +464,9 @@ module StatsCollect
464
464
  lValueType = nil
465
465
  lCategoryID = nil
466
466
  if (lKnownCategories[iCategory] == nil)
467
- logWarn "Unknown stats category given by location #{iLocation}: #{iCategory}. It will be created with an Unknown value type."
467
+ log_warn "Unknown stats category given by location #{iLocation}: #{iCategory}. It will be created with an Unknown value type."
468
468
  lValueType = STATS_VALUE_TYPE_UNKNOWN
469
- lCategoryID = @BackendInstance.addCategory(iCategory, lValueType)
469
+ lCategoryID = @BackendInstance.add_category(iCategory, lValueType)
470
470
  lKnownCategories[iCategory] = [ lCategoryID, lValueType ]
471
471
  lCheckExistence = false
472
472
  else
@@ -475,27 +475,27 @@ module StatsCollect
475
475
  # Check if we need to create the corresponding object
476
476
  lObjectID = lKnownObjects[iObject]
477
477
  if (lObjectID == nil)
478
- logInfo "Creating new object: #{iObject}"
479
- lObjectID = @BackendInstance.addObject(iObject)
478
+ log_info "Creating new object: #{iObject}"
479
+ lObjectID = @BackendInstance.add_object(iObject)
480
480
  lKnownObjects[iObject] = lObjectID
481
481
  lCheckExistence = false
482
482
  end
483
483
  # First, we ensure that this stats does not exist if we don't want duplicates
484
484
  lAdd = true
485
485
  if (lCheckExistence)
486
- lExistingValue = @BackendInstance.getStat(iTimeStamp, lLocationID, lObjectID, lCategoryID, lValueType)
486
+ lExistingValue = @BackendInstance.get_stat(iTimeStamp, lLocationID, lObjectID, lCategoryID, lValueType)
487
487
  if (lExistingValue != nil)
488
- logWarn "Stat value for #{iTimeStamp.strftime('%Y-%m-%d %H:%M:%S')}, Location: #{lLocationID}, Object: #{lObjectID}, Category: #{lCategoryID} already exists with value #{lExistingValue}. Will not duplicate it."
488
+ log_warn "Stat value for #{iTimeStamp.strftime('%Y-%m-%d %H:%M:%S')}, Location: #{lLocationID}, Object: #{lObjectID}, Category: #{lCategoryID} already exists with value #{lExistingValue}. Will not duplicate it."
489
489
  lAdd = false
490
490
  end
491
491
  end
492
492
  if (lAdd)
493
493
  # Add the stat
494
- @BackendInstance.addStat(iTimeStamp, lLocationID, lObjectID, lCategoryID, iValue, lValueType)
495
- logDebug "Added stat: Time: #{iTimeStamp}, Location: #{iLocation} (#{lLocationID}), Object: #{iObject} (#{lObjectID}), Category: #{iCategory} (#{lCategoryID}), Value: #{iValue}"
494
+ @BackendInstance.add_stat(iTimeStamp, lLocationID, lObjectID, lCategoryID, iValue, lValueType)
495
+ log_debug "Added stat: Time: #{iTimeStamp}, Location: #{iLocation} (#{lLocationID}), Object: #{iObject} (#{lObjectID}), Category: #{iCategory} (#{lCategoryID}), Value: #{iValue}"
496
496
  end
497
497
  end
498
- logInfo "#{lStatsToBeCommitted.size} stats added."
498
+ log_info "#{lStatsToBeCommitted.size} stats added."
499
499
  end
500
500
  end
501
501