# Path: collectors/etc/zabbix_bridge_conf.py
# def get_settings():
# 
# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


import os
import re
import sqlite3
import sys
import time
    import pymysql
from collectors.etc import zabbix_bridge_conf
from collectors.lib import utils


def main():
    utils.drop_privileges()
    if pymysql is None:
        utils.err("error: Python module `pymysql' is missing")
        return 1
    settings = zabbix_bridge_conf.get_settings()

    db_filename = settings['sqlitedb']
    db_is_new = not os.path.exists(db_filename)
    dbcache = sqlite3.connect(db_filename)

    if db_is_new:
        utils.err("Zabbix bridge SQLite DB file does not exist; creating: %s" % (db_filename))
        cachecur = dbcache.cursor()
        cachecur.execute('''CREATE TABLE zabbix_cache
             (id integer, key text, host text, proxy text)''')
        dbcache.commit()
    else:
        utils.err("Zabbix bridge SQLite DB exists @ %s" % (db_filename))


    dbzbx = pymysql.connect(**settings['mysql'])
    zbxcur = dbzbx.cursor()
    zbxcur.execute("SELECT i.itemid, i.key_, h.host, h2.host AS proxy FROM items i JOIN hosts h ON i.hostid=h.hostid LEFT JOIN hosts h2 ON h2.hostid=h.proxy_hostid")
    # Translation of item key_
    # Note: http://opentsdb.net/docs/build/html/user_guide/writing.html#metrics-and-tags
    disallow = re.compile(settings['disallow'])
    cachecur = dbcache.cursor()

# Path: collectors/etc/zabbix_bridge_conf.py
# def get_settings():
# 
# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


# Path: collectors/900/zabbix_bridge_cache.py
import os
import re
import sqlite3
import sys
import time
    import pymysql
from collectors.etc import zabbix_bridge_conf
from collectors.lib import utils



def main():
    utils.drop_privileges()
    if pymysql is None:
        utils.err("error: Python module `pymysql' is missing")
        return 1
    settings = zabbix_bridge_conf.get_settings()

    db_filename = settings['sqlitedb']
    db_is_new = not os.path.exists(db_filename)
    dbcache = sqlite3.connect(db_filename)

    if db_is_new:
        utils.err("Zabbix bridge SQLite DB file does not exist; creating: %s" % (db_filename))
        cachecur = dbcache.cursor()
        cachecur.execute('''CREATE TABLE zabbix_cache
             (id integer, key text, host text, proxy text)''')
        dbcache.commit()
    else:
        utils.err("Zabbix bridge SQLite DB exists @ %s" % (db_filename))


    dbzbx = pymysql.connect(**settings['mysql'])
    zbxcur = dbzbx.cursor()
    zbxcur.execute("SELECT i.itemid, i.key_, h.host, h2.host AS proxy FROM items i JOIN hosts h ON i.hostid=h.hostid LEFT JOIN hosts h2 ON h2.hostid=h.proxy_hostid")
    # Translation of item key_
    # Note: http://opentsdb.net/docs/build/html/user_guide/writing.html#metrics-and-tags
    disallow = re.compile(settings['disallow'])
    cachecur = dbcache.cursor()

    print('tcollector.zabbix_bridge.deleterows %d %s' %