Module: check_mk
Branch: master
Commit: 7072d94ae4ee45c4331ae45e436f4ef974eda7f7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7072d94ae4ee45…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Wed May 30 14:48:51 2018 +0200
5813 FIX mk_oracle.ps1: temporary files are no longer written to c:\windows\system32
Temporary files from this plugin are now generated in the official temp directory.
Its usually specified through the environment variable MK_TEMPDIR, set by the windows
agent.
Change-Id: Ib7bb4e4530e0173e9d1f7aef421b4917e06fe72b
---
.werks/5813 | 14 ++++++++++++++
agents/windows/plugins/mk_oracle.ps1 | 16 +++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/5813 b/.werks/5813
new file mode 100644
index 0000000..3febba5
--- /dev/null
+++ b/.werks/5813
@@ -0,0 +1,14 @@
+Title: mk_oracle.ps1: temporary files are no longer written to c:\windows\system32
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527684383
+
+Temporary files from this plugin are now generated in the official temp directory.
+Its usually specified through the environment variable MK_TEMPDIR, set by the windows
agent.
+
+
diff --git a/agents/windows/plugins/mk_oracle.ps1 b/agents/windows/plugins/mk_oracle.ps1
index f8ec0a2..64862ca 100644
--- a/agents/windows/plugins/mk_oracle.ps1
+++ b/agents/windows/plugins/mk_oracle.ps1
@@ -37,7 +37,7 @@
# usage
###############################################################################
# copy this file to C:\Program Files (x86)\check_mk\plugins
-# copy the config file to C:\Program Files (x86)\check_mk\
+# copy the config file to C:\Program Files (x86)\check_mk\config
# cd C:\Program Files (x86)\check_mk
# check_mk_agent test
###############################################################################
@@ -146,6 +146,15 @@ if (!$MK_CONFDIR) {
$MK_CONFDIR= "c:\Program Files (x86)\check_mk\config"
}
+# directory for tempfiles
+$MK_TEMPDIR = $env:MK_TEMPDIR
+
+# Fallback if the (old) agent does not provide the MK_TEMPDIR
+if (!$MK_TEMPDIR){
+ $MK_TEMPDIR = "C:\Program Files (x86)\check_mk\temp"
+}
+
+
# Source the optional configuration file for this agent plugin
$CONFIG_FILE="${MK_CONFDIR}\mk_oracle_cfg.ps1"
if (test-path -path "${CONFIG_FILE}" ) {
@@ -238,7 +247,7 @@ exit;
$res=$res.trim()
$res=[int]$res
$res
- }
+ }
# now we set our action on error back to our normal value
$ErrorActionPreference = $NORMAL_ACTION_PREFERENCE
}
@@ -466,7 +475,7 @@ Param(
# The temporary file to store the output of the SQL
# currently default path is used here. change this @TBR?
- $fullpath="$sql_message.$sqlsid.txt"
+ $fullpath= $MK_TEMPDIR + "\" + "$sql_message.$sqlsid.txt"
if ($delayed -gt 0)
{
@@ -1484,3 +1493,4 @@ if ($the_count -gt 0) {
}
debug_echo "got to the end"
+