- Products
- Learn
- Local User Groups
- Partners
- More
Check Point Jump-Start Online Training
Now Available on CheckMates for Beginners!
Why do Hackers Love IoT Devices so Much?
Join our TechTalk on Aug 17, at 5PM CET | 11AM EST
Welcome to Maestro Masters!
Talk to Masters, Engage with Masters, Be a Maestro Master!
ZTNA Buyer’s Guide
Zero Trust essentials for your most valuable assets
The SMB Cyber Master
Boost your knowledge on Quantum Spark SMB gateways!
As YOU DESERVE THE BEST SECURITY
Upgrade to our latest GA Jumbo
CheckFlix!
All Videos In One Space
Hello. I wrote python script to get result of cpstat fw command:
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}
r = requests.post(url,data=json.dumps(json_payload), headers=request_headers, verify=False)
return r.json()
def login(user,password):
payload = {'user':user, 'password' : password}
response = api_call(mgmt_server, 443, 'login',payload, '')
return response["sid"]
def run_script(script_name, script_command,sid):
payload = {'script-name':script_name, 'script':script_command, 'targets':otr_gws}
response = api_call(mgmt_server, 443, 'run-script', payload, sid)
return response
def show_task(task_id, sid):
payload = {'task-id':task_id, 'details-level':'full'}
response = api_call(mgmt_server, 443, 'show-task', payload, sid)
return response
def main():
sid = login(mgmt_username,mgmt_password)
print("session id: " + sid)
cpstat = run_script("cpstat","cpstat fw",sid)
print(cpstat)
print("------------------------------")
print("cpstat result: " + json.dumps(cpstat))
print("------------------------------")
task_id=cpstat["tasks"][0]["task-id"]
result=show_task(task_id, sid)
print(result)
logout_result = api_call(mgmt_server, 443,"logout", {},sid)
print("logout result: " + json.dumps(logout_result))
if __name__ == '__main__':
main()
But when I run script it just stucks on the management server and nothing hashappened. What could be the problem?
P.S. The main idea is I want to make script to check ISP Redundancy status and to switch ISP Manually.
The first part of script is:
import requests
import json
mgmt_username = ‘user’
mgmt_password = ‘pass’
mgmt_server = ‘x.x.x.x’
otr_gws = [‘gw-2’]
I don’t see you doing a base64 decoding of the command output either.
See: https://community.checkpoint.com/t5/Developers-API-CLI/run-script-output/m-p/2835#M213
Hi!
Here is the solution - https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solut...
Have you succeeded to fix this issue?
I have the same issue too.
I had the same problem when i did it in PHP. But i did some tests and i found what it is and how to bypass the problem.
That's a bug in WEBAPI. I'm using R81, so i don't know about other versions.
When you use teh "run-script", the issue will occur if you use a LIST on the "target" parameter. So, if there's more than 1 gateway on target, the tasks will stuck.
Instead a LIST on "target" parameter, try to use a Loop passing one gateway at time.
About CheckMates
Learn Check Point
Advanced Learning
YOU DESERVE THE BEST SECURITY