We'll do this by example. In our example we'll have a plugin called "test_plugin" and we're adding a form field to accomplish the above.
Note, this assumes you're already familiar with the plugin architecture.
Step 1: Add your column to the host MySQL table:
Code: Select all
ALTER TABLE host ADD COLUMN ( test_plugin_auto_graph_level tinyint(1) unsigned NOT NULL default 1 );
Step 2: Add your form element to the visible page:
Code: Select all
function test_plugin_config_form() {
global $fields_host_edit, $test_plugin_auto_graph_levels;
$fields_host_edit["test_plugin_auto_graph_level"] = array(
"method" => "drop_array",
"friendly_name" => "Auto-Graph Level",
"description" => "Select the Auto-Graph level for this host.",
"value" => "|arg1:test_plugin_auto_graph_level|",
"default" => "1",
"array" => $test_plugin_auto_graph_levels,
);
}
Code: Select all
function test_plugin_config_arrays() {
global $test_plugin_auto_graph_levels;
$test_plugin_auto_graph_levels = array(
"0" => "No Graphs",
"1" => "No Interface Graphs",
"2" => "All Graphs");
}
Code: Select all
function test_plugin_api_device_save($save) {
$save["test_plugin_auto_graph_level"] = $_POST["test_plugin_auto_graph_level"];
return $save;
}