forked from burner1024/zabbix-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add old data scripts for mysql; uppercase SQL words in other files
- Loading branch information
Ilya Ivanov
committed
Apr 28, 2014
1 parent
704524a
commit 1413819
Showing
6 changed files
with
54 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- intervals in days | ||
SET @history_interval = 7; | ||
SET @trends_interval = 90; | ||
|
||
SELECT count(alertid) AS alerts FROM alerts WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(acknowledgeid) AS acknowledges FROM acknowledges WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(eventid) AS events FROM events WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
|
||
SELECT count(itemid) AS history FROM history WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(itemid) AS history_uint FROM history_uint WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(itemid) AS history_str FROM history_str WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(itemid) AS history_text FROM history_text WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(itemid) AS history_log FROM history_log WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
|
||
SELECT count(itemid) AS trends FROM trends WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@trends_interval * 24 * 60 * 60); | ||
SELECT count(itemid) AS trends_uint FROM trends_uint WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@trends_interval * 24 * 60 * 60); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
-- keep 1 week of history and 3 months of trends | ||
-- intevals in days | ||
\set history_interval 7 | ||
\set trends_interval 90 | ||
|
||
SELECT count(alertid) AS alerts FROM alerts where age(to_timestamp(alerts.clock)) > (:history_interval * interval '1 day'); | ||
SELECT count(alertid) AS alerts FROM alerts WHERE age(to_timestamp(alerts.clock)) > (:history_interval * interval '1 day'); | ||
|
||
SELECT count(acknowledgeid) AS acknowledges FROM acknowledges where age(to_timestamp(acknowledges.clock)) > (:history_interval * interval '1 day'); | ||
SELECT count(acknowledgeid) AS acknowledges FROM acknowledges WHERE age(to_timestamp(acknowledges.clock)) > (:history_interval * interval '1 day'); | ||
|
||
SELECT count(eventid) AS events FROM events where age(to_timestamp(events.clock)) > (:history_interval * interval '1 day'); | ||
SELECT count(eventid) AS events FROM events WHERE age(to_timestamp(events.clock)) > (:history_interval * interval '1 day'); | ||
|
||
SELECT count(itemid) AS history FROM history where age(to_timestamp(history.clock)) > (:history_interval * interval '1 day'); | ||
SELECT count(itemid) AS history_uint FROM history_uint where age(to_timestamp(history_uint.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history_str FROM history_str where age(to_timestamp(history_str.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history_text FROM history_text where age(to_timestamp(history_text.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history_log FROM history_log where age(to_timestamp(history_log.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history FROM history WHERE age(to_timestamp(history.clock)) > (:history_interval * interval '1 day'); | ||
SELECT count(itemid) AS history_uint FROM history_uint WHERE age(to_timestamp(history_uint.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history_str FROM history_str WHERE age(to_timestamp(history_str.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history_text FROM history_text WHERE age(to_timestamp(history_text.clock)) > (:history_interval * interval '1 day') ; | ||
SELECT count(itemid) AS history_log FROM history_log WHERE age(to_timestamp(history_log.clock)) > (:history_interval * interval '1 day') ; | ||
|
||
SELECT count(itemid) AS trends FROM trends where age(to_timestamp(trends.clock)) > (:trends_interval * interval '1 day'); | ||
SELECT count(itemid) AS trends_uint FROM trends_uint where age(to_timestamp(trends_uint.clock)) > (:trends_interval * interval '1 day') ; | ||
SELECT count(itemid) AS trends FROM trends WHERE age(to_timestamp(trends.clock)) > (:trends_interval * interval '1 day'); | ||
SELECT count(itemid) AS trends_uint FROM trends_uint WHERE age(to_timestamp(trends_uint.clock)) > (:trends_interval * interval '1 day') ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- intervals in days | ||
SET @history_interval = 7; | ||
SET @trends_interval = 90; | ||
|
||
DELETE FROM alerts WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
SELECT count(acknowledgeid) AS acknowledges FROM acknowledges WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
DELETE FROM events WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
|
||
DELETE FROM history WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
DELETE FROM history_uint WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
DELETE FROM history_str WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
DELETE FROM history_text WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
DELETE FROM history_log WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@history_interval * 24 * 60 * 60); | ||
|
||
DELETE FROM trends WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@trends_interval * 24 * 60 * 60); | ||
DELETE FROM trends_uint WHERE (UNIX_TIMESTAMP(NOW()) - clock) > (@trends_interval * 24 * 60 * 60); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
delete from history where itemid not in (select itemid from items where status='0'); | ||
delete from history_uint where itemid not in (select itemid from items where status='0'); | ||
delete from history_str where itemid not in (select itemid from items where status='0'); | ||
delete from history_text where itemid not in (select itemid from items where status='0'); | ||
delete from history_log where itemid not in (select itemid from items where status='0'); | ||
DELETE FROM history WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); | ||
DELETE FROM history_uint WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); | ||
DELETE FROM history_str WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); | ||
DELETE FROM history_text WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); | ||
DELETE FROM history_log WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); | ||
|
||
delete from trends where itemid not in (select itemid from items where status='0'); | ||
delete from trends_uint where itemid not in (select itemid from items where status='0'); | ||
DELETE FROM trends WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); | ||
DELETE FROM trends_uint WHERE itemid NOT IN (SELECT itemid FROM items WHERE status='0'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
truncate alerts; | ||
truncate escalations; | ||
|
||
TRUNCATE alerts; | ||
TRUNCATE escalations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
update alerts set status=2,error='' where status=0 and alerttype=0; | ||
truncate escalations; | ||
UPDATE alerts SET status=2,error='' WHERE status=0 AND alerttype=0; | ||
TRUNCATE escalations; |