]> git.basschouten.com Git - openhab-addons.git/blob
d19f3c1bacf95713c8842983823822bea5e871c2
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.systeminfo.internal.model;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.library.types.DecimalType;
18 import org.openhab.core.library.types.StringType;
19
20 /**
21  * {@link SysteminfoInterface} defines the methods needed to provide this binding with the required system information.
22  *
23  * @author Svilen Valkanov - Initial contribution
24  * @author Wouter Born - Add null annotations
25  */
26 @NonNullByDefault
27 public interface SysteminfoInterface {
28
29     /**
30      * Initialize logic for the Systeminfo implementation
31      */
32     public void initializeSysteminfo();
33
34     // Operating system info
35     /**
36      * Get the Family of the operating system /e.g. Windows,Unix,.../
37      */
38     public StringType getOsFamily();
39
40     /**
41      * Get the manufacturer of the operating system
42      */
43     public StringType getOsManufacturer();
44
45     /**
46      * Get the version of the operating system
47      *
48      * @return
49      */
50     public StringType getOsVersion();
51
52     // CPU info
53     /**
54      * Get the name of the CPU
55      */
56     public StringType getCpuName();
57
58     /**
59      * Get description about the CPU e.g (model, family, vendor, serial number, identifier, architecture(32bit or
60      * 64bit))
61      */
62     public StringType getCpuDescription();
63
64     /**
65      * Get the number of logical CPUs/cores available for processing.
66      */
67     public DecimalType getCpuLogicalCores();
68
69     /**
70      * Get the number of physical CPUs/cores available for processing.
71      */
72     public DecimalType getCpuPhysicalCores();
73
74     /**
75      * Returns the system load average for the last minute.
76      *
77      * @return the load as a number of processes or null, if no information is available
78      */
79     public @Nullable DecimalType getCpuLoad1();
80
81     /**
82      * Returns the system load average for the last 5 minutes.
83      *
84      * @return the load as number of processes or null, if no information is available
85      */
86     public @Nullable DecimalType getCpuLoad5();
87
88     /**
89      * Returns the system load average for the last 15 minutes.
90      *
91      * @return the load as number of processes or null, if no information is available
92      */
93     public @Nullable DecimalType getCpuLoad15();
94
95     /**
96      * Get the System uptime (time since boot).
97      *
98      * @return time in minutes since boot
99      */
100     public DecimalType getCpuUptime();
101
102     /**
103      * Get the number of threads currently running
104      *
105      * @return number of threads
106      */
107     public DecimalType getCpuThreads();
108
109     // Memory info
110     /**
111      * Returns total size of memory
112      *
113      * @return memory size in MB
114      */
115     public DecimalType getMemoryTotal();
116
117     /**
118      * Returns available size of memory
119      *
120      * @return memory size in MB
121      */
122     public DecimalType getMemoryAvailable();
123
124     /**
125      * Returns used size of memory
126      *
127      * @return memory size in MB
128      */
129     public DecimalType getMemoryUsed();
130
131     /**
132      * Percents of available memory on the machine
133      *
134      * @return percent of available memory or null, if no information is available
135      */
136     public @Nullable DecimalType getMemoryAvailablePercent();
137
138     /**
139      * Percents of used memory on the machine
140      *
141      * @return percent of used memory or null, if no information is available
142      */
143     public @Nullable DecimalType getMemoryUsedPercent();
144
145     // Swap memory info
146     /**
147      * Returns total size of swap memory
148      *
149      * @return memory size in MB or 0, if no there is no swap memory
150      */
151     public @Nullable DecimalType getSwapTotal();
152
153     /**
154      * Returns available size swap of memory
155      *
156      * @return memory size in MB or 0, if no there is no swap memory
157      */
158     public @Nullable DecimalType getSwapAvailable();
159
160     /**
161      * Returns used size of swap memory
162      *
163      * @return memory size in MB or 0, if no there is no swap memory
164      */
165     public @Nullable DecimalType getSwapUsed();
166
167     /**
168      * Percents of available swap memory on the machine
169      *
170      * @return percent of available memory or null, if no there is no swap memory
171      */
172     public @Nullable DecimalType getSwapAvailablePercent();
173
174     /**
175      * Percents of used swap memory on the machine
176      *
177      * @return percent of used memory or null, if no there is no swap memory
178      */
179     public @Nullable DecimalType getSwapUsedPercent();
180
181     // Storage info
182     /**
183      * Returns the total space of the logical storage volume.
184      *
185      * @param deviceIndex - the index of the logical volume
186      * @return storage size in MB
187      * @throws DeviceNotFoundException
188      */
189     public DecimalType getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
190
191     /**
192      * Returns the available storage space on the logical storage volume
193      *
194      * @param deviceIndex - the index of the logical volume
195      * @return storage size in MB
196      * @throws DeviceNotFoundException
197      */
198     public DecimalType getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
199
200     /**
201      * Gets the used storage space on the logical storage volume
202      *
203      * @param deviceIndex - the index of the logical volume
204      * @return storage size in MB
205      * @throws DeviceNotFoundException
206      */
207     public DecimalType getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
208
209     /**
210      * Gets the percent of available storage on the logical volume
211      *
212      * @param deviceIndex - the index of the logical volume
213      * @return percent of available storage or null
214      * @throws DeviceNotFoundException
215      */
216     public @Nullable DecimalType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
217
218     /**
219      * Gets the percent of used storage on the logical volume
220      *
221      * @param deviceIndex - the index of the logical volume
222      * @return percent of used storage or null
223      * @throws DeviceNotFoundException
224      */
225     public @Nullable DecimalType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
226
227     /**
228      * Gets the name of the logical storage volume
229      *
230      * @throws DeviceNotFoundException
231      */
232     public StringType getStorageName(int deviceIndex) throws DeviceNotFoundException;
233
234     /**
235      * Gets the type of the logical storage volume (e.g. NTFS, FAT32)
236      *
237      * @throws DeviceNotFoundException
238      */
239     public StringType getStorageType(int deviceIndex) throws DeviceNotFoundException;
240
241     /**
242      * Gets the description of the logical storage volume
243      *
244      * @throws DeviceNotFoundException
245      */
246     public StringType getStorageDescription(int deviceIndex) throws DeviceNotFoundException;
247
248     // Hardware drive info
249     /**
250      * Gets the name of the physical storage drive
251      *
252      * @param deviceIndex - index of the storage drive
253      * @throws DeviceNotFoundException
254      */
255     public StringType getDriveName(int deviceIndex) throws DeviceNotFoundException;
256
257     /**
258      * Gets the model of the physical storage drive
259      *
260      * @param deviceIndex - index of the storage drive
261      * @throws DeviceNotFoundException
262      */
263     public StringType getDriveModel(int deviceIndex) throws DeviceNotFoundException;
264
265     /**
266      * Gets the serial number of the physical storage drive
267      *
268      * @param deviceIndex - index of the storage drive
269      * @throws DeviceNotFoundException
270      */
271     public StringType getDriveSerialNumber(int deviceIndex) throws DeviceNotFoundException;
272
273     // Network info
274     /**
275      * Get the Host IP address of the network.
276      *
277      * @param networkIndex - the index of the network
278      * @return 32-bit IPv4 address
279      * @throws DeviceNotFoundException
280      */
281     public StringType getNetworkIp(int networkIndex) throws DeviceNotFoundException;
282
283     /**
284      * Get the name of this network.
285      *
286      * @param networkIndex - the index of the network
287      * @throws DeviceNotFoundException
288      */
289     public StringType getNetworkName(int networkIndex) throws DeviceNotFoundException;
290
291     /**
292      * The description of the network. On some platforms, this is identical to the name.
293      *
294      * @param networkIndex - the index of the network
295      * @throws DeviceNotFoundException
296      */
297     public StringType getNetworkDisplayName(int networkIndex) throws DeviceNotFoundException;
298
299     /**
300      * Gets the MAC Address of the network.
301      *
302      * @param networkIndex - the index of the network
303      * @throws DeviceNotFoundException
304      */
305     public StringType getNetworkMac(int networkIndex) throws DeviceNotFoundException;
306
307     /**
308      * Get number of packets received
309      *
310      * @param networkIndex - the index of the network
311      * @throws DeviceNotFoundException
312      */
313     public DecimalType getNetworkPacketsReceived(int networkIndex) throws DeviceNotFoundException;
314
315     /**
316      * Get number of packets sent
317      *
318      * @param networkIndex - the index of the network
319      * @throws DeviceNotFoundException
320      */
321     public DecimalType getNetworkPacketsSent(int networkIndex) throws DeviceNotFoundException;
322
323     /**
324      * Get data sent in MB for this network
325      *
326      * @param networkIndex - the index of the network
327      * @throws DeviceNotFoundException
328      */
329     public DecimalType getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
330
331     /**
332      * Get data received in MB for this network
333      *
334      * @param networkIndex - the index of the network
335      * @throws DeviceNotFoundException
336      */
337     public DecimalType getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
338
339     // Display info
340     /**
341      * Get information about the display device as product number, manufacturer, serial number, width and height in cm";
342      *
343      * @param deviceIndex - the index of the display device
344      * @throws DeviceNotFoundException
345      */
346     public StringType getDisplayInformation(int deviceIndex) throws DeviceNotFoundException;
347
348     // Sensors info
349     /**
350      * Get the information from the CPU temperature sensors.
351      *
352      * @return Temperature in degrees Celsius if available, null otherwise.
353      */
354     public @Nullable DecimalType getSensorsCpuTemperature();
355
356     /**
357      * Get the information for the CPU voltage.
358      *
359      * @return Voltage in Volts if available, null otherwise.
360      */
361     public @Nullable DecimalType getSensorsCpuVoltage();
362
363     /**
364      * Get fan speed
365      *
366      * @param deviceIndex
367      * @return Speed in rpm or null if unable to measure fan speed
368      * @throws DeviceNotFoundException
369      */
370     public @Nullable DecimalType getSensorsFanSpeed(int deviceIndex) throws DeviceNotFoundException;
371
372     // Battery info
373     /**
374      * Get estimated time remaining for the power source.
375      *
376      * @param deviceIndex
377      * @return minutes remaining charge or null, if the time is estimated as unlimited
378      * @throws DeviceNotFoundException
379      */
380     public @Nullable DecimalType getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
381
382     /**
383      * Battery remaining capacity.
384      *
385      * @param deviceIndex
386      * @return percentage value /0-100/
387      * @throws DeviceNotFoundException
388      */
389     public DecimalType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
390
391     /**
392      * Get battery name
393      *
394      * @param deviceIndex
395      * @throws DeviceNotFoundException
396      */
397     public StringType getBatteryName(int deviceIndex) throws DeviceNotFoundException;
398
399     /**
400      * Returns the name of the process
401      *
402      * @param pid - the PID of the process
403      * @throws DeviceNotFoundException - thrown if process with this PID can not be found
404      */
405     public @Nullable StringType getProcessName(int pid) throws DeviceNotFoundException;
406
407     /**
408      * Returns the CPU usage of the process
409      *
410      * @param pid - the PID of the process
411      * @return - percentage value /0-100/
412      * @throws DeviceNotFoundException - thrown if process with this PID can not be found
413      */
414     public @Nullable DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException;
415
416     /**
417      * Returns the size of RAM memory only usage of the process
418      *
419      * @param pid - the PID of the process
420      * @return memory size in MB
421      * @throws DeviceNotFoundException- thrown if process with this PID can not be found
422      */
423     public @Nullable DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
424
425     /**
426      * Returns the full path of the executing process.
427      *
428      * @param pid - the PID of the process
429      * @throws DeviceNotFoundException - thrown if process with this PID can not be found
430      */
431     public @Nullable StringType getProcessPath(int pid) throws DeviceNotFoundException;
432
433     /**
434      * Returns the number of threads in this process.
435      *
436      * @param pid - the PID of the process
437      * @throws DeviceNotFoundException - thrown if process with this PID can not be found
438      */
439     public @Nullable DecimalType getProcessThreads(int pid) throws DeviceNotFoundException;
440 }