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