From e8d7dea99fa07db8b8b61c25a6abd8d28f5f32c9 Mon Sep 17 00:00:00 2001 From: sem Date: Mon, 7 Aug 2006 10:31:08 +0000 Subject: - Add plugin support Submitted by: Gustavo Fukao --- net-mgmt/cacti/Makefile | 21 +- net-mgmt/cacti/files/extrapatch-plugins | 601 ++++++++++++++++++++++++++++++++ net-mgmt/cacti/files/pkg-message.in | 11 + net-mgmt/cacti/pkg-plist | 15 +- 4 files changed, 641 insertions(+), 7 deletions(-) create mode 100644 net-mgmt/cacti/files/extrapatch-plugins (limited to 'net-mgmt/cacti') diff --git a/net-mgmt/cacti/Makefile b/net-mgmt/cacti/Makefile index a3c1aaf84416..3bedc1471edb 100644 --- a/net-mgmt/cacti/Makefile +++ b/net-mgmt/cacti/Makefile @@ -7,7 +7,7 @@ PORTNAME= cacti PORTVERSION= 0.8.6h.${PATCHLEVEL} -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= net www MASTER_SITES= http://www.cacti.net/downloads/ DISTNAME= ${PORTNAME}-${SITEDISTVERSION} @@ -44,9 +44,22 @@ PLIST_SUB+= CACTIDIR=${CACTIDIR} SUB_LIST+= CACTIDIR=${CACTIDIR} CACTIUSER=${CACTIUSER} \ CACTIGROUP=${CACTIGROUP} +OPTIONS= PLUGIN "Enable plugin support" off + +.include + +.if defined(WITH_PLUGIN) +EXTRA_PATCHES= ${FILESDIR}/extrapatch-plugins + +PLIST_SUB+= PLUGIN="" +.else +PLIST_SUB+= PLUGIN="@comment " +.endif + post-patch: @${FIND} ${WRKSRC} -name \*.orig -delete; \ ${MV} ${WRKSRC}/include/db-settings.php ${WRKSRC}/include/db-settings.php.orig + ${MV} ${WRKSRC}/include/config.php ${WRKSRC}/include/config.php.orig pre-install: @${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL; \ @@ -58,9 +71,13 @@ do-install: ${CP} ${PREFIX}/${CACTIDIR}/include/db-settings.php.orig \ ${PREFIX}/${CACTIDIR}/include/db-settings.php; \ fi + @if [ ! -f ${PREFIX}/${CACTIDIR}/include/config.php ]; then \ + ${CP} ${PREFIX}/${CACTIDIR}/include/config.php.orig \ + ${PREFIX}/${CACTIDIR}/include/config.php; \ + fi post-install: @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL @${CAT} ${PKGMESSAGE} -.include +.include diff --git a/net-mgmt/cacti/files/extrapatch-plugins b/net-mgmt/cacti/files/extrapatch-plugins new file mode 100644 index 000000000000..0c8ae8ba710f --- /dev/null +++ b/net-mgmt/cacti/files/extrapatch-plugins @@ -0,0 +1,601 @@ +--- data_sources.php.orig Wed Jan 4 01:08:30 2006 ++++ data_sources.php Fri Aug 4 00:26:18 2006 +@@ -1043,18 +1043,25 @@ + if (sizeof($data_sources) > 0) { + foreach ($data_sources as $data_source) { + form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ++ ++ $ds_table['data_source'] = $data_source; ++ $ds_table['data_input_name'] = $data_source['data_input_name']; ++ $ds_table['active'] = (($data_source["active"] == "on") ? "Yes" : "No"); ++ $ds_table['template_name'] = ((empty($data_source["data_template_name"])) ? "None" : $data_source["data_template_name"]); ++ $ds_table = do_hook_function("data_sources_table", $ds_table); ++ + ?> + + \\1", title_trim($data_source["name_cache"], read_config_option("max_title_data_source"))); }else{ print title_trim($data_source["name_cache"], read_config_option("max_title_data_source")); } ?> + + +- ++ + + +- No");?> ++ + + +- None" : $data_source["data_template_name"]);?> ++ + + + "> +--- graphs_new.php.orig Wed Jan 4 01:08:30 2006 ++++ graphs_new.php Fri Aug 4 00:26:18 2006 +@@ -399,7 +399,8 @@ + + + *">Edit this Host
+- *Create New Host ++ *Create New Host
++ + + + +--- include/config.php.orig Wed Jan 4 01:08:30 2006 ++++ include/config.php Fri Aug 4 03:35:23 2006 +@@ -32,6 +32,31 @@ + $database_password = "cactiuser"; + $database_port = "3306"; + ++$plugins = array(); ++//$plugins[] = 'devices'; ++//$plugins[] = 'discovery'; ++//$plugins[] = 'flowview'; ++//$plugins[] = 'haloe'; ++//$plugins[] = 'hostinfo'; ++//$plugins[] = 'links'; ++//$plugins[] = 'monitor'; ++//$plugins[] = 'ntop'; ++//$plugins[] = 'reports'; ++//$plugins[] = 'thold'; ++//$plugins[] = 'tools'; ++//$plugins[] = 'update'; ++//$plugins[] = 'weathermap'; ++ ++/* Do not edit this line */ ++$config = array(); ++ ++/* This is full URL Path to the Cacti installation ++ For example, if your cacti was accessible by http://server/cacti/ you would user '/cacti/' ++ as the url path. For just http://server/ use '/' ++*/ ++ ++$config["url_path"] = '/cacti/'; ++ + /* ----- you probably do not need to change anything below this line ----- */ + + /* Files that do not need http header information - Command line scripts */ +@@ -51,7 +76,6 @@ + "ss_sql.php" + ); + +-$config = array(); + $colors = array(); + + /* this should be auto-detected, set it manually if needed */ +@@ -64,6 +88,11 @@ + $config["base_path"] = strtr(ereg_replace("(.*)[\/\\]include", "\\1", dirname(__FILE__)), "\\", "/"); + $config["library_path"] = ereg_replace("(.*[\/\\])include", "\\1lib", dirname(__FILE__)); + $config["include_path"] = dirname(__FILE__); ++ ++/* include the plugin function, we do this before everything else, ++ incase we want to add hooks to change config options */ ++ ++include_once($config["include_path"] . "/plugins.php"); + + /* colors */ + $colors["dark_outline"] = "454E53"; +--- include/config_arrays.php.orig Wed Jan 4 01:08:30 2006 ++++ include/config_arrays.php Fri Aug 4 00:26:18 2006 +@@ -24,6 +24,8 @@ + +-------------------------------------------------------------------------+ + */ + ++global $menu; ++ + $messages = array( + 1 => array( + "message" => 'Save Successful.', +@@ -429,4 +431,6 @@ + GDC_SLASH => "/" + ); + +-?> ++do_hook("config_arrays"); ++ ++?> +\ No newline at end of file +--- include/config_form.php.orig Wed Jan 4 01:08:30 2006 ++++ include/config_form.php Fri Aug 4 00:26:18 2006 +@@ -999,4 +999,6 @@ + ) + ); + +-?> ++do_hook("config_form"); ++ ++?> +\ No newline at end of file +--- include/config_settings.php.orig Wed Jan 4 01:08:30 2006 ++++ include/config_settings.php Fri Aug 4 00:26:18 2006 +@@ -847,4 +847,6 @@ + ) + ); + +-?> ++do_hook("config_settings"); ++ ++?> +\ No newline at end of file +--- /dev/null Thu Aug 3 21:25:01 2006 ++++ include/plugins.php Tue Jul 25 03:30:14 2006 +@@ -0,0 +1,70 @@ ++ +--- include/top_graph_header.php.orig Wed Jan 4 01:08:30 2006 ++++ include/top_graph_header.php Fri Aug 4 00:26:18 2006 +@@ -81,17 +81,18 @@ + if ($_SESSION["custom"]) { + print "\r\n"; + }else{ +- print "\r\n"; ++ $refresh = do_hook_function("top_graph_refresh", read_graph_config_option("page_refresh")); ++ print "\r\n"; + } + } + ?> +- ++ + +- +- +- +- +- ++ ++ ++ ++ ++ + + + +@@ -102,13 +103,15 @@ + + + + + + +
+-  ConsoleGraphs  ++  ConsoleGraphs  + +- ++ + +- Settings';}?>  .gif" border="0" title="Tree View" alt="Tree View" align="absmiddle">.gif" border="0" title="List View" alt="List View" align="absmiddle">.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"> 
++ Settings';}?>  .gif" border="0" title="Tree View" alt="Tree View" align="absmiddle">.gif" border="0" title="List View" alt="List View" align="absmiddle">.gif" border="0" title="Preview View" alt="Preview View" align="absmiddle"> 
+
+@@ -116,7 +119,7 @@ + + + +-
++
+ + + +@@ -128,7 +131,7 @@ + + + +- Logged in as (Logout)  ++ Logged in as (Logout)  + + + +@@ -136,10 +139,10 @@ + + + +- +- " height="2" border="0">
++ ++ " height="2" border="0">
+ +- ++ + + + +--- include/top_header.php.orig Wed Jan 4 01:08:30 2006 ++++ include/top_header.php Fri Aug 4 00:26:18 2006 +@@ -24,17 +24,17 @@ + +-------------------------------------------------------------------------+ + */ + +-global $colors; ++global $colors, $config; + ?> + + + cacti +- +- ++ ++ + + + +- ++ + + + +@@ -42,10 +42,11 @@ +
+ + ++  ConsoleConsole + + +
+-  ConsoleConsole +- +- ++ +
+@@ -53,7 +54,7 @@ + + + +-
++
+ + + +@@ -65,7 +66,7 @@ + + + +- Logged in as (Logout)  ++ Logged in as (Logout)  + + + +@@ -73,10 +74,10 @@ + + + +- +-
++ ++
+ +- ++ + + + +@@ -86,9 +87,9 @@ + + + +-
+-

