Ad Widget

Collapse

Discovery Rule Create Items From CSV File Contents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brianhill1980
    Junior Member
    • Jul 2019
    • 7

    #1

    Discovery Rule Create Items From CSV File Contents

    Hello,

    I've spent the last couple of days trying to figure out how to create a discovery rule that reads the contents of a CSV file, creates items, and reads values from the CSV. But I'm stuck and lost and hoping I can get some help.

    The CSV I'm reading is an output of an MSSQL query. It contains 3 columns. Name, Keys, Duration. This file is updated every 15 minutes and will contain 100+ rows. Items can be added and removed occasionally.
    Name Keys Duration
    channel1 4 17.345
    channel2 4 16.457
    channel3 4 15.876
    I want Zabbix to read this CSV, use Item Prototypes to create items based on the Name column to get the number of keys per channel and the duration for each channel. Eg:
    • Channel1 Key Count: 4 keys
    • Channel1 Key Duration: 17.345 hours
    I created a Discovery Rule with the following key:
    "vfs.file.contents[C:\Scripts\KeyCoverage\KeyCoverage.csv]"

    Added a Preprocessing step for CSV to JSON:
    Click image for larger version

Name:	image.png
Views:	1098
Size:	5.5 KB
ID:	450279

    When I test this, it returns a valid JSON output. I'm just lost on how to get this into item prototypes now.

    Any help would be appreciated.
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    Next, describe the LLD macros as a path in JSON. Then use these macros in prototypes.

    Comment

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

      #3
      How do you plan to retrieve data? How it is now, you just create items/triggers, but you cannot insert any data from that file to items...
      I think you need one more "layer"... first, get contents of file, then create discovery as dependent item and then all the prototypes as dependent items also, which take data from "main" item. Then each time you pull that file, discovery will create/remove items and existing items get new values... First run creates items, second one already retrieves values....

      Comment

      Working...