How to: integrate check_truenas on Icinga

Hi, yesterday I found this plugin on the net for truenas and I can’t seem to install it properly:

I am not very good at creating non-nrpe services.
I want to create the 4 examples in the README:

  • alerts
  • all zpool health
  • Zpool capacity
  • updates

I am trying to create the first service alerts and at least I have managed to get it to appear on the dashboard but always with some kind of error.

/etc/icinga2/zones.d/COLT-RZ/local-conf/commands.conf

object CheckCommand "truenas" {
         import "plugin-check-command"
         command = [ PluginDir + "/check_truenas.py", "-H", "$truenas_host$", "-u", "$truenas_user$", "-p", "$truenas_pass$","-t", "$truenas_type$", "-nv", "-ns" ]

         arguments = {
                 "-H" = "$truenas_host$"
                 "-u" = "$truenas_user$"
                 "-p" = "$truenas_pass$"
                 "-t" = "$truenas_type$"
                 "-pn" = "$truenas_zpoolname$"
                 "-ns" = "$truenas_nossl$"
                 "-nv" = "$truenas_noverifycert$"
                 "-zw" = "$truenas_zpool-warn$"
                 "-zc" = "$truenas_zpool-crit$"
                 "-zp" = "$truenas_perfdata$"
         }

         vars.truenas_host = "$address$"
         vars.truenas_user = "root"
         vars.truenas_type = "alerts"
}

/etc/icinga2/zones.d/COLT-RZ/services/coltnas.conf

apply Service "truenas-alerts" {
        import "generic-service"
       assign where match ("coltnas*", host.name)
        check_command = "truenas"
        vars.truenas_host = "192.168.3.235"
        vars.truenas_pass = "12345"
        vars.sla = "24x7"
}

Does anyone know what I am doing wrong?

Dashboard:

UNKNOWN - request failed - Error when contacting TrueNAS server: (, HTTPError('401 Client Error: Unauthorized for url: https://192.168.3.235:443/api/v2.0/alert/list/'), )

I

Running it manually as nagios user from satellite works fine:

nagios@coltmon:~$ /usr/lib/nagios/plugins/check_truenas.py -H 192.168.3.235 -u root -p 12345 -t alerts -nv 
OK - No problem alerts

Thank you very much for your help!

wit api works , but with root user not…

         command = [ PluginDir + "/check_truenas.py", "-H", "$truenas_host$", "-p", "$truenas_pass$","-t", "$truenas_type$", "-nv", "-ns" ]

Hey @vbits

it helps to see what command icinga executes. Activate the debuglog on the satellite that executes the check or query the API.

curl -k -s -S -i -u username:password t -H 'Accept: application/json' 'https://localhost:5665/v1/objects/services?service=hostname!servicename&attrs=name&attrs=last_check_result&pretty=1'

Replace username, password, hostname and servicename as per your needs.

Kind regards