Command Definition for NSCP check_files


#1

Hi everybody,

I’m currently struggling with the command definition for a filesystem check. Unfortunately the ITL doesn’t bring a command definition for nscp check_files yet so i tried to build it by my own.

The command line looks like this:

“C:\Program Files\NSClient++\nscp.exe” client path=C:\mypath “filter=creation > -60s” “critical=count < 1” “empty-state=critical” “empty-syntax=%(status): MyText” -q check_files

I tried everything from using the generic nscp-local definition…

object CheckCommand "nscp-local" {
    import "plugin-check-command"
    command = [ PluginDir + "/.\\nscp.exe", "client" ]
    timeout = 1m
    arguments += {
        "--load-all" = {
            description = "Load all plugins (currently only used with generate)"
            set_if = "$nscp_load_all$"
        }
        "--log" = {
            description = "The log level to use"
            value = "$nscp_log_level$"
        }
        "--module" = {
            description = "Specify which NSClient++ modules are required. 'nscp client' just needs 'CheckSystem' by default."
            repeat_key = true
            value = "$nscp_modules$"
        }
        "--show-all" = {
            set_if = "$nscp_showall$"
        }
        "-a" = {
            description = "List of arguments (arguments gets -- prefixed automatically (--argument foo=bar is the same as setting '--foo bar')"
            repeat_key = true
            value = "$nscp_arguments$"
        }
        "-b" = {
            description = "Boot the client before executing command (similar as running the command from test mode)"
            set_if = "$nscp_boot$"
        }
        "-q" = {
            description = "Run a query with a given name"
            required = true
            value = "$nscp_query$"
        }
    }
    vars.nscp_boot = true
    vars.nscp_load_all = false
    vars.nscp_log_level = "critical"
    vars.nscp_modules = [ "CheckSystem" ]
    vars.nscp_showall = false
}

up to building my own definition

object CheckCommand "nscp-local-files" {
    import "plugin-check-command"
    command = [
        "C:\\Program",
        "Files\\NSClient++\\nscp.exe",
        "client",
        "$nscp_arguments$"
    ]
    timeout = 1m
    arguments += {
        "-q" = {
            description = "Run a query with a given name"
            required = true
            value = "$nscp_query$"
        }
    }
    vars.nscp_query = "check_files"
}

But I always have struggle with all the parameters and quotes.

I hope you guys have an idea on how to build this the best way.

kind regards!


(Chris) #2

Hello here a example Service, how i would do it (untested):

apply Service "check files" {
import "generic-service"

check_command = "nscp-local"
vars.nscp_modules = [ "CheckDisk" ]
vars.nscp_query = "check_files"
vars.nscp_arguments = [ "client path=C:\mypath", "filter=creation > -60s", "critical=count < 1", "empty-state=critical", "empty-syntax=%(status): MyText" ]

# to change for the local execution
command_endpoint = host.vars.remote_client

assign where host.vars.remote_client
}

You could do also a template in advance before creating the service

template Service "nscp-local-files" {
import "generic-service"

check_command = "nscp-local"
vars.nscp_modules = [ "CheckDisk" ]
vars.nscp_query = "check_files"

command_endpoint = host.vars.remote_client
}

an then the service:

apply Service "check files" {
import "nscp-local-files"

vars.nscp_arguments = [ "client path=C:\mypath", "filter=creation > -60s", "critical=count < 1", "empty-state=critical", "empty-syntax=%(status): MyText" ]

assign where host.vars.remote_client
}

Regards


#3

Thank you very much! The solution was, to define all the different filters in an array. Now it works as expected.

Have a nice weekend :slight_smile: