oec-scripts
oec-scripts copied to clipboard
Icinga: actionExecutor.py doesn't assure the working dir while generation Zip file(s)
During processing of the alert integration script tries to create ZIPed observation document with histogram and trend images from Icinga.
As a first step of it it creates a ZIP file with the embedded date in the name, but doesn't specify in which directory that file will be created.
Apparently, somewhere in the process the current working directory either changes or initially set to the non-writable directory.
Hence, we are getting this error:
Executed [Create] action via OEC[integrationId: fd2c40c5-xxxxxxxxxxxxxxxxxxx integrationType: Icinga] with errors.
Reason: Err: exit status 1, Stderr:
Traceback (most recent call last):
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 425, in <module> main()
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 408, in main send_create_request()
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 288, in send_create_request attach()
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 261, in attach zip = zipfile.ZipFile(file_name, 'w')
File "/usr/lib64/python3.6/zipfile.py", line 1113, in __init__ self.fp = io.open(file, filemode) PermissionError: [Errno 13]
Permission denied: 'details_2021_03_21_21_03_1616359507.zip'
Either script should set CWD in the beginning to it's home directory(and hope it's writable) or should use /tmp
or /var/tmp
for creating a temporary ZIP file or should have an option to specify writable tmp directory and use it in the filename
.
Also, readability of the script may benefit from using f'strings or format
...
I see this has been open for over a year.
I just encountered this problem, with the Python3 wrapper issue (due to CentOS 7) with the Nagios OEC.
Hi @b-a-t, you can track the progress about the issue from this ticket