function perform_connect() { got_failure = false; connected = $.Deferred(); http = cockpit.http("/var/run/docker.sock", { superuser: "******" }); connect_events(); if (watch && watch.valid) watch.close(); function got_info() { watch = cockpit.channel({ payload: "fslist1", path: self.info["DockerRootDir"], superuser: "******" }); $(watch) .on("message", function(event, data) { trigger_event(); }) .on("close", function(event, options) { if (options.problem && options.problem != "not-found") console.warn("monitor for docker directory failed: " + options.problem); }); $(self).off("info", got_info); } $(self).on("info", got_info); /* Starts fetching things */ $(self).triggerHandler("event"); usage_metrics_channel = cockpit.metrics(1000, { source: "internal", metrics: [ { name: "cgroup.memory.usage", units: "bytes" }, { name: "cgroup.cpu.usage", units: "millisec", derive: "rate" }, { name: "cgroup.memory.limit", units: "bytes" }, { name: "cgroup.cpu.shares", units: "count" } ] }); $(usage_metrics_channel).on("changed", function() { update_usage_grid(); }); usage_grid = cockpit.grid(1000, -1, -0); usage_metrics_channel.follow(); usage_grid.walk(); $(usage_grid).on('notify', function (event, index, count) { handle_usage_samples(); }); }
reset(x_range_seconds, x_stop_seconds) { if (this.flot) this.flot.clearSelection(true); // Fill the plot with about 1000 samples, but don't sample // faster than once per second. // // TODO - do this based on the actual size of the plot. this.interval = Math.ceil(x_range_seconds / 1000) * 1000; var x_offset; if (x_stop_seconds !== undefined) x_offset = (new Date().getTime()) - x_stop_seconds * 1000; else x_offset = 0; var beg = -Math.ceil((x_range_seconds * 1000 + x_offset) / this.interval); var end = -Math.floor(x_offset / this.interval); if (this.grid && this.grid.interval == this.interval) { this.grid.move(beg, end); } else { if (this.grid) this.grid.close(); this.grid = cockpit.grid(this.interval, beg, end); this.sync_suppressed++; for (var i = 0; i < this.series.length; i++) { this.series[i].stop(); this.series[i].interval = this.interval; this.series[i].grid = this.grid; this.series[i].reset_series(); } this.sync_suppressed--; this.sync(); $(this.grid).on('notify', (event, index, count) => { this.refresh(); }); } }