|
|
| Author |
Message |
Manish Roy
Joined: 15 Jul 2008 Posts: 1
|
Posted: Tue Jul 15, 2008 10:30 am Post subject: Adding Device Detailsin Cacti using CLI |
|
|
Hi Frz,
I want to know that is is possible to add Device Interface Details in Cacti
through CLI.Like i have a router (10.0.12.102 ) and Interfaces like Ethernate0/0,Ethernate0/1 etc.i need to add this interface details in cacti to genarate graph.
Please suggest me the possible steps to achive this.
Thanks |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Fri Jul 25, 2008 12:50 pm Post subject: |
|
|
The add_graph.php cli script is what you need. You should investigate how it works. I will be making significant performance enhancements to it in Cacti 0.8.7c once released in August.
TheWitness |
|
| Back to top |
|
 |
pointy
Joined: 26 Jul 2008 Posts: 8 Location: Washington, DC
|
Posted: Sat Jul 26, 2008 1:00 pm Post subject: |
|
|
| I've been investigating this same thing, and I'm still having trouble finding the correct flags for the script. My goal is to use a device ID and then ask the script to graph all of the ports on that device. I'm going to continue looking, but all I can see are ways to enter one graph at a time. |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Sat Jul 26, 2008 2:01 pm Post subject: |
|
|
I can post a nice function. Let me see about it. I will send myself a pm with this post.
TheWitness |
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Sat Jul 26, 2008 2:11 pm Post subject: |
|
|
Here you go. Does Regular Expression Matches as well:
| Code: | function add_graphs_for_dq($host, $graph_template_id, $snmp_query_id, $snmp_query_type_id, $snmp_field_name, $regmatch = "", $include = "on") {
global $config, $php_bin, $path_grid, $path_cacti;
/* let's see what queries are defined for this host */
$query_types = exec_into_array("$php_bin -q $path_grid/grid_add_graphs.php --host-id=" . $host["id"] . " --snmp-query-id=$snmp_query_id --list-query-types");
$found = false;
foreach($query_types as $type) {
if (substr_count($type, $snmp_query_type_id)) {
$found = true;
break;
}
}
/* now let's create some graphs, otherwise log and error */
if ($found) {
$items = exec_into_array("$php_bin -q $path_cacti/cli/add_graphs.php --host-id=" . $host["id"] . " --snmp-query-id=$snmp_query_id --snmp-field=$snmp_field_name --list-snmp-values");
if (sizeof($items)) {
foreach($items as $item) {
if ((trim($item) == "") ||
(substr_count($item, "Known")) ||
(substr_count($item, "FATAL:")) ||
(substr_count($item, "ERROR:"))) {
/* ignore */
continue;
}else{
if ($regmatch == "") {
/* add graph below */
}else if ((($include == "on") && (ereg($regmatch, $item))) ||
(($include != "on") && (!ereg($regmatch, $item)))) {
/* add graph below */
}else{
echo "NOTE: Bypassig item due to Regex rule: $item for Query Type ID: $snmp_query_type_id and Cluster: " . $cluster["clustername"] . "\n";
continue;
}
echo "NOTE: Adding item: $item for Query Type ID: $snmp_query_type_id and : " . $host["hostname"] . "\n";
$command = "$php_bin -q $path_cacti/cli/add_graphs.php" .
" --graph-template-id=$graph_template_id --graph-type=ds" .
" --snmp-query-type-id=$snmp_query_type_id --host-id=" . $host["id"] .
" --snmp-query-id=$snmp_query_id --snmp-field=$snmp_field_name" .
" --snmp-value=$item";
echo trim(shell_exec($command)) . "\n";
}
}
}
}else{
cacti_log("WARNING: Query Type ID ID: $snmp_query_type_id Not Assocated with Host: " . $host["hostname"], TRUE, "RTM");
}
} |
You will have to define the "globals" in the parent function.
Regards,
TheWitness |
|
| Back to top |
|
 |
pointy
Joined: 26 Jul 2008 Posts: 8 Location: Washington, DC
|
Posted: Sat Jul 26, 2008 2:16 pm Post subject: |
|
|
| This is great, thanks! |
|
| Back to top |
|
 |
|