Cacti 插件中setup.php 文件的编写
Cacti 插件中setup.php 文件的編寫
?
名詞: 初始化函數?? 預定義函數?
?
cacti 插件存放在 /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
?
setup.php的文件內容由插件初始化函數(plugin_init_插件名())和自定義函數組成
?
初始化函數聲明格式:
?
| $plugin_hooks | ['user_admin_edit'] | ['thold'] | ?= | 'thold_user_admin_edit' | ; |
|
| 預定義函數名 | 插件名 |
| 自定義函數 |
|
?
function plugin_init_thold() {?
??????? global $plugin_hooks;?
??????? $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_p_w_picpath | 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_p_w_picpath | api_plugin_hook_function() | graph_p_w_picpath.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 |
?
自定義函數舉例:
?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
??????????????????????????? );
}
?
轉載于:https://blog.51cto.com/12858058/890128
總結
以上是生活随笔為你收集整理的Cacti 插件中setup.php 文件的编写的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过小代码体验程序中BSS段和DATA段
- 下一篇: 嵌入式Linux全攻略 ACE程序移植过