6 Replies Latest reply on Jun 2, 2017 12:34 PM by Andrew Pandolfino

    Queries against Zabbix Database

    Luke Brady

      My company uses Zabbix to monitor a lot of Servers.  We'd like to analyze that data in Tableau.  I found this Zabbix Schema: https://www.zabbix.org/mw/images/a/ad/Zabbix_db_schema-2.4.3-MySQL.pdf  .  Does anyone have some pre-written Zabbix queries to look at CPU utilization over time, Alarms, Network usage, etc.  I could start to write my own, but I'd rather not re-invent the wheel unless I have to.  If someone has a Workbook which connects to a Zabbix DB which does some of these things, would you consider sharing it?

       

      Update 06/02/2017:

      Here is the SQL I wrote to partially answer this question.  Please check as to whether or not an inner join should be changed to left join, my zabbix data may be different than yours.

       

      SELECT
      T1.flags AS "Groups.Flags",
      T1.groupid AS "Groups.Group ID",
      T1.internal AS "Groups.Internal",
      T1.name AS "Groups.Name",
      T2.groupid AS "Hosts Groups.Group ID",
      T2.hostgroupid AS "Hosts Groups.Host Group ID",
      T2.hostid AS "Hosts Groups.Host ID",
      T3.available AS "Hosts.Available",
      T3.disable_until AS "Hosts.Disable Until",
      T3.error AS "Hosts.Error",
      T3.errors_from AS "Hosts.Errors From",
      T3.flags AS "Hosts.Flags",
      T3.host AS "Hosts.Host",
      T3.hostid AS "Hosts.Host ID",
      T3.ipmi_authtype AS "Hosts.Ipmi Authtype",
      T3.ipmi_available AS "Hosts.Ipmi Available",
      T3.ipmi_disable_until AS "Hosts.Ipmi Disable Until",
      T3.ipmi_error AS "Hosts.Ipmi Error",
      T3.ipmi_errors_from AS "Hosts.Ipmi Errors From",
      T3.ipmi_password AS "Hosts.Ipmi Password",
      T3.ipmi_privilege AS "Hosts.Ipmi Privilege",
      T3.ipmi_username AS "Hosts.Ipmi_username",
      T3.jmx_available AS "Hosts.Jmx Available",
      T3.jmx_disable_until AS "Hosts.Jmx Disable Until",
      T3.jmx_error AS "Hosts.Jmx Error",
      T3.jmx_errors_from AS "Hosts.Jmx Errors From",
      T3.lastaccess AS "Hosts.Last Access",
      T3.maintenance_from AS "Hosts.Maintenance From",
      T3.maintenance_status AS "Hosts.Maintenance Status",
      T3.maintenance_type AS "Hosts.Maintenance Type",
      T3.maintenanceid AS "Hosts.Maintenance ID",
      T3.name AS "Hosts.Name",
      T3.proxy_hostid AS "Hosts.Proxy Host ID",
      T3.snmp_available AS "Hosts.Snmp Available",
      T3.snmp_disable_until AS "Hosts.Snmp Disable Until",
      T3.snmp_error AS "Hosts.Snmp Error",
      T3.snmp_errors_from AS "Hosts.Snmp Errors From",
      T3.status AS "Hosts.Status",
      T3.templateid AS "Hosts.Template ID",
      T4.authtype AS "Items.Authtype",
      T4.data_type AS "Items.Data Type",
      T4.delay AS "Items.Delay",
      T4.delay_flex AS "Items.Delay Flex",
      T4.delta AS "Items.Delta",
      T4.description AS "Items.Description",
      T4.error AS "Items.Error",
      T4.filter AS "Items.Filter",
      T4.flags AS "Items.Flags",
      T4.formula AS "Items.Formula",
      T4.history AS "Items.History",
      T4.hostid AS "Items.Host ID",
      T4.interfaceid AS "Items.Interface ID",
      T4.inventory_link AS "Items.Inventory Link",
      T4.ipmi_sensor AS "Items.Ipmi Sensor",
      T4.itemid AS "Items.Item ID",
      T4.key_ AS "Items.Key",
      T4.lastlogsize AS "Items.Last Log Size",
      T4.lifetime AS "Items.Lifetime",
      T4.logtimefmt AS "Items.Logtime Fmt",
      T4.mtime AS "Items.Mtime",
      T4.multiplier AS "Items.Multiplier",
      T4.name AS "Items.Name",
      T4.params AS "Items.Params",
      T4.password AS "Items.Password",
      T4.port AS "Items.Port",
      T4.privatekey AS "Items.Privatekey",
      T4.publickey AS "Items.Publickey",
      T4.snmp_community AS "Items.Snmp Community",
      T4.snmp_oid AS "Items.Snmp_o ID",
      T4.snmpv3_authpassphrase AS "Items.Snmpv3 Auth Passphrase",
      T4.snmpv3_authprotocol AS "Items.Snmpv3 Authprotocol",
      T4.snmpv3_contextname AS "Items.Snmpv3 Contextname",
      T4.snmpv3_privpassphrase AS "Items.Snmpv3 Privpassphrase",
      T4.snmpv3_privprotocol AS "Items.Snmpv3 Privprotocol",
      T4.snmpv3_securitylevel AS "Items.Snmpv3 Securitylevel",
      T4.snmpv3_securityname AS "Items.Snmpv3 Securityname",
      T4.state AS "Items.State",
      T4.status AS "Items.Status",
      T4.templateid AS "Items.Template ID",
      T4.trapper_hosts AS "Items.Trapper Hosts",
      T4.trends AS "Items.Trends",
      T4.type AS "Items.Type",
      T4.units AS "Items.Units",
      T4.username AS "Items.Username",
      T4.value_type AS "Items.Value Type",
      T4.valuemapid AS "Items.Valuemap ID",
      T5.function AS "Functions.Function",
      T5.functionid AS "Functions.Function ID",
      T5.itemid AS "Functions.Item ID",
      T5.parameter AS "Functions.Parameter",
      T5.triggerid AS "Functions.Trigger ID",
      T6.clock AS "History.Clock",
      T6.itemid AS "History.Item ID",
      T6.ns AS "History.Ns",
      T6.value AS "History.Value",
      T7.applicationid AS "Items_applications.Application ID",
      T7.itemappid AS "Items_applications.Itemapp ID",
      T7.itemid AS "Items_applications.Item ID",
      T8.applicationid AS "Applications.Application ID",
      T8.hostid AS "Applications.Host ID",
      T8.name AS "Applications.Name",
      T9.comments AS "Triggers.Comments",
      T9.description AS "Triggers.Description",
      T9.error AS "Triggers.Error",
      T9.expression AS "Triggers.Expression",
      T9.flags AS "Triggers.Flags",
      T9.lastchange AS "Triggers.Last Change",
      T9.priority AS "Triggers.Priority",
      T9.state AS "Triggers.State",
      T9.status AS "Triggers.Status",
      T9.templateid AS "Triggers.Templateid",
      T9.triggerid AS "Triggers.Triggerid",
      T9.type AS "Triggers.Type",
      T9.url AS "Triggers.Url",
      T9.value AS "Triggers.Value",
      T10.acknowledged AS "Events.Acknowledged",
      from_unixtime(T10.clock) AS "Events.Clock",
      T10.ns AS "Events.Ns",
      T10.object AS "Events.Object",
      T10.objectid AS "Events.Objectid",
      T10.source AS "Events.Source",
      T10.value AS "Events.Value",
      T11.name AS "Trigger Discovery.Name",
      T11.parent_triggerid AS "Trigger Discovery.Parent Trigger ID",
      T11.triggerdiscoveryid AS "Trigger Discovery.Trigger Discovery ID",
      T11.triggerid AS "Trigger Discovery.Trigger ID",
      T12.comments AS "Triggers (Protype).Comments",
      T12.description AS "Triggers (Protype).Description",
      T12.error AS "Triggers (Protype).Error",
      T12.expression AS "Triggers (Protype).Expression",
      T12.flags AS "Triggers (Protype).Flags",
      T12.lastchange AS "Triggers (Protype).Last Change",
      T12.priority AS "Triggers (Protype).Priority",
      T12.state AS "Triggers (Protype).State",
      T12.status AS "Triggers (Protype).Status",
      T12.templateid AS "Triggers (Protype).Templateid",
      T12.triggerid AS "Triggers (Protype).Triggerid",
      T12.type AS "Triggers (Protype).Type",
      T12.url AS "Triggers (Protype).Url",
      T12.value AS "Triggers (Protype).Value"
      FROM
      groups T1
      INNER JOIN hosts_groups T2 ON T2.groupid = T1.groupid
      INNER JOIN hosts T3 ON T3.hostid = T2.hostid
      INNER JOIN items T4 ON T4.hostid = T3.hostid
      INNER JOIN functions T5 ON T5.itemid = T4.itemid
      LEFT JOIN history T6 ON T6.itemid = T4.itemid
      INNER JOIN items_applications T7 ON T7.itemid = T4.itemid
      INNER JOIN applications T8 ON T8.applicationid = T7.applicationid
      INNER JOIN triggers T9 ON T9.triggerid = T5.triggerid
      INNER JOIN events T10 ON T10.objectid = T9.triggerid
      LEFT JOIN trigger_discovery T11 ON T11.triggerid = T9.triggerid
        LEFT JOIN triggers T12 ON T12.triggerid = T11.parent_triggerid