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.Frequency;
17 import javax.measure.quantity.Temperature;
18 import javax.measure.quantity.Time;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.library.dimension.DataAmount;
23 import org.openhab.core.library.types.DecimalType;
24 import org.openhab.core.library.types.PercentType;
25 import org.openhab.core.library.types.QuantityType;
26 import org.openhab.core.library.types.StringType;
29 * {@link SysteminfoInterface} defines the methods needed to provide this binding with the required system information.
31 * @author Svilen Valkanov - Initial contribution
32 * @author Wouter Born - Add null annotations
33 * @author Mark Herwege - Add dynamic creation of extra channels
34 * @author Mark Herwege - Use units of measure
35 * @author Mark Herwege - Processor frequency channels
38 public interface SysteminfoInterface {
41 * Initialize logic for the Systeminfo implementation
43 void initializeSysteminfo();
45 // Operating system info
47 * Get the Family of the operating system /e.g. Windows, Unix,.../
49 StringType getOsFamily();
52 * Get the manufacturer of the operating system
54 StringType getOsManufacturer();
57 * Get the version of the operating system
61 StringType getOsVersion();
65 * Get the name of the CPU
67 StringType getCpuName();
70 * Get description about the CPU e.g (model, family, vendor, serial number, identifier, architecture(32bit or
73 StringType getCpuDescription();
76 * Get the number of logical CPUs/cores available for processing.
78 DecimalType getCpuLogicalCores();
81 * Get the number of physical CPUs/cores available for processing.
83 DecimalType getCpuPhysicalCores();
86 * Get the maximum CPU frequency of the processor.
89 QuantityType<Frequency> getCpuMaxFreq();
92 * Get the current CPU frequency of a logical processor.
95 QuantityType<Frequency> getCpuFreq(int logicalProcessorIndex);
98 * Returns the system cpu load.
100 * @return the system cpu load between 0 and 100% or null, if no information is available
103 PercentType getSystemCpuLoad();
106 * Returns the system load average for the last minute.
108 * @return the load as a number of processes or null, if no information is available
111 DecimalType getCpuLoad1();
114 * Returns the system load average for the last 5 minutes.
116 * @return the load as number of processes or null, if no information is available
119 DecimalType getCpuLoad5();
122 * Returns the system load average for the last 15 minutes.
124 * @return the load as number of processes or null, if no information is available
127 DecimalType getCpuLoad15();
130 * Get the System uptime (time since boot).
132 * @return time since boot
134 QuantityType<Time> getCpuUptime();
137 * Get the number of threads currently running
139 * @return number of threads
141 DecimalType getCpuThreads();
145 * Returns total size of memory
147 * @return memory size
149 QuantityType<DataAmount> getMemoryTotal();
152 * Returns available size of memory
154 * @return memory size
156 QuantityType<DataAmount> getMemoryAvailable();
159 * Returns used size of memory
161 * @return memory size
163 QuantityType<DataAmount> getMemoryUsed();
166 * Percents of available memory on the machine
168 * @return percent of available memory or null, if no information is available
171 PercentType getMemoryAvailablePercent();
174 * Percents of used memory on the machine
176 * @return percent of used memory or null, if no information is available
179 PercentType getMemoryUsedPercent();
183 * Returns total size of swap memory
185 * @return memory size or 0, if there is no swap memory
187 QuantityType<DataAmount> getSwapTotal();
190 * Returns available size swap of memory
192 * @return memory size or 0, if no there is no swap memory
194 QuantityType<DataAmount> getSwapAvailable();
197 * Returns used size of swap memory
199 * @return memory size or 0, if no there is no swap memory
201 QuantityType<DataAmount> getSwapUsed();
204 * Percents of available swap memory on the machine
206 * @return percent of available memory or null, if no there is no swap memory
209 PercentType getSwapAvailablePercent();
212 * Percents of used swap memory on the machine
214 * @return percent of used memory or null, if no there is no swap memory
217 PercentType getSwapUsedPercent();
221 * Returns the total space of the logical storage volume.
223 * @param deviceIndex - the index of the logical volume
224 * @return storage size
225 * @throws DeviceNotFoundException
227 QuantityType<DataAmount> getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
230 * Returns the available storage space on the logical storage volume
232 * @param deviceIndex - the index of the logical volume
233 * @return storage size
234 * @throws DeviceNotFoundException
236 QuantityType<DataAmount> getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
239 * Gets the used storage space on the logical storage volume
241 * @param deviceIndex - the index of the logical volume
242 * @return storage size
243 * @throws DeviceNotFoundException
245 QuantityType<DataAmount> getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
248 * Gets the percent of available storage on the logical volume
250 * @param deviceIndex - the index of the logical volume
251 * @return percent of available storage or null
252 * @throws DeviceNotFoundException
255 PercentType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
258 * Gets the percent of used storage on the logical volume
260 * @param deviceIndex - the index of the logical volume
261 * @return percent of used storage or null
262 * @throws DeviceNotFoundException
265 PercentType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
268 * Gets the name of the logical storage volume
270 * @throws DeviceNotFoundException
272 StringType getStorageName(int deviceIndex) throws DeviceNotFoundException;
275 * Gets the type of the logical storage volume (e.g. NTFS, FAT32)
277 * @throws DeviceNotFoundException
279 StringType getStorageType(int deviceIndex) throws DeviceNotFoundException;
282 * Gets the description of the logical storage volume
284 * @throws DeviceNotFoundException
286 StringType getStorageDescription(int deviceIndex) throws DeviceNotFoundException;
288 // Hardware drive info
290 * Gets the name of the physical storage drive
292 * @param deviceIndex - index of the storage drive
293 * @throws DeviceNotFoundException
295 StringType getDriveName(int deviceIndex) throws DeviceNotFoundException;
298 * Gets the model of the physical storage drive
300 * @param deviceIndex - index of the storage drive
301 * @throws DeviceNotFoundException
303 StringType getDriveModel(int deviceIndex) throws DeviceNotFoundException;
306 * Gets the serial number of the physical storage drive
308 * @param deviceIndex - index of the storage drive
309 * @throws DeviceNotFoundException
311 StringType getDriveSerialNumber(int deviceIndex) throws DeviceNotFoundException;
315 * Get the Host IP address of the network.
317 * @param networkIndex - the index of the network
318 * @return 32-bit IPv4 address
319 * @throws DeviceNotFoundException
321 StringType getNetworkIp(int networkIndex) throws DeviceNotFoundException;
324 * Get the name of this network.
326 * @param networkIndex - the index of the network
327 * @throws DeviceNotFoundException
329 StringType getNetworkName(int networkIndex) throws DeviceNotFoundException;
332 * The description of the network. On some platforms, this is identical to the name.
334 * @param networkIndex - the index of the network
335 * @throws DeviceNotFoundException
337 StringType getNetworkDisplayName(int networkIndex) throws DeviceNotFoundException;
340 * Gets the MAC Address of the network.
342 * @param networkIndex - the index of the network
343 * @throws DeviceNotFoundException
345 StringType getNetworkMac(int networkIndex) throws DeviceNotFoundException;
348 * Get number of packets received
350 * @param networkIndex - the index of the network
351 * @throws DeviceNotFoundException
353 DecimalType getNetworkPacketsReceived(int networkIndex) throws DeviceNotFoundException;
356 * Get number of packets sent
358 * @param networkIndex - the index of the network
359 * @throws DeviceNotFoundException
361 DecimalType getNetworkPacketsSent(int networkIndex) throws DeviceNotFoundException;
364 * Get data sent for this network
366 * @param networkIndex - the index of the network
367 * @throws DeviceNotFoundException
369 QuantityType<DataAmount> getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
372 * Get data received for this network
374 * @param networkIndex - the index of the network
375 * @throws DeviceNotFoundException
377 QuantityType<DataAmount> getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
381 * Get information about the display device as product number, manufacturer, serial number, width and height in cm";
383 * @param deviceIndex - the index of the display device
384 * @throws DeviceNotFoundException
386 StringType getDisplayInformation(int deviceIndex) throws DeviceNotFoundException;
390 * Get the information from the CPU temperature sensors.
392 * @return Temperature if available, null otherwise.
395 QuantityType<Temperature> getSensorsCpuTemperature();
398 * Get the information for the CPU voltage.
400 * @return Voltage if available, null otherwise.
403 QuantityType<ElectricPotential> getSensorsCpuVoltage();
409 * @return Speed in rpm or null if unable to measure fan speed
410 * @throws DeviceNotFoundException
413 DecimalType getSensorsFanSpeed(int deviceIndex) throws DeviceNotFoundException;
417 * Get estimated time remaining for the power source.
420 * @return duration remaining charge or null, if the time is estimated as unlimited
421 * @throws DeviceNotFoundException
424 QuantityType<Time> getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
427 * Battery remaining capacity.
430 * @return percentage value
431 * @throws DeviceNotFoundException
433 PercentType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
439 * @throws DeviceNotFoundException
441 StringType getBatteryName(int deviceIndex) throws DeviceNotFoundException;
444 * Get PID of process executing this code
446 * @return current process ID
448 int getCurrentProcessID();
451 * Returns the name of the process
453 * @param pid - the PID of the process
454 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
457 StringType getProcessName(int pid) throws DeviceNotFoundException;
460 * Returns the CPU usage of the process
462 * @param pid - the PID of the process
463 * @return - percentage value, can be above 100% if process uses multiple cores
464 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
467 DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException;
470 * Returns the size of RAM memory only usage of the process
472 * @param pid - the PID of the process
473 * @return memory size
474 * @throws DeviceNotFoundException thrown if process with this PID can not be found
477 QuantityType<DataAmount> getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
480 * Returns the full path of the executing process.
482 * @param pid - the PID of the process
483 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
486 StringType getProcessPath(int pid) throws DeviceNotFoundException;
489 * Returns the number of threads in this process.
491 * @param pid - the PID of the process
492 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
495 DecimalType getProcessThreads(int pid) throws DeviceNotFoundException;
498 * Returns the number of network interfaces.
500 * @return network interface count
502 int getNetworkIFCount();
505 * Returns the number of displays.
507 * @return display count
509 int getDisplayCount();
512 * Returns the number of storages.
514 * @return storage count
516 int getFileOSStoreCount();
519 * Returns the number of power sources/batteries.
521 * @return power source count
523 int getPowerSourceCount();
526 * Returns the number of drives.
528 * @return drive count
533 * Returns the number of fans.