Hi,
I need to extract from database or via API (but I don't see any function to do it via API) the average value of one item in an elapsed time : one month.
The idea is to have for some network interfaces the average InOctet of the current month, in order to generate billing for our customers.
Here is what I have done:
- Select the itemid of the InOctet wanted : 97674
- Select first 2 values of the months about this item:
mysql> select * from trends_uint where itemid=97674 AND MONTH(FROM_UNIXTIME(clock))=MONTH(NOW()) LIMIT 0,2;
+--------+------------+-----+-----------+-----------+-----------+
| itemid | clock | num | value_min | value_avg | value_max |
+--------+------------+-----+-----------+-----------+-----------+
| 97674 | 1377986400 | 60 | 3800 | 4630 | 7144 |
| 97674 | 1377990000 | 59 | 832 | 4177 | 7720 |
+--------+------------+-----+-----------+-----------+-----------+
- Then, average the value_avg of these first 2 items:
mysql> select ROUND(AVG(value_avg)) from trends_uint where itemid=97674 AND MONTH(FROM_UNIXTIME(clock))=MONTH(NOW()) GROUP BY itemid LIMIT 0,2;
+-----------------------+
| ROUND(AVG(value_avg)) |
+-----------------------+
| 53063 |
+-----------------------+
Could someone tell me here I am wrong ?
Because my average value should be 4403 and I am getting 53063 ...
Thank youu
Regards
I need to extract from database or via API (but I don't see any function to do it via API) the average value of one item in an elapsed time : one month.
The idea is to have for some network interfaces the average InOctet of the current month, in order to generate billing for our customers.
Here is what I have done:
- Select the itemid of the InOctet wanted : 97674
- Select first 2 values of the months about this item:
mysql> select * from trends_uint where itemid=97674 AND MONTH(FROM_UNIXTIME(clock))=MONTH(NOW()) LIMIT 0,2;
+--------+------------+-----+-----------+-----------+-----------+
| itemid | clock | num | value_min | value_avg | value_max |
+--------+------------+-----+-----------+-----------+-----------+
| 97674 | 1377986400 | 60 | 3800 | 4630 | 7144 |
| 97674 | 1377990000 | 59 | 832 | 4177 | 7720 |
+--------+------------+-----+-----------+-----------+-----------+
- Then, average the value_avg of these first 2 items:
mysql> select ROUND(AVG(value_avg)) from trends_uint where itemid=97674 AND MONTH(FROM_UNIXTIME(clock))=MONTH(NOW()) GROUP BY itemid LIMIT 0,2;
+-----------------------+
| ROUND(AVG(value_avg)) |
+-----------------------+
| 53063 |
+-----------------------+
Could someone tell me here I am wrong ?
Because my average value should be 4403 and I am getting 53063 ...
Thank youu
Regards
Comment