Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cf/mysql update #28

Open
wants to merge 3 commits into
base: cf/mysql
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ then
fi
if test "x$with_libmysql" = "xyes"
then
with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
mysql_config_status=$?

if test $mysql_config_status -ne 0
Expand Down
274 changes: 222 additions & 52 deletions contrib/write_mysql.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
-- MySQL dump 10.11
--
-- Host: localhost Database: collectd
-- ------------------------------------------------------
-- Server version 5.0.77

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
Expand All @@ -28,109 +22,285 @@ USE `collectd`;
--

DROP TABLE IF EXISTS `data`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `data` (
`id` bigint(20) NOT NULL auto_increment,
`timestamp` double NOT NULL,
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`date` datetime NOT NULL,
`host_id` int(11) NOT NULL,
`plugin_id` int(11) NOT NULL,
`plugin_instance` varchar(255) default NULL,
`plugin_instance` varchar(255) DEFAULT NULL,
`type_id` int(11) NOT NULL,
`typeinstance` varchar(255) default NULL,
`type_instance` varchar(255) DEFAULT NULL,
`dataset_id` int(11) NOT NULL,
`value` double NOT NULL,
PRIMARY KEY (`id`),
KEY `timestamp` (`timestamp`),
PRIMARY KEY (`id`),
UNIQUE KEY `host_id_3` (`host_id`,`plugin_id`,`plugin_instance`,`type_id`,`type_instance`,`dataset_id`),
KEY `host_id` (`host_id`),
KEY `plugin_id` (`plugin_id`),
KEY `type_id` (`type_id`),
KEY `typeinstance_id` (`typeinstance`),
KEY `dataset_id` (`dataset_id`),
CONSTRAINT `data_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `host` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `data_ibfk_2` FOREIGN KEY (`plugin_id`) REFERENCES `plugin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `data_ibfk_3` FOREIGN KEY (`type_id`) REFERENCES `type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `data_ibfk_4` FOREIGN KEY (`dataset_id`) REFERENCES `dataset` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8;
KEY `dataset_id` (`dataset_id`)
) ENGINE=MEMORY AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `data_view`
--

DROP TABLE IF EXISTS `data_view`;
/*!50001 DROP VIEW IF EXISTS `data_view`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `data_view` (
`date` datetime,
`host` varchar(255),
`plugin` varchar(255),
`plugin_instance` varchar(255),
`type` varchar(255),
`type_instance` varchar(255),
`dataset_name` varchar(255),
`value` double
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `dataset`
--

DROP TABLE IF EXISTS `dataset`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `dataset` (
`id` int(11) NOT NULL auto_increment,
`id` int(11) NOT NULL AUTO_INCREMENT,
`type_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`type` enum('COUNTER','GAUGE','DERIVE','ABSOLUTE') NOT NULL,
`min` double NOT NULL,
`max` double NOT NULL,
PRIMARY KEY (`id`),
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`,`type_id`),
KEY `name` (`name`),
KEY `type_id` (`type_id`),
CONSTRAINT `dataset_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `type` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `grouped_type`
--

DROP TABLE IF EXISTS `grouped_type`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `grouped_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `host`
--

DROP TABLE IF EXISTS `host`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `host` (
`id` int(11) NOT NULL auto_increment,
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
`nbcpu` int(11) NOT NULL DEFAULT '0',
`load` int(11) NOT NULL DEFAULT '0',
UNIQUE KEY `id` (`id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `notification`
--

DROP TABLE IF EXISTS `notification`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `notification` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`date` datetime NOT NULL,
`host_id` int(11) NOT NULL,
`plugin_id` int(11) NOT NULL,
`plugin_instance` varchar(255) DEFAULT NULL,
`type_id` int(11) NOT NULL,
`type_instance` varchar(255) DEFAULT NULL,
`severity` enum('FAILURE','WARNING','OKAY','UNKNOW') NOT NULL,
`message` mediumtext,
PRIMARY KEY (`id`,`date`),
KEY `type_instance` (`type_instance`),
KEY `plugin_instance` (`plugin_instance`),
KEY `severity` (`severity`),
KEY `host_id_2` (`host_id`,`plugin_id`,`type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8
/*!50100 PARTITION BY HASH (MONTH(`date`))
PARTITIONS 12 */;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `notification_view`
--

DROP TABLE IF EXISTS `notification_view`;
/*!50001 DROP VIEW IF EXISTS `notification_view`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `notification_view` (
`date` datetime,
`hostname` varchar(255),
`plugin` varchar(255),
`plugin_instance` varchar(255),
`type` varchar(255),
`type_instance` varchar(255),
`severity` enum('FAILURE','WARNING','OKAY','UNKNOW'),
`message` mediumtext
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;

--
-- Table structure for table `plugin`
--

DROP TABLE IF EXISTS `plugin`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `plugin` (
`id` int(11) NOT NULL auto_increment,
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `id` (`id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `plugin_view`
--

DROP TABLE IF EXISTS `plugin_view`;
/*!50001 DROP VIEW IF EXISTS `plugin_view`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `plugin_view` (
`host` varchar(255),
`plugin` varchar(255),
`plugin_instance` varchar(255),
`type` varchar(255),
`type_instance` varchar(255)
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;


--
-- Table structure for table `type`
--

DROP TABLE IF EXISTS `type`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `type` (
`id` int(11) NOT NULL auto_increment,
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `id` (`id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Temporary table structure for view `types_db`
--

DROP TABLE IF EXISTS `types_db`;
/*!50001 DROP VIEW IF EXISTS `types_db`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE TABLE `types_db` (
`type` varchar(255),
`ds` varchar(255)
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--
-- Final view structure for view `data_view`
--

/*!50001 DROP TABLE IF EXISTS `data_view`*/;
/*!50001 DROP VIEW IF EXISTS `data_view`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `data_view` AS select `data`.`date` AS `date`,`host`.`name` AS `host`,`plugin`.`name` AS `plugin`,`data`.`plugin_instance` AS `plugin_instance`,`type`.`name` AS `type`,`data`.`type_instance` AS `type_instance`,`dataset`.`name` AS `dataset_name`,`data`.`value` AS `value` from ((((`data` join `host`) join `plugin`) join `type`) join `dataset`) where ((`host`.`id` = `data`.`host_id`) and (`plugin`.`id` = `data`.`plugin_id`) and (`type`.`id` = `data`.`type_id`) and (`data`.`dataset_id` = `dataset`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;

--
-- Final view structure for view `notification_view`
--

/*!50001 DROP TABLE IF EXISTS `notification_view`*/;
/*!50001 DROP VIEW IF EXISTS `notification_view`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `notification_view` AS select `n`.`date` AS `date`,`h`.`name` AS `hostname`,`p`.`name` AS `plugin`,`n`.`plugin_instance` AS `plugin_instance`,`t`.`name` AS `type`,`n`.`type_instance` AS `type_instance`,`n`.`severity` AS `severity`,`n`.`message` AS `message` from (((`notification` `n` join `host` `h`) join `plugin` `p`) join `type` `t`) where ((`n`.`host_id` = `h`.`id`) and (`n`.`plugin_id` = `p`.`id`) and (`n`.`type_id` = `t`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;

--
-- Final view structure for view `plugin_view`
--

/*!50001 DROP TABLE IF EXISTS `plugin_view`*/;
/*!50001 DROP VIEW IF EXISTS `plugin_view`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `plugin_view` AS select `host`.`name` AS `host`,`plugin`.`name` AS `plugin`,`data`.`plugin_instance` AS `plugin_instance`,`type`.`name` AS `type`,`data`.`type_instance` AS `type_instance` from (((`data` join `host`) join `plugin`) join `type`) where ((`host`.`id` = `data`.`host_id`) and (`plugin`.`id` = `data`.`plugin_id`) and (`type`.`id` = `data`.`type_id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;


--
-- Final view structure for view `types_db`
--

-- Dump completed on 2011-11-07 12:57:15
/*!50001 DROP TABLE IF EXISTS `types_db`*/;
/*!50001 DROP VIEW IF EXISTS `types_db`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `types_db` AS select `type`.`name` AS `type`,`dataset`.`name` AS `ds` from (`type` join `dataset`) where (`dataset`.`type_id` = `type`.`id`) order by `type`.`name`,`dataset`.`id` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;

17 changes: 12 additions & 5 deletions src/collectd.conf.pod
Original file line number Diff line number Diff line change
Expand Up @@ -4888,13 +4888,20 @@ F<contrib/write_mysql.sql>.
Synopsis of the configuration is:

<Plugin write_mysql>
Host "localhost"
User "root"
Passwd ""
Database "collectd"
Port "3306"
<Database master4example>
Host "localhost"
User "root"
Passwd ""
Database "collectd"
Port "3306"
Replace true
</Database>
</Plugin>

A B<Database> block defines one connection to a MySQL database. It accepts a
single argument which specifies the name of the database. Repeat this option
to specify multiple database.

=over 4

=item B<Host> I<Hostname>
Expand Down
Loading