Implement the basename and dirname script functions

refs #9256
This commit is contained in:
Gunnar Beutner 2015-05-13 09:46:59 +02:00
parent 32e5ed957f
commit 24ae02386a
4 changed files with 9 additions and 4 deletions

View 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

View 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.

View File

@ -18,13 +18,13 @@
******************************************************************************/
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$"

View 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 */
#endif /* _WIN32 */