]> granicus.if.org Git - icinga2/commitdiff
Implement the basename and dirname script functions
authorGunnar Beutner <gunnar@beutner.name>
Wed, 13 May 2015 07:46:59 +0000 (09:46 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 13 May 2015 07:46:59 +0000 (09:46 +0200)
refs #9256

doc/20-library-reference.md
doc/7-icinga-template-library.md
itl/command-nscp-local.conf
lib/base/scriptutils.cpp

index b5fa91839f12208470130a6e816142ded886328d..6b78192d2f4e2156cfe20f044943bb449544ee9d 100644 (file)
@@ -19,6 +19,8 @@ log(severity, facility, value)  | Writes a message to the log. `severity` can be
 typeof(value)                   | Returns the type object for a value.
 get_time()                      | Returns the current UNIX timestamp.
 parse_performance_data(pd)      | Parses a performance data string and returns an array describing the values.
+dirname(path)                   | Returns the directory portion of the specified path.
+basename(path)                  | Returns the filename portion of the specified path.
 exit(integer)                   | Terminates the application.
 
 ## <a id="object-accessor-functions"></a> Object Accessor Functions
index fb6cfc053289be66a621a9a2e6f1dda7d8afc68d..f9daa340e49cea5c41b4045689e67d3fbdb79bf9 100644 (file)
@@ -1063,7 +1063,8 @@ file:
 
     const NscpPath = "C:\\Program Files (x86)\\NSClient++"
 
-By default the check commands assume that NSClient++ is installed in "C:\Program Files\NSClient++".
+By default Icinga 2 uses the Microsoft Installer API to determine where NSClient++ is installed. It should
+not be necessary to manually set this constant.
 
 Note that it is not necessary to run NSClient++ as a Windows service for these commands to work.
 
index f65520502ab704ca2fa1fcce98971019337c8e04..9f1a3f5b2dca0e19f3fef560d99238b2b5d7a4d8 100644 (file)
  ******************************************************************************/
 
 if (!globals.contains("NscpPath")) {
-       NscpPath = msi_get_component_path("{5C45463A-4AE9-4325-96DB-6E239C034F93}")
+       NscpPath = dirname(msi_get_component_path("{5C45463A-4AE9-4325-96DB-6E239C034F93}"))
 }
 
 object CheckCommand "nscp-local" {
        import  "plugin-check-command"
 
-       command = [ NscpPath, "client" ]
+       command = [ "$nscp_path$\\nscp.exe", "client" ]
 
        arguments = {
                "--log" = "$nscp_log_level$"
index afdfa61bf3ff8864b02d66a12edc052941cdf69a..1ac249fbf7773ac3993ec2526c1b4ee8655c0c84 100644 (file)
@@ -54,6 +54,8 @@ REGISTER_SAFE_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
 REGISTER_SAFE_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
 REGISTER_SAFE_SCRIPTFUNCTION(bool, &ScriptUtils::CastBool);
 REGISTER_SAFE_SCRIPTFUNCTION(get_time, &Utility::GetTime);
+REGISTER_SAFE_SCRIPTFUNCTION(basename, &Utility::BaseName);
+REGISTER_SAFE_SCRIPTFUNCTION(dirname, &Utility::DirName);
 #ifdef _WIN32
 REGISTER_SAFE_SCRIPTFUNCTION(msi_get_component_path, &ScriptUtils::MsiGetComponentPathShim);
 #endif /* _WIN32 */
@@ -282,4 +284,4 @@ String ScriptUtils::MsiGetComponentPathShim(const String& component)
        MsiGetComponentPath(productCode, component.CStr(), path, &szPath);
        return path;
 }
-#endif /* _WIN32 */
\ No newline at end of file
+#endif /* _WIN32 */