Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windbag generator/count + end=0 edge cases #145

Merged
merged 6 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ count = <integer>
* Maximum number of events to generate per sample file
* -1 means replay the entire sample.
* Defaults to -1.
* When used with the windbag generator, the event count is decided by the sample size

perDayVolume = <float>
* This is used in place of count. The perDayVolume is a size supplied in GB per Day. This value will allow
Expand Down
5 changes: 4 additions & 1 deletion splunk_eventgen/lib/eventgentimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, time, sample=None, config=None, genqueue=None, outputqueue=No
self.time = time
self.stopping = False
self.countdown = 0
self.executions = 0
self.interval = getattr(self.sample, "interval", config.interval)
#enable the logger
self._setup_logging()
Expand Down Expand Up @@ -101,10 +102,12 @@ def real_run(self):

self.logger.debug("Timer creating plugin for '%s'" % self.sample.name)

self.executions = 0
end = False
previous_count_left = 0
raw_event_size = self.predict_event_size()
if self.end and int(self.end) == 0:
self.logger.info("End = 0, no events will be generated for sample '%s'" % self.sample.name)
end = True
while not end:
# Need to be able to stop threads by the main thread or this thread. self.config will stop all threads
# referenced in the config object, while, self.stopping will only stop this one.
Expand Down
3 changes: 1 addition & 2 deletions splunk_eventgen/lib/plugins/generator/windbag.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import division
from generatorplugin import GeneratorPlugin
import logging
import datetime, time
import datetime
from datetime import timedelta

class WindbagGenerator(GeneratorPlugin):
Expand Down
6 changes: 6 additions & 0 deletions splunk_eventgen/lib/plugins/rater/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging.handlers
import datetime
import random
import os


class ConfigRater(object):
Expand Down Expand Up @@ -44,6 +45,11 @@ def _setup_logging(self):
def rate(self):
self._sample.count = int(self._sample.count)
if self._sample.count == -1:
# Load the windbag sample by default if we don't have any sample events, allows for a valid count
if not self._sample.sampleDict and self._sample.generator == 'windbag':
self._sample.name = 'windbag'
self._sample.filePath = os.path.join(self._sample.sampleDir, self._sample.name)
self._sample.loadSample()
self._sample.count = len(self._sample.sampleDict)
self._generatorWorkers = int(self._generatorWorkers)
count = self._sample.count/self._generatorWorkers
Expand Down