Ad Widget

Collapse

v5.4.9 - low level discovery using zabbix_sender

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • davama
    Junior Member
    • Oct 2019
    • 22

    #1

    v5.4.9 - low level discovery using zabbix_sender

    Hello,

    I am trying to get values into my discovered items
    Click image for larger version

Name:	2022-02-22_12-42.png
Views:	435
Size:	38.7 KB
ID:	440257
    I have a script locally on my agent that outputs the following:

    Code:
    [root@tamu46668 ~]# ./zabbix-lane-status.sh
    {"data":[
    {"{#POSLANE}":"tamu46668_lane_1_pos","{#POSLANESTA TUS}":"down"},
    {"{#POSLANE}":"tamu46668_lane_2_pos","{#POSLANESTA TUS}":"offline"},
    {"{#POSLANE}":"tamu46668_lane_3_pos","{#POSLANESTA TUS}":"down"},
    {"{#POSLANE}":"tamu46668_lane_4_pos","{#POSLANESTA TUS}":"idle"},
    {"{#POSLANE}":"tamu46668_lane_5_pos","{#POSLANESTA TUS}":"total"},
    {"{#POSLANE}":"tamu46668_lane_6_pos","{#POSLANESTA TUS}":"offline"},
    {"{#POSLANE}":"tamu46668_lane_7_pos","{#POSLANESTA TUS}":"offline"},
    {"{#POSLANE}":"tamu46668_lane_8_pos","{#POSLANESTA TUS}":"down"},
    {"{#POSLANE}":"tamu46668_lane_9_pos","{#POSLANESTA TUS}":"offline"},
    {"{#POSLANE}":"tamu46668_lane_10_pos","{#POSLANEST ATUS}":"offline"},
    {"{#POSLANE}":"tamu46668_lane_11_pos","{#POSLANEST ATUS}":"offline"},
    {"{#POSLANE}":"tamu46668_lane_12_pos","{#POSLANEST ATUS}":"idle"},
    {"{#POSLANE}":"tamu46668_lane_13_pos","{#POSLANEST ATUS}":"idle"},
    {"{#POSLANE}":"tamu46668_lane_14_pos","{#POSLANEST ATUS}":"down"},
    {"{#POSLANE}":"tamu46668_lane_15_pos","{#POSLANEST ATUS}":"idle"},
    {"{#POSLANE}":"tamu46668_lane_16_pos","{#POSLANEST ATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_1_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_2_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_3_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_4_printer","{#PRINTERLANESTATUS}":"online"},
    {"{#PRINTERLANE}":"tamu46668_lane_5_printer","{#PRINTERLANESTATUS}":"online"},
    {"{#PRINTERLANE}":"tamu46668_lane_6_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_7_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_8_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_9_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_10_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_11_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_12_printer","{#PRINTERLANESTATUS}":"online"},
    {"{#PRINTERLANE}":"tamu46668_lane_13_printer","{#PRINTERLANESTATUS}":"online"},
    {"{#PRINTERLANE}":"tamu46668_lane_14_printer","{#PRINTERLANESTATUS}":"offline"},
    {"{#PRINTERLANE}":"tamu46668_lane_15_printer","{#PRINTERLANESTATUS}":"online"},
    {"{#PRINTERLANE}":"tamu46668_lane_16_printer","{#PRINTERLANESTATUS}":"offline"}
    ]}
    inside /etc/zabbix/zabbix_agentd.conf we have:

    Code:
    UserParameter=jbrain.pos.lane.discovery,/usr/local/bin/zabbix-lane-status.sh
    My zabbix template has the discovery item as so:
    Click image for larger version

Name:	2022-02-22_09-45.png
Views:	389
Size:	51.8 KB
ID:	440258

    Along with the item prototype as so:

    Click image for larger version

Name:	2022-02-22_09-46.png
Views:	388
Size:	47.3 KB
ID:	440259

    This as shown in the 1st screenshot creates the discovered lanes.

    I want the value of `#POSLANESTATUS` to be there but not sure what I'm doing wrong. In other words, I want pos_lane_X with a value of pos_lane_X_status

    Im certain it has to do with my zabbix template setup but not sure what...

    any input is much appreciated!!

    Thank you,
    Dave
  • Answer selected by davama at 24-02-2022, 21:50.
    davama
    Junior Member
    • Oct 2019
    • 22

    Update:

    Happy to report that got it working!!!

    So changes and final settings that are working for me now:

    output of the script no just outputs a json list.

    Code:
    [root@apcd0995-ng ~]# zabbix_agentd -t jbrain.lane.get.item
    zabbix_agentd [16441]: Warning: both HostMetadata and HostMetadataItem defined, using [Jbrain-old-7]
    jbrain.lane.get.item [t|[{"pos_status":"sign_on","pos_lane":"apcd0995-ng_lane_1_pos"},{"printer_lane":"apcd0995-ng_lane_1_printer","printer_status":"offline"}]]
    adjusted my item prototype to below:
    Click image for larger version  Name:	2022-02-24_14-46.png Views:	0 Size:	31.6 KB ID:	440428
    preprocessing looks similar to the link reference I was given:
    Code:
    $.[?(@.pos_lane=='{#POSLANE}')].pos_status.first()
    And here is my trigger prototype which works:

    Click image for larger version  Name:	2022-02-24_14-47.png Views:	0 Size:	32.7 KB ID:	440429

    Click image for larger version

