Ad Widget

Collapse

Shocking AI success: ExternalScript (JSON to py-zabbix) by Gemini with four prompts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jtnfoley
    Member
    • Mar 2022
    • 76

    #1

    Shocking AI success: ExternalScript (JSON to py-zabbix) by Gemini with four prompts

    I have a data source with non-standard JSON (multiple packed strings of semi-colon delimited key:value pairs in a comma separated list, in text fields, wrapped in JSON!)
    The goal was to create a quick proof of concept, graphing time series data from this source. Basically, line graphs documenting the rate of change of these key:value pairs.

    When I realized I'd have to learn to unpack and process the key:value pairs from CSV within the JSON, I decided to give AI a try.
    "Create a simple python script that downloads and displays a text file from http://www.xxx.yyy.zzz/reports/report"
    Gemini replied that I should resolve dependencies and ensure I have "requests" installed by pip, and gave me a clean download script with error handling and everything.
    "The downloaded file is a JSON with embedded CSV. Decode, parameterize, and send to Zabbix. The source file looks like this:" (followed by a paste of the actual CSV packed JSON)
    Gemini advised that I'd need to pip install py-zabbix and json.
    The JSON also has metadata in the first message response that is not useful to me, so...
    "Adjust logic to ignore first "type" line of the JSON structure"
    I edited the resulting python script to set the AI-generated ZABBIX_SERVER variable to the proper IP address, and ZABBIX_HOST to a host name I created for the purpose, and ran it.
    There were no items yet in the host, so I gave Gemini one more prompt:
    "debug print zabbix item names to console"

    When I run the script now, I get a beautiful table of the dissected JSON->CSV-key:value pair->Zabbix host item names, and their values. I created Trapper items in the zabbix host with keys matching the variable names invented by Gemini, and ran it again and it just worked.
    Total time invested, about 15 minutes.
    I created an agent item with a 5 minute refresh interval to execute the script and put it in /usr/lib/zabbix/ExternalScripts, set the appropriate settings in zabbix_agentd.conf and now the thing just runs.

    Including talking to the data owners and potential consumers, my all-in on getting this going is about two man hours.
    When the POC has sufficient interest from the requestors, data, and process owners, I'll hand the reigns to our business intelligence types to figure out how to do near-realtime time series graphing in their more conventional tools.
Working...