******************************************************************************/
if (!globals.contains("NscpPath")) {
- NscpPath = "C:\\Program Files\\NSClient++"
+ NscpPath = msi_get_component_path("{5C45463A-4AE9-4325-96DB-6E239C034F93}")
}
object CheckCommand "nscp-local" {
import "plugin-check-command"
- command = [ "$nscp_path$\\nscp.exe", "client" ]
+ command = [ NscpPath, "client" ]
arguments = {
"-q" = {
#include <boost/regex.hpp>
#include <algorithm>
#include <set>
+#ifdef _WIN32
+#include <msi.h>
+#endif /* _WIN32 */
using namespace icinga;
REGISTER_SAFE_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
REGISTER_SAFE_SCRIPTFUNCTION(bool, &ScriptUtils::CastBool);
REGISTER_SAFE_SCRIPTFUNCTION(get_time, &Utility::GetTime);
+#ifdef _WIN32
+REGISTER_SAFE_SCRIPTFUNCTION(msi_get_component_path, &ScriptUtils::MsiGetComponentPathShim);
+#endif /* _WIN32 */
String ScriptUtils::CastString(const Value& value)
{
BOOST_THROW_EXCEPTION(std::runtime_error("Assertion failed"));
}
+#ifdef _WIN32
+String ScriptUtils::MsiGetComponentPathShim(const String& component)
+{
+ TCHAR productCode[39];
+ if (MsiGetProductCode(component.CStr(), productCode) != ERROR_SUCCESS)
+ return "";
+ TCHAR path[2048];
+ DWORD szPath = sizeof(path);
+ path[0] = '\0';
+ MsiGetComponentPath(productCode, component.CStr(), path, &szPath);
+ return path;
+}
+#endif /* _WIN32 */
\ No newline at end of file
static DynamicObject::Ptr GetObject(const Type::Ptr& type, const String& name);
static Array::Ptr GetObjects(const Type::Ptr& type);
static void Assert(const Value& arg);
+#ifdef _WIN32
+ static String MsiGetComponentPathShim(const String& component);
+#endif /* _WIN32 */
private:
ScriptUtils(void);