Example #1
0
function displayTreeNodes($tree_id, $nodeType = '', $parentNode = 0, $quietMode = FALSE)
{
    global $tree_sort_types, $tree_item_types, $host_group_types;
    if ($parentNode == 0) {
        if (!$quietMode) {
            echo "Known Tree Nodes:\n";
            echo "type\tid\tparentid\ttitle\tattribs\n";
        }
    }
    $parentID = 0;
    $nodes = db_fetch_assoc_prepared('SELECT id, local_graph_id, rra_id, title,
		host_id, host_grouping_type, sort_children_type
		FROM graph_tree_items
		WHERE graph_tree_id = ?
		AND parent = ?
		ORDER BY position', array($tree_id, $parentNode));
    if (sizeof($nodes)) {
        foreach ($nodes as $node) {
            /* taken from tree.php, funtion item_edit() */
            $current_type = TREE_ITEM_TYPE_HEADER;
            if ($node['local_graph_id'] > 0) {
                $current_type = TREE_ITEM_TYPE_GRAPH;
            }
            if ($node['host_id'] > 0) {
                $current_type = TREE_ITEM_TYPE_HOST;
            }
            switch ($current_type) {
                case TREE_ITEM_TYPE_HEADER:
                    if ($nodeType == '' || $nodeType == 'header') {
                        echo $tree_item_types[$current_type] . "\t";
                        echo $node['id'] . "\t";
                        if ($parentNode == 0) {
                            echo "N/A\t";
                        } else {
                            echo $parentNode . "\t";
                        }
                        echo $node['title'] . "\t";
                        echo $tree_sort_types[$node['sort_children_type']] . "\t";
                        echo "\n";
                    }
                    displayTreeNodes($tree_id, $nodeType, $node['id'], $quietMode);
                    break;
                case TREE_ITEM_TYPE_GRAPH:
                    if ($nodeType == '' || $nodeType == 'graph') {
                        echo $tree_item_types[$current_type] . "\t";
                        echo $node['id'] . "\t";
                        if ($parentNode == 0) {
                            echo "N/A\t";
                        } else {
                            echo $parentNode . "\t";
                        }
                        /* fetch the title for that graph */
                        $graph_title = db_fetch_cell_prepared('SELECT gtg.title_cache AS name
							FROM graph_templates_graph AS gtg
							WHERE gtg.local_graph_id = ?', array($node['local_graph_id']));
                        $rra = db_fetch_cell_prepared('SELECT name FROM rra WHERE id = ?', array($node['rra_id']));
                        echo $graph_title . "\t";
                        echo $rra . "\t";
                        echo "\n";
                    }
                    break;
                case TREE_ITEM_TYPE_HOST:
                    if ($nodeType == '' || $nodeType == 'host') {
                        echo $tree_item_types[$current_type] . "\t";
                        echo $node['id'] . "\t";
                        if ($parentNode == 0) {
                            echo "N/A\t";
                        } else {
                            echo $parentNode . "\t";
                        }
                        $name = db_fetch_cell_prepared('SELECT hostname FROM host WHERE id = ?', array($node['host_id']));
                        echo $name . "\t";
                        echo $host_group_types[$node['host_grouping_type']] . "\t";
                        echo "\n";
                    }
                    break;
            }
        }
    }
    if ($parentNode == 0) {
        if (!$quietMode) {
            echo "\n";
        }
    }
}
Example #2
0
 }
 if ($displayHosts) {
     displayHosts($hosts, $quietMode);
     exit(0);
 }
 if ($displayTrees) {
     displayTrees($quietMode);
     exit(0);
 }
 if ($displayNodes) {
     if (!isset($treeId)) {
         echo "ERROR: You must supply a tree_id before you can list its nodes\n";
         echo "Try --list-trees\n";
         exit(1);
     }
     displayTreeNodes($treeId, $nodeType, $parentNode, $quietMode);
     exit(0);
 }
 if ($displayRRAs) {
     displayRRAs($quietMode);
     exit(0);
 }
 if ($displayGraphs) {
     if (!isset($hostId) || $hostId == 0) {
         echo "ERROR: You must supply a host_id before you can list its graphs\n";
         echo "Try --list-hosts\n";
         exit(1);
     }
     displayHostGraphs($hostId, $quietMode);
     exit(0);
 }
Example #3
0
		exit(0);
	}

	if ($displayTrees) {
		displayTrees($quietMode);
		exit(0);
	}

	if ($displayNodes) {
		if (!isset($treeId)) {
			echo "ERROR: You must supply a tree_id before you can list its nodes\n";
			echo "Try --list-trees\n";
			exit(1);
		}

		displayTreeNodes($treeId, $quietMode);
		exit(0);
	}

	if ($displayRRAs) {
		displayRRAs($quietMode);
		exit(0);
	}

	if ($displayGraphs) {
		if (!isset($hostId) || $hostId == 0) {
			echo "ERROR: You must supply a host_id before you can list its graphs\n";
			echo "Try --list-hosts\n";
			exit(1);
		}