2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.systeminfo.internal.model;
15 import javax.measure.quantity.ElectricPotential;
16 import javax.measure.quantity.Temperature;
17 import javax.measure.quantity.Time;
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;
28 * {@link SysteminfoInterface} defines the methods needed to provide this binding with the required system information.
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
36 public interface SysteminfoInterface {
39 * Initialize logic for the Systeminfo implementation
41 void initializeSysteminfo();
43 // Operating system info
45 * Get the Family of the operating system /e.g. Windows, Unix,.../
47 StringType getOsFamily();
50 * Get the manufacturer of the operating system
52 StringType getOsManufacturer();
55 * Get the version of the operating system
59 StringType getOsVersion();
63 * Get the name of the CPU
65 StringType getCpuName();
68 * Get description about the CPU e.g (model, family, vendor, serial number, identifier, architecture(32bit or
71 StringType getCpuDescription();
74 * Get the number of logical CPUs/cores available for processing.
76 DecimalType getCpuLogicalCores();
79 * Get the number of physical CPUs/cores available for processing.
81 DecimalType getCpuPhysicalCores();
84 * Returns the system cpu load.
86 * @return the system cpu load between 0 and 100% or null, if no information is available
89 PercentType getSystemCpuLoad();
92 * Returns the system load average for the last minute.
94 * @return the load as a number of processes or null, if no information is available
97 DecimalType getCpuLoad1();
100 * Returns the system load average for the last 5 minutes.
102 * @return the load as number of processes or null, if no information is available
105 DecimalType getCpuLoad5();
108 * Returns the system load average for the last 15 minutes.
110 * @return the load as number of processes or null, if no information is available
113 DecimalType getCpuLoad15();
116 * Get the System uptime (time since boot).
118 * @return time since boot
120 QuantityType<Time> getCpuUptime();
123 * Get the number of threads currently running
125 * @return number of threads
127 DecimalType getCpuThreads();
131 * Returns total size of memory
133 * @return memory size
135 QuantityType<DataAmount> getMemoryTotal();
138 * Returns available size of memory
140 * @return memory size
142 QuantityType<DataAmount> getMemoryAvailable();
145 * Returns used size of memory
147 * @return memory size
149 QuantityType<DataAmount> getMemoryUsed();
152 * Percents of available memory on the machine
154 * @return percent of available memory or null, if no information is available
157 PercentType getMemoryAvailablePercent();
160 * Percents of used memory on the machine
162 * @return percent of used memory or null, if no information is available
165 PercentType getMemoryUsedPercent();
169 * Returns total size of swap memory
171 * @return memory size or 0, if there is no swap memory
173 QuantityType<DataAmount> getSwapTotal();
176 * Returns available size swap of memory
178 * @return memory size or 0, if no there is no swap memory
180 QuantityType<DataAmount> getSwapAvailable();
183 * Returns used size of swap memory
185 * @return memory size or 0, if no there is no swap memory
187 QuantityType<DataAmount> getSwapUsed();
190 * Percents of available swap memory on the machine
192 * @return percent of available memory or null, if no there is no swap memory
195 PercentType getSwapAvailablePercent();
198 * Percents of used swap memory on the machine
200 * @return percent of used memory or null, if no there is no swap memory
203 PercentType getSwapUsedPercent();
207 * Returns the total space of the logical storage volume.
209 * @param deviceIndex - the index of the logical volume
210 * @return storage size
211 * @throws DeviceNotFoundException
213 QuantityType<DataAmount> getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
216 * Returns the available storage space on the logical storage volume
218 * @param deviceIndex - the index of the logical volume
219 * @return storage size
220 * @throws DeviceNotFoundException
222 QuantityType<DataAmount> getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
225 * Gets the used storage space on the logical storage volume
227 * @param deviceIndex - the index of the logical volume
228 * @return storage size
229 * @throws DeviceNotFoundException
231 QuantityType<DataAmount> getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
234 * Gets the percent of available storage on the logical volume
236 * @param deviceIndex - the index of the logical volume
237 * @return percent of available storage or null
238 * @throws DeviceNotFoundException
241 PercentType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
244 * Gets the percent of used storage on the logical volume
246 * @param deviceIndex - the index of the logical volume
247 * @return percent of used storage or null
248 * @throws DeviceNotFoundException
251 PercentType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
254 * Gets the name of the logical storage volume
256 * @throws DeviceNotFoundException
258 StringType getStorageName(int deviceIndex) throws DeviceNotFoundException;
261 * Gets the type of the logical storage volume (e.g. NTFS, FAT32)
263 * @throws DeviceNotFoundException
265 StringType getStorageType(int deviceIndex) throws DeviceNotFoundException;
268 * Gets the description of the logical storage volume
270 * @throws DeviceNotFoundException
272 StringType getStorageDescription(int deviceIndex) throws DeviceNotFoundException;
274 // Hardware drive info
276 * Gets the name of the physical storage drive
278 * @param deviceIndex - index of the storage drive
279 * @throws DeviceNotFoundException
281 StringType getDriveName(int deviceIndex) throws DeviceNotFoundException;
284 * Gets the model of the physical storage drive
286 * @param deviceIndex - index of the storage drive
287 * @throws DeviceNotFoundException
289 StringType getDriveModel(int deviceIndex) throws DeviceNotFoundException;
292 * Gets the serial number of the physical storage drive
294 * @param deviceIndex - index of the storage drive
295 * @throws DeviceNotFoundException
297 StringType getDriveSerialNumber(int deviceIndex) throws DeviceNotFoundException;
301 * Get the Host IP address of the network.
303 * @param networkIndex - the index of the network
304 * @return 32-bit IPv4 address
305 * @throws DeviceNotFoundException
307 StringType getNetworkIp(int networkIndex) throws DeviceNotFoundException;
310 * Get the name of this network.
312 * @param networkIndex - the index of the network
313 * @throws DeviceNotFoundException
315 StringType getNetworkName(int networkIndex) throws DeviceNotFoundException;
318 * The description of the network. On some platforms, this is identical to the name.
320 * @param networkIndex - the index of the network
321 * @throws DeviceNotFoundException
323 StringType getNetworkDisplayName(int networkIndex) throws DeviceNotFoundException;
326 * Gets the MAC Address of the network.
328 * @param networkIndex - the index of the network
329 * @throws DeviceNotFoundException
331 StringType getNetworkMac(int networkIndex) throws DeviceNotFoundException;
334 * Get number of packets received
336 * @param networkIndex - the index of the network
337 * @throws DeviceNotFoundException
339 DecimalType getNetworkPacketsReceived(int networkIndex) throws DeviceNotFoundException;
342 * Get number of packets sent
344 * @param networkIndex - the index of the network
345 * @throws DeviceNotFoundException
347 DecimalType getNetworkPacketsSent(int networkIndex) throws DeviceNotFoundException;
350 * Get data sent for this network
352 * @param networkIndex - the index of the network
353 * @throws DeviceNotFoundException
355 QuantityType<DataAmount> getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
358 * Get data received for this network
360 * @param networkIndex - the index of the network
361 * @throws DeviceNotFoundException
363 QuantityType<DataAmount> getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
367 * Get information about the display device as product number, manufacturer, serial number, width and height in cm";
369 * @param deviceIndex - the index of the display device
370 * @throws DeviceNotFoundException
372 StringType getDisplayInformation(int deviceIndex) throws DeviceNotFoundException;
376 * Get the information from the CPU temperature sensors.
378 * @return Temperature if available, null otherwise.
381 QuantityType<Temperature> getSensorsCpuTemperature();
384 * Get the information for the CPU voltage.
386 * @return Voltage if available, null otherwise.
389 QuantityType<ElectricPotential> getSensorsCpuVoltage();
395 * @return Speed in rpm or null if unable to measure fan speed
396 * @throws DeviceNotFoundException
399 DecimalType getSensorsFanSpeed(int deviceIndex) throws DeviceNotFoundException;
403 * Get estimated time remaining for the power source.
406 * @return duration remaining charge or null, if the time is estimated as unlimited
407 * @throws DeviceNotFoundException
410 QuantityType<Time> getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
413 * Battery remaining capacity.
416 * @return percentage value
417 * @throws DeviceNotFoundException
419 PercentType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
425 * @throws DeviceNotFoundException
427 StringType getBatteryName(int deviceIndex) throws DeviceNotFoundException;
430 * Get PID of process executing this code
432 * @return current process ID
434 int getCurrentProcessID();
437 * Returns the name of the process
439 * @param pid - the PID of the process
440 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
443 StringType getProcessName(int pid) throws DeviceNotFoundException;
446 * Returns the CPU usage of the process
448 * @param pid - the PID of the process
449 * @return - percentage value, can be above 100% if process uses multiple cores
450 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
453 DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException;
456 * Returns the size of RAM memory only usage of the process
458 * @param pid - the PID of the process
459 * @return memory size
460 * @throws DeviceNotFoundException thrown if process with this PID can not be found
463 QuantityType<DataAmount> getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
466 * Returns the full path of the executing process.
468 * @param pid - the PID of the process
469 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
472 StringType getProcessPath(int pid) throws DeviceNotFoundException;
475 * Returns the number of threads in this process.
477 * @param pid - the PID of the process
478 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
481 DecimalType getProcessThreads(int pid) throws DeviceNotFoundException;
484 * Returns the number of network interfaces.
486 * @return network interface count
488 int getNetworkIFCount();
491 * Returns the number of displays.
493 * @return display count
495 int getDisplayCount();
498 * Returns the number of storages.
500 * @return storage count
502 int getFileOSStoreCount();
505 * Returns the number of power sources/batteries.
507 * @return power source count
509 int getPowerSourceCount();
512 * Returns the number of drives.
514 * @return drive count
519 * Returns the number of fans.