zabbix 后台数据库清除数据

alerts 表 problem 表 escalations 表 events 表  对 这些表进行清除 防止不停发送邮件

  1 -- alerts table rebuild.
  2 -- ----------------------------
  3 -- Table structure for alerts
  4 -- ----------------------------
  5 SET FOREIGN_KEY_CHECKS=0;
  6 DROP TABLE IF EXISTS `alerts`;
  7 CREATE TABLE `alerts` (
  8   `alertid` bigint(20) unsigned NOT NULL,
  9   `actionid` bigint(20) unsigned NOT NULL,
 10   `eventid` bigint(20) unsigned NOT NULL,
 11   `userid` bigint(20) unsigned DEFAULT NULL,
 12   `clock` int(11) NOT NULL DEFAULT '0',
 13   `mediatypeid` bigint(20) unsigned DEFAULT NULL,
 14   `sendto` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT '',
 15   `subject` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
 16   `message` text COLLATE utf8_bin NOT NULL,
 17   `status` int(11) NOT NULL DEFAULT '0',
 18   `retries` int(11) NOT NULL DEFAULT '0',
 19   `error` varchar(2048) COLLATE utf8_bin NOT NULL DEFAULT '',
 20   `esc_step` int(11) NOT NULL DEFAULT '0',
 21   `alerttype` int(11) NOT NULL DEFAULT '0',
 22   `p_eventid` bigint(20) unsigned DEFAULT NULL,
 23   `acknowledgeid` bigint(20) unsigned DEFAULT NULL,
 24   PRIMARY KEY (`alertid`),
 25   KEY `alerts_1` (`actionid`),
 26   KEY `alerts_2` (`clock`),
 27   KEY `alerts_3` (`eventid`),
 28   KEY `alerts_4` (`status`),
 29   KEY `alerts_5` (`mediatypeid`),
 30   KEY `alerts_6` (`userid`),
 31   KEY `alerts_7` (`p_eventid`),
 32   KEY `c_alerts_6` (`acknowledgeid`),
 33   CONSTRAINT `c_alerts_1` FOREIGN KEY (`actionid`) REFERENCES `actions` (`actionid`) ON DELETE CASCADE,
 34   CONSTRAINT `c_alerts_2` FOREIGN KEY (`eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE,
 35   CONSTRAINT `c_alerts_3` FOREIGN KEY (`userid`) REFERENCES `users` (`userid`) ON DELETE CASCADE,
 36   CONSTRAINT `c_alerts_4` FOREIGN KEY (`mediatypeid`) REFERENCES `media_type` (`mediatypeid`) ON DELETE CASCADE,
 37   CONSTRAINT `c_alerts_5` FOREIGN KEY (`p_eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE,
 38   CONSTRAINT `c_alerts_6` FOREIGN KEY (`acknowledgeid`) REFERENCES `acknowledges` (`acknowledgeid`) ON DELETE CASCADE
 39 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 40 SET FOREIGN_KEY_CHECKS=1;
 41 
 42 --------------------------------------------------------------------------------------------------------
 43 -- problem table rebuild.
 44 -- ----------------------------
 45 -- Table structure for problem
 46 -- ----------------------------
 47 SET FOREIGN_KEY_CHECKS=0;
 48 DROP TABLE IF EXISTS `problem`;
 49 CREATE TABLE `problem` (
 50   `eventid` bigint(20) unsigned NOT NULL,
 51   `source` int(11) NOT NULL DEFAULT '0',
 52   `object` int(11) NOT NULL DEFAULT '0',
 53   `objectid` bigint(20) unsigned NOT NULL DEFAULT '0',
 54   `clock` int(11) NOT NULL DEFAULT '0',
 55   `ns` int(11) NOT NULL DEFAULT '0',
 56   `r_eventid` bigint(20) unsigned DEFAULT NULL,
 57   `r_clock` int(11) NOT NULL DEFAULT '0',
 58   `r_ns` int(11) NOT NULL DEFAULT '0',
 59   `correlationid` bigint(20) unsigned DEFAULT NULL,
 60   `userid` bigint(20) unsigned DEFAULT NULL,
 61   PRIMARY KEY (`eventid`),
 62   KEY `problem_1` (`source`,`object`,`objectid`),
 63   KEY `problem_2` (`r_clock`),
 64   KEY `problem_3` (`r_eventid`),
 65   CONSTRAINT `c_problem_1` FOREIGN KEY (`eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE,
 66   CONSTRAINT `c_problem_2` FOREIGN KEY (`r_eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE
 67 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 68 SET FOREIGN_KEY_CHECKS=1;
 69 
 70 ------------------------------------------------------------------------------------------------------
 71 -- escalations table rebuild
 72 -- ------------------------------------
 73 -- Table structure for escalations
 74 ---------------------------------------
 75 SET FOREIGN_KEY_CHECKS=0;
 76 CREATE TABLE `escalations` (
 77   `escalationid` bigint(20) unsigned NOT NULL,
 78   `actionid` bigint(20) unsigned NOT NULL,
 79   `triggerid` bigint(20) unsigned DEFAULT NULL,
 80   `eventid` bigint(20) unsigned DEFAULT NULL,
 81   `r_eventid` bigint(20) unsigned DEFAULT NULL,
 82   `nextcheck` int(11) NOT NULL DEFAULT '0',
 83   `esc_step` int(11) NOT NULL DEFAULT '0',
 84   `status` int(11) NOT NULL DEFAULT '0',
 85   `itemid` bigint(20) unsigned DEFAULT NULL,
 86   `acknowledgeid` bigint(20) unsigned DEFAULT NULL,
 87   PRIMARY KEY (`escalationid`),
 88   UNIQUE KEY `escalations_1` (`actionid`,`triggerid`,`itemid`,`escalationid`)
 89 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 90 SET FOREIGN_KEY_CHECKS=1;
 91 
 92 ---------------------------------------------------------------------------------------------------
 93 ---------------------------------------------------------------------------------------------------
 94 -- events table rebuild
 95 -- ------------------------------------
 96 -- Table structure for events
 97 ---------------------------------------
 98 SET FOREIGN_KEY_CHECKS=0;
 99 CREATE TABLE `events` (
100   `eventid` bigint(20) unsigned NOT NULL,
101   `source` int(11) NOT NULL DEFAULT '0',
102   `object` int(11) NOT NULL DEFAULT '0',
103   `objectid` bigint(20) unsigned NOT NULL DEFAULT '0',
104   `clock` int(11) NOT NULL DEFAULT '0',
105   `value` int(11) NOT NULL DEFAULT '0',
106   `acknowledged` int(11) NOT NULL DEFAULT '0',
107   `ns` int(11) NOT NULL DEFAULT '0',
108   PRIMARY KEY (`eventid`),
109   KEY `events_1` (`source`,`object`,`objectid`,`clock`),
110   KEY `events_2` (`source`,`object`,`clock`)
111 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
112 SET FOREIGN_KEY_CHECKS=1;

猜你喜欢

转载自www.cnblogs.com/shuitian-ys/p/10024946.html