Ad Widget

Collapse

ChatGPT and/or Bard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Argon0
    Member
    • Mar 2023
    • 51

    #1

    ChatGPT and/or Bard

    Has anyone tried creating a template with Bard or ChatGPT?

    I asked Bard, but I'm not convinced the output is correct, or even close to correct, it ISN'T doing what I asked it to do (or not what I *thought* I'd asked it to do (write me a zabbix template to gather print jobs from windows print server):

    [zabbix-template]
    name=Windows Print Server
    description=Gathers print jobs from a Windows print server

    [triggers]
    print-job-received=1

    [items]
    print-job=job,job_status,job_printer,job_pages,job_user

    [job]
    type=print-job
    name=Print Job

    [job_status]
    type=numeric
    name=Status

    [job_printer]
    type=text
    name=Printer Name

    [job_pages]
    type=numeric
    name=Pages Printed

    [job_user]
    type=text
    name=User​
    Does it look anything like correct?

    I am assuming this is expecting an active Zabbix agent on a print server - as it triggers on receiving a print job...
    Last edited by Argon0; 29-03-2023, 14:59. Reason: Forgot some detail at the end.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    You are not convinced? If you look at any real template you can be sure that this is some mumbo-jumbo you got there..
    example of real one... https://git.zabbix.com/projects/ZBX/..._linux.yaml​

    Comment

    • Argon0
      Member
      • Mar 2023
      • 51

      #3
      Yeah, been working on template for Zebra printer today, knew it couldn't be that simple!

      Comment

    • Argon0
      Member
      • Mar 2023
      • 51

      #4
      OTOH I got ChatGPT to generate some code to convert a CSV table to XML ready to import hosts into Zabbix... Which looks good... AND when I asked it to generate the XML file itself it came up with a valid (as far as I can tell - about to test) file. It got a bit lazy when I asked it to do the same for 50 hosts - saying just either 1) use the python code I've generated or 2) "<!-- ... Repeat the structure for each host ... -->​" after the first 1 whic is kind of what I wanted it to do!!!

      Comment

      • Argon0
        Member
        • Mar 2023
        • 51

        #5
        I'm thinking I can use that as a template to use in Excel using the concatenation stuff to create a line of XML per host, then curring and pasting that into the shell code around it... Hmmm....

        Comment

        • Argon0
          Member
          • Mar 2023
          • 51

          #6
          (actually, before I got to test it I noticed an error in the code that ChatGPT generated it had nested <host> tags in the XML thus:
          Code:
          <zabbix_export version="6.4">
          <hosts>
          [COLOR=#e74c3c]<host>
          <host>[/COLOR]FQDN.hostname[COLOR=#e74c3c]</host>[/COLOR]
          ....
          [COLOR=#e74c3c]</host>​[/COLOR]
          However, the most important thing is that it made me think about how to generate the relevant code, so I'm now using concatenation within the Excel CSC file I have to generate the XML, using, as guide an export from matching hosts)

          <ERM> my bad... It looks like Zabbix EXPECTS the nested <host> tags... I would have written it differently!
          Last edited by Argon0; 09-06-2023, 12:28.

          Comment

          • Argon0
            Member
            • Mar 2023
            • 51

            #7
            Hmmm... Not bad, but not as good as asking BARD which, in this case came up with a formula on the basis of a google sheet and the XML from a host Export that I shared with it.

            Code:
            =ARRAYFORMULA(
            IF(A2<>"",
            "<host>
            <host>"&A2&"</host>
            <name>"&A3&"</name>
            <description>"&A4&"</description>
            <templates>
            <template>
            <name>"&A5&"</name>
            </template>
            </templates>
            <groups>
            <group>
            <name>Cerner 724</name>
            </group>
            </groups>
            <interfaces>
            <interface>
            <useip>NO</useip>
            <ip/>
            <dns>"&A6&"</dns>
            <interface_ref>if1</interface_ref>
            </interface>
            </interfaces>
            <inventory_mode>DISABLED</inventory_mode>
            </host>
            ",
            "")
            )​
            With a bit of back and forth this works as expected.Now to test in Zabbix..

            Comment

            • Argon0
              Member
              • Mar 2023
              • 51

              #8
              Which now I look again got it wrong.. Seems to think (in this case that I've got the data in one column... I'm sure it didn't do that before!

              Oh, it did, why? Better fomula:

              Code:
              =ARRAYFORMULA(
              IF(A2<>"",
              "<host>
                  <host>"&A2&"</host>
                  <name>"&B2&"</name>
                  <description>"&C2&"</description>
                  <templates>
                      <template>
                          <name>724 Workstation - Windows by Zabbix agent</name>
                      </template>
                  </templates>
                  <groups>
                      <group>
                          <name>Cerner 724</name>
                      </group>
                  </groups>
                  <interfaces>
                      <interface>
                          <useip>NO</useip>
                          <ip/>
                          <dns>"&A2&"</dns>
                          <interface_ref>if1</interface_ref>
                      </interface>
                  </interfaces>
                  <inventory_mode>DISABLED</inventory_mode>
              </host>
              ",
              "")
              )​

              Comment

              • Argon0
                Member
                • Mar 2023
                • 51

                #9
                Which worked, like a dream!!! YAY!

                It just didn't like the unescaped & in the description... for one host
                (fingers crossed now going to have to double check each of the 8 imports hosts...​

                Comment

                Working...