Name:	2022-02-24_14-48.png
Views:	365
Size:	33.6 KB
ID:	440430
    Click image for larger version

Name:	2022-02-24_14-49.png
Views:	357
Size:	26.4 KB
ID:	440431

    Awesome!

    Comment

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

      #2
      Issue you have is, that those items you create are "trapper items", you should send data to them one by one (or from script /input file etc). But you are not doing this. Just running this discovery doesn't do it.

      Change your discovery into normal item (lets call it master here). It will return data from that userparameter. Then add discovery as "dependent item", depending on your master item. Your discovery should have declarations for LLD macros. what you will use in item prototypes etc (you probably have it as your items are created)...Your item prototype should be also dependent item, depending on same master item. Little preprocessing to point them to correct value. something along
      Each time your master receives new values, discovery runs over it and creates/obsoletes items, second time new set of values arrive, you will get values to discovered items.

      Concept is same as here https://www.zabbix.com/documentation...ed_filesystems
      Last edited by cyber; 23-02-2022, 09:59.

      Comment

      • davama
        Junior Member
        • Oct 2019
        • 22

        #3
        cyber

        Thank you for the reply!

        I attempted to mimic the link you sent.

        So now my script that runs locally on the agent outputs the below:

        Code:
        [root@tamu46668 ~]# /usr/local/bin/zabbix-lane-status.sh
        {
        "data": [
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_1_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_2_pos"
        },
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_3_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_4_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_5_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_6_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_7_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_8_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_9_pos"
        },
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_10_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_11_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_12_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_13_pos"
        },
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_14_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_15_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_16_pos"
        },
        {
        "printer_lane": "tamu46668_lane_1_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_2_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_3_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_4_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_5_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_6_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_7_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_8_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_9_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_10_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_11_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_12_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_13_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_14_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_15_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_16_printer",
        "printer_status": "offline"
        }
        ]
        }
        My userparameter is now:
        Code:
        UserParameter=jbrain.lane.get.item,/usr/local/bin/zabbix-lane-status.sh
        My master key: jbrain.lane.get.item
        Click image for larger version

Name:	2022-02-23_11-10.png
Views:	376
Size:	45.3 KB
ID:	440338

        My discovery rule: key=jbrain.lane.discovery
        Click image for larger version

Name:	2022-02-23_11-11.png
Views:	358
Size:	32.4 KB
ID:	440339

        My LLD Macros:

        Click image for larger version

Name:	2022-02-23_11-12.png
Views:	364
Size:	28.9 KB
ID:	440340

        my item prototype(s):

        Click image for larger version

Name:	2022-02-23_11-12_1.png
Views:	360
Size:	42.2 KB
ID:	440341
        Along with the preprocessing for this item prototype:

        Click image for larger version

