mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
add ios to cfg gates in client/service (#6622)
* done * sysinfo should not be not android * add back sysinfo dep to satisfy web wasm ci
This commit is contained in:
@@ -76,8 +76,7 @@ sc-tracing = { version = "2.0.0-rc4", path = "../tracing" }
|
|||||||
tracing = "0.1.10"
|
tracing = "0.1.10"
|
||||||
parity-util-mem = { version = "0.7.0", default-features = false, features = ["primitive-types"] }
|
parity-util-mem = { version = "0.7.0", default-features = false, features = ["primitive-types"] }
|
||||||
|
|
||||||
|
[target.'cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))'.dependencies]
|
||||||
[target.'cfg(all(any(unix, windows), not(target_os = "android")))'.dependencies]
|
|
||||||
netstat2 = "0.8.1"
|
netstat2 = "0.8.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ use sc_network::config::Role;
|
|||||||
|
|
||||||
use sysinfo::{self, ProcessExt, SystemExt};
|
use sysinfo::{self, ProcessExt, SystemExt};
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
use netstat2::{
|
use netstat2::{
|
||||||
TcpState, ProtocolSocketInfo, iterate_sockets_info, AddressFamilyFlags, ProtocolFlags,
|
TcpState, ProtocolSocketInfo, iterate_sockets_info, AddressFamilyFlags, ProtocolFlags,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PrometheusMetrics {
|
struct PrometheusMetrics {
|
||||||
// system
|
// system
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
load_avg: GaugeVec<F64>,
|
load_avg: GaugeVec<F64>,
|
||||||
|
|
||||||
// process
|
// process
|
||||||
@@ -45,7 +45,7 @@ struct PrometheusMetrics {
|
|||||||
threads: Gauge<U64>,
|
threads: Gauge<U64>,
|
||||||
open_files: GaugeVec<U64>,
|
open_files: GaugeVec<U64>,
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
netstat: GaugeVec<U64>,
|
netstat: GaugeVec<U64>,
|
||||||
|
|
||||||
// -- inner counters
|
// -- inner counters
|
||||||
@@ -89,7 +89,7 @@ impl PrometheusMetrics {
|
|||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
// system
|
// system
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
load_avg: register(GaugeVec::new(
|
load_avg: register(GaugeVec::new(
|
||||||
Opts::new("load_avg", "System load average"),
|
Opts::new("load_avg", "System load average"),
|
||||||
&["over"]
|
&["over"]
|
||||||
@@ -104,7 +104,7 @@ impl PrometheusMetrics {
|
|||||||
"cpu_usage_percentage", "Node CPU usage",
|
"cpu_usage_percentage", "Node CPU usage",
|
||||||
)?, registry)?,
|
)?, registry)?,
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
netstat: register(GaugeVec::new(
|
netstat: register(GaugeVec::new(
|
||||||
Opts::new("netstat_tcp", "Current TCP connections "),
|
Opts::new("netstat_tcp", "Current TCP connections "),
|
||||||
&["status"]
|
&["status"]
|
||||||
@@ -154,7 +154,7 @@ impl PrometheusMetrics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ConnectionsCount {
|
struct ConnectionsCount {
|
||||||
listen: u64,
|
listen: u64,
|
||||||
@@ -186,7 +186,7 @@ struct ProcessInfo {
|
|||||||
|
|
||||||
pub struct MetricsService {
|
pub struct MetricsService {
|
||||||
metrics: Option<PrometheusMetrics>,
|
metrics: Option<PrometheusMetrics>,
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
system: sysinfo::System,
|
system: sysinfo::System,
|
||||||
pid: Option<sysinfo::Pid>,
|
pid: Option<sysinfo::Pid>,
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ impl MetricsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "linux")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios"), not(target_os = "linux")))]
|
||||||
impl MetricsService {
|
impl MetricsService {
|
||||||
fn inner_new(metrics: Option<PrometheusMetrics>) -> Self {
|
fn inner_new(metrics: Option<PrometheusMetrics>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -245,7 +245,7 @@ impl MetricsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(not(all(any(unix, windows), not(target_os = "android"))))]
|
#[cfg(not(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios"))))]
|
||||||
impl MetricsService {
|
impl MetricsService {
|
||||||
fn inner_new(metrics: Option<PrometheusMetrics>) -> Self {
|
fn inner_new(metrics: Option<PrometheusMetrics>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -280,7 +280,7 @@ impl MetricsService {
|
|||||||
Self::inner_new(None)
|
Self::inner_new(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
fn process_info_for(&mut self, pid: &sysinfo::Pid) -> ProcessInfo {
|
fn process_info_for(&mut self, pid: &sysinfo::Pid) -> ProcessInfo {
|
||||||
let mut info = ProcessInfo::default();
|
let mut info = ProcessInfo::default();
|
||||||
if self.system.refresh_process(*pid) {
|
if self.system.refresh_process(*pid) {
|
||||||
@@ -292,7 +292,7 @@ impl MetricsService {
|
|||||||
info
|
info
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
fn connections_info(&self) -> Option<ConnectionsCount> {
|
fn connections_info(&self) -> Option<ConnectionsCount> {
|
||||||
self.pid.as_ref().and_then(|pid| {
|
self.pid.as_ref().and_then(|pid| {
|
||||||
let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;
|
let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;
|
||||||
@@ -423,7 +423,7 @@ impl MetricsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android"), not(target_os = "ios")))]
|
||||||
{
|
{
|
||||||
let load = self.system.get_load_average();
|
let load = self.system.get_load_average();
|
||||||
metrics.load_avg.with_label_values(&["1min"]).set(load.one);
|
metrics.load_avg.with_label_values(&["1min"]).set(load.one);
|
||||||
|
|||||||
Reference in New Issue
Block a user