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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
use serde::{Serialize, Deserialize};

/// System status
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DiskUsage {
    /// Name of the disk
    pub name: String,
    /// Total bytes used
    pub used: u64,
    /// Total disk capacity
    pub total: u64,
}

/// Process usage
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Process {
    /// Process identificator
    pub pid: i32,
    /// Cpu used as percentage
    pub cpu: f64,
    
}

/// Graphic card usage by process
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GraphicsProcessUtilization {
    /// Process identificator
    pub pid: u32,
    /// Gpu identificator
    pub gpu: u32,
    /// Memory usage
    pub memory: u32,
    /// Gpu encoder utilization as percentage
    pub encoder: u32,
    /// Gpu decoder utilization as percentage
    pub decoder: u32    
}

/// Graphic card usage summary
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GraphicsUsage {
    /// Graphic card id
    pub id: String,
    /// Memory utilization as percentage
    pub memory_usage: u32,
    /// Memroy usage as bytes
    pub memory_used: u64,
    /// Gpu encoder utilization as percentage
    pub encoder: u32,
    /// Gpu decoder utilization as percentage
    pub decoder: u32,
    /// Gpu utilization as percentage
    pub gpu: u32,
    /// Gpu temperature
    pub temperature: u32,
    /// Processes using this GPU
    pub processes: Vec<GraphicsProcessUtilization>
}

/// System global utilization
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SystemStatus {
    /// Total memory used
    pub memory: i32,
    /// Total CPU used as percentage
    pub cpu: i32,
}

/// Summary of the system
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SystemInfo {
    /// Operating system name
    pub os_name: String,
    /// Running kernel version
    pub kernel_version: String,
    /// Operating system version
    pub os_version: String,
    /// System hostname
    pub hostname: String,
    /// Distribution id like ubuntu, neon, raspbian...
    pub distribution: String,
    /// Total memory of the machine
    pub memory: u64,
    /// Microprocessor description
    pub processor: Processor,
    /// Total amount of processors
    pub total_processors: usize,
    /// List of graphic cards
    pub graphics: Vec<GraphicCard>,
    /// List of available disks
    pub disks: Vec<Disk>,
    /// List of available cameras
    pub cameras: Vec<Camera>,
    /// Nvidia driver info
    pub nvidia: Option<NvidiaInfo>,
    /// If the machine supports vaapi
    pub vaapi: bool,
    /// Machine model. Some machines has special models like rpi
    pub model: Option<String>
}

/// Information about microprocessor
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Processor {
    /// Processor clock speed
    pub frequency: u64,
    /// Processor vendor
    pub vendor: String,
    /// Processor brand
    pub brand: String
}

/// Information about a graphic card
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GraphicCard {
    /// Device id
    pub id: String,
    /// Device id
    pub name: String,
    /// Device brand
    pub brand: String,
    /// Total memory
    pub memory: u64,
    /// Device temperature
    pub temperature: u32
}

/// Information about a hard disk
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Disk {
    /// Disk name
    pub name: String,
    /// Filesystem
    pub fs: String,
    /// Storage type (ssd, hd...)
    pub storage_type: String,
    /// Where it is mounted
    pub mount_point: String,
    /// Available space
    pub available: u64,
    /// Total size
    pub size: u64
}

/// Connected camera information
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Camera {
    /// The camera name
    pub name: String,
    /// Camera path like /dev/video0
    pub path: String
}

/// Nvidia drivers configuration
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NvidiaInfo {
     /// Nvidia drivers
     pub driver_version: String,
     /// NVML version
     pub nvml_version: String,
     /// Cuda version
     pub cuda_version: i32,
}