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