Hello,
I have simple Python script located in /usr/lib/zabbix/externalscripts/
#!/usr/bin/python2
import winrm
import sys
ip_address = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
script_name = sys.argv[4]
f = open (script_name, 'rb')
ps_script = f.read()
s = winrm.Session('http://%s' % ip_address, auth=('%s' % username, '%s' % password), transport='ntlm')
r = s.run_ps(ps_script)
if r.status_code != 0:
print (r.std_err.decode('utf-8'))
else:
print (r.std_out.decode('utf-8'))
This script will execute Powershell Remote command written in PowerShell script also located in /externalscripts/ folder . Example of script execution:
python testwinrm.py 'ipaddress' 'username' 'password' 'WinSrvBasic.ps'
When I run this py script in CLI it works great and I get output from Powershell command.
When I try to run script in frontend I am getting following error:
Any1 have any ideas? So from this error my conclusion is that Zabbix don't recognize that python script is actually using powershell script to execute remote command. How could i fix that? Probably one solution is to have powershell command insite python script, but I want to have 1 global python script which will call dozen's of PowerShell scripts.
Item configuration:
Type: External Check
Key: testwinrm.py["{$HOST.CONN}","{$USER}","{$PASS}","{$PSFILE}"]
Best Regards
I have simple Python script located in /usr/lib/zabbix/externalscripts/
#!/usr/bin/python2
import winrm
import sys
ip_address = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
script_name = sys.argv[4]
f = open (script_name, 'rb')
ps_script = f.read()
s = winrm.Session('http://%s' % ip_address, auth=('%s' % username, '%s' % password), transport='ntlm')
r = s.run_ps(ps_script)
if r.status_code != 0:
print (r.std_err.decode('utf-8'))
else:
print (r.std_out.decode('utf-8'))
This script will execute Powershell Remote command written in PowerShell script also located in /externalscripts/ folder . Example of script execution:
python testwinrm.py 'ipaddress' 'username' 'password' 'WinSrvBasic.ps'
When I run this py script in CLI it works great and I get output from Powershell command.
When I try to run script in frontend I am getting following error:
| 2019-01-30 11:18:30 | Traceback (most recent call last): File "/usr/lib/zabbix/externalscripts/testwinrm.py", line 10, in <module> f = open (script_name, 'rb') IOError: [Errno 2] No such file or directory: 'WinSrvBasic.ps' |
Item configuration:
Type: External Check
Key: testwinrm.py["{$HOST.CONN}","{$USER}","{$PASS}","{$PSFILE}"]
Best Regards
Comment