Check_qnap3.sh with icinga2 running?


#1

Hello
did somebody get check_qnap3.sh on icinga2 running?

with icinga2 daemon -C i have no error any more!
but in gui
Plugin Output
Check_QNAP3 1.23.1
Warning: Wrong command line arguments.

Usage: ./check_qnap <hostname> <community> <part> <warning> <critical>

this information looks wrong because it should be Usage: ./check_qnap3

have a nice day
vinc


#2

It’d be helpful if you’d show your service definition. Mentioning that “icinga2 daemon -C” is errorfree isn’t an indicator that your config contains the definition you expect.


#3

i wrote a small howto install
http://wombat3.kozo.ch/j/icinga-list/9777-icinga2-add-nas-qnap

doing it in cli
./check_qnap3.sh 10.147.42.70 public systemuptime 0 0
System Uptime 3:22:30.94 - Network Uptime 3:16:36.65
works!


#4

Editing the plugin you’ll see (about line 29)

echo "Usage: ./check_qnap <hostname> <community> <part> <warning> <critical>"

So which output would you expect to see if the author didn’t care to change the line?

It seems that the warning and critical values in the plugin are in text format (instead of numbers). Have you tried to call the plugin using these values on the command line and see if the result is still the same? Have you tried to enable debugging and take a look at the log file?


#5

@Wolfgang no did not because to start like this it did work.

./check_qnap3.sh 10.147.42.70 public systemuptime 0 0
System Uptime 3:22:30.94 - Network Uptime 3:16:36.65

But yes i was a bit surprised about the “hostname” and $ARG1$ in the description


#6

Add a line to the plugin to output the command line arguments to a file might shed some light on it if you’re not willing to enable debugging in Icinga2.

Looking at the help text of the plugin you’ll see host_addresses_…


#7

[2018-07-31 22:48:34 +0200] information/ExternalCommandListener: Executing external command: [1533070114] SCHEDULE_FORCED_SVC_CHECK;NAS-01.kozo.ch;
check_qnap3-sysinfo;1533070114
[2018-07-31 22:48:47 +0200] information/ExternalCommandListener: Executing external command: [1533070127] SCHEDULE_FORCED_SVC_CHECK;NAS-01.kozo.ch;
check_qnap3-sysinfo;1533070127

output from the icinga2.log after enable the debuglog


#8

Excerpt from the documentation:

Enable Debug Output on Linux/Unix ¶

Enable the debuglog feature:

# icinga2 feature enable debuglog
# service icinga2 restart

The debug log file can be found in /var/log/icinga2/debug.log.

#9

is there a way to limit to one host this debugging or to search in the file ?


#10

To find out the exact plugin call you can query the Icinga 2 API.

For example call this URL in your web browser:

https://<Icinga 2 Host>:5665/v1/objects/services?service=<Hostname>!<ServiceName>

Change all <placeholder> to your needs. For example if you want to know the plugin call for the service downstreamrate which is applied to the host object FritzBox your call URL is:

https://<Icinga 2 Host>:5665/v1/objects/services?service=FritzBox!downstreamrate

For authentication use one of your API users with the appropriate permissions.

In the response you’ll notice the attribute last_check_result, here you can find the exact plugin call.

last_check_result": {
          "active": true,
          "check_source": "icinga2.vagrant.demo.icinga.com",
          "command": [
            "/usr/lib64/nagios/plugins/check_tr64_fritz",
            "-P",
            "SuperSecretPassw0rd",
            "-f",
            "downstreamrate",
            "-h",
            "192.168.178.1",
            "-p",
            "49443",
            "-u",
            "dslf-config"
          ],

More insights on the API can be found in the documentation at https://www.icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#introduction


#11

https://10.147.42.36:5665/v1/objects/services?service=check_qnap3-sysinfo!sysinfo
{“error”:404.0,“status”:“No objects found.”}


#12

check_qnap3-sysinfo doesn’t seem to be the hostname?!


#13

Your’e mixing things up , it’s ?service=<Hostname>!<ServiceName>

When I understand your configuration right it should be something like:

https://10.147.42.36:5665/v1/objects/services?service=NAS-01.kozo.ch!check_qnap3-sysinfo

#14

