Ad Widget

Collapse

How to correctly use external scripts in zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • limbooface
    Member
    • Jun 2016
    • 77

    #1

    How to correctly use external scripts in zabbix

    my external script is in the zabbix server /usr/lib/zabbix/externalscripts/
    I have on my zabbix_server.conf file
    ExternalScripts=/usr/lib/zabbix/externalscripts

    and I have created 2 items for the client.
    But I am getting in the zabbix_server.log (items not suported). I know this happens when in my zabbix_agent.conf i do not have a correct item key for UserParameter. But as I am using an external script do I need to set a UserParameter?

    I am using zabbix 3.0.1
  • pyloor
    Junior Member
    • Jul 2016
    • 5

    #2
    Hi,

    could you provide the item key you used and the script name? Perhaps chmod/chown is not correct?

    Best,
    pyloor

    Comment

    • Linwood
      Senior Member
      • Dec 2013
      • 398

      #3
      If you hover over the "X" where it shows not supported, what does it say? It should give you a clue.

      Some possibilities:

      - It needs execute mode
      - The zabbix account needs to be able to run it
      - The parameters with which you call it (if any) need to be coming in correctly

      One thing to try (on linux) is something like:

      su - zabbix
      /usr/lib/zabbix/externalscripts/yourscriptname

      or

      /usr/lib/zabbix/externalscripts/yourscriptname "param1" "param2" ...

      See that it returns a value as you expect (if an external check) or a properly formatted json string (LLD External).

      Comment

      • limbooface
        Member
        • Jun 2016
        • 77

        #4
        hover over "X" shows: Unsupported Item Key.
        chown zabbix:zabbix
        chmod 775

        does the external script need to be a .sh bash script or can a perl script work fine .pl file?

        Comment

        • limbooface
          Member
          • Jun 2016
          • 77

          #5
          im trying to get this working

          Comment

          • Linwood
            Senior Member
            • Dec 2013
            • 398

            #6
            Originally posted by limbooface
            hover over "X" shows: Unsupported Item Key.
            chown zabbix:zabbix
            chmod 775

            does the external script need to be a .sh bash script or can a perl script work fine .pl file?
            It can be perl.

            Try something really simple first and see what you are getting. Here's an example with a parameter:

            File named test.pl in the external script directory with just two lines of code:

            Code:
            #!/usr/bin/perl
            print 102077 + $ARGV[0];
            Made executable (it was already readable):

            chmod +x test.pl

            Create an external item with key:

            test.pl[3]


            Let it run a couple of iterations and you should see it returning the value 102080 (the 102077 + 3). OK, not real interesting but it has a parameter and it should return a value.

            Get something like that running first.

            The "Unsupported item key" probably means you have some kind of syntax error after any macro substitution -- did it give you more details? Why are you not sharing what your item key is, since it has been identified as the problem?

            The thread you referenced has a somewhat complicated key structure, depending on what the replacement items are, you might want o try putting them in quotes (") (each individual parameter that is) in case spacing or punctuation are causing an issue, but it's hard to say without seeing them.

            Are you sure you are putting this in an item definition and not an item prototype? The requirements for keys in a prototype are different (they need to depend on a returned value macro like [{#SNMPINDEX}].

            Anyway -- I think you need to provide more specifics, pyloor asked you for the key specifically already.

            Comment

            • limbooface
              Member
              • Jun 2016
              • 77

              #7
              All I am getting is unsupported license key.

              That is why I posted the link, because in that page it shows the 2 item keys that I am making.

              I have now set the item type to be External check was zabbix agent. Now the item issued is enabled. Using Decimal.

              However item used is disabled: Red 'X' Received value[] is not suitable for value type [Numeric unsigned] and data type [Decimal]

              server log
              50692:20160712:152831.801 item "server.local:lmstat.pl[-H,{HOST.CONN},-p,27001,-f,feature,--issued]" became supported
              50689:20160712:152833.803 error reason for "server.local:lmstat.pl[-H,{HOST.CONN},-p,27001,-f,feature,--used]" changed: Received value [] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]

              Comment

              • Linwood
                Senior Member
                • Dec 2013
                • 398

                #8
                The error is saying that it is returning a blank (or not returning anything at all). My suggestion is run the script manually until you get the script running properly. I don't use that product so I have no idea how it should work or how to debug it, but it sounds like you are beyond the zabbix aspects, and need to just get the script working.

                Comment

                • limbooface
                  Member
                  • Jun 2016
                  • 77

                  #9
                  I have now got this working.

                  I was missing the correct feature name. I am getting the desired results in a graph.

                  server.log

                  91026:20160712:164832.464 item "server.local:lmstat.pl[-H,{HOST.CONN},-p,27001,-f,86213MAYA_2015_0F,--issued]" became supported
                  91028:20160712:164834.465 item "serverlocal:lmstat.pl[-H,{HOST.CONN},-p,27001,-f,86213MAYA_2015_0F,--used]" became supported

                  Do you know how I assign the trigger?
                  trigger for the --issued item (.last(0)=0) if you desire to get an alert when it doesn't detect any issued licenses.

                  Comment

                  • frank108
                    Junior Member
                    • Mar 2022
                    • 15

                    #10
                    Old topic, but where to put scripts that zabbix agent2 can see and execute?
                    ExternalScripts
                    is not supported anymore in the configuration file.

                    I see AllowKey, shall I provide full path for allowed scripts?

                    Comment

                    • cyber
                      Senior Member
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Dec 2006
                      • 4807

                      #11
                      Originally posted by frank108
                      Old topic, but where to put scripts that zabbix agent2 can see and execute?
                      is not supported anymore in the configuration file.

                      I see AllowKey, shall I provide full path for allowed scripts?
                      ExternalScripts it absolutely supported option... Just it is for Server, not for Agent...

                      You really should read manual ... Then you would know what for AllowKeys options is for... https://www.zabbix.com/documentation.../zabbix_agent2

                      Manual helps you to understand, that there is no ExternalScripts for agents... you can place your scripts where ever you need, if you describe them properly as UserParameters and execute them as agent items...

                      Comment

                      • frank108
                        Junior Member
                        • Mar 2022
                        • 15

                        #12
                        Hello, thanks, AllowKeys are allowing scripts on other locations as well.
                        Thanks for answer.

                        Comment

                        Working...