0

How can I list the graphs for a host, or at the very least the number of graphs?

I'm thinking of a condition where I'd add more graphs depending on such output but all I see is to list available queries and such, I need the actual number/names of the graphs you see when you go to edit a host and click "*Graph List"

Recct
  • 370
  • 1
  • 3
  • 22

1 Answers1

2

You don't actually say programmatically, but you have tagged this 'perl'... The graph_local table in the Cacti SQL database has a list of all graphs and which host they are related to.

select host_id,count(*) from graph_local group by host_id;

Will give you a list broken down by host_id. Pull in the host description from the host table if you need it:

select host.description, host.id, count(*) from graph_local,host where graph_local.host_id=host.id group by host_id;

However you should also look at the Autom8 plugin, if what you are trying to achieve is something like: "Find all 'up' ethernet interfaces, and create a traffic graph for one's that don't already have one", or "Find all devices with Host Template XX, and add a graph for CPU usage if they don't have one". Autom8 will do this for you.

AnotherHowie
  • 206
  • 3
  • 13
  • Neat! I can run my other scripts with my existing conditions as long as I know on which host_id's to do it on which this will help me get. But yes deffo will check Autom8 – Recct Sep 16 '13 at 09:03