-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add new hardware and software metrics #11062
Changes from 7 commits
dccce70
99633f9
55c7358
909df21
706e4d3
c1e409f
a05159a
fff4573
3d15f0e
a8c71c1
d215b39
c1da1fa
b98bcfa
0d25408
46c9de2
56a1e3a
457b4da
bb26cfa
77f9c5f
73b230a
c3214e5
b6d78a0
19f43ab
15e5f9e
e5f210f
0cafbf8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // This file is part of Substrate. | ||
|
|
||
| // Copyright (C) 2022 Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| fn main() { | ||
| let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is always set in build scripts; qed"); | ||
| let out_dir = std::path::PathBuf::from(out_dir); | ||
| let target_os = std::env::var("CARGO_CFG_TARGET_OS") | ||
| .expect("CARGO_CFG_TARGET_OS is always set in build scripts; qed"); | ||
| let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH") | ||
| .expect("CARGO_CFG_TARGET_ARCH is always set in build scripts; qed"); | ||
| let target_env = std::env::var("CARGO_CFG_TARGET_ENV") | ||
| .expect("CARGO_CFG_TARGET_ENV is always set in build scripts; qed"); | ||
| std::fs::write(out_dir.join("target_os.txt"), target_os).unwrap(); | ||
| std::fs::write(out_dir.join("target_arch.txt"), target_arch).unwrap(); | ||
| std::fs::write(out_dir.join("target_env.txt"), target_env).unwrap(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,10 @@ use sp_runtime::{ | |
| }; | ||
| use std::{str::FromStr, sync::Arc, time::SystemTime}; | ||
|
|
||
| const TARGET_OS: &str = include_str!(concat!(env!("OUT_DIR"), "/target_os.txt")); | ||
| const TARGET_ARCH: &str = include_str!(concat!(env!("OUT_DIR"), "/target_arch.txt")); | ||
| const TARGET_ENV: &str = include_str!(concat!(env!("OUT_DIR"), "/target_env.txt")); | ||
|
|
||
| /// A utility trait for building an RPC extension given a `DenyUnsafe` instance. | ||
| /// This is useful since at service definition time we don't know whether the | ||
| /// specific interface where the RPC extension will be exposed is safe or not. | ||
|
|
@@ -487,8 +491,72 @@ where | |
| ) | ||
| .map_err(|e| Error::Application(Box::new(e)))?; | ||
|
|
||
| let database_path = match config.database { | ||
| sc_client_db::DatabaseSource::Auto { ref paritydb_path, ref rocksdb_path, .. } => | ||
| if rocksdb_path.exists() { | ||
| Some(rocksdb_path.as_path()) | ||
| } else { | ||
| Some(paritydb_path.as_path()) | ||
| }, | ||
| sc_client_db::DatabaseSource::RocksDb { ref path, .. } | | ||
| sc_client_db::DatabaseSource::ParityDb { ref path, .. } => Some(path.as_path()), | ||
| sc_client_db::DatabaseSource::Custom { .. } => None, | ||
| }; | ||
|
|
||
| let sysinfo = crate::sysinfo::gather_sysinfo(); | ||
| let hwbench = if config.disable_hardware_benchmarks { | ||
| None | ||
| } else { | ||
| Some(crate::sysinfo::gather_hwbench(database_path)) | ||
| }; | ||
|
|
||
| info!("💻 Operating system: {}", TARGET_OS); | ||
| info!("💻 CPU architecture: {}", TARGET_ARCH); | ||
| if !TARGET_ENV.is_empty() { | ||
| info!("💻 Target environment: {}", TARGET_ENV); | ||
| } | ||
|
||
| if let Some(ref cpu) = sysinfo.cpu { | ||
| info!("💻 CPU: {}", cpu); | ||
| } | ||
| if let Some(core_count) = sysinfo.core_count { | ||
| info!("💻 CPU cores: {}", core_count); | ||
| } | ||
| if let Some(memory) = sysinfo.memory { | ||
| info!("💻 Memory: {}MB", memory / (1024 * 1024)); | ||
| } | ||
| if let Some(ref linux_kernel) = sysinfo.linux_kernel { | ||
| info!("💻 Kernel: {}", linux_kernel); | ||
| } | ||
| if let Some(ref linux_distro) = sysinfo.linux_distro { | ||
| info!("💻 Linux distribution: {}", linux_distro); | ||
| } | ||
| if let Some(is_virtual_machine) = sysinfo.is_virtual_machine { | ||
| info!("💻 Virtual machine: {}", if is_virtual_machine { "yes" } else { "no" }); | ||
| } | ||
|
|
||
| if let Some(ref hwbench) = hwbench { | ||
| info!("🏁 CPU score: {}MB/s", hwbench.cpu_score); | ||
| info!("🏁 Memory score: {}MB/s", hwbench.memory_score); | ||
|
|
||
| if let Some(score) = hwbench.disk_sequential_write_score { | ||
| info!("🏁 Disk score (seq. writes): {}MB/s", score); | ||
| } | ||
| if let Some(score) = hwbench.disk_random_write_score { | ||
| info!("🏁 Disk score (rand. writes): {}MB/s", score); | ||
| } | ||
| } | ||
|
|
||
| let telemetry = telemetry | ||
| .map(|telemetry| init_telemetry(&mut config, network.clone(), client.clone(), telemetry)) | ||
| .map(|telemetry| { | ||
| init_telemetry( | ||
| &mut config, | ||
| network.clone(), | ||
| client.clone(), | ||
| telemetry, | ||
| Some(sysinfo), | ||
| hwbench, | ||
| ) | ||
| }) | ||
| .transpose()?; | ||
|
|
||
| info!("📦 Highest known block at #{}", chain_info.best_number); | ||
|
|
@@ -609,12 +677,17 @@ fn init_telemetry<TBl: BlockT, TCl: BlockBackend<TBl>>( | |
| network: Arc<NetworkService<TBl, <TBl as BlockT>::Hash>>, | ||
| client: Arc<TCl>, | ||
| telemetry: &mut Telemetry, | ||
| sysinfo: Option<sc_telemetry::SysInfo>, | ||
| hwbench: Option<sc_telemetry::HwBench>, | ||
| ) -> sc_telemetry::Result<TelemetryHandle> { | ||
| let genesis_hash = client.block_hash(Zero::zero()).ok().flatten().unwrap_or_default(); | ||
| let connection_message = ConnectionMessage { | ||
| name: config.network.node_name.to_owned(), | ||
| implementation: config.impl_name.to_owned(), | ||
| version: config.impl_version.to_owned(), | ||
| target_os: TARGET_OS.into(), | ||
| target_arch: TARGET_ARCH.into(), | ||
| target_env: TARGET_ENV.into(), | ||
| config: String::new(), | ||
| chain: config.chain_spec.name().to_owned(), | ||
| genesis_hash: format!("{:?}", genesis_hash), | ||
|
|
@@ -625,6 +698,8 @@ fn init_telemetry<TBl: BlockT, TCl: BlockBackend<TBl>>( | |
| .unwrap_or(0) | ||
| .to_string(), | ||
| network_id: network.local_peer_id().to_base58(), | ||
| sysinfo, | ||
| hwbench, | ||
| }; | ||
|
|
||
| telemetry.start_telemetry(connection_message)?; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.