machine_info/
model.rs

1use serde::{Serialize, Deserialize};
2
3/// System status
4#[derive(Deserialize, Serialize, Debug)]
5#[serde(rename_all = "camelCase")]
6pub struct DiskUsage {
7    /// Name of the disk
8    pub name: String,
9    /// Total bytes used
10    pub used: u64,
11    /// Total disk capacity
12    pub total: u64,
13}
14
15/// Process usage
16#[derive(Deserialize, Serialize, Debug)]
17#[serde(rename_all = "camelCase")]
18pub struct Process {
19    /// Process identificator
20    pub pid: i32,
21    /// Cpu used as percentage
22    pub cpu: f64,
23    
24}
25
26/// Graphic card usage by process
27#[derive(Deserialize, Serialize, Debug)]
28#[serde(rename_all = "camelCase")]
29pub struct GraphicsProcessUtilization {
30    /// Process identificator
31    pub pid: u32,
32    /// Gpu identificator
33    pub gpu: u32,
34    /// Memory usage
35    pub memory: u32,
36    /// Gpu encoder utilization as percentage
37    pub encoder: u32,
38    /// Gpu decoder utilization as percentage
39    pub decoder: u32    
40}
41
42/// Graphic card usage summary
43#[derive(Deserialize, Serialize, Debug)]
44#[serde(rename_all = "camelCase")]
45pub struct GraphicsUsage {
46    /// Graphic card id
47    pub id: String,
48    /// Memory utilization as percentage
49    pub memory_usage: u32,
50    /// Memroy usage as bytes
51    pub memory_used: u64,
52    /// Gpu encoder utilization as percentage
53    pub encoder: u32,
54    /// Gpu decoder utilization as percentage
55    pub decoder: u32,
56    /// Gpu utilization as percentage
57    pub gpu: u32,
58    /// Gpu temperature
59    pub temperature: u32,
60    /// Processes using this GPU
61    pub processes: Vec<GraphicsProcessUtilization>
62}
63
64/// System global utilization
65#[derive(Deserialize, Serialize, Debug)]
66#[serde(rename_all = "camelCase")]
67pub struct SystemStatus {
68    /// Total memory used
69    pub memory: i32,
70    /// Total CPU used as percentage
71    pub cpu: i32,
72}
73
74/// Summary of the system
75#[derive(Deserialize, Serialize, Debug)]
76#[serde(rename_all = "camelCase")]
77pub struct SystemInfo {
78    /// Operating system name
79    pub os_name: String,
80    /// Running kernel version
81    pub kernel_version: String,
82    /// Operating system version
83    pub os_version: String,
84    /// System hostname
85    pub hostname: String,
86    /// Distribution id like ubuntu, neon, raspbian...
87    pub distribution: String,
88    /// Total memory of the machine
89    pub memory: u64,
90    /// Microprocessor description
91    pub processor: Processor,
92    /// Total amount of processors
93    pub total_processors: usize,
94    /// List of graphic cards
95    pub graphics: Vec<GraphicCard>,
96    /// List of available disks
97    pub disks: Vec<Disk>,
98    /// List of available cameras
99    pub cameras: Vec<Camera>,
100    /// Nvidia driver info
101    pub nvidia: Option<NvidiaInfo>,
102    /// If the machine supports vaapi
103    pub vaapi: bool,
104    /// Machine model. Some machines has special models like rpi
105    pub model: Option<String>
106}
107
108/// Information about microprocessor
109#[derive(Deserialize, Serialize, Debug)]
110#[serde(rename_all = "camelCase")]
111pub struct Processor {
112    /// Processor clock speed
113    pub frequency: u64,
114    /// Processor vendor
115    pub vendor: String,
116    /// Processor brand
117    pub brand: String
118}
119
120/// Information about a graphic card
121#[derive(Deserialize, Serialize, Debug)]
122#[serde(rename_all = "camelCase")]
123pub struct GraphicCard {
124    /// Device id
125    pub id: String,
126    /// Device id
127    pub name: String,
128    /// Device brand
129    pub brand: String,
130    /// Total memory
131    pub memory: u64,
132    /// Device temperature
133    pub temperature: u32
134}
135
136/// Information about a hard disk
137#[derive(Deserialize, Serialize, Debug)]
138#[serde(rename_all = "camelCase")]
139pub struct Disk {
140    /// Disk name
141    pub name: String,
142    /// Filesystem
143    pub fs: String,
144    /// Storage type (ssd, hd...)
145    pub storage_type: String,
146    /// Where it is mounted
147    pub mount_point: String,
148    /// Available space
149    pub available: u64,
150    /// Total size
151    pub size: u64
152}
153
154/// Connected camera information
155#[derive(Debug, Serialize, Deserialize)]
156#[serde(rename_all = "camelCase")]
157pub struct Camera {
158    /// The camera name
159    pub name: String,
160    /// Camera path like /dev/video0
161    pub path: String
162}
163
164/// Nvidia drivers configuration
165#[derive(Debug, Serialize, Deserialize)]
166#[serde(rename_all = "camelCase")]
167pub struct NvidiaInfo {
168     /// Nvidia drivers
169     pub driver_version: String,
170     /// NVML version
171     pub nvml_version: String,
172     /// Cuda version
173     pub cuda_version: i32,
174}