Ad Widget

Collapse

Discovery Rule. Get data from file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • A66aT
    Junior Member
    • Jan 2020
    • 6

    #1

    Discovery Rule. Get data from file

    Hello

    I need to monitor connections state from one servers to another (check for monitoring is ready), the question is that each server, i nned to monitor may have connections to multiple other servers, so i need to create few tests from template. for one server it must bu one check, for qnother its need to be three tests.
    I have a file with list of ip addresses, connections to which i need to monitor.
    I wanted to do it with discovery rule. Read that file, get values and according to its number create checks. I made this discovery rule
    Test discovery rule Item prototypes Trigger prototypes Graph prototypes Host prototypes vfs.file.contents[/usr/etc/customfile.txt] 30s Zabbix agent Enabled
    File /usr/etc/customfile.txt - is that file with ip addresses list. But i didn`t find how to receive data properly from that file. How can i do it?
    Thank you
  • leandro.s.teixeira
    Junior Member
    • Dec 2020
    • 4

    #2
    Hello!

    Do you find a solution?

    Comment

    • joelmeckert
      Junior Member
      • Nov 2020
      • 1

      #3
      I'm running into the exact same issue here Devices are remote and on the public internet, and need to be (nmap) scanned to determine the services that need to be monitored. Nmap has XML output, and I was hoping to use the XML output in the LLD by converting it to s psobject then a JSON with PowerShell. I was considering creating a separate discovery rule for each type of service, provide a YAML template to a colleague, have them fill in the values (more than one address = array, multiple entries), and then have the upload it to the web server. PowerShell ConvertFrom-Yaml to PowerShell object, then convert the PowerShell object to JSON. I had been doing this with host macros, but as things scale, it makes it more difficult to manage.
      It would also be possible via the API, PowerShell, it issues the HTTP POST request, grabs all of the hosts, and then prompts the staff member to press a number that coincides with their target host, ConvertFrom-Json to psobject, and then ConvertTo-Yaml. The file could be uploaded to the Zabbix server via WinSCP, into a specific folder that only Zabbix could access, or a completely new Apache virtualhost that only allows connections from the Zabbix server itself. Perhaps PowerShell could split the object into multiple files for the upload, depending on the service type being monitored.
      Perhaps that makes it way way more complicated than it needs to be, but I'm of the mindset that systems should be code and not random mouseclicks, and should be tested and done once right.

      Comment

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

        #4

        Originally posted by A66aT
        Hello

        I need to monitor connections state from one servers to another (check for monitoring is ready), the question is that each server, i nned to monitor may have connections to multiple other servers, so i need to create few tests from template. for one server it must bu one check, for qnother its need to be three tests.
        I have a file with list of ip addresses, connections to which i need to monitor.
        I wanted to do it with discovery rule. Read that file, get values and according to its number create checks. I made this discovery rule
        Test discovery rule Item prototypes Trigger prototypes Graph prototypes Host prototypes vfs.file.contents[/usr/etc/customfile.txt] 30s Zabbix agent Enabled
        File /usr/etc/customfile.txt - is that file with ip addresses list. But i didn`t find how to receive data properly from that file. How can i do it?
        Thank you
        Discovery needs LLD macros to work. it expects json input. So either you provide your customfile.txt already in json format, so you can point LLD macro to certain json path. Or you add somekind of JS preprocessing, which takes your IP list and formats it as json and then you point your LLD macros to needed json path.

        Comment

        Working...