{“results”:[{“attrs”:{"__name":“NAS-01.kozo.ch!check_qnap3-sysinfo”,“acknowledgement”:0.0,“acknowledgement_expiry”:0.0,“action_url”:"",“active”:true,“check_attempt”:1.0,“check_command”:“check_qnap3-sysinfo”,“check_interval”:60.0,“check_period”:"",“check_timeout”:null,“command_endpoint”:"",“display_name”:" - Sysinfos",“downtime_depth”:0.0,“enable_active_checks”:true,“enable_event_handler”:true,“enable_flapping”:false,“enable_notifications”:true,“enable_passive_checks”:true,“enable_perfdata”:true,“event_command”:"",“flapping”:false,“flapping_current”:0.0,“flapping_last_change”:0.0,“flapping_threshold”:0.0,“flapping_threshold_high”:30.0,“flapping_threshold_low”:25.0,“force_next_check”:false,“force_next_notification”:false,“groups”:[],“ha_mode”:0.0,“host_name”:“NAS-01.kozo.ch”,“icon_image”:"",“icon_image_alt”:"",“last_check”:1533072486.3429911137,“last_check_result”:{“active”:true,“check_source”:“icinga2-01.kozo.ch”,“command”:["/usr/lib/nagios/pluginsCustom/check_qnap3/check_qnap3.sh","$ARG1$",“10.147.42.70”,"$ARG2$",“public”,"$ARG3$",“sysinfo”,"$ARG4$",“0”,"$ARG5$",“0”],“execution_end”:1533072486.3429400921,“execution_start”:1533072486.3402769566,“exit_status”:3.0,“output”:“Check_QNAP3 1.23.1\n\nWarning: Wrong command line arguments.\n\nUsage: ./check_qnap \n\nParts are: sysinfo, systemuptime, temp, cpu, cputemp, freeram, powerstatus, fans, diskused, hdstatus, hd#status, hdtemp, hd#temp, volstatus (Raid Volume Status), vol#status\n\nhdstatus shows status & temp; volstatus check all vols and vols space; powerstatus check power supply\n<#> is 1-8 for hd, 1-5 for vol\n\n Example for diskusage: ./check_qnap3.sh 127.0.0.1 public diskused 80 95\n\n Example for volstatus: ./check_qnap3.sh 127.0.0.1 public volstatus 15 10\n critical and warning value are releted to free disk space\n\n Example for fans: ./check_qnap3.sh 127.0.0.1 public fans 2000 1900\n critical and warning are minimum speed in rpm for fans”,“performance_data”:[],“schedule_end”:1533072486.3429911137,“schedule_start”:1533072486.3399999142,“state”:3.0,“ttl”:0.0,“type”:“CheckResult”,“vars_after”:{“attempt”:1.0,“reachable”:true,“state”:3.0,“state_type”:1.0},“vars_before”:{“attempt”:1.0,“reachable”:true,“state”:3.0,“state_type”:1.0}},“last_hard_state”:3.0,“last_hard_state_change”:1533024853.5427269936,“last_reachable”:true,“last_state”:3.0,“last_state_change”:1533024734.6759710312,“last_state_critical”:0.0,“last_state_ok”:0.0,“last_state_type”:1.0,“last_state_unknown”:1533072486.3429999352,“last_state_unreachable”:1533055239.6727130413,“last_state_warning”:0.0,“max_check_attempts”:5.0,“name”:“check_qnap3-sysinfo”,“next_check”:1533072546.3399999142,“notes”:"",“notes_url”:"",“original_attributes”:null,“package”:"_etc",“paused”:false,“retry_interval”:30.0,“severity”:72.0,“source_location”:{“first_column”:0.0,“first_line”:1.0,“last_column”:34.0,“last_line”:1.0,“path”:"/etc/icinga2/zones.d/nas-01/check_qnap3-sysinfo.conf"},“state”:3.0,“state_type”:1.0,“templates”:[“check_qnap3-sysinfo”,“generic-service”],“type”:“Service”,“vars”:null,“version”:0.0,“volatile”:false,“zone”:“master”},“joins”:{},“meta”:{},“name”:“NAS-01.kozo.ch!check_qnap3-sysinfo”,“type”:“Service”}]}


#15

Please format your output. Just posting the unformatted output here is not very helpful.

Use a browser addon to automatically format JSON (Example for Chrome: JSON Formatter). If you search for the terms json formatter you’ll find results for nearly any other browser.

If you don’t like to install an addon you can query the API on the CLI using curl and python -m json.tool to make the JSON output readable. You can find examples in the documentation.

Also use Markdown to format your posts. Instructions can be found in the FAQ.


#16
   “results”:[  
      {  
         “attrs”:{  
            "__name":“NAS-01.kozo.ch!check_qnap3-sysinfo”,
            “acknowledgement”:0.0,
            “acknowledgement_expiry”:0.0,
            “action_url”:"",
            “active”:true,
            “check_attempt”:1.0,
            “check_command”:“check_qnap3-sysinfo”,
            “check_interval”:60.0,
            “check_period”:"",
            “check_timeout”:null,
            “command_endpoint”:"",
            “display_name”:" - Sysinfos",
            “downtime_depth”:0.0,
            “enable_active_checks”:true,
            “enable_event_handler”:true,
            “enable_flapping”:false,
            “enable_notifications”:true,
            “enable_passive_checks”:true,
            “enable_perfdata”:true,
            “event_command”:"",
            “flapping”:false,
            “flapping_current”:0.0,
            “flapping_last_change”:0.0,
            “flapping_threshold”:0.0,
            “flapping_threshold_high”:30.0,
            “flapping_threshold_low”:25.0,
            “force_next_check”:false,
            “force_next_notification”:false,
            “groups”:[  

            ],
            “ha_mode”:0.0,
            “host_name”:“NAS-01.kozo.ch”,
            “icon_image”:"",
            “icon_image_alt”:"",
            “last_check”:1533072486.3429911137,
            “last_check_result”:{  
               “active”:true,
               “check_source”:“icinga2-01.kozo.ch”,
               “command”:[  
                  "/usr/lib/nagios/pluginsCustom/check_qnap3/check_qnap3.sh",
                  "$ARG1$",
                  “10.147.42.70”,
                  "$ARG2$",
                  “public”,
                  "$ARG3$",
                  “sysinfo”,
                  "$ARG4$",
                  “0”,
                  "$ARG5$",
                  “0”
               ],
               “execution_end”:1533072486.3429400921,
               “execution_start”:1533072486.3402769566,
               “exit_status”:3.0,
               “output”:               “Check_QNAP3 1.23.1\n\nWarning:               Wrong command line arguments.\n\nUsage:               ./check_qnap \n\nParts are:sysinfo,
               systemuptime,
               temp,
               cpu,
               cputemp,
               freeram,
               powerstatus,
               fans,
               diskused,
               hdstatus,
               hd#status,
               hdtemp,
               hd#temp,
               volstatus (Raid Volume Status),
               vol#status\n\nhdstatus shows status & temp; volstatus check all vols and vols space; powerstatus check power supply\n<#> is 1-8 for hd,
               1-5               for vol\n\n Example for diskusage:               ./check_qnap3.sh 127.0.0.1 public diskused 80 95\n\n Example for volstatus:               ./check_qnap3.sh 127.0.0.1 public volstatus 15 10\n critical and warning value are releted to free disk space\n\n Example for fans:./check_qnap3.sh 127.0.0.1 public fans 2000 1900\n critical and warning are minimum speed in rpm for fans”,
               “performance_data”:[  

               ],
               “schedule_end”:1533072486.3429911137,
               “schedule_start”:1533072486.3399999142,
               “state”:3.0,
               “ttl”:0.0,
               “type”:“CheckResult”,
               “vars_after”:{  
                  “attempt”:1.0,
                  “reachable”:true,
                  “state”:3.0,
                  “state_type”:1.0
               },
               “vars_before”:{  
                  “attempt”:1.0,
                  “reachable”:true,
                  “state”:3.0,
                  “state_type”:1.0
               }
            },
            “last_hard_state”:3.0,
            “last_hard_state_change”:1533024853.5427269936,
            “last_reachable”:true,
            “last_state”:3.0,
            “last_state_change”:1533024734.6759710312,
            “last_state_critical”:0.0,
            “last_state_ok”:0.0,
            “last_state_type”:1.0,
            “last_state_unknown”:1533072486.3429999352,
            “last_state_unreachable”:1533055239.6727130413,
            “last_state_warning”:0.0,
            “max_check_attempts”:5.0,
            “name”:“check_qnap3-sysinfo”,
            “next_check”:1533072546.3399999142,
            “notes”:"",
            “notes_url”:"",
            “original_attributes”:null,
            “package”:"_etc",
            “paused”:false,
            “retry_interval”:30.0,
            “severity”:72.0,
            “source_location”:{  
               “first_column”:0.0,
               “first_line”:1.0,
               “last_column”:34.0,
               “last_line”:1.0,
               “path”:"/etc/icinga2/zones.d/nas-01/check_qnap3-sysinfo.conf"
            },
            “state”:3.0,
            “state_type”:1.0,
            “templates”:[  
               “check_qnap3-sysinfo”,
               “generic-service”
            ],
            “type”:“Service”,
            “vars”:null,
            “version”:0.0,
            “volatile”:false,
            “zone”:“master”
         },
         “joins”:{  

         },
         “meta”:{  

         },
         “name”:“NAS-01.kozo.ch!check_qnap3-sysinfo”,
         “type”:“Service”
      }
   ]
}

man lernt doch nie aus…


#17

/usr/lib/nagios/pluginsCustom/check_qnap3/check_qnap3.sh 10.147.42.70 public sysinfo 0 0
NAS NAS-01-2TB, Model TS-212, Firmware 4.3.3, Max HD number 2, No. Volume 1

the command like this it would be working, but on the output you have all the " " and commas too


#18

The check is executed with the prefix of the arguments, e.g.:

/usr/lib/nagios/pluginsCustom/check_qnap3/check_qnap3.sh $ARG1$ 10.147.42.70

But the check cant handle the prefix and expect the only the argument value, e.g.:

/usr/lib/nagios/pluginsCustom/check_qnap3/check_qnap3.sh 10.147.42.70

You can skip the prefix with the skip_key = true parameter in your CheckCommand object.

arguments = {
	"$ARG1$" = {
       	        value = "$qnap_host$"
		skip_key = true
	}
}

Since the plugin also expects the attributes in a certain order you should set the order parameter. You can find examples and explanations here.


(Rafael Voss) #19

Command

object CheckCommand "qnap" {
    import "plugin-check-command"
    command = [ CustomPluginDir + "/check_qnap3.sh" ]
    timeout = 40s
    arguments += {
        "(no key)" = {
            order = 1
            required = true
            skip_key = true
            value = "$snmp_address$"
        }
        "(no key.2)" = {
            order = 2
            required = true
            skip_key = true
            value = "$snmp_community$"
        }
        "(no key.3)" = {
            order = 3
            required = true
            skip_key = true
            value = "$qnap_check$"
        }
        "(no key.4)" = {
            order = 4
            required = true
            skip_key = true
            value = "$qnap_warn$"
        }
        "(no key.5)" = {
            order = 5
            required = true
            skip_key = true
            value = "$qnap_crit$"
        }
    }
}

aplly rule

apply Service "Temperature" {
    import "qnap-snmp"

    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "temp"
    vars.qnap_crit = "70"
    vars.qnap_warn = "60"

    import DirectorOverrideTemplate
}

apply Service "CPU Load" {
    import "qnap-snmp"

    icon_image = "cpu.png"
    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "cpu"
    vars.qnap_crit = "100"
    vars.qnap_warn = "99"

    import DirectorOverrideTemplate
}

apply Service "HDD Status" {
    import "qnap-snmp"

    icon_image = "storage.png"
    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "hdstatus"
    vars.qnap_crit = "95"
    vars.qnap_warn = "90"

    import DirectorOverrideTemplate
}

apply Service "Raid Status" {
    import "qnap-snmp"

    icon_image = "disk.png"
    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "volstatus"
    vars.qnap_crit = "0"
    vars.qnap_warn = "0"

    import DirectorOverrideTemplate
}

apply Service "Disk Usage" {
    import "qnap-snmp"

    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "diskused"
    vars.qnap_crit = "95"
    vars.qnap_warn = "90"

    import DirectorOverrideTemplate
}

apply Service "System Info" {
    import "qnap-snmp"

    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "sysinfo"
    vars.qnap_crit = "0"
    vars.qnap_warn = "0"

    import DirectorOverrideTemplate
}

apply Service "CPU Temperature" {
    import "qnap-snmp"

    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "cputemp"
    vars.qnap_crit = "70"
    vars.qnap_warn = "60"

    import DirectorOverrideTemplate
}

apply Service "Free RAM" {
    import "qnap-snmp"

    icon_image = "ram.png"
    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "freeram"
    vars.qnap_crit = "95"
    vars.qnap_warn = "90"

    import DirectorOverrideTemplate
}

apply Service "Fans (Minimum speed)" {
    import "qnap-snmp"

    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "fans"
    vars.qnap_crit = "50"
    vars.qnap_warn = "100"

    import DirectorOverrideTemplate
}

apply Service "System Uptime" {
    import "qnap-snmp"

    assign where match("*", host.vars.snmp_community) && host.vars.vendor == "qnap"
    vars.qnap_check = "systemuptime"
    vars.qnap_crit = "1"
    vars.qnap_warn = "1"

    import DirectorOverrideTemplate
}

#20

it works!!!
thanks for your help and support. - there is much red ;-( - a disk crashed a couple of days ago! Also the FANs speed are not showing up but i think the MIB are wrong - will try to find it out.