Cacti 插件中setup.php 文件的编写

运维 系统运维
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。在用Cacti时,有一些插件是非常好用的,setup就是其中一个,本文就讲下Cacti 插件中setup.php 文件的编写!

setupCacti 插件中一个比较常用的!下面来看下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_插件名())和自定义函数组成

 

  1.   function plugin_init_thold() {  
  2.  
  3.   global $plugin_hooks;  
  4.  
  5.   $plugin_hooks['user_admin_edit']['thold'] = 'thold_user_admin_edit';  
  6.  
  7.   }  
  8.  

 

#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#

  自定义函数举例:

 

  1.   function thold_user_admin_edit ($user) {  
  2.  
  3.   global $fields_user_user_edit_host;  
  4.  
  5.   $value = '';  
  6.  
  7.   if ($user != 0) {  
  8.  
  9.   $value = db_fetch_cell("SELECT data FROM plugin_thold_contacts WHERE user_id  
  10.  
  11.   = $user AND type = 'email'");  
  12.  
  13.   }  
  14.  

 

 

  1.   $fields_user_user_edit_host['email'] = array(  
  2.  
  3.   "method" => "textbox",  
  4.  
  5.   "value" => $value,  
  6.  
  7.   "friendly_name" => "电子邮件地址",  
  8.  
  9.   "form_id" => "|arg1:id|",  
  10.  
  11.   "default" => "",  
  12.  
  13.   "max_length" => 255  
  14.  
  15.   );  
  16.  

 

通过上文的描述,我们知道了Cacti 插件中setup.php 文件的编写的全过程,有点复杂但是还是值得的!

【编辑推荐】

责任编辑:赵鹏 来源: 网络转载
相关推荐

2011-04-06 10:57:09

Cacti插件安装

2011-03-25 09:00:36

Cacti插件

2011-03-25 09:00:36

Cacti插件

2011-03-31 09:23:02

Cacti插件

2011-06-27 17:24:37

Qt 插件

2010-06-17 17:22:30

Cacti 监控Lin

2010-05-26 15:43:45

cacti 监控lin

2011-03-31 15:23:39

Cactirrd

2011-04-02 16:38:49

Cactirrd

2011-03-29 11:28:00

Cacti插件

2011-03-28 11:20:11

Nagios 插件

2011-04-06 16:02:26

Nagios插件

2010-06-09 16:55:04

2009-12-02 18:43:35

PHP脚本编写

2009-11-17 17:28:21

PHP静态页面

2015-05-07 14:45:40

Cocos 插件

2010-05-31 15:21:17

Cacti配置

2010-06-09 17:01:26

Cacti使用手册

2011-08-23 18:04:40

LuaWiresharkDissector

2009-11-24 18:37:55

PHP数组转换
点赞
收藏

51CTO技术栈公众号