I've now updated our entire rulebase to log sessions using the Management API and using Python. We'll see what data this will give.
Here is how, in case someone needs to do the same (I'm not responsible if it goes wrong).
In any case, I'd suggest using a different account to perform the settings via the API, then Take Over that session from SmartDashboard and review the changes made.
If all ok, publish and install.
You may want to adapt
* the server name
* the layer name
* the rule-number range
(This is Python 3.4)
#!/usr/bin/python3
import requests, json, getpass, sys, time
import cpapi
if len(sys.argv)==2:
sid = sys.argv[1]
else:
user = input("Smartcenter User: ")
password = getpass.getpass("Password: ")
sid = cpapi.login(user, password)
print("Session id: " + sid)
for k in range(11,325):
print()
print ('------------------------- rule id: ' + str(k) + ' ----------------------------')
print()
req = {'layer': 'Unified',
'rule-number': k,
'track': {'per-session': True}}
print(json.dumps(cpapi.api_call('set-access-rule', req, sid), indent=4, sort_keys=True))
time.sleep(1)
cpapi.logout(sid)
And here is my "cpapi" module imported above (inspired from the Management API website)
#!/usr/bin/python3
import requests, json
def api_call(command, json_payload, sid):
return _api_call('smartcenter', 443, command, json_payload, sid)
def _api_call(ip_addr, port, command, json_payload, sid):
url = 'https://' + ip_addr + ':' + str(port) + '/web_api/' + command
if sid == '':
request_headers = {'Content-Type' : 'application/json'}
else:
request_headers = {'Content-Type' : 'application/json', 'X-chkp-sid' : sid}
req = requests.post(url, data=json.dumps(json_payload), headers=request_headers, verify=False)
#print(vars(req))
return req.json()
def login(user, password):
payload = {'user':user, 'password':password}
response = api_call('login', payload, '')
return response["sid"]
def logout(sid):
response = api_call('logout', {}, sid)
print (response)