Skip to content

Instantly share code, notes, and snippets.

@okdas
Created August 18, 2015 12:45
Show Gist options
  • Save okdas/c6ec4fade0dc6ba71de1 to your computer and use it in GitHub Desktop.
Save okdas/c6ec4fade0dc6ba71de1 to your computer and use it in GitHub Desktop.
SELECT DISTINCT `triggers`.`triggerid` AS t0_r0, `triggers`.`expression` AS t0_r1, `triggers`.`description` AS t0_r2, `triggers`.`url` AS t0_r3, `triggers`.`status` AS t0_r4, `triggers`.`value` AS t0_r5, `triggers`.`priority` AS t0_r6, `triggers`.`lastchange` AS t0_r7, `triggers`.`comments` AS t0_r8, `triggers`.`error` AS t0_r9, `triggers`.`templateid` AS t0_r10, `triggers`.`type` AS t0_r11, `triggers`.`state` AS t0_r12, `triggers`.`flags` AS t0_r13, `hosts`.`hostid` AS t1_r0, `hosts`.`proxy_hostid` AS t1_r1, `hosts`.`host` AS t1_r2, `hosts`.`status` AS t1_r3, `hosts`.`disable_until` AS t1_r4, `hosts`.`error` AS t1_r5, `hosts`.`available` AS t1_r6, `hosts`.`errors_from` AS t1_r7, `hosts`.`lastaccess` AS t1_r8, `hosts`.`ipmi_authtype` AS t1_r9, `hosts`.`ipmi_privilege` AS t1_r10, `hosts`.`ipmi_username` AS t1_r11, `hosts`.`ipmi_password` AS t1_r12, `hosts`.`ipmi_disable_until` AS t1_r13, `hosts`.`ipmi_available` AS t1_r14, `hosts`.`snmp_disable_until` AS t1_r15, `hosts`.`snmp_available` AS t1_r16, `hosts`.`maintenanceid` AS t1_r17, `hosts`.`maintenance_status` AS t1_r18, `hosts`.`maintenance_type` AS t1_r19, `hosts`.`maintenance_from` AS t1_r20, `hosts`.`ipmi_errors_from` AS t1_r21, `hosts`.`snmp_errors_from` AS t1_r22, `hosts`.`ipmi_error` AS t1_r23, `hosts`.`snmp_error` AS t1_r24, `hosts`.`jmx_disable_until` AS t1_r25, `hosts`.`jmx_available` AS t1_r26, `hosts`.`jmx_errors_from` AS t1_r27, `hosts`.`jmx_error` AS t1_r28, `hosts`.`name` AS t1_r29, `hosts`.`flags` AS t1_r30, `hosts`.`templateid` AS t1_r31, `hosts`.`description` AS t1_r32, `interface`.`interfaceid` AS t2_r0, `interface`.`hostid` AS t2_r1, `interface`.`main` AS t2_r2, `interface`.`type` AS t2_r3, `interface`.`useip` AS t2_r4, `interface`.`ip` AS t2_r5, `interface`.`dns` AS t2_r6, `interface`.`port` AS t2_r7, `interface`.`bulk` AS t2_r8, `groups`.`groupid` AS t3_r0, `groups`.`name` AS t3_r1, `groups`.`internal` AS t3_r2, `groups`.`flags` AS t3_r3, `functions_triggers`.`functionid` AS t4_r0, `functions_triggers`.`itemid` AS t4_r1, `functions_triggers`.`triggerid` AS t4_r2, `functions_triggers`.`function` AS t4_r3, `functions_triggers`.`parameter` AS t4_r4, `items_functions`.`itemid` AS t5_r0, `items_functions`.`type` AS t5_r1, `items_functions`.`snmp_community` AS t5_r2, `items_functions`.`snmp_oid` AS t5_r3, `items_functions`.`hostid` AS t5_r4, `items_functions`.`name` AS t5_r5, `items_functions`.`key_` AS t5_r6, `items_functions`.`delay` AS t5_r7, `items_functions`.`history` AS t5_r8, `items_functions`.`trends` AS t5_r9, `items_functions`.`status` AS t5_r10, `items_functions`.`value_type` AS t5_r11, `items_functions`.`trapper_hosts` AS t5_r12, `items_functions`.`units` AS t5_r13, `items_functions`.`multiplier` AS t5_r14, `items_functions`.`delta` AS t5_r15, `items_functions`.`snmpv3_securityname` AS t5_r16, `items_functions`.`snmpv3_securitylevel` AS t5_r17, `items_functions`.`snmpv3_authpassphrase` AS t5_r18, `items_functions`.`snmpv3_privpassphrase` AS t5_r19, `items_functions`.`formula` AS t5_r20, `items_functions`.`error` AS t5_r21, `items_functions`.`lastlogsize` AS t5_r22, `items_functions`.`logtimefmt` AS t5_r23, `items_functions`.`templateid` AS t5_r24, `items_functions`.`valuemapid` AS t5_r25, `items_functions`.`delay_flex` AS t5_r26, `items_functions`.`params` AS t5_r27, `items_functions`.`ipmi_sensor` AS t5_r28, `items_functions`.`data_type` AS t5_r29, `items_functions`.`authtype` AS t5_r30, `items_functions`.`username` AS t5_r31, `items_functions`.`password` AS t5_r32, `items_functions`.`publickey` AS t5_r33, `items_functions`.`privatekey` AS t5_r34, `items_functions`.`mtime` AS t5_r35, `items_functions`.`flags` AS t5_r36, `items_functions`.`filter` AS t5_r37, `items_functions`.`interfaceid` AS t5_r38, `items_functions`.`port` AS t5_r39, `items_functions`.`description` AS t5_r40, `items_functions`.`inventory_link` AS t5_r41, `items_functions`.`lifetime` AS t5_r42, `items_functions`.`snmpv3_authprotocol` AS t5_r43, `items_functions`.`snmpv3_privprotocol` AS t5_r44, `items_functions`.`state` AS t5_r45, `items_functions`.`snmpv3_contextname` AS t5_r46, `items_functions`.`evaltype` AS t5_r47 FROM `triggers` INNER JOIN `functions` ON `functions`.`triggerid` = `triggers`.`triggerid` INNER JOIN `items` ON `items`.`itemid` = `functions`.`itemid` LEFT OUTER JOIN `functions` `functions_triggers_join` ON `functions_triggers_join`.`triggerid` = `triggers`.`triggerid` LEFT OUTER JOIN `items` `items_triggers_join` ON `items_triggers_join`.`itemid` = `functions_triggers_join`.`itemid` LEFT OUTER JOIN `hosts` ON `hosts`.`hostid` = `items_triggers_join`.`hostid` LEFT OUTER JOIN `interface` ON `interface`.`hostid` = `hosts`.`hostid` LEFT OUTER JOIN `hosts_groups` ON `hosts_groups`.`hostid` = `hosts`.`hostid` LEFT OUTER JOIN `groups` ON `groups`.`groupid` = `hosts_groups`.`groupid` AND `hosts`.`status` = 0 LEFT OUTER JOIN `functions` `functions_triggers` ON `functions_triggers`.`triggerid` = `triggers`.`triggerid` LEFT OUTER JOIN `items` `items_functions` ON `items_functions`.`itemid` = `functions_triggers`.`itemid` WHERE `hosts`.`status` = 0 AND `items`.`status` = 0 AND `triggers`.`value` = 1 AND `triggers`.`status` = 0 AND (`triggers`.`triggerid` NOT IN (SELECT `trigger_depends`.`triggerid_down` FROM `trigger_depends` WHERE `trigger_depends`.`triggerid_up` IN (SELECT `triggers`.`triggerid` FROM `triggers` INNER JOIN `functions` ON `functions`.`triggerid` = `triggers`.`triggerid` INNER JOIN `items` ON `items`.`itemid` = `functions`.`itemid` WHERE `hosts`.`status` = 0 AND `items`.`status` = 0 AND `triggers`.`value` = 1 AND `triggers`.`status` = 0 ORDER BY `triggers`.`lastchange` DESC))) ORDER BY `triggers`.`lastchange` DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment