Beispiel #1
0
 def test_1 (self):
     payload = CarbonPayload ()
     payload.append ("vps.netflow.%d.in"%(1), time.time (), 1*1024 * 1024)
     send_data (("127.0.0.1", 2004), payload.serialize ())
Beispiel #2
0
                                           (vps_id), ts, write_byte)
                            payload.append("vps.io.%d.swap.util" %
                                           (vps_id), ts, util)

            self.last_netflow = net_result
            self.last_diskstat = disk_result
            self.last_monitor_ts = ts
        except Exception, e:
            self.logger_misc.exception(e)
            return
        if payload.is_empty():
            self.logger_misc.info("no netflow data is to be sent")
            return
        if 'METRIC_SERVER' in dir(conf):
            try:
                send_data(conf.METRIC_SERVER, payload.serialize())
                self.logger_misc.info("monitor data sent")
            except Exception, e:
                self.logger_misc.exception(
                    "cannot send monitor data: %s" % (str(e)))

    def run_once(self, cmd, vps_id, vps_info):
        if not vps_info:
            return False
        h = self.handlers.get(cmd)
        if callable(h):
            try:
                if self._try_lock_vps(cmd, vps_id):
                    h(self, vps_info)
                    self._unlock_vps(cmd, vps_id)
                    return True
Beispiel #3
0
                                write_byte)
                            payload.append("vps.io.%d.swap.util" % (vps_id),
                                           ts, util)

            self.last_netflow = net_result
            self.last_diskstat = disk_result
            self.last_monitor_ts = ts
        except Exception, e:
            self.logger_misc.exception(e)
            return
        if payload.is_empty():
            self.logger_misc.info("no netflow data is to be sent")
            return
        if 'METRIC_SERVER' in dir(conf):
            try:
                send_data(conf.METRIC_SERVER, payload.serialize())
                self.logger_misc.info("monitor data sent")
            except Exception, e:
                self.logger_misc.exception("cannot send monitor data: %s" %
                                           (str(e)))

    def run_once(self, cmd, vps_id, vps_info):
        if not vps_info:
            return False
        h = self.handlers.get(cmd)
        if callable(h):
            try:
                if self._try_lock_vps(cmd, vps_id):
                    h(self, vps_info)
                    self._unlock_vps(cmd, vps_id)
                    return True