2 * Copyright (c) 2010-2023 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 public void initializeSysteminfo();
43 // Operating system info
45 * Get the Family of the operating system /e.g. Windows,Unix,.../
47 public StringType getOsFamily();
50 * Get the manufacturer of the operating system
52 public StringType getOsManufacturer();
55 * Get the version of the operating system
59 public StringType getOsVersion();
63 * Get the name of the CPU
65 public StringType getCpuName();
68 * Get description about the CPU e.g (model, family, vendor, serial number, identifier, architecture(32bit or
71 public StringType getCpuDescription();
74 * Get the number of logical CPUs/cores available for processing.
76 public DecimalType getCpuLogicalCores();
79 * Get the number of physical CPUs/cores available for processing.
81 public 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
88 public @Nullable PercentType getSystemCpuLoad();
91 * Returns the system load average for the last minute.
93 * @return the load as a number of processes or null, if no information is available
95 public @Nullable DecimalType getCpuLoad1();
98 * Returns the system load average for the last 5 minutes.
100 * @return the load as number of processes or null, if no information is available
102 public @Nullable DecimalType getCpuLoad5();
105 * Returns the system load average for the last 15 minutes.
107 * @return the load as number of processes or null, if no information is available
109 public @Nullable DecimalType getCpuLoad15();
112 * Get the System uptime (time since boot).
114 * @return time since boot
116 public QuantityType<Time> getCpuUptime();
119 * Get the number of threads currently running
121 * @return number of threads
123 public DecimalType getCpuThreads();
127 * Returns total size of memory
129 * @return memory size
131 public QuantityType<DataAmount> getMemoryTotal();
134 * Returns available size of memory
136 * @return memory size
138 public QuantityType<DataAmount> getMemoryAvailable();
141 * Returns used size of memory
143 * @return memory size
145 public QuantityType<DataAmount> getMemoryUsed();
148 * Percents of available memory on the machine
150 * @return percent of available memory or null, if no information is available
152 public @Nullable PercentType getMemoryAvailablePercent();
155 * Percents of used memory on the machine
157 * @return percent of used memory or null, if no information is available
159 public @Nullable PercentType getMemoryUsedPercent();
163 * Returns total size of swap memory
165 * @return memory size or 0, if there is no swap memory
167 public QuantityType<DataAmount> getSwapTotal();
170 * Returns available size swap of memory
172 * @return memory size or 0, if no there is no swap memory
174 public QuantityType<DataAmount> getSwapAvailable();
177 * Returns used size of swap memory
179 * @return memory size or 0, if no there is no swap memory
181 public QuantityType<DataAmount> getSwapUsed();
184 * Percents of available swap memory on the machine
186 * @return percent of available memory or null, if no there is no swap memory
188 public @Nullable PercentType getSwapAvailablePercent();
191 * Percents of used swap memory on the machine
193 * @return percent of used memory or null, if no there is no swap memory
195 public @Nullable PercentType getSwapUsedPercent();
199 * Returns the total space of the logical storage volume.
201 * @param deviceIndex - the index of the logical volume
202 * @return storage size
203 * @throws DeviceNotFoundException
205 public QuantityType<DataAmount> getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
208 * Returns the available storage space on the logical storage volume
210 * @param deviceIndex - the index of the logical volume
211 * @return storage size
212 * @throws DeviceNotFoundException
214 public QuantityType<DataAmount> getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
217 * Gets the used storage space on the logical storage volume
219 * @param deviceIndex - the index of the logical volume
220 * @return storage size
221 * @throws DeviceNotFoundException
223 public QuantityType<DataAmount> getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
226 * Gets the percent of available storage on the logical volume
228 * @param deviceIndex - the index of the logical volume
229 * @return percent of available storage or null
230 * @throws DeviceNotFoundException
232 public @Nullable PercentType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
235 * Gets the percent of used storage on the logical volume
237 * @param deviceIndex - the index of the logical volume
238 * @return percent of used storage or null
239 * @throws DeviceNotFoundException
241 public @Nullable PercentType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
244 * Gets the name of the logical storage volume
246 * @throws DeviceNotFoundException
248 public StringType getStorageName(int deviceIndex) throws DeviceNotFoundException;
251 * Gets the type of the logical storage volume (e.g. NTFS, FAT32)
253 * @throws DeviceNotFoundException
255 public StringType getStorageType(int deviceIndex) throws DeviceNotFoundException;
258 * Gets the description of the logical storage volume
260 * @throws DeviceNotFoundException
262 public StringType getStorageDescription(int deviceIndex) throws DeviceNotFoundException;
264 // Hardware drive info
266 * Gets the name of the physical storage drive
268 * @param deviceIndex - index of the storage drive
269 * @throws DeviceNotFoundException
271 public StringType getDriveName(int deviceIndex) throws DeviceNotFoundException;
274 * Gets the model of the physical storage drive
276 * @param deviceIndex - index of the storage drive
277 * @throws DeviceNotFoundException
279 public StringType getDriveModel(int deviceIndex) throws DeviceNotFoundException;
282 * Gets the serial number of the physical storage drive
284 * @param deviceIndex - index of the storage drive
285 * @throws DeviceNotFoundException
287 public StringType getDriveSerialNumber(int deviceIndex) throws DeviceNotFoundException;
291 * Get the Host IP address of the network.
293 * @param networkIndex - the index of the network
294 * @return 32-bit IPv4 address
295 * @throws DeviceNotFoundException
297 public StringType getNetworkIp(int networkIndex) throws DeviceNotFoundException;
300 * Get the name of this network.
302 * @param networkIndex - the index of the network
303 * @throws DeviceNotFoundException
305 public StringType getNetworkName(int networkIndex) throws DeviceNotFoundException;
308 * The description of the network. On some platforms, this is identical to the name.
310 * @param networkIndex - the index of the network
311 * @throws DeviceNotFoundException
313 public StringType getNetworkDisplayName(int networkIndex) throws DeviceNotFoundException;
316 * Gets the MAC Address of the network.
318 * @param networkIndex - the index of the network
319 * @throws DeviceNotFoundException
321 public StringType getNetworkMac(int networkIndex) throws DeviceNotFoundException;
324 * Get number of packets received
326 * @param networkIndex - the index of the network
327 * @throws DeviceNotFoundException
329 public DecimalType getNetworkPacketsReceived(int networkIndex) throws DeviceNotFoundException;
332 * Get number of packets sent
334 * @param networkIndex - the index of the network
335 * @throws DeviceNotFoundException
337 public DecimalType getNetworkPacketsSent(int networkIndex) throws DeviceNotFoundException;
340 * Get data sent for this network
342 * @param networkIndex - the index of the network
343 * @throws DeviceNotFoundException
345 public QuantityType<DataAmount> getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
348 * Get data received for this network
350 * @param networkIndex - the index of the network
351 * @throws DeviceNotFoundException
353 public QuantityType<DataAmount> getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
357 * Get information about the display device as product number, manufacturer, serial number, width and height in cm";
359 * @param deviceIndex - the index of the display device
360 * @throws DeviceNotFoundException
362 public StringType getDisplayInformation(int deviceIndex) throws DeviceNotFoundException;
366 * Get the information from the CPU temperature sensors.
368 * @return Temperature if available, null otherwise.
370 public @Nullable QuantityType<Temperature> getSensorsCpuTemperature();
373 * Get the information for the CPU voltage.
375 * @return Voltage if available, null otherwise.
377 public @Nullable QuantityType<ElectricPotential> getSensorsCpuVoltage();
383 * @return Speed in rpm or null if unable to measure fan speed
384 * @throws DeviceNotFoundException
386 public @Nullable DecimalType getSensorsFanSpeed(int deviceIndex) throws DeviceNotFoundException;
390 * Get estimated time remaining for the power source.
393 * @return duration remaining charge or null, if the time is estimated as unlimited
394 * @throws DeviceNotFoundException
396 public @Nullable QuantityType<Time> getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
399 * Battery remaining capacity.
402 * @return percentage value
403 * @throws DeviceNotFoundException
405 public PercentType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
411 * @throws DeviceNotFoundException
413 public StringType getBatteryName(int deviceIndex) throws DeviceNotFoundException;
416 * Get PID of process executing this code
418 * @return current process ID
420 int getCurrentProcessID();
423 * Returns the name of the process
425 * @param pid - the PID of the process
426 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
428 public @Nullable StringType getProcessName(int pid) throws DeviceNotFoundException;
431 * Returns the CPU usage of the process
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
437 public @Nullable DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException;
440 * Returns the size of RAM memory only usage of the process
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
446 public @Nullable QuantityType<DataAmount> getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
449 * Returns the full path of the executing process.
451 * @param pid - the PID of the process
452 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
454 public @Nullable StringType getProcessPath(int pid) throws DeviceNotFoundException;
457 * Returns the number of threads in this process.
459 * @param pid - the PID of the process
460 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
462 public @Nullable DecimalType getProcessThreads(int pid) throws DeviceNotFoundException;
465 * Returns the number of network interfaces.
467 * @return network interface count
469 public int getNetworkIFCount();
472 * Returns the number of displays.
474 * @return display count
476 public int getDisplayCount();
479 * Returns the number of storages.
481 * @return storage count
483 public int getFileOSStoreCount();
486 * Returns the number of power sources/batteries.
488 * @return power source count
490 public int getPowerSourceCount();
493 * Returns the number of drives.
495 * @return drive count
497 public int getDriveCount();
500 * Returns the number of fans.