gaugesEngine.js 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. *
  3. *
  4. */
  5. function MySQLBackendGaugesEngine() {
  6. var self = this;
  7. }
  8. /**
  9. *
  10. *
  11. */
  12. MySQLBackendGaugesEngine.prototype.buildQuerries = function(gauges, time_stamp) {
  13. var querries = [];
  14. // Iterate on each gauge
  15. for(var gaugeName in gauges) {
  16. var gaugeValue = gauges[gaugeName];
  17. if(gaugeValue === 0) {
  18. continue;
  19. } else {
  20. /**********************************************************************
  21. * Edit following line to custumize where statsd datas are inserted
  22. *
  23. * Parameters :
  24. * - userCounterName: Counter name
  25. * - counterValue: Counter value
  26. */
  27. querries.push("insert into `gauges_statistics` values ("+time_stamp+", '"+gaugeName+"', "+gaugeValue+");");
  28. }
  29. }
  30. return querries;
  31. }
  32. /**
  33. *
  34. *
  35. */
  36. exports.init = function() {
  37. var instance = new MySQLBackendGaugesEngine();
  38. return instance;
  39. };