This commit is contained in:
parent
8d4f191d49
commit
af0b73cb27
|
|
@ -117,9 +117,8 @@ public class SystemMemoryMeasurementProvider extends StaticMeasurementProvider {
|
|||
long total = (long) SystemMonitor.totalSystemMemory.getValue();
|
||||
|
||||
info.max = total;
|
||||
info.used = (long) (total - SystemMonitor.freeSystemMemory.getValue());
|
||||
info.usage = BigDecimal.valueOf(((double)info.getUsed() / info.getMax()) * 100D).setScale(2, ROUND_HALF_UP)
|
||||
.doubleValue();
|
||||
info.used = (long) (total- SystemMonitor.freeSystemMemory.getValue());
|
||||
info.usage = BigDecimal.valueOf(((double) info.getUsed() / info.getMax()) * 100D).setScale(2, ROUND_HALF_UP).doubleValue();
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.jetlinks.community.dashboard.measurements;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
|
|
@ -64,8 +65,8 @@ public enum SystemMonitor {
|
|||
register(systemCpuUsage.name(), "getSystemCpuLoad", usage -> usage * 100D);
|
||||
register(jvmCpuUsage.name(), "getProcessCpuLoad", usage -> usage * 100D);
|
||||
register(freeSystemMemory.name(), "getFreePhysicalMemorySize", val -> val / 1024 / 1024);
|
||||
register(freeSystemMemory.name(), "getFreePhysicalMemorySize", val -> val / 1024 / 1024);
|
||||
register(totalSystemMemory.name(), "getTotalPhysicalMemorySize", val -> val / 1024 / 1024);
|
||||
register("virtualMemory", "getCommittedVirtualMemorySize", val -> val / 1024 / 1024);
|
||||
register(openFileCount.name(), "getOpenFileDescriptorCount", Function.identity());
|
||||
register(maxOpenFileCount.name(), "getMaxFileDescriptorCount", Function.identity());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.Setter;
|
||||
import org.hswebframework.web.authorization.annotation.Authorize;
|
||||
import org.hswebframework.web.authorization.annotation.Resource;
|
||||
import org.hswebframework.web.authorization.annotation.ResourceAction;
|
||||
import org.jetlinks.community.network.manager.web.response.TopicMessageResponse;
|
||||
import org.jetlinks.community.gateway.*;
|
||||
import org.jetlinks.community.gateway.supports.DeviceGatewayProvider;
|
||||
|
|
@ -26,7 +27,9 @@ public class MessageGatewayController {
|
|||
this.messageGatewayManager = gatewayManager;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/{id}/subscribe", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
@ResourceAction(id = "subscribe", name = "订阅消息")
|
||||
public Flux<TopicMessage> subscribe(@PathVariable String id, @RequestParam String topic) {
|
||||
|
||||
return messageGatewayManager
|
||||
|
|
@ -35,6 +38,7 @@ public class MessageGatewayController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/{id}/publish")
|
||||
@ResourceAction(id = "publish", name = "推送消息")
|
||||
public Mono<Long> publish(@PathVariable String id, @RequestBody TopicMessageResponse response) {
|
||||
return messageGatewayManager
|
||||
.getGateway(id)
|
||||
|
|
@ -44,6 +48,7 @@ public class MessageGatewayController {
|
|||
|
||||
|
||||
@GetMapping(value = "/all")
|
||||
@Authorize(merge = false)
|
||||
public Flux<GatewayInfo> getAllGateway() {
|
||||
return messageGatewayManager
|
||||
.getAllGateway()
|
||||
|
|
|
|||
Loading…
Reference in New Issue