File tree Expand file tree Collapse file tree 2 files changed +10
-40
lines changed Expand file tree Collapse file tree 2 files changed +10
-40
lines changed Original file line number Diff line number Diff line change @@ -153,26 +153,11 @@ mysql_w "SELECT COUNT(*) FROM trigger_depends WHERE triggerid_up NOT IN (SELECT
153
153
154
154
155
155
echo " Count the amount of records in the history/trends table for items that no longer exist"
156
- echo -n " Table: history orphaned items: "
157
- mysql_w " SELECT COUNT(itemid) FROM history WHERE itemid NOT IN (SELECT itemid FROM items);"
158
-
159
- echo -n " Table: history_uint orphaned items: "
160
- mysql_w " SELECT COUNT(itemid) FROM history_uint WHERE itemid NOT IN (SELECT itemid FROM items);"
161
-
162
- echo -n " Table: history_log orphaned items: "
163
- mysql_w " SELECT COUNT(itemid) FROM history_log WHERE itemid NOT IN (SELECT itemid FROM items);"
164
-
165
- echo -n " Table: history_str orphaned items: "
166
- mysql_w " SELECT COUNT(itemid) FROM history_str WHERE itemid NOT IN (SELECT itemid FROM items);"
167
-
168
- echo -n " Table: history_text orphaned items: "
169
- mysql_w " SELECT COUNT(itemid) FROM history_text WHERE itemid NOT IN (SELECT itemid FROM items);"
170
-
171
- echo -n " Table: trends orphaned items: "
172
- mysql_w " SELECT COUNT(itemid) FROM trends WHERE itemid NOT IN (SELECT itemid FROM items);"
173
-
174
- echo -n " Table: trends_uint orphaned items: "
175
- mysql_w " SELECT COUNT(itemid) FROM trends_uint WHERE itemid NOT IN (SELECT itemid FROM items);"
156
+ TABLES=(history history_uint history_log history_str history_text trends trends_uint)
157
+ for table in " ${TABLES[@]} " ; do
158
+ echo -n " Table: $table orphaned items: "
159
+ mysql_w " SELECT COUNT(itemid) FROM $table WHERE itemid NOT IN (SELECT itemid FROM items);"
160
+ done
176
161
177
162
178
163
echo " Count the amount of records in the events table for triggers/items that no longer exist"
Original file line number Diff line number Diff line change @@ -153,26 +153,11 @@ mysql_w "DELETE FROM trigger_depends WHERE triggerid_up NOT IN (SELECT triggerid
153
153
154
154
155
155
echo " Delete records in the history/trends table where items that no longer exist"
156
- echo -n " Table: history orphaned items: "
157
- mysql_w " DELETE FROM history WHERE itemid NOT IN (SELECT itemid FROM items);"
158
-
159
- echo -n " Table: history_uint orphaned items: "
160
- mysql_w " DELETE FROM history_uint WHERE itemid NOT IN (SELECT itemid FROM items);"
161
-
162
- echo -n " Table: history_log orphaned items: "
163
- mysql_w " DELETE FROM history_log WHERE itemid NOT IN (SELECT itemid FROM items);"
164
-
165
- echo -n " Table: history_str orphaned items: "
166
- mysql_w " DELETE FROM history_str WHERE itemid NOT IN (SELECT itemid FROM items);"
167
-
168
- echo -n " Table: history_text orphaned items: "
169
- mysql_w " DELETE FROM history_text WHERE itemid NOT IN (SELECT itemid FROM items);"
170
-
171
- echo -n " Table: trends orphaned items: "
172
- mysql_w " DELETE FROM trends WHERE itemid NOT IN (SELECT itemid FROM items);"
173
-
174
- echo -n " Table: trends_uint orphaned items: "
175
- mysql_w " DELETE FROM trends_uint WHERE itemid NOT IN (SELECT itemid FROM items);"
156
+ TABLES=(history history_uint history_log history_str history_text trends trends_uint)
157
+ for table in " ${TABLES[@]} " ; do
158
+ echo -n " Table: $table orphaned items: "
159
+ mysql_w " DELETE FROM $table WHERE itemid NOT IN (SELECT itemid FROM items);"
160
+ done
176
161
177
162
178
163
echo " Delete records in the events table where triggers/items no longer exist"
You can’t perform that action at this time.
0 commit comments