2 * Copyright (c) 2010-2022 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 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;
22 * {@link SysteminfoInterface} defines the methods needed to provide this binding with the required system information.
24 * @author Svilen Valkanov - Initial contribution
25 * @author Wouter Born - Add null annotations
26 * @author Mark Herwege - Add dynamic creation of extra channels
29 public interface SysteminfoInterface {
32 * Initialize logic for the Systeminfo implementation
34 public void initializeSysteminfo();
36 // Operating system info
38 * Get the Family of the operating system /e.g. Windows,Unix,.../
40 public StringType getOsFamily();
43 * Get the manufacturer of the operating system
45 public StringType getOsManufacturer();
48 * Get the version of the operating system
52 public StringType getOsVersion();
56 * Get the name of the CPU
58 public StringType getCpuName();
61 * Get description about the CPU e.g (model, family, vendor, serial number, identifier, architecture(32bit or
64 public StringType getCpuDescription();
67 * Get the number of logical CPUs/cores available for processing.
69 public DecimalType getCpuLogicalCores();
72 * Get the number of physical CPUs/cores available for processing.
74 public DecimalType getCpuPhysicalCores();
77 * Returns the system cpu load.
79 * @return the system cpu load between 0 and 1 or null, if no information is available
81 public @Nullable PercentType getSystemCpuLoad();
84 * Returns the system load average for the last minute.
86 * @return the load as a number of processes or null, if no information is available
88 public @Nullable DecimalType getCpuLoad1();
91 * Returns the system load average for the last 5 minutes.
93 * @return the load as number of processes or null, if no information is available
95 public @Nullable DecimalType getCpuLoad5();
98 * Returns the system load average for the last 15 minutes.
100 * @return the load as number of processes or null, if no information is available
102 public @Nullable DecimalType getCpuLoad15();
105 * Get the System uptime (time since boot).
107 * @return time in minutes since boot
109 public DecimalType getCpuUptime();
112 * Get the number of threads currently running
114 * @return number of threads
116 public DecimalType getCpuThreads();
120 * Returns total size of memory
122 * @return memory size in MB
124 public DecimalType getMemoryTotal();
127 * Returns available size of memory
129 * @return memory size in MB
131 public DecimalType getMemoryAvailable();
134 * Returns used size of memory
136 * @return memory size in MB
138 public DecimalType getMemoryUsed();
141 * Percents of available memory on the machine
143 * @return percent of available memory or null, if no information is available
145 public @Nullable DecimalType getMemoryAvailablePercent();
148 * Percents of used memory on the machine
150 * @return percent of used memory or null, if no information is available
152 public @Nullable DecimalType getMemoryUsedPercent();
156 * Returns total size of swap memory
158 * @return memory size in MB or 0, if no there is no swap memory
160 public @Nullable DecimalType getSwapTotal();
163 * Returns available size swap of memory
165 * @return memory size in MB or 0, if no there is no swap memory
167 public @Nullable DecimalType getSwapAvailable();
170 * Returns used size of swap memory
172 * @return memory size in MB or 0, if no there is no swap memory
174 public @Nullable DecimalType getSwapUsed();
177 * Percents of available swap memory on the machine
179 * @return percent of available memory or null, if no there is no swap memory
181 public @Nullable DecimalType getSwapAvailablePercent();
184 * Percents of used swap memory on the machine
186 * @return percent of used memory or null, if no there is no swap memory
188 public @Nullable DecimalType getSwapUsedPercent();
192 * Returns the total space of the logical storage volume.
194 * @param deviceIndex - the index of the logical volume
195 * @return storage size in MB
196 * @throws DeviceNotFoundException
198 public DecimalType getStorageTotal(int deviceIndex) throws DeviceNotFoundException;
201 * Returns the available storage space on the logical storage volume
203 * @param deviceIndex - the index of the logical volume
204 * @return storage size in MB
205 * @throws DeviceNotFoundException
207 public DecimalType getStorageAvailable(int deviceIndex) throws DeviceNotFoundException;
210 * Gets the used storage space on the logical storage volume
212 * @param deviceIndex - the index of the logical volume
213 * @return storage size in MB
214 * @throws DeviceNotFoundException
216 public DecimalType getStorageUsed(int deviceIndex) throws DeviceNotFoundException;
219 * Gets the percent of available storage on the logical volume
221 * @param deviceIndex - the index of the logical volume
222 * @return percent of available storage or null
223 * @throws DeviceNotFoundException
225 public @Nullable DecimalType getStorageAvailablePercent(int deviceIndex) throws DeviceNotFoundException;
228 * Gets the percent of used storage on the logical volume
230 * @param deviceIndex - the index of the logical volume
231 * @return percent of used storage or null
232 * @throws DeviceNotFoundException
234 public @Nullable DecimalType getStorageUsedPercent(int deviceIndex) throws DeviceNotFoundException;
237 * Gets the name of the logical storage volume
239 * @throws DeviceNotFoundException
241 public StringType getStorageName(int deviceIndex) throws DeviceNotFoundException;
244 * Gets the type of the logical storage volume (e.g. NTFS, FAT32)
246 * @throws DeviceNotFoundException
248 public StringType getStorageType(int deviceIndex) throws DeviceNotFoundException;
251 * Gets the description of the logical storage volume
253 * @throws DeviceNotFoundException
255 public StringType getStorageDescription(int deviceIndex) throws DeviceNotFoundException;
257 // Hardware drive info
259 * Gets the name of the physical storage drive
261 * @param deviceIndex - index of the storage drive
262 * @throws DeviceNotFoundException
264 public StringType getDriveName(int deviceIndex) throws DeviceNotFoundException;
267 * Gets the model of the physical storage drive
269 * @param deviceIndex - index of the storage drive
270 * @throws DeviceNotFoundException
272 public StringType getDriveModel(int deviceIndex) throws DeviceNotFoundException;
275 * Gets the serial number of the physical storage drive
277 * @param deviceIndex - index of the storage drive
278 * @throws DeviceNotFoundException
280 public StringType getDriveSerialNumber(int deviceIndex) throws DeviceNotFoundException;
284 * Get the Host IP address of the network.
286 * @param networkIndex - the index of the network
287 * @return 32-bit IPv4 address
288 * @throws DeviceNotFoundException
290 public StringType getNetworkIp(int networkIndex) throws DeviceNotFoundException;
293 * Get the name of this network.
295 * @param networkIndex - the index of the network
296 * @throws DeviceNotFoundException
298 public StringType getNetworkName(int networkIndex) throws DeviceNotFoundException;
301 * The description of the network. On some platforms, this is identical to the name.
303 * @param networkIndex - the index of the network
304 * @throws DeviceNotFoundException
306 public StringType getNetworkDisplayName(int networkIndex) throws DeviceNotFoundException;
309 * Gets the MAC Address of the network.
311 * @param networkIndex - the index of the network
312 * @throws DeviceNotFoundException
314 public StringType getNetworkMac(int networkIndex) throws DeviceNotFoundException;
317 * Get number of packets received
319 * @param networkIndex - the index of the network
320 * @throws DeviceNotFoundException
322 public DecimalType getNetworkPacketsReceived(int networkIndex) throws DeviceNotFoundException;
325 * Get number of packets sent
327 * @param networkIndex - the index of the network
328 * @throws DeviceNotFoundException
330 public DecimalType getNetworkPacketsSent(int networkIndex) throws DeviceNotFoundException;
333 * Get data sent in MB for this network
335 * @param networkIndex - the index of the network
336 * @throws DeviceNotFoundException
338 public DecimalType getNetworkDataSent(int networkIndex) throws DeviceNotFoundException;
341 * Get data received in MB for this network
343 * @param networkIndex - the index of the network
344 * @throws DeviceNotFoundException
346 public DecimalType getNetworkDataReceived(int networkIndex) throws DeviceNotFoundException;
350 * Get information about the display device as product number, manufacturer, serial number, width and height in cm";
352 * @param deviceIndex - the index of the display device
353 * @throws DeviceNotFoundException
355 public StringType getDisplayInformation(int deviceIndex) throws DeviceNotFoundException;
359 * Get the information from the CPU temperature sensors.
361 * @return Temperature in degrees Celsius if available, null otherwise.
363 public @Nullable DecimalType getSensorsCpuTemperature();
366 * Get the information for the CPU voltage.
368 * @return Voltage in Volts if available, null otherwise.
370 public @Nullable DecimalType getSensorsCpuVoltage();
376 * @return Speed in rpm or null if unable to measure fan speed
377 * @throws DeviceNotFoundException
379 public @Nullable DecimalType getSensorsFanSpeed(int deviceIndex) throws DeviceNotFoundException;
383 * Get estimated time remaining for the power source.
386 * @return minutes remaining charge or null, if the time is estimated as unlimited
387 * @throws DeviceNotFoundException
389 public @Nullable DecimalType getBatteryRemainingTime(int deviceIndex) throws DeviceNotFoundException;
392 * Battery remaining capacity.
395 * @return percentage value /0-100/
396 * @throws DeviceNotFoundException
398 public DecimalType getBatteryRemainingCapacity(int deviceIndex) throws DeviceNotFoundException;
404 * @throws DeviceNotFoundException
406 public StringType getBatteryName(int deviceIndex) throws DeviceNotFoundException;
409 * Get PID of process executing this code
411 * @return current process ID
413 int getCurrentProcessID();
416 * Returns the name of the process
418 * @param pid - the PID of the process
419 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
421 public @Nullable StringType getProcessName(int pid) throws DeviceNotFoundException;
424 * Returns the CPU usage of the process
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
430 public @Nullable DecimalType getProcessCpuUsage(int pid) throws DeviceNotFoundException;
433 * Returns the size of RAM memory only usage of the process
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
439 public @Nullable DecimalType getProcessMemoryUsage(int pid) throws DeviceNotFoundException;
442 * Returns the full path of the executing process.
444 * @param pid - the PID of the process
445 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
447 public @Nullable StringType getProcessPath(int pid) throws DeviceNotFoundException;
450 * Returns the number of threads in this process.
452 * @param pid - the PID of the process
453 * @throws DeviceNotFoundException - thrown if process with this PID can not be found
455 public @Nullable DecimalType getProcessThreads(int pid) throws DeviceNotFoundException;
458 * Returns the number of network interfaces.
460 * @return network interface count
462 public int getNetworkIFCount();
465 * Returns the number of displays.
467 * @return display count
469 public int getDisplayCount();
472 * Returns the number of storages.
474 * @return storage count
476 public int getFileOSStoreCount();
479 * Returns the number of power sources/batteries.
481 * @return power source count
483 public int getPowerSourceCount();
486 * Returns the number of drives.
488 * @return drive count
490 public int getDriveCount();
493 * Returns the number of fans.