setup是Cacti 插件中一个比较常用的!下面来看下Cacti 插件中setup.php 文件的编写!
插件放在 /plugins 目录 由setup.php与cacti 做关联
setup.php文件由/include/plugins.php /lib/plugins.php这两个文件做解释
插件名要在/include/config.php 或/include/global.php 文件中声明
$plugins[] = 'thold';
setup.php文件放置目录/plugins/插件名/setup.php
编写的文件内容由插件初始化函数(plugin_init_插件名())和自定义函数组成
- function plugin_init_thold() {
- global $plugin_hooks;
- $plugin_hooks['user_admin_edit']['thold'] = 'thold_user_admin_edit';
- }
#p#
初始化函数声明格式:
$plugin_hooks |
['user_admin_edit'] |
['thold'] |
|
'thold_user_admin_edit' |
; |
|
预定义函数名 |
插件名 |
|
自定义函数 |
|
预定义函数名列表:
预定义函数名 |
插件引用函数 |
对应修改页面 |
auth_alternate_realms |
do_hook_function() |
auth.php |
login_options_navigate |
api_plugin_hook_function() |
auth_changepassword.php |
|
|
auth_login.php |
login_before |
api_plugin_hook() |
auth_login.php |
cacti_image |
api_plugin_hook_function() |
auth_login.php |
login_after |
api_plugin_hook() |
auth_login.php |
data_sources_table |
api_plugin_hook_function() |
data_sources.php |
graph_buttons |
api_plugin_hook() |
graph.php |
|
|
/lib/html.php |
graphs_action_array |
api_plugin_hook_function() |
graphs.php |
graphs_action_execute |
api_plugin_hook_function() |
graphs.php |
graphs_action_prepare |
api_plugin_hook_function() |
graphs.php |
graphs_new_top_links |
api_plugin_hook() |
graphs_new.php |
graph_image |
api_plugin_hook_function() |
graph_image.php |
device_action_array |
api_plugin_hook_function() |
host.php |
device_action_execute |
api_plugin_hook_function() |
host.php |
device_action_prepare |
api_plugin_hook_function() |
host.php |
console_before |
api_plugin_hook() |
index.php |
console_after |
api_plugin_hook() |
index.php |
poller_top |
api_plugin_hook() |
poller.php |
poller_command_args |
api_plugin_hook_function() |
poller.php |
poller_bottom |
api_plugin_hook() |
poller.php |
user_admin_action |
api_plugin_hook_function() |
user_admin.php |
user_admin_setup_sql_save |
api_plugin_hook_function() |
user_admin.php |
user_admin_user_save |
api_plugin_hook() |
user_admin.php |
user_admin_edit |
api_plugin_hook_function() |
user_admin.php |
user_admin_tab |
api_plugin_hook() |
user_admin.php |
user_admin_run_action |
api_plugin_hook_function() |
user_admin.php |
utilities_action |
api_plugin_hook_function() |
utilities.php |
utilities_list |
api_plugin_hook() |
utilities.php |
config_arrays |
api_plugin_hook() |
/include/global_arrays.php |
config_form |
api_plugin_hook() |
/include/global_form.php |
valid_host_fields |
api_plugin_hook_function() |
/include/global_form.php |
config_settings |
api_plugin_hook() |
/include/global_settings.php |
top_graph_header |
api_plugin_hook_function() |
/include/top_graph_header.php |
page_title |
api_plugin_hook_function() |
/include/top_graph_header.php |
|
|
/include/top_header.php |
top_graph_refresh |
api_plugin_hook_function() |
/include/top_graph_header.php |
page_head |
api_plugin_hook() |
/include/top_graph_header.php |
|
|
/include/top_header.php |
top_graph_header_tabs |
api_plugin_hook() |
/include/top_graph_header.php |
top_header |
api_plugin_hook_function() |
/include/top_header.php |
top_header_tabs |
api_plugin_hook() |
/include/top_header.php |
api_device_save |
api_plugin_hook_function() |
/lib/api_device.php |
draw_navigation_tex |
api_plugin_hook_function() |
/lib/functions.php |
poller_output |
api_plugin_hook_function() |
/lib/poller.php |
poller_on_demand |
api_plugin_hook_function() |
/lib/poller.php |
rrdtool_function_graph_cache_check |
api_plugin_hook_function() |
/lib/rrd.php |
rrd_graph_graph_options |
api_plugin_hook_function() |
/lib/rrd.php |
prep_graph_array |
api_plugin_hook_function() |
/lib/rrd.php |
rrdtool_function_graph_set_file |
api_plugin_hook_function() |
/lib/rrd.php |
substitute_host_data |
api_plugin_hook_function() |
/lib/variables.php |
#p#
自定义函数举例:
- function thold_user_admin_edit ($user) {
- global $fields_user_user_edit_host;
- $value = '';
- if ($user != 0) {
- $value = db_fetch_cell("SELECT data FROM plugin_thold_contacts WHERE user_id
- = $user AND type = 'email'");
- }
- $fields_user_user_edit_host['email'] = array(
- "method" => "textbox",
- "value" => $value,
- "friendly_name" => "电子邮件地址",
- "form_id" => "|arg1:id|",
- "default" => "",
- "max_length" => 255
- );
通过上文的描述,我们知道了Cacti 插件中setup.php 文件的编写的全过程,有点复杂但是还是值得的!
【编辑推荐】