-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathbulk-set.py
41 lines (37 loc) · 1.42 KB
/
bulk-set.py
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
# Sets an attribute across all collectors and sources in a given account.
#
# python bulk-set.py <accessId> <accessKey> <attribute> <value>
import pprint
import sys
import time
from sumologic import SumoLogic
args = sys.argv
sumo = SumoLogic(args[1], args[2])
delay = .25
time.sleep(delay)
attr, val = args[3], args[4]
cs = sumo.collectors()
time.sleep(delay)
f = [{u'regexp': u'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.(\\d{1,3})', u'mask': u'255', u'filterType': u'Mask', u'name': u'last octet mask'}]
for c in cs:
if 'category' not in c or 'bwe' not in c['category'] and 'bwm' not in c['category']:
print('collector: ' + c['name'])
ss = sumo.sources(c['id'])
time.sleep(delay)
for s in ss:
sv, etag = sumo.source(c['id'], s['id'])
time.sleep(delay)
svi = sv['source']
if 'category' not in svi or 'bwe' not in svi['category'] and 'bwm' not in svi['category']:
print('source: ' + svi['name'])
svi['filters'] = f
r = sumo.update_source(c['id'], sv, etag)
print(r)
print(r.text)
time.sleep(delay)
#if svi['forceTimeZone'] == False:
# svi['forceTimeZone'] = True
# svi[u'timeZone'] = u'UTC'
# r = sumo.update_source(c['id'], sv, etag)
# print(str(r) + ': ' + str(r.text))
# time.sleep(delay)