ok前面基本就成可以监控database的占用空间了,只是一个小小的功能,希望能够帮助大家学习cacti
这里放上完整的内容,包括php query的xml以及 cacti的模板,具体安装见附件的 readme
模板:
<cacti> <hash_040024b001126355178ea420a30cd1c47ab45e> <name>Get MySql DataBase Usage</name> <description>Get MySql DataBase Usage from php query</description> <xml_path><path_cacti>/resource/script_queries/flashapp_mysql_space.xml</xml_path> <data_input_id>hash_03002480e9e4c4191a5da189ae26d0e237f015</data_input_id> <graphs> <hash_110024b0634039debc20e3e0a717bafc84a1bc> <name>get mysql database space by php script query</name> <graph_template_id>hash_000024c3bd011b048a0376ca06e2937624becc</graph_template_id> <rrd> <item_000> <snmp_field_name>hrDataBasesSize</snmp_field_name> <data_template_id>hash_010024750c86d980a785aa8e56cf52a564b52f</data_template_id> <data_template_rrd_id>hash_08002462c34e48d9ac2f34d76d3ded5a4f6769</data_template_rrd_id> </item_000> </rrd> <sv_graph> <hash_12002491ef1e5514038ce6de714e5e6e9d6ff0> <field_name>title</field_name> <sequence>1</sequence> <text>|host_description| - Database Usage - |query_hrDataBasesDescr|</text> </hash_12002491ef1e5514038ce6de714e5e6e9d6ff0> </sv_graph> <sv_data_source> <hash_13002471e333f451eb825e0ff46f3a4ec496b1> <field_name>name</field_name> <data_template_id>hash_010024750c86d980a785aa8e56cf52a564b52f</data_template_id> <sequence>1</sequence> <text>|host_description| - Database Usage - |query_hrDataBasesDescr|</text> </hash_13002471e333f451eb825e0ff46f3a4ec496b1> </sv_data_source> </hash_110024b0634039debc20e3e0a717bafc84a1bc> </graphs> </hash_040024b001126355178ea420a30cd1c47ab45e> <hash_03002480e9e4c4191a5da189ae26d0e237f015> <name>Get Script Data (Indexed)</name> <type_id>4</type_id> <input_string></input_string> <fields> <hash_070024d39556ecad6166701bfb0e28c5a11108> <name>Index Type</name> <update_rra></update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code>index_type</type_code> <input_output>in</input_output> <data_name>index_type</data_name> </hash_070024d39556ecad6166701bfb0e28c5a11108> <hash_0700243b7caa46eb809fc238de6ef18b6e10d5> <name>Index Value</name> <update_rra></update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code>index_value</type_code> <input_output>in</input_output> <data_name>index_value</data_name> </hash_0700243b7caa46eb809fc238de6ef18b6e10d5> <hash_07002474af2e42dc12956c4817c2ef5d9983f9> <name>Output Type ID</name> <update_rra></update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code>output_type</type_code> <input_output>in</input_output> <data_name>output_type</data_name> </hash_07002474af2e42dc12956c4817c2ef5d9983f9> <hash_0700248ae57f09f787656bf4ac541e8bd12537> <name>Output Value</name> <update_rra>on</update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code></type_code> <input_output>out</input_output> <data_name>output</data_name> </hash_0700248ae57f09f787656bf4ac541e8bd12537> </fields> </hash_03002480e9e4c4191a5da189ae26d0e237f015> <hash_000024c3bd011b048a0376ca06e2937624becc> <name>flashapp - MySQL - Database Usage</name> <graph> <t_title></t_title> <title>|host_description| - Mysql Database Usage- |query_hrDataBasesDescr|</title> <t_image_format_id></t_image_format_id> <image_format_id>1</image_format_id> <t_height></t_height> <height>120</height> <t_width></t_width> <width>500</width> <t_slope_mode></t_slope_mode> <slope_mode>on</slope_mode> <t_auto_scale></t_auto_scale> <auto_scale>on</auto_scale> <t_auto_scale_opts></t_auto_scale_opts> <auto_scale_opts>2</auto_scale_opts> <t_auto_scale_log></t_auto_scale_log> <auto_scale_log></auto_scale_log> <t_scale_log_units></t_scale_log_units> <scale_log_units></scale_log_units> <t_auto_scale_rigid></t_auto_scale_rigid> <auto_scale_rigid></auto_scale_rigid> <t_auto_padding></t_auto_padding> <auto_padding>on</auto_padding> <t_export></t_export> <export>on</export> <t_upper_limit></t_upper_limit> <upper_limit>100</upper_limit> <t_lower_limit></t_lower_limit> <lower_limit>0</lower_limit> <t_base_value></t_base_value> <base_value>1000</base_value> <t_unit_value></t_unit_value> <unit_value></unit_value> <t_unit_exponent_value></t_unit_exponent_value> <unit_exponent_value></unit_exponent_value> <t_vertical_label></t_vertical_label> <vertical_label></vertical_label> </graph> <items> <hash_1000243d73e23783f325147d26107b8ad900f7> <task_item_id>hash_08002462c34e48d9ac2f34d76d3ded5a4f6769</task_item_id> <color_id>FF5F00</color_id> <alpha>FF</alpha> <graph_type_id>7</graph_type_id> <consolidation_function_id>1</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060024e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>Disk Usage</text_format> <hard_return></hard_return> <sequence>1</sequence> </hash_1000243d73e23783f325147d26107b8ad900f7> </items> <inputs> <hash_090024ec2ffa8d507d6cc2e10641044ef3bc9d> <name>Data Source [database_space]</name> <description></description> <column_name>task_item_id</column_name> <items>hash_0000243d73e23783f325147d26107b8ad900f7</items> </hash_090024ec2ffa8d507d6cc2e10641044ef3bc9d> </inputs> </hash_000024c3bd011b048a0376ca06e2937624becc> <hash_010024750c86d980a785aa8e56cf52a564b52f> <name>flashapp - Get MySql Database usage</name> <ds> <t_name>on</t_name> <name>|host_description| - MySql Space -|query_hrDataBasesDescr|</name> <data_input_id>hash_03002480e9e4c4191a5da189ae26d0e237f015</data_input_id> <t_rra_id></t_rra_id> <t_rrd_step></t_rrd_step> <rrd_step>300</rrd_step> <t_active></t_active> <active>on</active> <rra_items>hash_150024c21df5178e5c955013591239eb0afd46|hash_1500240d9c0af8b8acdc7807943937b3208e29|hash_1500246fc2d038fb42950138b0ce3e9874cc60|hash_150024e36f3adb9f152adfa5dc50fd2b23337e</rra_items> </ds> <items> <hash_08002462c34e48d9ac2f34d76d3ded5a4f6769> <t_data_source_name></t_data_source_name> <data_source_name>database_space</data_source_name> <t_rrd_minimum></t_rrd_minimum> <rrd_minimum>0</rrd_minimum> <t_rrd_maximum></t_rrd_maximum> <rrd_maximum>0</rrd_maximum> <t_data_source_type_id></t_data_source_type_id> <data_source_type_id>1</data_source_type_id> <t_rrd_heartbeat></t_rrd_heartbeat> <rrd_heartbeat>600</rrd_heartbeat> <t_data_input_field_id></t_data_input_field_id> <data_input_field_id>0</data_input_field_id> </hash_08002462c34e48d9ac2f34d76d3ded5a4f6769> </items> <data> <item_000> <data_input_field_id>hash_07002474af2e42dc12956c4817c2ef5d9983f9</data_input_field_id> <t_value>on</t_value> <value></value> </item_000> <item_001> <data_input_field_id>hash_0700243b7caa46eb809fc238de6ef18b6e10d5</data_input_field_id> <t_value>on</t_value> <value></value> </item_001> <item_002> <data_input_field_id>hash_070024d39556ecad6166701bfb0e28c5a11108</data_input_field_id> <t_value>on</t_value> <value></value> </item_002> </data> </hash_010024750c86d980a785aa8e56cf52a564b52f> <hash_150024c21df5178e5c955013591239eb0afd46> <name>Daily (5 Minute Average)</name> <x_files_factor>0.5</x_files_factor> <steps>1</steps> <rows>600</rows> <timespan>86400</timespan> <cf_items>1|3</cf_items> </hash_150024c21df5178e5c955013591239eb0afd46> <hash_1500240d9c0af8b8acdc7807943937b3208e29> <name>Weekly (30 Minute Average)</name> <x_files_factor>0.5</x_files_factor> <steps>6</steps> <rows>700</rows> <timespan>604800</timespan> <cf_items>1|3</cf_items> </hash_1500240d9c0af8b8acdc7807943937b3208e29> <hash_1500246fc2d038fb42950138b0ce3e9874cc60> <name>Monthly (2 Hour Average)</name> <x_files_factor>0.5</x_files_factor> <steps>24</steps> <rows>775</rows> <timespan>2678400</timespan> <cf_items>1|3</cf_items> </hash_1500246fc2d038fb42950138b0ce3e9874cc60> <hash_150024e36f3adb9f152adfa5dc50fd2b23337e> <name>Yearly (1 Day Average)</name> <x_files_factor>0.5</x_files_factor> <steps>288</steps> <rows>797</rows> <timespan>33053184</timespan> <cf_items>1|3</cf_items> </hash_150024e36f3adb9f152adfa5dc50fd2b23337e> <hash_060024e9c43831e54eca8069317a2ce8c6f751> <name>Normal</name> <gprint_text>%8.2lf %s</gprint_text> </hash_060024e9c43831e54eca8069317a2ce8c6f751> </cacti>