Name:	2022-02-23_11-13.png
Views:	379
Size:	12.6 KB
ID:	440342

        When I query the item with zabbix_agent on the agent itself I get the below:

        Code:
        [root@tamu46668 ~]# zabbix_agentd -t jbrain.lane.get.item
        zabbix_agentd [26465]: Warning: both HostMetadata and HostMetadataItem defined, using [Jbrain-old-7]
        jbrain.lane.get.item [t|{
        "data": [
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_1_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_2_pos"
        },
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_3_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_4_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_5_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_6_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_7_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_8_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_9_pos"
        },
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_10_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_11_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_12_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_13_pos"
        },
        {
        "pos_status": "down",
        "pos_lane": "tamu46668_lane_14_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_15_pos"
        },
        {
        "pos_status": "offline",
        "pos_lane": "tamu46668_lane_16_pos"
        },
        {
        "printer_lane": "tamu46668_lane_1_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_2_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_3_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_4_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_5_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_6_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_7_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_8_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_9_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_10_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_11_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_12_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_13_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_14_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_15_printer",
        "printer_status": "offline"
        },
        {
        "printer_lane": "tamu46668_lane_16_printer",
        "printer_status": "offline"
        }
        ]
        }]
        But now I don't see any data in "Latest Data" for this agent...

        Im sure it's something simple... unless I misconfigured....

        Any input is much appreciated!!

        Thank you,
        Dave

        Comment

        • davama
          Junior Member
          • Oct 2019
          • 22

          #4
          Update:

          was able to get discovery items!!

          still missing the `value` field though but progress!

          what I did:

          I change the output of my script to compact the json output.

          now it looks like so

          Code:
          [root@tamu46668 zabbix]# zabbix_agentd -t jbrain.lane.get.item
          zabbix_agentd [18649]: Warning: both HostMetadata and HostMetadataItem defined, using [Jbrain-old-7]
          jbrain.lane.get.item [t|{"data":[{"pos_status":"offline","pos_lane":"tamu46668_lane _1_pos"},{"pos_status":"offline","pos_lane":"tamu4 6668_lane_2_pos"},{"pos_status":"offline","pos_lan e":"tamu46668_lane_3_pos"},{"pos_status":"offline" ,"pos_lane":"tamu46668_lane_4_pos"},{"pos_status": "offline","pos_lane":"tamu46668_lane_5_pos"},{"pos _status":"offline","pos_lane":"tamu46668_lane_6_po s"},{"pos_status":"offline","pos_lane":"tamu46668_ lane_7_pos"},{"pos_status":"offline","pos_lane":"t amu46668_lane_8_pos"},{"pos_status":"offline","pos _lane":"tamu46668_lane_9_pos"},{"pos_status":"down ","pos_lane":"tamu46668_lane_10_pos"},{"pos_status ":"offline","pos_lane":"tamu46668_lane_11_pos"},{" pos_status":"offline","pos_lane":"tamu46668_lane_1 2_pos"},{"pos_status":"offline","pos_lane":"tamu46 668_lane_13_pos"},{"pos_status":"down","pos_lane": "tamu46668_lane_14_pos"},{"pos_status":"offline"," pos_lane":"tamu46668_lane_15_pos"},{"pos_status":" offline","pos_lane":"tamu46668_lane_16_pos"},{"pri nter_lane":"tamu46668_lane_1_printer","printer_sta tus":"offline"},{"printer_lane":"tamu46668_lane_2_ printer","printer_status":"offline"},{"printer_lan e":"tamu46668_lane_3_printer","printer_status":"of fline"},{"printer_lane":"tamu46668_lane_4_printer" ,"printer_status":"offline"},{"printer_lane":"tamu 46668_lane_5_printer","printer_status":"offline"}, {"printer_lane":"tamu46668_lane_6_printer","printe r_status":"offline"},{"printer_lane":"tamu46668_la ne_7_printer","printer_status":"offline"},{"printe r_lane":"tamu46668_lane_8_printer","printer_status ":"offline"},{"printer_lane":"tamu46668_lane_9_pri nter","printer_status":"offline"},{"printer_lane": "tamu46668_lane_10_printer","printer_status":"offl ine"},{"printer_lane":"tamu46668_lane_11_printer", "printer_status":"offline"},{"printer_lane":"tamu4 6668_lane_12_printer","printer_status":"offline"}, {"printer_lane":"tamu46668_lane_13_printer","print er_status":"offline"},{"printer_lane":"tamu46668_l ane_14_printer","printer_status":"offline"},{"prin ter_lane":"tamu46668_lane_15_printer","printer_sta tus":"offline"},{"printer_lane":"tamu46668_lane_16 _printer","printer_status":"offline"}]}]
          Click image for larger version

Name:	2022-02-24_10-32.png
Views:	295
Size:	39.6 KB
ID:	440416

          I don't see any values under the values column. Am I missing something??

          Gonna continue and try to create a trigger and see where that goes.

          Thanks

          Comment

          • davama
            Junior Member
            • Oct 2019
            • 22

            #5
            Update:

            Happy to report that got it working!!!

            So changes and final settings that are working for me now:

            output of the script no just outputs a json list.

            Code:
            [root@apcd0995-ng ~]# zabbix_agentd -t jbrain.lane.get.item
            zabbix_agentd [16441]: Warning: both HostMetadata and HostMetadataItem defined, using [Jbrain-old-7]
            jbrain.lane.get.item [t|[{"pos_status":"sign_on","pos_lane":"apcd0995-ng_lane_1_pos"},{"printer_lane":"apcd0995-ng_lane_1_printer","printer_status":"offline"}]]
            adjusted my item prototype to below:
            Click image for larger version  Name:	2022-02-24_14-46.png Views:	0 Size:	31.6 KB ID:	440428
            preprocessing looks similar to the link reference I was given:
            Code:
            $.[?(@.pos_lane=='{#POSLANE}')].pos_status.first()
            And here is my trigger prototype which works:

            Click image for larger version  Name:	2022-02-24_14-47.png Views:	0 Size:	32.7 KB ID:	440429

            Click image for larger version

Name:	2022-02-24_14-48.png
Views:	365
Size:	33.6 KB
ID:	440430
            Click image for larger version

Name:	2022-02-24_14-49.png
Views:	357
Size:	26.4 KB
ID:	440431

            Awesome!

            Comment

            Working...