Skip to content

Commit 41fa0a2

Browse files
authored
Merge pull request #828 from jettero/4.0-pulsar-fix
4.0 pulsar fix
2 parents 82d4e86 + dac7bae commit 41fa0a2

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

hubblestack/extmods/modules/pulsar.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def __init__(self, configfile=None, verbose=False):
185185
self.nc_config['paths'] = configfile
186186
else:
187187
self.nc_config['paths'] = [configfile]
188-
else:
188+
elif 'paths' not in self.nc_config:
189189
self.nc_config['paths'] = []
190190
config = self.config
191191
config['verbose'] = verbose
@@ -904,8 +904,11 @@ def process(configfile='salt://hubblestack_pulsar/hubblestack_pulsar_config.yaml
904904
# file really is new since the last time we thought about it
905905
# (aka the last time we ran the process() function).
906906
_, abspath, dirname, basename = cm.format_path(path)
907-
config_path = config['paths'][0]
908-
pulsar_config = config_path[config_path.rfind('/') + 1:len(config_path)]
907+
try:
908+
config_path = config['paths'][0]
909+
pulsar_config = config_path[config_path.rfind('/') + 1:len(config_path)]
910+
except IndexError:
911+
pulsar_config = 'unknown'
909912
fake_sub = { 'change': 'IN_CREATE',
910913
'path': abspath, # goes to object_path in splunk
911914
'tag': dirname, # goes to file_path in splunk

hubblestack/extmods/returners/splunk_pulsar_return.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,16 @@ def _build_linux_event(alert, change):
241241
'pulsar_config': alert['pulsar_config']}
242242
if 'contents' in alert:
243243
event['contents'] = alert['contents']
244-
if alert['stats']: # Gather more data if the change wasn't a delete
244+
# Gather more data if the change wasn't a delete
245+
if 'stats' in alert and isinstance(alert['stats'], dict):
245246
stats = alert['stats']
246-
event['object_id'] = stats['inode']
247-
event['file_acl'] = stats['mode']
248-
event['file_create_time'] = stats['ctime']
249-
event['file_modify_time'] = stats['mtime']
250-
event['file_size'] = stats['size'] / 1024.0 # Convert bytes to kilobytes
251-
event['user'] = stats['user']
252-
event['group'] = stats['group']
247+
event['object_id'] = stats.get('inode')
248+
event['file_acl'] = stats.get('mode')
249+
event['file_create_time'] = stats.get('ctime')
250+
event['file_modify_time'] = stats.get('mtime')
251+
event['file_size'] = stats.get('size', 0) / 1024.0 # Convert bytes to kilobytes
252+
event['user'] = stats.get('user')
253+
event['group'] = stats.get('group')
253254
if object_type == 'file':
254255
chk = alert.get('checksum')
255256
if chk:

mk-requires.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
D="$(dirname "$0")"
44
F="$D/requirements.txt"
55

6-
echo "# This file was generated by $0" > "$F"
7-
echo "# $(date -u)" >> "$F"
6+
echo "# This file was generated by $(basename "$0")" > "$F"
87
echo >> "$F"
98

109
bash "$D/pkg/generate-requirements.sh" "$@" | tee -a "$F"

requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# This file was generated by ./mk-requires.sh
2-
# Wed Mar 18 14:02:09 UTC 2020
1+
# This file was generated by mk-requires.sh
32

43
ansi2html
54
argparse

0 commit comments

Comments
 (0)