PDA

View Full Version : SQL query - Trends


bobrivers
12-08-2009, 21:16
Hi,

I'm trying to build a sql query to calculate hard disk space consumption. I thought that I could search the "trends" table and search for the data that I want.

I was planning to get the oldest data for a specific item, then the newest data to this same item. Through the difference between this two values divided by the time gap (in days), I could determine the amount of space consumed.

But the problem is that the table trends doesn't have any data to the itemid that I need...

First I searched the hosts table and identified the hostid. Then I searched the items table and discovered the itemid.

Finally I'm searching the trends table with: SELECT * FROM trends t where t.itemid = 23944; (this item represents vfs.fs.size[c:,free])

Any advice? I thought that every monitored item should have data in trends table.

Thanks,

Bob.

Obs.: Just to share something: the following sql query displays a table with the available disk drive spaces in all monitored servers (windows).

SELECT h.host, MAX(IF(i.key_='vfs.fs.size[c:,pfree]', i.lastvalue, '')) AS 'c:',
MAX(IF(i.key_='vfs.fs.size[d:,pfree]', i.lastvalue, '')) AS 'd:',
MAX(IF(i.key_='vfs.fs.size[e:,pfree]', i.lastvalue, '')) AS 'e:'
FROM `hosts` h, hosts_groups hg, items i
WHERE h.hostid = hg.hostid AND h.hostid = i.hostid
AND hg.groupid = 3 AND i.key_ LIKE '%pfree%'
GROUP BY h.host

prashants
13-08-2009, 07:13
But the problem is that the table trends doesn't have any data to the itemid that I need...


Have you searched in "trends_uint" table?

-Prashant

bobrivers
13-08-2009, 15:45
I really forgot to look into this table... Yes, the data that I need is there. As soon as I develop the query I'll share it.

Thanks