Ad Widget

Collapse

SQL query - Trends

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bobrivers
    Senior Member
    • Feb 2007
    • 115

    #1

    SQL query - Trends

    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).

    PHP Code:
    SELECT h.hostMAX(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 `hostshhosts_groups hgitems i
    WHERE h
    .hostid hg.hostid AND h.hostid i.hostid
    AND hg.groupid AND i.key_ LIKE '%pfree%'
    GROUP BY h.host 
  • prashants
    Junior Member
    • Dec 2008
    • 4

    #2
    Originally posted by bobrivers
    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

    Comment

    • bobrivers
      Senior Member
      • Feb 2007
      • 115

      #3
      Thanks

      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

      Comment

      Working...