1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! An unofficial interface for obtaining metrics from Supermicro BMCs.
//!
//! The following metrics are accessible:
//!
//! - **Sensor**: temperature, fan, voltage, power supply status, etc.
//! - **PMBus**: power consumption, fans, temperatures, etc. per power supply.
//!
//! This library depends on the BMC web interface being available.
//!
//! # Clients
//!
//! [`Client`] is async (Tokio); enable the `blocking` feature for
//! [`blocking::Client`]. Both log in on first use and refresh the session
//! when it expires.
//!
//! ```no_run
//! # async fn run() -> smbmc::Result<()> {
//! use smbmc::{Client, MetricKind};
//!
//! let client = Client::new("https://192.168.1.1", "ADMIN", "secret")?;
//! let metrics = client.metrics(&MetricKind::ALL).await?;
//! println!("{:#?}", metrics.pmbus);
//! # Ok(())
//! # }
//! ```
//!
//! # Features
//!
//! - `rustls` *(default)*: TLS via rustls.
//! - `native-tls`: TLS via the platform library instead.
//! - `blocking`: the synchronous [`blocking::Client`].
//! - `serde`: `Serialize`/`Deserialize` for the models.
//!
//! # Parsing only
//!
//! The parsing layer is independent of any HTTP client, so responses obtained
//! by other means can be decoded with [`parse_sensors`] and
//! [`parse_power_supplies`]:
//!
//! ```
//! let xml = r#"<?xml version="1.0"?>
//! <IPMI><SENSOR_INFO>
//! <SENSOR ID="001" NAME="System Temp" READING="19c000" OPTION="c0"
//! UNR="5a" UC="55" UNC="50" LNC="fb" LC="f9" LNR="f7" STYPE="01"
//! RTYPE="01" ERTYPE="01" UNIT1="80" UNIT="01" L="00" M="0100" B="0000" RB="00"/>
//! </SENSOR_INFO></IPMI>"#;
//!
//! let sensors = smbmc::parse_sensors(xml)?;
//! assert_eq!(sensors[0].name, "System Temp");
//! assert_eq!(sensors[0].reading, 25.0);
//! assert_eq!(sensors[0].unit, smbmc::SensorUnit::DegreesCelsius);
//! # Ok::<(), smbmc::Error>(())
//! ```
//!
//! Supermicro have released some BMC/IPMI code under the GPL, which has been
//! used as a reference; this crate is therefore licensed as GPL-3.0-only. It
//! is not associated with Super Micro Computer, Inc.
pub use Client;
pub use ;
pub use ;
pub use ;
pub use parse_power_supplies;
pub use parse_sensors;
/// Synchronous client (requires the `blocking` feature).