采集zabbix 数据SQL

SELECT 
  HOST,
  hosts.name AS host_name,
  items.name AS item_name,
  items.itemid,
  hstgrp.name AS group_name,
  h1.value AS VALUE 
FROM
  `hosts` 
  JOIN hosts_groups 
    ON hosts_groups.hostid = hosts.hostid 
  JOIN hstgrp 
    ON hosts_groups.groupid = hstgrp.groupid 
  JOIN items 
    ON items.hostid = hosts.hostid 
  JOIN history AS h1 
    ON h1.itemid = items.itemid 
WHERE hosts.host = "10.203.4.23" 
  AND h1.clock > UNIX_TIMESTAMP(NOW()) - 3 * 60 
UNION
SELECT 
  HOST,
  hosts.name AS host_name,
  items.name AS item_name,
  items.itemid,
  hstgrp.name AS group_name,
  h2.value 
FROM
  `hosts`
  JOIN hosts_groups 
    ON hosts_groups.hostid = hosts.hostid 
  JOIN hstgrp 
    ON hosts_groups.groupid = hstgrp.groupid 
  JOIN items 
    ON items.hostid = hosts.hostid 
  JOIN history_uint AS h2 
    ON h2.itemid = items.itemid 
WHERE hosts.host = "10.203.4.23" 
  AND h2.clock > UNIX_TIMESTAMP(NOW()) - 3 * 60 
ORDER BY item_name