Module: check_mk
Branch: master
Commit: 18d955d419ad3badd80dfee812d77bb9e2d55566
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18d955d419ad3b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun May 6 20:27:46 2012 +0200
Used tmp-file for POST data if too large for command line
---
ChangeLog | 2 +-
web/htdocs/wato.py | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 964da72..3b270a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,7 +7,7 @@
* FIX: better error message if not logged into site during
action that needs remote access
* FIX: send automation data via POST not GET. This fixes inventory
- on hosts with up to 2000 services
+ on hosts with more than 500 services.
Multisite:
* FIX: fixed filter of recent event views (4 hours didn't catch)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 2f9511f..a6d167e 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6657,9 +6657,22 @@ def get_url(url, insecure, user=None, password=None, params =
'', post_data = No
# -s: silent
# -S: show errors
# -w '%{http_code}': add the http status code to the end of the output
- command = 'curl -w "\n%%{http_code}" -s -S%s%s%s "%s"
2>&1' % (insecure, cred, params, url)
+ command = 'curl -w "\n%%{http_code}" -s -S%s%s%s "%s"
2>&1' % (
+ insecure, cred, params, url)
+ tmp_file = None
if post_data != None:
- command += ' --data-binary "%s"' % post_data
+ # Put POST data on command line as long as it is not
+ # longer than 50 KB (remember: Linux has an upper limit
+ # of 132 KB for command line plus environment
+ if len(post_data) < 50000:
+ command += ' --data-binary "%s"' % post_data
+ else:
+ import tempfile
+ tmp_file = tempfile.NamedTemporaryFile(dir = defaults.tmp_dir)
+ tmp_file.write(post_data)
+ tmp_file.flush()
+ command += ' --data-binary "@%s"' % tmp_file.name
+
response = os.popen(command).read().strip()
try:
status_code = int(response[-3:])