This script is only meant to run at the command line.");
}
$host_id = $_SERVER["argv"][1];
$snmp_query_id = 1;
$graph_template_id = 31; //Interface - Traffic (bits/sec, 95th Percentile)
$graph_template_id2 = 22; //Interface - Errors/Discards
$graph_template_id_cg = 18; //Cisco - CPU Usage
$suggested_values_array = array();
$xml_array = get_data_query_array($snmp_query_id);
$snmp_query_indexes = array();
reset($xml_array["fields"]);
while (list($field_name, $field_array) = each($xml_array["fields"])) {
if ($field_array["direction"] == "input") {
$raw_data = db_fetch_assoc("select field_value,snmp_index from host_snmp_cache where host_id=" . $host_id . " and field_name='$field_name' and snmp_query_id=" . $snmp_query_id);
/* don't even both to display the column if it has no data */
if (sizeof($raw_data) > 0) {
/* draw each header item */
foreach ($raw_data as $data) {
$snmp_query_data[$field_name]{$data["snmp_index"]} = $data["field_value"];
if (!in_array($data["snmp_index"], $snmp_query_indexes,TRUE)) {
array_push($snmp_query_indexes, $data["snmp_index"]);
}
}
}elseif (sizeof($raw_data) == 0) {
/* we are choosing to not display this column, so unset the associated
field in the xml array so it is not drawn */
unset($xml_array["fields"][$field_name]);
}
}
}
$local_data_ids = array();
reset($snmp_query_indexes);
if (sizeof($snmp_query_indexes) > 0) {
while (list($id, $snmp_index) = each($snmp_query_indexes)) {
$snmp_query_array = array();
$snmp_query_array["snmp_query_id"] = 1;
$snmp_query_array["snmp_index_on"] = get_best_data_query_index_type($host_id, 1);
$snmp_query_array["snmp_query_graph_id"] = 20;
$snmp_query_array["snmp_index"] = $snmp_index;
//print_r($snmp_query_array);
//print "create_complete_graph_from_template($graph_template_id, $host_id, $snmp_query_array, $suggested_values_array)\n";
$return_array = create_complete_graph_from_template($graph_template_id, $host_id, $snmp_query_array, $suggested_values_array);
print "Created graph: " . get_graph_title($return_array["local_graph_id"]) . "\n";
array_push($local_data_ids, $return_array["local_data_id"][41]);
$snmp_query_array = array();
$snmp_query_array["snmp_query_id"] = 1;
$snmp_query_array["snmp_index_on"] = get_best_data_query_index_type($host_id, 1);
$snmp_query_array["snmp_query_graph_id"] = 2;
$snmp_query_array["snmp_index"] = $snmp_index;
//print_r($snmp_query_array);
//print "create_complete_graph_from_template($graph_template_id, $host_id, $snmp_query_array, $suggested_values_array)\n";
$return_array = create_complete_graph_from_template($graph_template_id2, $host_id, $snmp_query_array, $suggested_values_array);
print "Created graph: " . get_graph_title($return_array["local_graph_id"]) . "\n";
array_push($local_data_ids, $return_array["local_data_id"][38]);
}
}
$values_cg = array();
$return_array = create_complete_graph_from_template($graph_template_id_cg, $host_id, "", $values_cg);
print "Created graph: " . get_graph_title($return_array["local_graph_id"]) . "\n";
array_push($local_data_ids, $return_array["local_data_id"][27]);
print "Creating rrd files\n";
foreach($local_data_ids as $local_data_id) {
if(is_numeric($local_data_id) && ($local_data_id > 0)) {
printf("Creating for %d\n", $local_data_id);
$command_line = rrdtool_function_create($local_data_id, true, array());
$command_line = str_replace("\\\n", " ", $command_line);
system(escape_command($command_line));
}
}
?> |