$name) { print $id . "\t" . $name . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayHostTemplates($host_templates, $quietMode = false) { if (!$quietMode) { print 'Valid Device Templates: (id, name)' . PHP_EOL; } if ($host_templates !== false && cacti_sizeof($host_templates)) { foreach ($host_templates as $id => $name) { print "$id\t$name" . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayCommunities($quietMode = false) { if (!$quietMode) { print 'Known SNMP Communities: (community)' . PHP_EOL; } $communities = db_fetch_assoc('SELECT DISTINCT snmp_community FROM host ORDER BY snmp_community'); if ($communities !== false &&cacti_sizeof($communities)) { foreach ($communities as $community) { print $community['snmp_community'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displaySNMPFields($fields, $hostId, $quietMode = false) { if (!$quietMode) { print 'Known SNMP Fields for host-id ' . $hostId . ': (name)' . PHP_EOL; } if ($fields !== false && cacti_sizeof($fields)) { foreach ($fields as $field => $values) { print $field . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displaySNMPValues($values, $hostId, $field, $quietMode = false) { if (!$quietMode) { print 'Known SNMP Values for Field ' . $field . ' and host-id ' . $hostId . ': (name)' . PHP_EOL; } if ($values !== false && cacti_sizeof($values)) { foreach ($values as $value => $foo) { print $value . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displaySNMPQueries($queries, $quietMode = false) { if (!$quietMode) { print 'Known SNMP Queries: (id, name)' . PHP_EOL; } if ($queries !== false &&cacti_sizeof($queries)) { foreach ($queries as $id => $name) { print $id . "\t" . $name . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayInputFields($input_fields, $quietMode = false) { if (!$quietMode) { print 'Known Input Fields: (name, default, description)' . PHP_EOL; } if ($input_fields !== false &&cacti_sizeof($input_fields)) { foreach ($input_fields as $row) { print $row['data_template_id'] . ':' . $row['name'] . "\t" . $row['default'] . "\t" . $row['description'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayGraphTemplates($templates, $quietMode = false) { if (!$quietMode) { print 'Known Graph Templates: (id, name)' . PHP_EOL; } if ($templates !== false && cacti_sizeof($templates)) { foreach ($templates as $id => $name) { print $id . "\t" . $name . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayHosts($hosts, $quietMode = false) { if (!$quietMode) { print 'Known Devices: (id, hostname, template, description)' . PHP_EOL; } if ($hosts !== false && cacti_sizeof($hosts)) { foreach($hosts as $host) { print $host['id'] . "\t" . $host['hostname'] . "\t" . $host['host_template_id'] . "\t" . $host['description'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displaySites($sites, $quietMode = false) { if (!$quietMode) { print 'Known Sites: (id, name)' . PHP_EOL; } if ($sites !== false && cacti_sizeof($sites)) { foreach($sites as $site) { print $site['id'] . "\t" . $site['name'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayTrees($quietMode = false) { global $tree_sort_types; if (!$quietMode) { print 'Known Trees: (id, sort method, name)' . PHP_EOL; } $trees = db_fetch_assoc('SELECT id, sort_type, name FROM graph_tree ORDER BY id'); if (cacti_sizeof($trees)) { foreach ($trees as $tree) { print $tree['id'] . "\t"; print $tree_sort_types[$tree['sort_type']] . "\t"; print $tree['name'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayTreeNodes($tree_id, $nodeType = '', $parentNode = 0, $quietMode = false) { global $tree_sort_types, $tree_item_types, $host_group_types; if ($parentNode == 0) { if (!$quietMode) { print 'Known Tree Nodes: (type, id, parentid, title, attribs)' . PHP_EOL; } } $parentID = 0; $nodes = db_fetch_assoc_prepared('SELECT id, local_graph_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 (cacti_sizeof($nodes)) { foreach ($nodes as $node) { /* taken from tree.php, function 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') { print $tree_item_types[$current_type]."\t"; print $node['id']."\t"; if ($parentNode == 0) { print "N/A\t"; } else { print $parentNode . "\t"; } print $node['title'] . "\t"; print $tree_sort_types[$node['sort_children_type']] . "\t"; print PHP_EOL; } displayTreeNodes($tree_id, $nodeType, $node['id'], $quietMode); break; case TREE_ITEM_TYPE_GRAPH: if ($nodeType == '' || $nodeType == 'graph') { print $tree_item_types[$current_type] . "\t"; print $node['id'] . "\t"; if ($parentNode == 0) { print "N/A\t"; } else { print $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'])); print $graph_title . "\t"; print PHP_EOL; } break; case TREE_ITEM_TYPE_HOST: if ($nodeType == '' || $nodeType == 'host') { print $tree_item_types[$current_type] . "\t"; print $node['id'] . "\t"; if ($parentNode == 0) { print "N/A\t"; } else { print $parentNode . "\t"; } $name = db_fetch_cell_prepared('SELECT hostname FROM host WHERE id = ?', array($node['host_id'])); print $name . "\t"; print $host_group_types[$node['host_grouping_type']] . "\t"; print PHP_EOL; } break; } } } if ($parentNode == 0) { if (!$quietMode) { print PHP_EOL; } } } function displayRRAs($quietMode = false) { if (!$quietMode) { print 'Known RRAs: (id, steps, rows, name)' . PHP_EOL; } $rras = db_fetch_assoc('SELECT id, name, steps, `rows` FROM data_source_profiles_rra ORDER BY id'); if (cacti_sizeof($rras)) { foreach ($rras as $rra) { print $rra['id'] . "\t"; print $rra['steps'] . "\t"; print $rra['rows'] . "\t"; print $rra['name'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayHostGraphs($host_id, $quietMode = false) { if (!$quietMode) { print 'Known Device Graphs: (id, name, template)' . PHP_EOL; } $graphs = db_fetch_assoc_prepared('SELECT graph_templates_graph.local_graph_id AS id, graph_templates_graph.title_cache AS name, graph_templates.name AS template_name FROM (graph_local, graph_templates_graph) LEFT JOIN graph_templates ON (graph_local.graph_template_id = graph_templates.id) WHERE graph_local.id = graph_templates_graph.local_graph_id AND graph_local.host_id = ? ORDER BY graph_templates_graph.local_graph_id', array($host_id)); if (cacti_sizeof($graphs)) { foreach ($graphs as $graph) { print $graph['id'] . "\t"; print $graph['name'] . "\t"; print $graph['template_name'] . "\t"; print PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } } function displayUsers($quietMode = false) { if (!$quietMode) { print 'Known Users: (id, username, full_name)'. PHP_EOL; } $groups = db_fetch_assoc('SELECT id, username, full_name FROM user_auth ORDER BY id'); if (cacti_sizeof($groups)) { foreach ($groups as $group) { print $group['id'] ."\t"; print $group['username'] ."\t"; print $group['full_name'] . PHP_EOL; } } if (!$quietMode) { print PHP_EOL; } }