Ad Widget

Collapse

Read from file discovery rule

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PeterZielony
    Senior Member
    • Nov 2022
    • 146

    #16
    Click image for larger version  Name:	image.png Views:	0 Size:	778.1 KB ID:	475887

    Click image for larger version  Name:	image.png Views:	0 Size:	15.5 KB ID:	475888​​​


    small update on it. i'll try to finish it tomorrow . Just really note on this - each item will exist with combination of macro test and description as i noticed that some [test xx] have same numbers but different description - you can play with it later if you want. If one of them changes it will create another item.
    how often output is changing? And I hope they are not rotating.. meaning one time for one server and another cycle for another- this way will end up with a log of items triggered as failure...
    you can modify this if thats the case for different files if multiple tests are running - then each output would have to be to a different file.


    you can buy me a coffee one day
    Last edited by PeterZielony; 14-12-2023, 23:37.

    Hiring in the UK? Drop a message

    Comment

    • ijonjic
      Junior Member
      • Nov 2023
      • 10

      #17
      Thanks a lot PeterZielony . This looks awesome.

      Yes, i',m aware there is some TEST xx duplicates,i will fix that later. Regarding output changes, basically every line value is fixed, only "status" part is changing. Eventually, maybe more test will be added under new TEST xx. Each server will have its own script and its own set of tests in output,maybe some of them will be the same as on another server,but that should not be the problem,since discovery is done on each server separately.

      Comment

      • PeterZielony
        Senior Member
        • Nov 2022
        • 146

        #18
        so you have few files in zip
        in convertJson.sh (based on your file it uses python3 env) you need to change the location for sh_output.txt

        Note: zabbix agent needs to have access to run this script as well to sh_output.txt! ​


        ​DiscoveryJson.conf - needs to go to your Userparameter folder specified in agent config:



        this is how zabbix runs discovery using this key
        (discovery cannot accept parameters unfortunately like file path - and I don't advise running "system.run" for discovery either)


        in agent config, you will also need make sure you can run remote commands - but to be honest i never remember if for discovery this is needed (probably is), in my test system i have installed everything w/o any restriction for building. i suggest reading documentation about permissions and remote commands.

        so what it is - it you have discovery "converJson" that reads your original result and instead writing to file - it just output it to console (which zabbix agent grabs and passes to zbx). Then you have depended item on this which creates item - in preprocessing it grabs values and populates item with values.
        if value is not there - (something has changes) it will set value to 0 - which will fire trigger. Same if value is "failure" it will set to 0 too

        also you might want to add to the parameters below ( i mean change it) an additional condition to check message val too - since you have multiple tests with same number - it might not work correctly.
        but if you cant change tests number to be unique do something like this:

        $[?(@.TestNo=='{#TESTNUMBER}'&&@.Message=='{#MESSAGE }')].Status.first()

        Click image for larger version  Name:	image.png Views:	0 Size:	25.3 KB ID:	475959

        this ​way you will have full history with tests and dynamically creating new items if you have more in future (or they've changed).

        this val will determine for how long you have item if its not there anymore:
        Click image for larger version  Name:	image.png Views:	0 Size:	26.4 KB ID:	475960


        also make sure you set data retention for discovery item to "not keep history" (forgot to change it but useful for debugging sometimes)

        Click image for larger version  Name:	image.png Views:	0 Size:	34.3 KB ID:	475962

        once you deploy files make sure to restart agent to load userparameters !

        enjoy​
        ​​
        Attached Files
        Last edited by PeterZielony; 15-12-2023, 15:26.

        Hiring in the UK? Drop a message

        Comment

        • ijonjic
          Junior Member
          • Nov 2023
          • 10

          #19
          Thank you for your effort. I will try everything on monday. I owe you whole coffeee shop for this,not just a cup

          Comment

          Working...