[HOWTO] Create a list of all hosts with related graphs?

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

Post Reply
Chino77
Posts: 2
Joined: Thu Dec 03, 2009 3:22 am

[HOWTO] Create a list of all hosts with related graphs?

Post by Chino77 »

Hello,

I need a mysql-select-query to get the current hosts an their related graphs in a list, sorted by the hostname.

Can anybody help me out?

Thanks
Last edited by Chino77 on Wed Aug 11, 2010 2:26 am, edited 1 time in total.
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Post by noname »

For example:

Code: Select all

SELECT * FROM
        (
        SELECT * FROM
                (SELECT id, host_id FROM graph_local) AS g
        INNER JOIN
                (SELECT local_graph_id, title_cache FROM graph_templates_graph) AS t
        ON g.id = t.local_graph_id
        ) AS gt
INNER JOIN
        (SELECT id, description, hostname FROM host) AS h
ON gt.host_id = h.id
ORDER BY host_id;
Be careful with server load for big tables.

EDIT: I made a mistake. Use 'description' or 'hostname' instead of 'host_id' at the last line.
Chino77
Posts: 2
Joined: Thu Dec 03, 2009 3:22 am

Post by Chino77 »

Thank you!
Works perfectly!
User avatar
Hyperlord
Cacti User
Posts: 211
Joined: Tue Feb 10, 2009 3:24 am
Location: Frankfurt (a.M.), Germany

Post by Hyperlord »

Epic! Thanks!
Om Tat Sat
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest