Problems to find what is wrong

I’m facing some trouble to adapt one script for telegraf + grafana + oracle.

I’m receiving this error:

2021-08-17T13:54:00Z E! [inputs.exec] Error in plugin: metric parse error: expected field at 224:72: “oracle_status,fqdn=ORADB-DASE,delphix=none,db=TEST instancename=TEST,db_status=OPEN”

Here is the code:

import socket
import argparse
import subprocess
import re
import cx_Oracle

fqdn = socket.getfqdn()

class OraStats():

    def __init__(self, user, passwd, sid):
        self.user = user
        self.passwd = passwd
        self.sid = sid
        self.delengine = "none"
        self.connection = cx_Oracle.connect(self.user, self.passwd, self.sid)
        cursor = self.connection.cursor()
        cursor.execute("select distinct(SVRNAME)  from v$dnfs_servers")
        rows = cursor.fetchall()

        for i in range(0, cursor.rowcount):
            self.dengine_ip = rows[i][0]
            proc = subprocess.Popen(["nslookup", self.dengine_ip], stdout=subprocess.PIPE)
            lookupresult = proc.communicate()[0].split('\n')

            for line in lookupresult:
                if 'name=' in re.sub(r'\s', '', line):
                    self.delengine = re.sub('\..*$', '', re.sub(r'^.*name=', '', re.sub(r'\s', '', re.sub(r'.$', '', line))))
   def dbstatus(self, user, passwd, sid, format):
        cursor = self.connection.cursor()
        select instance_name,status from v$instance
        for stat in cursor:
            instancename = stat[0]
            stat_status = stat[1]
            print "oracle_status,fqdn={0},delphix={1},db={2} instancename={3},db_status={4}".format(fqdn,self.delengine,sid, re.sub(' ','_', instancename),re.sub(' ','_', stat_status))
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('-f', '--format', help="Output format, default influx", choices=['kafka', 'influx'], default='influx')
    subparsers = parser.add_subparsers(dest='stat')
    parser_all = subparsers.add_parser('ALL', help="Get all database stats")
    parser_all.add_argument('-u', '--user', help="Username with sys views grant", required=True)
    parser_all.add_argument('-p', '--passwd', required=True)
    parser_all.add_argument('-s', '--sid', help="tnsnames SID to connect", required=True)

    args = parser.parse_args()

    if args.stat == "ALL":
        stats.dbstatus(args.user, args.passwd, args.sid, args.format)

Hello @fredpsrm,
First thing I’d like to ask is do you have any fields that aren’t strings?
I just want to verify that you want…
…your measurement to be: oracle_status
…your tag keys to be: fqdn, delphix, db
…your field keys to be: instancename, db_status
…where field values are strings

If that’s the case just add some more code to wrap your field values in strings so that your resulting line protocol looks like this:

oracle_status,fqdn=ORADB-DASE,delphix=none,db=TEST instancename="TEST",db_status="OPEN"