+-
++
++

about.php'>

++
+ + + +--- lib/api_device.php.orig Wed Jan 4 01:08:30 2006 ++++ lib/api_device.php Fri Aug 4 00:26:18 2006 +@@ -76,6 +76,8 @@ + $save["snmp_timeout"] = form_input_validate($snmp_timeout, "snmp_timeout", "^[0-9]+$", false, 3); + $save["disabled"] = form_input_validate($disabled, "disabled", "", true, 3); + ++ $save = do_hook_function("api_device_save", $save); ++ + $host_id = 0; + + if (!is_error_message()) { +--- lib/functions.php.orig Wed Jan 4 01:08:30 2006 ++++ lib/functions.php Fri Aug 4 00:26:18 2006 +@@ -186,9 +186,9 @@ + user + @returns - (bool) whether the messages array contains an error or not */ + function is_error_message() { +- global $config; ++ global $config, $messages; + +- include($config["include_path"] . "/config_arrays.php"); ++ include_once($config["include_path"] . "/config_arrays.php"); + + if (isset($_SESSION["sess_messages"])) { + if (is_array($_SESSION["sess_messages"])) { +@@ -562,6 +562,8 @@ + } + } + ++ do_hook_function("update_host_status", array('issue_log_message' => $issue_log_message, 'status' => $status, 'host_id' => $host_id, 'hosts' => $hosts)); ++ + db_execute("update host set + status = '" . $hosts[$host_id]["status"] . "', + status_event_count = '" . $hosts[$host_id]["status_event_count"] . "', +@@ -1345,6 +1347,8 @@ + "templates_export.php:save" => array("title" => "Export Results", "mapping" => "index.php:,templates_export.php:", "url" => "templates_export.php", "level" => "2"), + "templates_import.php:" => array("title" => "Import Templates", "mapping" => "index.php:", "url" => "templates_import.php", "level" => "1"), + ); ++ ++ $nav = do_hook_function("draw_navigation_text", $nav); + + $current_page = basename($_SERVER["PHP_SELF"]); + $current_action = (isset($_REQUEST["action"]) ? $_REQUEST["action"] : ""); +--- lib/html.php.orig Wed Jan 4 01:08:30 2006 ++++ lib/html.php Fri Aug 4 00:26:18 2006 +@@ -88,6 +88,7 @@ + @arg $extra_url_args - extra arguments to append to the url + @arg $header - html to use as a header */ + function html_graph_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") { ++ global $config; + $i = 0; + if (sizeof($graph_array) > 0) { + if ($header != "") { +@@ -101,10 +102,10 @@ + + + + + +
+- <?php print $graph["title_cache"];?> ++ graph.php?local_graph_id=&rra_id=all'>graph_image.php?local_graph_id=&rra_id=0' border='0' alt=''> + +- Zoom Graph
++ graph.php?action=zoom&local_graph_id=&rra_id=0&'>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'>
+
+@@ -130,6 +131,7 @@ + @arg $extra_url_args - extra arguments to append to the url + @arg $header - html to use as a header */ + function html_graph_thumbnail_area(&$graph_array, $no_graphs_message = "", $extra_url_args = "", $header = "") { ++ global $config; + $i = 0; $k = 0; + if (sizeof($graph_array) > 0) { + if ($header != "") { +@@ -144,10 +146,10 @@ + + + + + +
+- <?php print $graph["title_cache"];?> ++ graph.php?rra_id=all&local_graph_id='>graph_image.php?local_graph_id=&rra_id=0&graph_height=&graph_width=&graph_nolegend=true' border='0' alt=''> + +- Zoom Graph
++ graph.php?action=zoom&local_graph_id=&rra_id=0&'>images/graph_zoom.gif' border='0' alt='Zoom Graph' title='Zoom Graph' style='padding: 3px;'>
+
+@@ -430,6 +432,8 @@ + } + + while (list($item_sub_url, $item_sub_title) = each($item_title)) { ++ $item_sub_url = $config['url_path'] . $item_sub_url; ++ + /* indent sub-items */ + if ($i > 0) { + $prepend_string = "--- "; +@@ -439,7 +443,7 @@ + + /* do not put a line between each sub-item */ + if (($i == 0) || ($draw_sub_items == false)) { +- $background = "images/menu_line.gif"; ++ $background = $config['url_path'] . "images/menu_line.gif"; + }else{ + $background = ""; + } +@@ -468,17 +472,18 @@ + }else{ + if ((isset($user_realms[$current_realm_id])) || (!isset($user_auth_realm_filenames{basename($item_url)}))) { + /* draw normal (non sub-item) menu item */ ++ $item_url = $config['url_path'] . $item_url; + if (basename($_SERVER["PHP_SELF"]) == basename($item_url)) { +- print "$item_title\n"; ++ print "$item_title\n"; + }else{ +- print "$item_title\n"; ++ print "$item_title\n"; + } + } + } + } + } + +- print "\n"; ++ print "\n"; + + print ''; + } +@@ -488,18 +493,19 @@ + @arg $actions_array - an array that contains a list of possible actions. this array should + be compatible with the form_dropdown() function */ + function draw_actions_dropdown($actions_array) { ++ global $config; + ?> + + + + + + +
+-   ++ images/arrow.gif' alt='' align='absmiddle'>  + + Choose an action: + + +- ++ images/button_go.gif' alt='Go'> +
+@@ -526,4 +532,4 @@ + + ++?> +\ No newline at end of file +--- lib/html_form.php.orig Wed Jan 4 01:08:30 2006 ++++ lib/html_form.php Fri Aug 4 00:26:18 2006 +@@ -434,6 +434,7 @@ + @arg $force_type - if specified, will force the 'action' button to be either + 'save' or 'create'. otherwise this field should be properly auto-detected */ + function form_save_button($cancel_url, $force_type = "", $key_field = "id") { ++ global $config; + if (empty($force_type)) { + if (empty($_GET[$key_field])) { + $img = "button_create.gif"; +@@ -454,8 +455,8 @@ + + + +- Cancel +- ++ images/button_cancel2.gif' alt='Cancel' align='absmiddle' border='0'> ++ images/' alt='' align='absmiddle'> + + + +--- /dev/null Thu Aug 3 21:25:01 2006 ++++ plugins/index.php Tue Jul 25 03:30:15 2006 +@@ -0,0 +1,5 @@ ++ +--- poller.php.orig Wed Jan 4 01:08:30 2006 ++++ poller.php Fri Aug 4 00:26:18 2006 +@@ -40,6 +40,8 @@ + include_once($config["base_path"] . "/lib/graph_export.php"); + include_once($config["base_path"] . "/lib/rrd.php"); + ++do_hook("poller_top"); ++ + /* Record Start Time */ + list($micro,$seconds) = split(" ", microtime()); + $start = $seconds + $micro; +@@ -268,4 +270,6 @@ + } + // End Mainline Processing + +-?> ++do_hook("poller_bottom"); ++ ++?> +\ No newline at end of file +--- utilities.php.orig Wed Jan 4 01:08:30 2006 ++++ utilities.php Fri Aug 4 00:26:18 2006 +@@ -88,6 +88,9 @@ + include_once("./include/bottom_footer.php"); + break; + default: ++ ++ do_hook_function("utilities_action", $_REQUEST["action"]); ++ + include_once("./include/top_header.php"); + + utilities(); +@@ -353,6 +356,8 @@ + + +