diff --git a/reference/.gitignore b/reference/.gitignore new file mode 100644 index 0000000..1b1362c --- /dev/null +++ b/reference/.gitignore @@ -0,0 +1,10 @@ +# Output +target +.project +.settings +.classpath +.idea +.DS_Store +*.iml +.mvn/wrapper/maven-wrapper.jar +oshi-core-shaded/dependency-reduced-pom.xml diff --git a/reference/.mvn/wrapper/MavenWrapperDownloader.java b/reference/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..c32394f --- /dev/null +++ b/reference/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.5"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/reference/.mvn/wrapper/maven-wrapper.properties b/reference/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..fa87ad7 --- /dev/null +++ b/reference/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar diff --git a/reference/.travis.yml b/reference/.travis.yml new file mode 100644 index 0000000..56d91f9 --- /dev/null +++ b/reference/.travis.yml @@ -0,0 +1,60 @@ +language: java + +before_install: + # When building the coverity_scan branch, allow only the first job to continue. + - if [[ "${TRAVIS_BRANCH}" == "coverity_scan" && "$MATRIX_ID" != "first" ]]; then exit 0; fi + # Get most recent JDK versions on-the-fly + - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh + +after_success: + - bash <(curl -s https://codecov.io/bash) + - if [ "$MATRIX_ID" == "first" ]; then + ./mvnw clean test jacoco:report coveralls:report; + ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar; + fi + +env: + global: + # COVERITY_SCAN_TOKEN + - secure: "JuTWT2u7BWQEJGMGkVvQMIQxwxajntxqbCGYt+bJD3JQhioPVFUJoEFrLCx+jJ0qLy5usrneCDFrvRhvTh6C+95kvHypvGQ3UoeWyXS8zD+GRPUyskbuQ7P60kqqIqc+naGd3uyGddniixoAA6C/Ptmknhls4FlhDCMjW3HDS0c=" + +addons: + coverity_scan: + project: + name: "dblock/oshi" + description: "Build submitted via Travis CI" + notification_email: widdis@gmail.com + build_command_prepend: "cov-configure --comptype gcc --compiler gcc-4.8 --template" + build_command: "./mvnw -DskipTests=true clean compile" + branch_pattern: coverity_scan + sonarcloud: + organization: "default" # the key of the open source org + hosts: + - oshi + hostname: oshi + +matrix: + include: + - os: osx + env: + - JDK = "Oracle JDK 8 - Mac" + - MATRIX_ID="first" + osx_image: xcode9.3 + - os: osx + env: JDK = "OpenJDK 11 - Mac" + osx_image: xcode10.1 + - os: linux + install: . ./install-jdk.sh -F 11 -L GPL + env: JDK = "OpenJDK 11 - Linux" + - os: linux + install: . ./install-jdk.sh -F 12 -L GPL + env: JDK = "OpenJDK 12 - Linux" + - os: linux + install: . ./install-jdk.sh -F ea -L GPL + env: JDK = "OpenJDK 13-ea - Linux" + +script: + # Skip tests on coverity_scan branch + - if [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]; then exit 0; fi + - java -version + - mvn test diff --git a/reference/CHANGELOG.md b/reference/CHANGELOG.md new file mode 100644 index 0000000..b2b2ca9 --- /dev/null +++ b/reference/CHANGELOG.md @@ -0,0 +1,358 @@ +4.0.0 (in progress) +================ +* [#756](https://github.com/oshi/oshi/pull/756): Require Java 8. - [@dbwiddis](https://github.com/dbwiddis). +* [#773](https://github.com/oshi/oshi/pull/773): Remove oshi-json artifact. - [@dbwiddis](https://github.com/dbwiddis). +* [#774](https://github.com/oshi/oshi/pull/774): API overhaul - ComputerSystem, Baseboard, and Firmware. - [@dbwiddis](https://github.com/dbwiddis). +* [#775](https://github.com/oshi/oshi/pull/775): API overhaul - GlobalMemory, new VirtualMemory. - [@dbwiddis](https://github.com/dbwiddis). +* [#776](https://github.com/oshi/oshi/pull/776): oshi-demo artifact. - [@dbwiddis](https://github.com/dbwiddis). +* [#779](https://github.com/oshi/oshi/pull/779): API overhaul - CentralProcessor, new LogicalProcessor. - [@dbwiddis](https://github.com/dbwiddis). +* [#794](https://github.com/oshi/oshi/pull/794): Add NUMA nodes to Logical Processors. - [@dbwiddis](https://github.com/dbwiddis). +* [#838](https://github.com/oshi/oshi/pull/838): JNA 5.3.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#845](https://github.com/oshi/oshi/pull/845): JNA 5.3.1. - [@dbwiddis](https://github.com/dbwiddis). +* [#857](https://github.com/oshi/oshi/pull/857): Fix CPU temperature - [@rlouwerens](https://github.com/rlouwerens). +* [#901](https://github.com/oshi/oshi/pull/901): Fix incorrect physical processor count on Linux. - [@ellesummer](https://github.com/ellesummer). +* [#845](https://github.com/oshi/oshi/pull/911): JNA 5.4.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#914](https://github.com/oshi/oshi/pull/914): Add System Boot Time. - [@shannondavid](https://github.com/shannondavid). +* [#916](https://github.com/oshi/oshi/pull/916): Move Uptime and Boot Time to OperatingSystem class. - [@dbwiddis](https://github.com/dbwiddis). +* [#917](https://github.com/oshi/oshi/pull/917): API overhaul - Sensors. - [@dbwiddis](https://github.com/dbwiddis). +* [#918](https://github.com/oshi/oshi/pull/918): Removed time interval based caching. - [@dbwiddis](https://github.com/dbwiddis). +* [#921](https://github.com/oshi/oshi/pull/921): Removed static map based caching. - [@dbwiddis](https://github.com/dbwiddis). +* [#922](https://github.com/oshi/oshi/pull/922): Show OSProcess Bitness. - [@dbwiddis](https://github.com/dbwiddis). +* [#926](https://github.com/oshi/oshi/pull/926): Fix SMC datatype reading. - [@dbwiddis](https://github.com/dbwiddis). +* [#928](https://github.com/oshi/oshi/pull/928): Raspberry Pi compatibility fixes. - [@dbwiddis](https://github.com/dbwiddis). +* [#929](https://github.com/oshi/oshi/pull/929): Add isElevated check to OperatingSystem. - [@dbwiddis](https://github.com/dbwiddis). +* [#931](https://github.com/oshi/oshi/pull/931): Standardize attribute updating. - [@dbwiddis](https://github.com/dbwiddis). +* Your contribution here. + +3.13.0 (1/18/2019), 3.13.1 (4/21/2019), 3.13.2 (4/28/2019), 3.13.3 (6/5/2019) +================ +* [#763](https://github.com/oshi/oshi/pull/763): Refactor PDH/WMI Fallback. - [@dbwiddis](https://github.com/dbwiddis). +* [#766](https://github.com/oshi/oshi/pull/766): Use query key to update counters in groups. - [@dbwiddis](https://github.com/dbwiddis). +* [#767](https://github.com/oshi/oshi/pull/767): Allow subclassing WmiQueryHandler with reflection. - [@dbwiddis](https://github.com/dbwiddis). +* [#769](https://github.com/oshi/oshi/pull/769): Close PDH handles after each query. - [@dbwiddis](https://github.com/dbwiddis). +* [#839](https://github.com/oshi/oshi/pull/838): JNA 5.3.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#845](https://github.com/oshi/oshi/pull/845): JNA 5.3.1. - [@dbwiddis](https://github.com/dbwiddis). + +3.12.1 (12/31/2018), 3.12.2 (1/10/2019) +================ +* [#728](https://github.com/oshi/oshi/pull/728): Separate WMI Query Handling from Util. - [@retomerz](https://github.com/retomerz). +* [#730](https://github.com/oshi/oshi/pull/730): Fix Windows process token handle leak. - [@dbwiddis](https://github.com/dbwiddis). +* [#731](https://github.com/oshi/oshi/pull/731): Switch to MIT License, JNA 5.2.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#735](https://github.com/oshi/oshi/pull/735): Windows XP Compatibility fixes. - [@dbwiddis](https://github.com/dbwiddis). +* [#737](https://github.com/oshi/oshi/pull/737): Properly handle redundant COM initialization. - [@dbwiddis](https://github.com/dbwiddis). + +3.12.0 (12/16/2018) +================ +* [#694](https://github.com/oshi/oshi/pull/694): ComputerIdentifier Util Method - [@Aashishthakur10](https://github.com/Aashishthakur10). +* [#699](https://github.com/oshi/oshi/pull/699): Fix PerfData error handling - [@dbwiddis](https://github.com/dbwiddis). +* [#703](https://github.com/oshi/oshi/pull/703): Remove deprecated CentralProcessor serialNumber method - [@dbwiddis](https://github.com/dbwiddis). +* [#704](https://github.com/oshi/oshi/pull/704): Check for Virtual Machine - [@haidong](https://github.com/haidong). +* [#724](https://github.com/oshi/oshi/pull/724): Refactor unsigned long bitmasking - [@LiborB] (https://github.com/LiborB). + +3.11.0 (11/21/2018) +================ +* [#685](https://github.com/oshi/oshi/pull/685): Get Linux HZ from system config - [@dbwiddis](https://github.com/dbwiddis). +* [#686](https://github.com/oshi/oshi/pull/686): JNA 5.1.0 - [@dbwiddis](https://github.com/dbwiddis). +* [#688](https://github.com/oshi/oshi/pull/688): Fix Linux proc stat and pagesize parsing - [@dbwiddis](https://github.com/dbwiddis). +* [#689](https://github.com/oshi/oshi/pull/689): Optionally skip slow OSProcess fields - [@dbwiddis](https://github.com/dbwiddis). +* [#690](https://github.com/oshi/oshi/pull/690): Prioritize system-release for Fedora and CentOS version - [@dbwiddis](https://github.com/dbwiddis). +* [#691](https://github.com/oshi/oshi/pull/691): Cache OSProcesses on Linux - [@dbwiddis](https://github.com/dbwiddis). + +3.10.0 (11/03/2018) +================ +* [#656](https://github.com/oshi/oshi/pull/656): JNA 5.0.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#659](https://github.com/oshi/oshi/pull/659): Add free/total inode counts. - [@Space2Man](https://github.com/Space2Man). +* [#666](https://github.com/oshi/oshi/pull/666): Recreate counter handles when invalid - [@dbwiddis](https://github.com/dbwiddis). +* [#675](https://github.com/oshi/oshi/pull/675): Solaris 10 network stats compatibility fix - [@dbwiddis](https://github.com/dbwiddis). + +3.9.1 (10/14/2018) +================ +* [#647](https://github.com/oshi/oshi/pull/647): Fix Windows idle counter calculation. - [@dbwiddis](https://github.com/dbwiddis). +* [#653](https://github.com/oshi/oshi/pull/653): Fix transferTime in WindowsDisks by using 1-%Idle - [@Space2Man](https://github.com/Space2Man). + +3.9.0 (10/7/2018) +================ +* [#630](https://github.com/oshi/oshi/pull/630), [#640](https://github.com/oshi/oshi/pull/640), [#645](https://github.com/oshi/oshi/pull/645), [#652](https://github.com/oshi/oshi/pull/652), [#655](https://github.com/oshi/oshi/pull/655): Add Sound Card list. - [@bilalAM](https://github.com/bilalAM). +* [#636](https://github.com/oshi/oshi/pull/636): Catch exception when english counters missing. - [@dbwiddis](https://github.com/dbwiddis). +* [#639](https://github.com/oshi/oshi/pull/639): Implement QueueLength metric in HWDiskStore. - [@Space2Man](https://github.com/Space2Man). + +3.8.1 (09/01/2018), 3.8.2 (09/07/2018), 3.8.3 (09/14/2018), 3.8.4 (09/24/2018) +================ +* [#592](https://github.com/oshi/oshi/pull/592): Test for non-numeric doubles in JSON parsing. - [@dbwiddis](https://github.com/dbwiddis). +* [#597](https://github.com/oshi/oshi/pull/597): Fix Windows serialnumber fallback bug. - [@dbwiddis](https://github.com/dbwiddis). +* [#603](https://github.com/oshi/oshi/pull/603): Fix Process Uptime bug. - [@anitakosman](https://github.com/anitakosman). +* [#604](https://github.com/oshi/oshi/pull/604): Fix Windows interrupt count bug. - [@dbwiddis](https://github.com/dbwiddis). +* [#605](https://github.com/oshi/oshi/pull/605): Update OSGi imports. - [@dbwiddis](https://github.com/dbwiddis). +* [#608](https://github.com/oshi/oshi/pull/608): Fix Windows context swith count bug. - [@dbwiddis](https://github.com/dbwiddis). +* [#611](https://github.com/oshi/oshi/pull/611): Fix proc stat parsing on older Linux distros. - [@dbwiddis](https://github.com/dbwiddis). +* [#612](https://github.com/oshi/oshi/pull/612): OSProcess toString. - [@dbwiddis](https://github.com/dbwiddis). +* [#614](https://github.com/oshi/oshi/pull/614): Remove unneeded debug query and fix a WMI cast error - [@dbwiddis](https://github.com/dbwiddis). +* [#626](https://github.com/oshi/oshi/pull/626): Fix calculation of Hz on Linux - [@dbwiddis](https://github.com/dbwiddis). + +3.8.0 (08/20/2018) +================ +* [#580](https://github.com/oshi/oshi/pull/580): Windows process uptime wasn't updating. - [@dbwiddis](https://github.com/dbwiddis). +* [#585](https://github.com/oshi/oshi/pull/585): Fix WMI type mapping and BSTR allocation. - [@dbwiddis](https://github.com/dbwiddis). +* [#586](https://github.com/oshi/oshi/pull/586): Add PerfDataUtil.removeAllCounters. - [@dbwiddis](https://github.com/dbwiddis). +* [#587](https://github.com/oshi/oshi/pull/587): Localize PDH instance enumeration. - [@dbwiddis](https://github.com/dbwiddis). +* [#588](https://github.com/oshi/oshi/pull/588): WMI backup for all PDH Counters. - [@dbwiddis](https://github.com/dbwiddis). + +3.7.1 (07/28/2018), 3.7.2 (08/01/2018) +================ +* [#571](https://github.com/oshi/oshi/pull/571): CIM date broken for timezones east of GMT. - [@dbwiddis](https://github.com/dbwiddis). +* [#573](https://github.com/oshi/oshi/pull/573): Don't get PDH swap stats if no swap. - [@dbwiddis](https://github.com/dbwiddis). +* [#574](https://github.com/oshi/oshi/pull/574): Suppress repeat updates of failed PDH counters. - [@dbwiddis](https://github.com/dbwiddis). +* [#575](https://github.com/oshi/oshi/pull/575): Replace WMI value types with Variant types. - [@dbwiddis](https://github.com/dbwiddis). +* [#577](https://github.com/oshi/oshi/pull/577): Get Windows temperature from PDH counters. - [@dbwiddis](https://github.com/dbwiddis). + +3.7.0 (07/28/2018) +================ +* [#551](https://github.com/oshi/oshi/pull/551): Check for zero-length PDH counter lists to avoid exceptions - [@dbwiddis](https://github.com/dbwiddis). +* [#556](https://github.com/oshi/oshi/pull/556): WMI timeouts, standardization, and simplification. - [@dbwiddis](https://github.com/dbwiddis). +* [#557](https://github.com/oshi/oshi/pull/557): Localize PDH Counter paths. - [@dbwiddis](https://github.com/dbwiddis). +* [#561](https://github.com/oshi/oshi/pull/561): Optimize Process CPU sort. - [@dbwiddis](https://github.com/dbwiddis). +* [#564](https://github.com/oshi/oshi/pull/564): Cache WMI connections. - [@dbwiddis](https://github.com/dbwiddis). +* [#567](https://github.com/oshi/oshi/pull/567): Cache USB devices. - [@dbwiddis](https://github.com/dbwiddis). +* [#569](https://github.com/oshi/oshi/pull/569): Remove threetenbp dependency. - [@dbwiddis](https://github.com/dbwiddis). + +3.6.1 (6/28/2018), 3.6.2 (7/10/2018) +================ +* [#527](https://github.com/oshi/oshi/pull/527): Correct process information caching and command line retrieval under Windows - [@dustin-johnson](https://github.com/dustin-johnson). +* [#533](https://github.com/oshi/oshi/pull/533): Filter to CPU zone if multiple Windows Thermal sensors. - [@dbwiddis](https://github.com/dbwiddis). +* [#542](https://github.com/oshi/oshi/pull/542): Disabled Windows performance collection leads to empty Process cache - [@MarcMil](https://github.com/MarcMil). +* [#547](https://github.com/oshi/oshi/pull/547): Remove DataTypeConverter dependency so OSHI builds on Java 9+ - [@dbwiddis](https://github.com/dbwiddis). + +3.6.0 (6/20/2018) +================ +* [#489](https://github.com/oshi/oshi/pull/489): Switch from WMI to native methods for most Windows Process data. - [@dbwiddis](https://github.com/dbwiddis). +* [#501](https://github.com/oshi/oshi/pull/501): Added HWDiskStore.updateDiskStats. - [@cjbrowne](https://github.com/cjbrowne). +* [#503](https://github.com/oshi/oshi/pull/503): Expose memory page size to API. - [@dbwiddis](https://github.com/dbwiddis). +* [#507](https://github.com/oshi/oshi/pull/507): Replace WMI with (faster) PDH queries for WindowsCentralProcessor. - [@dbwiddis](https://github.com/dbwiddis). +* [#508](https://github.com/oshi/oshi/pull/508): Replace WMI with (faster) registry data for Windows Processes. - [@dbwiddis](https://github.com/dbwiddis). +* [#509](https://github.com/oshi/oshi/pull/509): Add pages swapped in/out to paging/swap file. - [@dbwiddis](https://github.com/dbwiddis). +* [#518](https://github.com/oshi/oshi/pull/518): Add OS bitness. - [@dbwiddis](https://github.com/dbwiddis). + +3.5.0 (4/15/2018) +================ +* [#446](https://github.com/oshi/oshi/pull/446): Add getChildProcesses to OperatingSystem. - [@jsimomaa](https://github.com/jsimomaa) +* [#447](https://github.com/oshi/oshi/pull/447), [#471](https://github.com/oshi/oshi/pull/471): Added context switches and interrupts - [@jpbempel](https://github.com/jpbempel), [@dbwiddis](https://github.com/dbwiddis). +* [#476](https://github.com/dblock/oshi/pull/476): Count CPU Packages - [@dbwiddis](https://github.com/dbwiddis). +* [#478](https://github.com/dblock/oshi/pull/478): Windows RSS now reports Private Working Set, matching Task Manager - [@dbwiddis](https://github.com/dbwiddis). +* Updated to JNA 4.5.1 + +3.4.5 (4/11/2018) +================ +* [#433](https://github.com/oshi/oshi/pull/433): Performance improvements for getProcesses() on Linux - [@bildechinger](https://github.com/bildechinger). +* [#455](https://github.com/oshi/oshi/pull/455): Open files/handles support - [@spyhunter99](https://github.com/spyhunter99). +* [#459](https://github.com/oshi/oshi/pull/459): New methods for querying for a list of specific pids - [@spyhunter99](https://github.com/spyhunter99). +* [#464](https://github.com/oshi/oshi/pull/464): OSGi fixes - [@lprimak](https://github.com/lprimak). +* [#465](https://github.com/oshi/oshi/pull/465): Include a shaded jar with all dependencies - [@lprimak](https://github.com/lprimak). + +3.4.4 (10/15/17) +================ +* [#392](https://github.com/dblock/oshi/pull/392): Fix NPE for processes terminating before iteration - [@dbwiddis](https://github.com/dbwiddis). +* [#396](https://github.com/oshi/oshi/pull/396): Fix issue on Mac OS X whereby the buffer size for the call to proc_listpids() was improperly calculated - [@brettwooldridge](https://github.com/brettwooldridge) +* Updated to JNA 4.5.0 + +3.4.3 (6/2/17) +================ +* [#336](https://github.com/dblock/oshi/pull/336): Add Process Current Working Directory - [@dbwiddis](https://github.com/dbwiddis). +* [#357](https://github.com/dblock/oshi/pull/357): Prioritize OpenHardwareMonitor for Windows Sensors - [@dbwiddis](https://github.com/dbwiddis). +* [#362](https://github.com/oshi/oshi/pull/362): Add logical volume attribute to OSFileStore (Linux support only), providing a place for an alternate volume name. [@darinhoward](https://github.com/darinhoward) +* [#363](https://github.com/oshi/oshi/pull/363): Adding Steal Tick Type for Linux - [@darinhoward](https://github.com/darinhoward). +* [#375](https://github.com/oshi/oshi/pull/375): Added OSGi bundle support - [@swimmesberger](https://github.com/swimmesberger) +* Updated to JNA 4.4.0. + +3.4.2 (3/2/2017) +================ +* [#332](https://github.com/dblock/oshi/pull/332): Remove streamsupport dependency - [@dbwiddis](https://github.com/dbwiddis). + +3.4.1 (3/1/2017) +================ +* [#327](https://github.com/dblock/oshi/pull/327): Restore Java 7 compatibility. - [@dbwiddis](https://github.com/dbwiddis). +* [#328](https://github.com/dblock/oshi/pull/328): Updated to JNA 4.3.0. - [@dbwiddis](https://github.com/dbwiddis). + +3.4.0 (2/26/2017) +================ +* Switch groupId to com.github.oshi +* [#294](https://github.com/oshi/oshi/pull/294), [#305](https://github.com/oshi/oshi/pull/305): Add NetworkParams for network parameter of OS - [@chikei](https://github.com/chikei), [@dbwiddis](https://github.com/dbwiddis). +* [#295](https://github.com/oshi/oshi/pull/295): Make OSProcess (AbstractProcess.java) more easily extendible - [@michaeldesigaud](https://github.com/michaeldesigaud). +* [#307](https://github.com/dblock/oshi/pull/307): Deprecate CentralProcessor's getSystemSerialNumber method that duplicated ComputerSystem's getSerialNumber method. - [@dbwiddis](https://github.com/dbwiddis). +* [#308](https://github.com/dblock/oshi/pull/308): Add getProcessorID to CentralProcessor. - [@dbwiddis](https://github.com/dbwiddis). +* [#309](https://github.com/dblock/oshi/pull/309): Reduce C library duplication. - [@dbwiddis](https://github.com/dbwiddis). +* [#317](https://github.com/dblock/oshi/pull/317): Add user/uid, group/gid, and command line to OSProcess. - [@dbwiddis](https://github.com/dbwiddis). + +3.3 (12/31/2016) +================ +* [#262](https://github.com/dblock/oshi/pull/262): Add bytesRead and bytesWritten to OSProcess - [@plamenko](https://github.com/plamenko). +* [#264](https://github.com/dblock/oshi/pull/264), [#289](https://github.com/dblock/oshi/pull/289): BIOS, manufacturer, and baseboard information - [@lundefugl](https://github.com/lundefugl), [@dbwiddis](https://github.com/dbwiddis). +* [#281](https://github.com/dblock/oshi/pull/281): Improve Linux battery AC device exclusion - [@dbwiddis](https://github.com/dbwiddis). +* [#282](https://github.com/dblock/oshi/pull/282): Get Windows version from WMI - [@dbwiddis](https://github.com/dbwiddis). +* [#283](https://github.com/dblock/oshi/pull/283): Fix Linux block device stats on some distributions - [@lu-ko](https://github.com/lu-ko). +* [#284](https://github.com/dblock/oshi/pull/284): Remove incorrect IOWait counter from WindowsCentralProcessor - [@dbwiddis](https://github.com/dbwiddis). +* [#285](https://github.com/dblock/oshi/pull/285): Rebrand Mac OS 10.12+ as macOS - [@dbwiddis](https://github.com/dbwiddis). +* [#286](https://github.com/dblock/oshi/pull/286): Reduce required calculations for LinuxProcess initialization - [@dbwiddis](https://github.com/dbwiddis). +* [#290](https://github.com/dblock/oshi/pull/290): Add input/output errors to Network IF - [@dbwiddis](https://github.com/dbwiddis). + +3.2 (9/1/2016) +================ +* [#243](https://github.com/dblock/oshi/pull/243): Make Windows network statistics 64-bit - [@dbwiddis](https://github.com/dbwiddis). +* [#244](https://github.com/dblock/oshi/pull/244): Add timestamps to Disk and Network IO Stats - [@dbwiddis](https://github.com/dbwiddis). +* [#253](https://github.com/dblock/oshi/pull/253): Properly handle CoreStorage Volumes on OSX - [@dbwiddis](https://github.com/dbwiddis). +* [#256](https://github.com/dblock/oshi/pull/256): Use DeviceID to link Windows Disks and Partitions - [@dbwiddis](https://github.com/dbwiddis). + +3.1.1 (8/5/2016) +================ +* [#239](https://github.com/dblock/oshi/pull/239): Fix exceptions on windows disks/partitions - [@dbwiddis](https://github.com/dbwiddis). +* [#240](https://github.com/dblock/oshi/pull/240): Check sysfs for Linux system serial number - [@dbwiddis](https://github.com/dbwiddis). + +3.1 (8/1/2016) +================ +* [#225](https://github.com/dblock/oshi/pull/225): Bugfixes from Coverity, FindBugs, and PMD - [@dbwiddis](https://github.com/dbwiddis). +* [#229](https://github.com/dblock/oshi/pull/229): Solaris port - [@dbwiddis](https://github.com/dbwiddis). +* [#232](https://github.com/dblock/oshi/pull/232): FreeBSD port - [@dbwiddis](https://github.com/dbwiddis). +* [#234](https://github.com/dblock/oshi/pull/234): Add read/write count and active disk time to HWDiskStores - [@dbwiddis](https://github.com/dbwiddis). +* [#235](https://github.com/dblock/oshi/pull/235): Add partition information to HWDiskStores - [@dbwiddis](https://github.com/dbwiddis). + +3.0 (7/1/2016) +================ +* [#205](https://github.com/dblock/oshi/pull/205): Separated oshi-core and oshi-json modules - [@dbwiddis](https://github.com/dbwiddis). +* [#209](https://github.com/dblock/oshi/pull/209): Move FileSystem and Processes to OperatingSystem - [@dbwiddis](https://github.com/dbwiddis). +* [#210](https://github.com/dblock/oshi/pull/210): Streamlined macOS FileSystem - [@dbwiddis](https://github.com/dbwiddis). +* [#211](https://github.com/dblock/oshi/pull/211): Combine IOwait and IRQ ticks into processor tick array - [@dbwiddis](https://github.com/dbwiddis). +* [#213](https://github.com/dblock/oshi/pull/213): Sort and Limit returned Processes - [@dbwiddis](https://github.com/dbwiddis). +* [#214](https://github.com/dblock/oshi/pull/214): Offer flat or tree USB listing - [@dbwiddis](https://github.com/dbwiddis). +* [#216](https://github.com/dblock/oshi/pull/216): Filter JSON output with properties - [@dbwiddis](https://github.com/dbwiddis). +* [#219](https://github.com/dblock/oshi/pull/219): NetworkIFs can now update stats - [@dbwiddis](https://github.com/dbwiddis). +* [#223](https://github.com/dblock/oshi/pull/223): JUnit Test overhaul, adds, refactoring - [@dbwiddis](https://github.com/dbwiddis). + +2.6.2 (6/21/2016) +================ +* [#199](https://github.com/dblock/oshi/pull/199): Use WMI queries for raw data instead of maintaining PDH threads - [@dbwiddis](https://github.com/dbwiddis). +* Multiple efficiency improvements + +2.6-java7 / 2.6.1 (6/17/2016) +================ +* [#190](https://github.com/dblock/oshi/pull/190): Add VendorID and ProductID to UsbDevice - [@dbwiddis](https://github.com/dbwiddis). +* [#193](https://github.com/dblock/oshi/pull/193): Add read/write to Windows and OS X HWDiskStores - [@dbwiddis](https://github.com/dbwiddis). +* [#194](https://github.com/dblock/oshi/pull/194): Add volume name to OSFileStores - [@henryx](https://github.com/henryx). +* [#195](https://github.com/dblock/oshi/pull/195): Fixed reading multiple (in particular external) displays on Mac - [@dpagano](https://github.com/dpagano). +* [#197](https://github.com/dblock/oshi/pull/197): Add UUID to OSFileStores - [@dbwiddis](https://github.com/dbwiddis). +* [#198](https://github.com/dblock/oshi/pull/198): macOS 10.12 (Sierra) - [@dbwiddis](https://github.com/dbwiddis). +* Created a Java 7 backport using threeten.org dependency released as 2.6-m-java7 + +2.5.1-java7 / 2.5.2 (6/9/2016) +================ +* [#186](https://github.com/dblock/oshi/pull/186), [#187](https://github.com/dblock/oshi/pull/187), [#188](https://github.com/dblock/oshi/pull/188): Improve USB device trees - [@dbwiddis](https://github.com/dbwiddis). +* Created a Java 7 backport using threeten.org dependency released as 2.5.1-java7 + +2.5 (6/4/2016) +================ +* Upgraded to Java 8 base support +* [#163](https://github.com/dblock/oshi/pull/163): Update getFileStores() method to include mount point [@henryx](https://github.com/henryx). +* [#165](https://github.com/dblock/oshi/pull/165): Added system-wide file descriptor counts - [@cholland1989](https://github.com/cholland1989). +* [#168](https://github.com/dblock/oshi/pull/168): Switched WMI queries to use COM - [@dbwiddis](https://github.com/dbwiddis). +* [#171](https://github.com/dblock/oshi/pull/171): Added detailed process statistics - [@dbwiddis](https://github.com/dbwiddis). +* [#176](https://github.com/dblock/oshi/pull/176): Eliminate Swing threads in WindowsFileSystem - [@henryx](https://github.com/henryx). +* [#180](https://github.com/dblock/oshi/pull/180): Made all system information classes serializable - [@dbwiddis](https://github.com/dbwiddis). +* [#181](https://github.com/dblock/oshi/pull/181): Added USB Device listing - [@dbwiddis](https://github.com/dbwiddis). +* [#184](https://github.com/dblock/oshi/pull/184): Improve Linux OS version parsing - [@dbwiddis](https://github.com/dbwiddis). + +2.4 (5/2/2016) +================ +* [#140](https://github.com/dblock/oshi/pull/140): Added process and thread counts - [@dbwiddis](https://github.com/dbwiddis). +* [#142](https://github.com/dblock/oshi/pull/142): Added methods for getting swap (total and used) in the system - [@henryx](https://github.com/henryx). +* [#145](https://github.com/dblock/oshi/pull/145): Refactored common code to abstract classes - [@dbwiddis](https://github.com/dbwiddis). +* [#147](https://github.com/dblock/oshi/pull/147), [#149](https://github.com/dblock/oshi/pull/149): Added disk information and statistics - [@henryx](https://github.com/henryx), [@dbwiddis](https://github.com/dbwiddis). +* [#150](https://github.com/dblock/oshi/pull/150): Added filesystem types - [@dbwiddis](https://github.com/dbwiddis). +* [#155](https://github.com/dblock/oshi/pull/155), [#157](https://github.com/dblock/oshi/pull/157): Added network interface statistics - [@henryx](https://github.com/henryx), [@dbwiddis](https://github.com/dbwiddis). + +2.3 (4/14/2016) +================ +* [#124](https://github.com/dblock/oshi/pull/124): Read Windows Sensor info from Open Hardware Monitor as fallback - [@dbwiddis](https://github.com/dbwiddis). +* [#129](https://github.com/dblock/oshi/pull/129): Improve Linux version and code name parsing - [@dbwiddis](https://github.com/dbwiddis). +* [#132](https://github.com/dblock/oshi/pull/132), [#133](https://github.com/dblock/oshi/pull/133): Fix NPEs on Raspberry Pi - [@pcollaog](https://github.com/pcollaog). +* [#136](https://github.com/dblock/oshi/pull/136): Updated CPU load average to use system call - [@henryx](https://github.com/henryx). +* [#137](https://github.com/dblock/oshi/pull/137): Added iowait and irq ticks - [@dbwiddis](https://github.com/dbwiddis). + +2.2 (3/1/2016) +================ +* [#121](https://github.com/dblock/oshi/pull/121): Added CPU temperature, fan speeds, and voltage - [@dbwiddis](https://github.com/dbwiddis). +* [#123](https://github.com/dblock/oshi/pull/123): Handle JSON nulls - [@dbwiddis](https://github.com/dbwiddis). + +2.1.2 (2/24/2016) +================ +* [#118](https://github.com/dblock/oshi/pull/118): Port JSON to javax.json - [@dbwiddis](https://github.com/dbwiddis). +* [#120](https://github.com/dblock/oshi/pull/120): Support all windows processor methods - [@dbwiddis](https://github.com/dbwiddis). + +2.1.1 (2/19/2016) +================ +* [#114](https://github.com/dblock/oshi/pull/114): Memory information wasn't updating for Windows - [@dbwiddis](https://github.com/dbwiddis). +* [#116](https://github.com/dblock/oshi/pull/116): Added JSON output - [@dbwiddis](https://github.com/dbwiddis). + +2.1 (1/1/2016) +================ +* [#108](https://github.com/dblock/oshi/pull/108): Added Display info from EDID - [@dbwiddis](https://github.com/dbwiddis). +* [#111](https://github.com/dblock/oshi/pull/111): Catch exceptions when Linux c library missing - [@dbwiddis](https://github.com/dbwiddis). + +2.0 (11/28/2015) +================ +* [#101](https://github.com/dblock/oshi/pull/101): Refactored package structure for consistency - [@dbwiddis](https://github.com/dbwiddis). +* [#103](https://github.com/dblock/oshi/pull/103): Switched CentralProcessor to a single object for all processors - [@dbwiddis](https://github.com/dbwiddis). +* See [UPGRADING.md](UPGRADING.md) for more details. + +1.5.2 (11/23/2015) +================ +* [#98](https://github.com/dblock/oshi/pull/98): Upgraded JNA to 4.2.1 - [@dbwiddis](https://github.com/dbwiddis). +* [#100](https://github.com/dblock/oshi/pull/100): Add physical and logical CPU counts - [@dbwiddis](https://github.com/dbwiddis). + +1.5.1 (10/15/2015) +================ +* [#94](https://github.com/dblock/oshi/pull/94): Upgraded JNA to 4.2.0 - [@dbwiddis](https://github.com/dbwiddis). +* [#96](https://github.com/dblock/oshi/pull/96): Read buffer immediately after Runtime.exec to prevent deadlock - [@dbwiddis](https://github.com/dbwiddis). +* [#97](https://github.com/dblock/oshi/pull/97): Add system serial number - [@dbwiddis](https://github.com/dbwiddis). + +1.5 (9/21/2015) +================ +* [#87](https://github.com/dblock/oshi/pull/87): Added SLF4J logging, changed exception throwing to log errors to be robust to lack of permissions - [@dbwiddis](https://github.com/dbwiddis). + +1.4 (9/3/2015) +================ +* [#71](https://github.com/dblock/oshi/pull/71), [#72](https://github.com/dblock/oshi/pull/72): Added support for Windows 10 & Windows Server 2016 - [@laurent-r](https://github.com/laurent-r). +* [#75](https://github.com/dblock/oshi/pull/75): Added uptime information - [@dbwiddis](https://github.com/dbwiddis). +* [#76](https://github.com/dblock/oshi/pull/76): Better linux CPU processor counting - [@dbwiddis](https://github.com/dbwiddis). +* [#78](https://github.com/dblock/oshi/pull/78): Execute FileSystemView on Swing's Event Dispatch Thread - [@dbwiddis](https://github.com/dbwiddis). + +1.3 (6/27/2015) +================ +* Upgraded to Java 7 base support +* Upgraded JNA to 4.1.0 +* Brought over lessons learned from [waffle](https://github.com/dblock/waffle) for building project from source. +* [#50](https://github.com/dblock/oshi/pull/50): Added file store information - [@dbwiddis](https://github.com/dbwiddis). +* [#51](https://github.com/dblock/oshi/pull/51): Added CPU Ticks and switched to OperatingSystemMXBean for CPU load / load average - [@dbwiddis](https://github.com/dbwiddis). +* [#62](https://github.com/dblock/oshi/pull/62): Added Per-Processor CPU Load and Ticks - [@dbwiddis](https://github.com/dbwiddis). + +1.2 (6/13/2014) +================ + +* Added TODO list and enhanced README documentation - [@ptitvert](https://github.com/ptitvert) +* Added Travis-CI - [@dblock](https://github.com/dblock). +* [#3](https://github.com/dblock/oshi/pull/3): Mavenized project - [@le-yams](https://github.com/le-yams). +* [#5](https://github.com/dblock/oshi/pull/5): Added Linux support - [@ptitvert](https://github.com/ptitvert). +* [#7](https://github.com/dblock/oshi/pull/7): Added Mac OS X Support - [@ptitvert](https://github.com/ptitvert). +* [#13](https://github.com/dblock/oshi/pull/13): Support for Windows 8.1 and Windows Server 2008 R2 - [@NagyGa1](https://github.com/NagyGa1). +* [#15](https://github.com/dblock/oshi/pull/15), [#18](https://github.com/dblock/oshi/pull/18): Added support for CPU load - [@kamenitxan](https://github.com/kamenitxan), [@Sorceror](https://github.com/Sorceror). +* [#25](https://github.com/dblock/oshi/pull/25), [#29](https://github.com/dblock/oshi/pull/29): Included inactive/reclaimable memory amount in GlobalMemory#getAvailable on Mac/Linux - [@dbwiddis](https://github.com/dbwiddis). +* [#27](https://github.com/dblock/oshi/pull/27): Replaced all Mac OS X command line parsing with JNA or System properties - [@dbwiddis](https://github.com/dbwiddis). +* [#30](https://github.com/dblock/oshi/pull/30): Added processor vendor frequency information - [@alessiofachechi](https://github.com/alessiofachechi). +* [#32](https://github.com/dblock/oshi/pull/32): Added battery state information - [@dbwiddis](https://github.com/dbwiddis). + +1.1 (10/13/2013) +================ + +* Added support for Windows 8 to `oshi.software.os.OperatingSystemVersion`, `oshi.software.os.windows.nt.OSVersionInfoEx` - [@laurent-r](https://github.com/laurent-r). + +1.0 (6/23/2010) +=============== + +* Initial public release - [@dblock](https://github.com/dblock). diff --git a/reference/CONTRIBUTING.md b/reference/CONTRIBUTING.md new file mode 100644 index 0000000..1098523 --- /dev/null +++ b/reference/CONTRIBUTING.md @@ -0,0 +1,116 @@ +Contributing to Oshi +===================== + +Oshi is work of [many contributors](https://github.com/oshi/oshi/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/oshi/oshi/pulls), [propose features and discuss issues](https://github.com/oshi/oshi/issues). + +OSHI is [first-timers-only](https://www.firsttimersonly.com/) friendly. If you're new to open source, or coding, or git, we're happy to help you get started! Look for the `first-timers-only` or `good first issue` tags on issues, or simply post a new issue asking how you can help. We'll walk you through the steps needed to contribute to the project. + +#### Fork the Project + +Fork the project on Github by clicking on the word "Fork" above and to the right of this page. This will create your own fork at https://github.com/yournamehere/oshi.git. Then clone your fork to your local repository on your machine using these commands: +``` +git clone https://github.com/yournamehere/oshi.git +cd oshi +git remote add upstream https://github.com/oshi/oshi.git +``` + +#### Create a Topic Branch + +Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. + +``` +git checkout master +git pull upstream master +git checkout -b my-feature-branch +``` + +#### Build and Test + +Ensure that you can build the project and run tests. + +``` +mvn test +``` + +#### Write Tests + +Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. + +We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. + +#### Write Code + +Implement your feature or bug fix. + +Make sure that `mvn test` completes without errors. + +#### Write Documentation + +Document any external behavior in the [README](README.md). + +#### Update Changelog + +Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account. + +#### Commit Changes + +Make sure git knows your name and email address: + +``` +git config --global user.name "Your Name" +git config --global user.email "contributor@example.com" +``` + +Writing good commit logs is important. A commit log should describe what changed and why. + +``` +git add ... +git commit +``` + +#### Push + +``` +git push origin my-feature-branch +``` + +#### Make a Pull Request + +Go to https://github.com/contributor/oshi and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. + +#### Rebase + +If you've been working on a change for a while, rebase with upstream/master. + +``` +git fetch upstream +git rebase upstream/master +git push origin my-feature-branch -f +``` + +#### Update CHANGELOG Again + +Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. + +``` +* [#123](https://github.com/oshi/oshi/pull/123): Reticulated splines - [@contributor](https://github.com/contributor). +``` + +Amend your previous commit and force push the changes. + +``` +git commit --amend +git push origin my-feature-branch -f +``` + +#### Check on Your Pull Request + +Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above. + +#### Be Patient + +It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there! + +#### Thank You + +Please do know that we really appreciate and value your time and work. We love you, really. diff --git a/reference/FAQ.md b/reference/FAQ.md new file mode 100644 index 0000000..9fc0a5b --- /dev/null +++ b/reference/FAQ.md @@ -0,0 +1,38 @@ +What is the intended use of the API? +======== +Users should create a new instance of [SystemInfo](http://oshi.github.io/oshi/apidocs/oshi/SystemInfo.html). This provides access to the platform-specific hardware and software interfaces using the respective `get*()` methods. The interfaces in `oshi.hardware` and `oshi.software.os` provide cross-platform functionality. See the `main()` method of [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) for sample code. + +Methods return a "snapshot" of current levels. To display values which change over time, it is intended that users poll for information no more frequently than approximately every second. Disk and file system calls may incur some latency and should be polled less frequently. + +Is the API compatible between versions? +======== +The interfaces and classes in `oshi.hardware` and `oshi.software.os` are considered the OSHI API and are guaranteed to be compatible with the same major version. Differences between major versions can be found in the [UPGRADING.md](UPGRADING.md) document. + +Most, if not all, of the platform-specific implementations of these APIs in lower level packages will remain the same, although it is not intended that users access platform-specific code, and some changes may occur between minor versions. Supporting code in the `oshi.util` package may, rarely, change between minor versions, usually associated with organizing package structure or changing parsing methods for efficiency/consistency/ease of use. + +Code in the platform-specific `oshi.jna.*` packages is intended to be temporary and will be removed when that respective code is included in the JNA project. + +What minimum Java version is required? +======== +OSHI 3.x is compatible with Java 7 and will remain so with bug fixes. OSHI 4.x requires minimum Java 8 compatibility, and OSHI 5.x (envisioned in 2020) will require Java 11. + +Which operating systems are supported? +======== +OSHI has been implemented and tested on the following systems. Some features may work on earlier versions. +* Windows 7 and higher. (Nearly all features work on Vista and most work on Windows XP.) +* Mac OS X version 10.6 (Snow Leopard) and higher +* Linux (Most major distributions) Kernel 2.6 and higher +* Unix: Solaris 11 (SunOS 5.11) / FreeBSD 10 + + +What API features are not implemented on some operating systems? +======== +The following generally summarizes known exceptions. If you have missing data that is not on this list, please report it in an issue so we can investigate. +* Windows does not provide a load average, so the Processor's `getSystemLoadAverage()` returns -1. +* MacOS does not track time processors spend idle due to hard disk latency (iowait) or time spent processing hardware or software interrupts, and returns 0 for those associated tick values. +* Windows sensor (temperature, fans, voltage) readings are drawn from Microsoft's Windows Management Instrumentation (WMI) API; however, most hardware manufacturers do not publish these readings to WMI. If a value is not available through the Microsoft API, Oshi will attempt to retrieve values as published by the [Open Hardware Monitor](http://openhardwaremonitor.org/) if it is running. Only temperature sensors are detected on FreeBSD using `coretemp`. +* Linux, Solaris, and FreeBSD may require either running as root/sudo or additional software installs for full capability, particularly HAL daemon (`hald`/`lshal`) and X (`xrandr`). + +Will you implement ... ? +======== +Maybe! If you can contribute all the code to implement the feature, it will almost certainly be added. Even if you can't code but can provide pointers to where the information can be found cross-platform, your feature has a good chance. Otherwise, you can always submit an issue to ask, but are at the mercy of the developers' time, enthusiasm level, and the availability of documentation for the feature. diff --git a/reference/LICENSE_HEADER b/reference/LICENSE_HEADER new file mode 100644 index 0000000..7837e10 --- /dev/null +++ b/reference/LICENSE_HEADER @@ -0,0 +1,21 @@ +OSHI (https://github.com/oshi/oshi) + +Copyright (c) 2010 - 2019 The OSHI Project Team: +https://github.com/oshi/oshi/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/reference/README.md b/reference/README.md new file mode 100644 index 0000000..509d037 --- /dev/null +++ b/reference/README.md @@ -0,0 +1,229 @@ +![OSHI](https://dl.dropboxusercontent.com/s/c82qboyvvudpvdp/oshilogo.png) + +[![Maven central](https://maven-badges.herokuapp.com/maven-central/com.github.oshi/oshi-core/badge.svg?)](https://search.maven.org/search?q=com.github.oshi) +[![Travis Build Status](https://travis-ci.org/oshi/oshi.svg)](https://travis-ci.org/oshi/oshi) +[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/v489i8xoyfspxx7s?svg=true)](https://ci.appveyor.com/project/dbwiddis/oshi) +[![Coverage Status](https://coveralls.io/repos/github/oshi/oshi/badge.svg?branch=master)](https://coveralls.io/github/oshi/oshi?branch=master) +[![codecov.io](https://codecov.io/github/oshi/oshi/coverage.svg?branch=master)](https://codecov.io/github/oshi/oshi?branch=master) +[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/9332.svg)](https://scan.coverity.com/projects/dblock-oshi) +[![Codacy Grade](https://api.codacy.com/project/badge/Grade/5370178ae91d4f56b43de2f26f7c5e7a)](https://www.codacy.com/app/widdis/oshi?utm_source=github.com&utm_medium=referral&utm_content=oshi/oshi&utm_campaign=Badge_Grade) +[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![SonarQube Bugs](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=bugs)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Maintainability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Reliability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Security](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=security_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/oshi/oshi.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/oshi/oshi/context:java) +[![LGTM Stats](https://www.openhub.net/p/oshi/widgets/project_thin_badge.gif)](https://www.openhub.net/p/oshi?ref=github) +[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/) +[![Join the chat at https://gitter.im/oshi/oshi](https://badges.gitter.im/oshi/oshi.svg)](https://gitter.im/oshi/oshi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/dbwiddis) + +OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java. +It does not require the installation of any additional native libraries and aims to provide a +cross-platform implementation to retrieve system information, such as OS version, processes, +memory & CPU usage, disks & partitions, devices, sensors, etc. + +Supported platforms +--------------------------- +Windows • Linux • Mac OS X • Unix (Solaris, FreeBSD) + +Essentials +---------- +* [API](http://oshi.github.io/oshi/apidocs/) +* [Find OSHI on Maven Central](https://search.maven.org/search?q=com.github.oshi) +* [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md) +* [Upgrading from an earlier version?](https://github.com/oshi/oshi/blob/master/UPGRADING.md) + +Supported features +-------------------------- +* Computer System and firmware, baseboard +* Operating System and Version/Build +* Physical (core) and Logical (hyperthreaded) CPUs +* System and per-processor load % and tick counters +* CPU uptime, processes, and threads +* Process uptime, CPU, memory usage +* Physical and virtual memory used/available +* Mounted filesystems (type, usable and total space) +* Disk drives (model, serial, size) and partitions +* Network interfaces (IPs, bandwidth in/out) +* Battery state (% capacity, time remaining) +* Connected displays (with EDID info) +* USB Devices +* Sensors (temperature, fan speeds, voltage) + +Downloads +--------- +| Stable Release Version | Current Development Version | Dependencies | +| ------------- | ------------- | ------------- | +| [oshi-core-3.13.3](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.github.oshi&a=oshi-core&v=3.13.3&e=jar) | [oshi-core-4.0.0-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.github.oshi&a=oshi-core&v=4.0.0-SNAPSHOT&e=jar) | [JNA](https://github.com/java-native-access/jna) • [SLF4J](http://www.slf4j.org/) | + +Output +------------- +OSHI provides output directly via Java methods for each of its interfaces. +By periodically polling dynamic information (e.g., every second), users can calculate and track changes. + +The `main()` method of [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +provides sample code demonstrating the use of `oshi-core` interfaces to retrieve information and calculate additional metrics shown in the examples below. + +General information about the operating system and computer system. +``` +Apple macOS 10.12.3 (Sierra) build 16D32 +manufacturer: Apple Inc. +model: MacBook Pro (MacBookPro8,2) +serialnumber: C02FG6XYDF71 +``` +Processor identification. +``` +Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz + 4 physical CPU(s) + 8 logical CPU(s) +Identifier: Intel64 Family 6 Model 42 Stepping 7 +ProcessorID: BFEBFBFF000206A7 +``` +By measuring ticks (user, nice, system, idle, iowait, and irq) between time intervals, percent usage can be calculated. +Java MXBean and per-processor information is also provided. +``` +CPU, IOWait, and IRQ ticks @ 0 sec:[967282, 15484, 195343, 124216619], 6176, [4054, 2702] +CPU, IOWait, and IRQ ticks @ 1 sec:[967308, 15484, 195346, 124216790], 6177, [4057, 2705] +User: 13.0% Nice: 0.0% System: 1.5% Idle: 85.5% +CPU load: 8.8% (counting ticks) +CPU load: 9.0% (OS MXBean) +CPU load averages: 2.69 2.47 2.38 +CPU load per processor: 23.6% 1.3% 18.2% 0.7% 12.9% 0.7% 12.1% 1.3% +``` +Process information including CPU and memory per process is available. +``` +Processes: 401, Threads: 1159 + PID %CPU %MEM VSZ RSS Name + 55977 27.9 0.2 6.8 GiB 34.3 MiB java + 51820 18.7 5.6 6.3 GiB 919.2 MiB eclipse + 39272 11.2 17.8 7.1 GiB 2.8 GiB prl_vm_app + 85316 6.5 2.9 5.6 GiB 471.4 MiB thunderbird + 35301 5.4 0.5 1.7 GiB 89.8 MiB Microsoft Excel + ``` +Memory and swapfile information is available. +``` +Memory: 2.9 GiB/16 GiB +Swap used: 90.8 MiB/1 GiB +``` +The EDID for each Display is provided. This can be parsed with various utilities for detailed information. OSHI provides a summary of selected data. +``` +Displays: + Display 0: + Manuf. ID=SAM, Product ID=2ad, Analog, Serial=HA19, ManufDate=3/2008, EDID v1.3 + 41 x 27 cm (16.1 x 10.6 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: H9FQ345476 + Display 1: + Manuf. ID=SAM, Product ID=226, Analog, Serial=HA19, ManufDate=4/2007, EDID v1.3 + 41 x 26 cm (16.1 x 10.2 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: HMCP431880 +``` +Disks and usage (reads, writes, transfer times) are shown, and partitions can be mapped to filesystems. +``` +Disks: + disk0: (model: SanDisk Ultra II 960GB - S/N: 161008800550) size: 960.2 GB, reads: 1053132 (23.0 GiB), writes: 243792 (11.1 GiB), xfer: 73424854 ms + |-- disk0s1: EFI (EFI System Partition) Maj:Min=1:1, size: 209.7 MB + |-- disk0s2: Macintosh HD (Macintosh SSD) Maj:Min=1:2, size: 959.3 GB @ / + disk1: (model: Disk Image - S/N: ) size: 960.0 GB, reads: 3678 (60.0 MiB), writes: 281 (8.6 MiB), xfer: 213627 ms + |-- disk1s1: EFI (EFI System Partition) Maj:Min=1:4, size: 209.7 MB + |-- disk1s2: Dropbox (disk image) Maj:Min=1:5, size: 959.7 GB @ /Volumes/Dropbox + +``` +Sensor readings are available for some hardware (see notes in the [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md)). +``` +Sensors: + CPU Temperature: 69.8°C + Fan Speeds:[4685, 4687] + CPU Voltage: 3.9V +``` +Attached USB devices can be listed: +``` +USB Devices: + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- IR Receiver (Apple Computer, Inc.) + |-- USB Receiver (Logitech) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- FaceTime HD Camera (Built-in) (Apple Inc.) [s/n: DJHB1V077FDH5HL0] + |-- IOUSBHostDevice + |-- Apple Internal Keyboard / Trackpad (Apple Inc.) + |-- BRCM2070 Hub (Apple Inc.) + |-- Bluetooth USB Host Controller (Apple Inc.) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- Apple Thunderbolt Display (Apple Inc.) [s/n: 162C0C25] + |-- Display Audio (Apple Inc.) [s/n: 162C0C25] + |-- FaceTime HD Camera (Display) (Apple Inc.) [s/n: CCGCAN000TDJ7DFX] + |-- USB2.0 Hub + |-- ANT USBStick2 (Dynastream Innovations) [s/n: 051] + |-- Fitbit Base Station (Fitbit Inc.) +``` + +You can run the [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +and see the full output for your system by cloning the project and building it with [Maven](http://maven.apache.org/index.html). + +``` +git clone https://github.com/oshi/oshi.git && cd oshi + +mvn test-compile -pl oshi-core -q exec:java \ + -Dexec.mainClass="oshi.SystemInfoTest" \ + -Dexec.classpathScope="test" +``` + +Where are we? +------------- +[OSHI originated](http://code.dblock.org/2010/06/23/introducing-oshi-operating-system-and-hardware-information-java.html) +as a platform-independent library that did not require additional software and had a license compatible with +both open source and commercial products. We have developed a strong core of features on major Operating Systems, +but we would love for *you* to help by: +* Testing! Our CI testing is limited. Download and test the program on various operating systems/versions and hardware and help identify gaps that our limited development and testing may have missed. +* Contributing ports. Have an OS that's not covered? It's likely one of the existing ports can be slightly modified. +* Contributing code. See something that's not working right or could work better? Help us fix it! New contributors welcome. +* Documenting implementation. Our Wiki is blank. Want to help new users follow in your footsteps? +* Suggesting new features. Do you need OSHI to do something it doesn't currently do? Let us know. + +Acknowledgements +------------------- +Many thanks to the following companies for providing free support of Open Source projects including OSHI: +* [SonarCloud](https://sonarcloud.io/about) for a range of code quality tools +* [Travis CI](https://travis-ci.org/) for continuous integration testing +* The [jProfile Java Profiler](https://www.ej-technologies.com/products/jprofiler/overview.html) used to eliminate cpu bottlenecks + +Projects using OSHI +------------------- +* [CAS Server](https://apereo.github.io/cas) +* [JPPF](https://jppf.org/) +* [Apache Flink](https://flink.apache.org/) +* [DeepLearning4J](https://deeplearning4j.org/) +* [PSI Probe](https://github.com/psi-probe/psi-probe) +* [GigaSpaces XAP](https://xap.github.io/) +* [openHAB Systeminfo Binding](https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.systeminfo) +* [Jenkins swarm plugin](https://wiki.jenkins.io/display/JENKINS/Swarm+Plugin) +* [Java for IBM Watson IoT Platform](https://ibm-watson-iot.github.io/iot-java/) +* [Semux](https://www.semux.org/) +* [Arthas](https://alibaba.github.io/arthas/en/) +* [Hawkular Agent](https://github.com/hawkular/hawkular-agent) +* [GeoServer](https://docs.geoserver.org/stable/en/user/community/status-monitoring/index.html) +* [UniversalMediaServer](https://github.com/UniversalMediaServer/UniversalMediaServer) +* [Dagr](https://github.com/fulcrumgenomics/dagr) +* [sys-API](https://github.com/Krillsson/sys-API) +* [NexCapMAT](http://www.nexess-solutions.com/fr/produits/application-nexcap-mat/) +* [360Suite](https://360suite.io/) +* [GoMint](https://gomint.io/) +* [Stefan's OS](https://BotCompany.de/) +* [Eclipse Passage](https://projects.eclipse.org/projects/technology.passage) +* [Eclipse Orbit](https://projects.eclipse.org/projects/tools.orbit) + +License +------- +This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/reference/RELEASING.md b/reference/RELEASING.md new file mode 100644 index 0000000..659f8b4 --- /dev/null +++ b/reference/RELEASING.md @@ -0,0 +1,49 @@ +Releasing OSHI +===================== +### Credentials + +* Put your [repository credentials in your Maven settings.xml file](http://central.sonatype.org/pages/apache-maven.html#distribution-management-and-authentication) for both snapshot and staging repositories in [pom.xml](pom.xml). +* Put your [gpg certificate credentials in the settings.xml file](http://central.sonatype.org/pages/apache-maven.html#gpg-signed-components) + +### Snapshots + +* Snapshot releases may be deployed using `mvn clean deploy` + * The version number in the pom.xml must end in -SNAPSHOT + +### Prepare + +* Make sure tests are green on [Travis CI](https://travis-ci.org/oshi/oshi). +* Review [SonarQube](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) for any bugs. +* Run `mvn clean test` on every OS you have access to +* Choose an appropriate [version number](http://semver.org/) for the release + * Proactively change version numbers in the download links on [README.md](README.md). + * Copy [README.md](README.md) to [src/site/markdown/README.md](src/site/markdown/README.md) + * HTML-escape `&`, `<`, and `>` in any links in the site version + * Change "Next" or in-progress version in [CHANGELOG.md](CHANGELOG.md) to this new version. + * Move "Your contribution here." to a new empty "Next" section + * Commit changes as a "prep for x.x release" + +### Release + +* See [this page](http://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin) for a summary of the below steps +* `mvn clean deploy` + * Do a final snapshot release and fix any errors in the javadocs + * If license headers are rewritten as part of this deployment, commit the changes +* `mvn release:clean` + * Takes a few seconds +* `mvn release:prepare` + * Takes a few minutes + * This will ask for the version being released, removing -SNAPSHOT + * This will suggest the next version, increment appropriately +* `mvn release:perform` + * Takes a few minutes. + * This pushes the release to the [Nexus](https://oss.sonatype.org/) staging repository + * This also pushes to [gh_pages](https://oshi.github.io/oshi) +* Log on to [Nexus](https://oss.sonatype.org/) and [release the deployment from OSSRH to the Central Repository](http://central.sonatype.org/pages/releasing-the-deployment.html). + +* Add a title and release notes [to the tag](https://github.com/oshi/oshi/tags) on GitHub and publish the release to make it current. + +* As development progresses, update version in [pom.xml](pom.xml) using -SNAPSHOT appended to the new version using [Semantic Versioning](http://semver.org/) standards: + * Increment major version (x.0) for API-breaking changes or additions + * Increment minor version (x.1) for substantive additions, bugfixes and changes that are backwards compatible + * Increment patch version (x.x.1) for minor bugfixes or changes that are backwards compatible diff --git a/reference/UPGRADING.md b/reference/UPGRADING.md new file mode 100644 index 0000000..97fc050 --- /dev/null +++ b/reference/UPGRADING.md @@ -0,0 +1,135 @@ + +# Guide to upgrading from OSHI 3.x to 4.x + +OSHI 4.0 requires minimum Java 8 compatibility. + +The `oshi-json` artifact has been completely removed. It is trivial to obtain +JSON output using [Jackson's ObjectMapper](http://www.mkyong.com/java/ +jackson-2-convert-java-object-to-from-json/). + +There is a new `oshi-demo` artifact which will contain many "how to" classes +to demonstrate OSHI's capabilities and integration with other libraries. + +## API Changes + +`NetworkIF#getNetworkInterface()` is now `queryNetworkInterface()` to prevent +Jackson's ObjectMapper from attempting to serialize the returned object. + +There is a new `VirtualMemory `class which is accessible with a getter from +`GlobalMemory`. Methods associated with swap file usage were moved to this +new class. + +The `CentralProcessor` setters were removed from the API. The methods +`getSystemCpuLoadBetweenTicks()` and `getProcessorCpuLoadBetweenTicks()` now take +an argument with the previous set of ticks, rather than internally saving the +previous call. This enables users to measure over a longer period or multiple +different periods. The `getSystemCpuLoad()` method is now a direct passthrough +to the `OperatingSystemMXBean` method if running an Oracle JVM, otherwise it +returns a negative value. The no-argument `getSystemLoadAverage()` has been +removed; users can call with an argument of 1 to obtain the same value. + +The `getSystemUptime()` method was moved from the `CentralProcessor` class to +the `OperatingSystem` class. + +The `NetworkIF#updateNetworkStats()` and `HWDiskStore#updateDiskStats()` methods +were renamed to `updateAttributes()` to conform to other similarly named methods +to permit update of individual elements of arrays. + +# Guide to upgrading from OSHI 2.x to 3.x + +The most significant change in OSHI 3.0 is the separation of JSON output to a +separate artifact, filtering output using configurable properties. Users of +`oshi-core` who do not require JSON will find most of the API the same except +as noted below. Those who use JSON will find improved functionality in the +`oshi-json` module. + +## API Changes - oshi-core + +The `CentralProcessor`'s `getSystemIOWaitTicks()` and `getSystemIrqTicks()` +methods were removed. The `getSystemCpuLoadTicks()` now include the IOWait and +IRQ tick information previously reported by those methods, although Idle time +no longer includes IOWait, and System Time no longer includes IRQ ticks. The +`getProcessorCpuLoadTicks()` now includes per-processor IOWait and IRQ tick +information. + +The `getFileSystem()` method was moved from the `HardwareAbstractionLayer` to +the `OperatingSystem`. The `getFileStores()` method on the +`HardwareAbstractionLayer` was redundant with the same method on the +`FileSystem` class and was removed. + +The `OSProcess` methods (`getProcesses()`, `getProcess()`, `getProcessId()`, +`getProcessCount()`, and `getThreadCount()`) were moved from the +`CentralProcessor` to the `OperatingSystem`. + +The (`OperatingSystem`'s) `getProcesses()` method now takes two arguments, to +limit the number of results returned, and to sort the results. + +The `HardwareAbstractionLayer`'s `getUsbDevices()` method now takes a boolean +argument which offers both the existing tree-based or a flat list format. + +The `Networks` interface had an `updateNetworkStats()` method that was not +reachable from cross-platform code. That method is now on the `NetworkIF` +class. + +## API Changes - oshi-json + +Decorator classes for the OSHI API which enable JSON functionality are now in +the `oshi.json.*` packages with the same API changes in the previous section. + +JSON objects associated with the above method changes were updated: + - `systemCpuLoadTicks` and `processorCpuLoadTicks` now have 7-element arrays + instead of 4, and the `systemIOWaitTicks` and `systemIrqTicks` elements have + been removed from the `processor` object. + - `fileSystem` is now an element of `operatingSystem` rather than `processor`. + - `fileStores` is now an element of `fileSystem` rather than `processor`. + - `processID`, `processCount`, `threadCount`, and `processes` are now + elements of `operatingSystem` rather than `processor`. + +While the existing `toJSON()` method remains and is backwards compatible, the +new API permits using a `java.util.Properties` object as an optional parameter +which will be persistent to future (no argument) calls to that method until +replaced. See the [FAQ](FAQ.md) for more information. + +# Guide to upgrading from OSHI 1.x to 2.x + +Even though it's a major release, OSHI 2.0 functionality is identical to +1.5.2. For the most part, the highest level APIs demonstrated in the test +classes have remained the same, except as documented below. Several lower +level packages and classes have been moved and/or renamed. + +## Package Changes + +New packages `oshi.jna.platform.*` were created and code which extends +`com.sun.jna.Library` was moved into its respective platform library. These +classes should be considered non-API as they may be removed if/when their +code is incorporated into the JNA project. + +New packages `oshi.hardware.platform.*` were created and contain the +platform-specific implementations of interfaces in `oshi.hardware`, with +implementing classes renamed to prepend the platform name to the interface +name. Similar renaming was done for implementations of `oshi.software.os` +in the respective `oshi.software.os.*` packages. + +## API Changes + +The `Memory` interface was renamed `GlobalMemory` to avoid name conflict with +JNA's `Memory` class. + +The `Processor` interface, which represented one of an array of logical +processor objects, was renamed `CentralProcessor` and represents the entire +System CPU which may contain multiple logical processors. Methods applicable +to an individual logical processor were modified to return arrays. + +The `HardwareAbstractionLayer`'s `getProcessors()` method was renamed to +`getProcessor()` and now returns a singular `CentralProcessor` object. + +Specific changes to `CentralProcessor` methods: +* The constructor no longer takes a processor number argument and the +`getProcessorNumber()` method was removed +* The deprecated `getLoad()` method was removed. Use +`getSystemCpuLoadBetweenTicks()`. +* The `getProcessorCpuLoadBetweenTicks()` method now returns an array of +load values, one value for each logical processor. +* The `getProcessorCpuLoadTicks()` method now returns a two dimensional +array; one array per logical processor, each containing the tick values +previously returned for a single processor. diff --git a/reference/appveyor.yml b/reference/appveyor.yml new file mode 100644 index 0000000..5fac482 --- /dev/null +++ b/reference/appveyor.yml @@ -0,0 +1,52 @@ +# +# OSHI (https://github.com/oshi/oshi) +# +# Copyright (c) 2010 - 2019 The OSHI Project Team: +# https://github.com/oshi/oshi/graphs/contributors +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +version: '{build}' + +image: Visual Studio 2017 + +branches: + except: + - coverity_scan + +skip_tags: true + +environment: + TERM: dumb + matrix: + - JAVA_HOME: C:\Program Files\Java\jdk1.8.0 + - JAVA_HOME: C:\Program Files\Java\jdk11 + +init: + - git config --global --unset core.autocrlf + +install: + - mvn --version + - java -version + +build_script: + - appveyor-retry mvn clean package -Dmaven.test.skip=true + +test_script: + - mvn test diff --git a/reference/mvnw b/reference/mvnw new file mode 100755 index 0000000..d2f0ea3 --- /dev/null +++ b/reference/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/reference/mvnw.cmd b/reference/mvnw.cmd new file mode 100644 index 0000000..b26ab24 --- /dev/null +++ b/reference/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/reference/oshi-core-shaded/pom.xml b/reference/oshi-core-shaded/pom.xml new file mode 100644 index 0000000..0636e43 --- /dev/null +++ b/reference/oshi-core-shaded/pom.xml @@ -0,0 +1,127 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-core-shaded + jar + + oshi-core-shaded + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + ${project.parent.basedir} + + + + + org.slf4j + slf4j-jdk14 + ${slf4j.version} + runtime + true + + + ${project.groupId} + oshi-core + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade-plugin.version} + + + package + + shade + + + + + org.slf4j:slf4j-api: + org.slf4j:slf4j-jdk14: + + + true + true + + + + + + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + javadoc-jar + package + + jar + + + true + + + com.github.oshi:* + + + + + + + biz.aQute.bnd + bnd-maven-plugin + ${bnd-maven-plugin.version} + + + + + + + diff --git a/reference/oshi-core/pom.xml b/reference/oshi-core/pom.xml new file mode 100644 index 0000000..a299c0b --- /dev/null +++ b/reference/oshi-core/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-core + jar + + oshi-core + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + 5.4.0 + ${project.parent.basedir} + + + + + net.java.dev.jna + jna + ${jna.version} + + + net.java.dev.jna + jna-platform + ${jna.version} + + + + com.squareup + javapoet + 1.11.1 + + + com.fasterxml.jackson.core + jackson-databind + 2.6.3 + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + diff --git a/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java b/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java new file mode 100644 index 0000000..7877890 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.api.hardware.nic.NicFreeBsd; + +@Generated("oshi.ApiGenerator") +public interface FreeBsdSystem extends MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareFreeBsd getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java b/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java new file mode 100644 index 0000000..85ac695 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskLinux; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.api.hardware.nic.NicLinux; + +@Generated("oshi.ApiGenerator") +public interface LinuxSystem extends MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareLinux getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java b/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java new file mode 100644 index 0000000..0388301 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskMac; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.api.hardware.nic.NicMac; + +@Generated("oshi.ApiGenerator") +public interface MacSystem extends MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareMac getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java b/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java new file mode 100644 index 0000000..1abef24 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.Disk; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.nic.Nic; + +@Generated("oshi.ApiGenerator") +public interface MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + Firmware getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java b/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java new file mode 100644 index 0000000..d98066c --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.api.hardware.nic.NicSolaris; + +@Generated("oshi.ApiGenerator") +public interface SolarisSystem extends MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareSolaris getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java b/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java new file mode 100644 index 0000000..39e2425 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskWindows; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.api.hardware.nic.NicWindows; + +@Generated("oshi.ApiGenerator") +public interface WindowsSystem extends MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareWindows getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java new file mode 100644 index 0000000..23cc81d --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java @@ -0,0 +1,147 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; +import oshi.api.Container; + +@Generated("oshi.ApiGenerator") +public interface Disk extends Container { + String getName(); + + String getPath(); + + String getModel(); + + String getSerial(); + + Long getSize(); + + Long querySize(); + + Long getReads(); + + Long queryReads(); + + Long getReadBytes(); + + Long queryReadBytes(); + + Long getWrites(); + + Long queryWrites(); + + Long getWriteBytes(); + + Long queryWriteBytes(); + + Long getQueueLength(); + + Long queryQueueLength(); + + Long getTransferTime(); + + Long queryTransferTime(); + + String getModelFamily(); + + String queryModelFamily(); + + String getFirmwareVersion(); + + String queryFirmwareVersion(); + + Long getRotationRate(); + + Long queryRotationRate(); + + Long getReadErrorRate(); + + Long queryReadErrorRate(); + + Long getSpinUpTime(); + + Long querySpinUpTime(); + + Long getStartStopCycles(); + + Long queryStartStopCycles(); + + Long getReallocatedSectors(); + + Long queryReallocatedSectors(); + + Long getSeekErrorRate(); + + Long querySeekErrorRate(); + + Long getPowerOnTime(); + + Long queryPowerOnTime(); + + Long getSpinRetries(); + + Long querySpinRetries(); + + Long getCalibrationRetries(); + + Long queryCalibrationRetries(); + + Long getPowerCycles(); + + Long queryPowerCycles(); + + Long getPoweroffRetracts(); + + Long queryPoweroffRetracts(); + + Long getLoadCycles(); + + Long queryLoadCycles(); + + Long getTemperature(); + + Long queryTemperature(); + + Long getReallocatedEvents(); + + Long queryReallocatedEvents(); + + Long getCurrentPendingSector(); + + Long queryCurrentPendingSector(); + + Long getOfflineUncorrectable(); + + Long queryOfflineUncorrectable(); + + Long getCrcErrors(); + + Long queryCrcErrors(); + + Long getMultizoneErrorRate(); + + Long queryMultizoneErrorRate(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java new file mode 100644 index 0000000..6e57bf6 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java @@ -0,0 +1,103 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.internal.DiskAttributeEnum; + +@Generated("oshi.ApiGenerator") +public class DiskAttribute { + public static final AttributeKey NAME = new AttributeKey<>(DiskAttributeEnum.NAME); + + public static final AttributeKey PATH = new AttributeKey<>(DiskAttributeEnum.PATH); + + public static final AttributeKey MODEL = new AttributeKey<>(DiskAttributeEnum.MODEL); + + public static final AttributeKey SERIAL = new AttributeKey<>(DiskAttributeEnum.SERIAL); + + /** + * The disk's total size in bytes + */ + public static final AttributeKey SIZE = new AttributeKey<>(DiskAttributeEnum.SIZE); + + public static final AttributeKey READS = new AttributeKey<>(DiskAttributeEnum.READS); + + public static final AttributeKey READ_BYTES = new AttributeKey<>(DiskAttributeEnum.READ_BYTES); + + public static final AttributeKey WRITES = new AttributeKey<>(DiskAttributeEnum.WRITES); + + public static final AttributeKey WRITE_BYTES = new AttributeKey<>(DiskAttributeEnum.WRITE_BYTES); + + public static final AttributeKey QUEUE_LENGTH = new AttributeKey<>(DiskAttributeEnum.QUEUE_LENGTH); + + public static final AttributeKey TRANSFER_TIME = new AttributeKey<>(DiskAttributeEnum.TRANSFER_TIME); + + public static final AttributeKey MODEL_FAMILY = new AttributeKey<>(DiskAttributeEnum.MODEL_FAMILY); + + public static final AttributeKey FIRMWARE_VERSION = new AttributeKey<>(DiskAttributeEnum.FIRMWARE_VERSION); + + public static final AttributeKey ROTATION_RATE = new AttributeKey<>(DiskAttributeEnum.ROTATION_RATE); + + public static final AttributeKey READ_ERROR_RATE = new AttributeKey<>(DiskAttributeEnum.READ_ERROR_RATE); + + public static final AttributeKey SPIN_UP_TIME = new AttributeKey<>(DiskAttributeEnum.SPIN_UP_TIME); + + public static final AttributeKey START_STOP_CYCLES = new AttributeKey<>(DiskAttributeEnum.START_STOP_CYCLES); + + public static final AttributeKey REALLOCATED_SECTORS = new AttributeKey<>( + DiskAttributeEnum.REALLOCATED_SECTORS); + + public static final AttributeKey SEEK_ERROR_RATE = new AttributeKey<>(DiskAttributeEnum.SEEK_ERROR_RATE); + + public static final AttributeKey POWER_ON_TIME = new AttributeKey<>(DiskAttributeEnum.POWER_ON_TIME); + + public static final AttributeKey SPIN_RETRIES = new AttributeKey<>(DiskAttributeEnum.SPIN_RETRIES); + + public static final AttributeKey CALIBRATION_RETRIES = new AttributeKey<>( + DiskAttributeEnum.CALIBRATION_RETRIES); + + public static final AttributeKey POWER_CYCLES = new AttributeKey<>(DiskAttributeEnum.POWER_CYCLES); + + public static final AttributeKey POWEROFF_RETRACTS = new AttributeKey<>(DiskAttributeEnum.POWEROFF_RETRACTS); + + public static final AttributeKey LOAD_CYCLES = new AttributeKey<>(DiskAttributeEnum.LOAD_CYCLES); + + public static final AttributeKey TEMPERATURE = new AttributeKey<>(DiskAttributeEnum.TEMPERATURE); + + public static final AttributeKey REALLOCATED_EVENTS = new AttributeKey<>( + DiskAttributeEnum.REALLOCATED_EVENTS); + + public static final AttributeKey CURRENT_PENDING_SECTOR = new AttributeKey<>( + DiskAttributeEnum.CURRENT_PENDING_SECTOR); + + public static final AttributeKey OFFLINE_UNCORRECTABLE = new AttributeKey<>( + DiskAttributeEnum.OFFLINE_UNCORRECTABLE); + + public static final AttributeKey CRC_ERRORS = new AttributeKey<>(DiskAttributeEnum.CRC_ERRORS); + + public static final AttributeKey MULTIZONE_ERROR_RATE = new AttributeKey<>( + DiskAttributeEnum.MULTIZONE_ERROR_RATE); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java new file mode 100644 index 0000000..a4a30c7 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskFreeBsd extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java new file mode 100644 index 0000000..143aa31 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskLinux extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java new file mode 100644 index 0000000..a9d2f65 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskMac extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java new file mode 100644 index 0000000..727eb5d --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskSolaris extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java new file mode 100644 index 0000000..dc44c35 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskWindows extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttributeEnum.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttributeEnum.java new file mode 100644 index 0000000..c9698ca --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttributeEnum.java @@ -0,0 +1,93 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; +import oshi.driver.AttributeEnum; + +@Generated("oshi.ApiGenerator") +public enum DiskAttributeEnum implements AttributeEnum { + NAME, + + PATH, + + MODEL, + + SERIAL, + + SIZE, + + READS, + + READ_BYTES, + + WRITES, + + WRITE_BYTES, + + QUEUE_LENGTH, + + TRANSFER_TIME, + + MODEL_FAMILY, + + FIRMWARE_VERSION, + + ROTATION_RATE, + + READ_ERROR_RATE, + + SPIN_UP_TIME, + + START_STOP_CYCLES, + + REALLOCATED_SECTORS, + + SEEK_ERROR_RATE, + + POWER_ON_TIME, + + SPIN_RETRIES, + + CALIBRATION_RETRIES, + + POWER_CYCLES, + + POWEROFF_RETRACTS, + + LOAD_CYCLES, + + TEMPERATURE, + + REALLOCATED_EVENTS, + + CURRENT_PENDING_SECTOR, + + OFFLINE_UNCORRECTABLE, + + CRC_ERRORS, + + MULTIZONE_ERROR_RATE +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java new file mode 100644 index 0000000..2d842e6 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java @@ -0,0 +1,581 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.DetachedContainerException; +import oshi.api.hardware.disk.Disk; +import oshi.api.internal.AbstractContainer; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public abstract class DiskContainer extends AbstractContainer implements Disk { + public String name; + + public String path; + + public String model; + + public String serial; + + /** + * The disk's total size in bytes + */ + public Long size; + + public Long reads; + + public Long readBytes; + + public Long writes; + + public Long writeBytes; + + public Long queueLength; + + public Long transferTime; + + public String modelFamily; + + public String firmwareVersion; + + public Long rotationRate; + + public Long readErrorRate; + + public Long spinUpTime; + + public Long startStopCycles; + + public Long reallocatedSectors; + + public Long seekErrorRate; + + public Long powerOnTime; + + public Long spinRetries; + + public Long calibrationRetries; + + public Long powerCycles; + + public Long poweroffRetracts; + + public Long loadCycles; + + public Long temperature; + + public Long reallocatedEvents; + + public Long currentPendingSector; + + public Long offlineUncorrectable; + + public Long crcErrors; + + public Long multizoneErrorRate; + + @Override + public String getName() { + return name; + } + + @Override + public String getPath() { + return path; + } + + @Override + public String getModel() { + return model; + } + + @Override + public String getSerial() { + return serial; + } + + @Override + public Long getSize() { + return size; + } + + @Override + public Long querySize() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SIZE); + return size; + } + + @Override + public Long getReads() { + return reads; + } + + @Override + public Long queryReads() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.READS); + return reads; + } + + @Override + public Long getReadBytes() { + return readBytes; + } + + @Override + public Long queryReadBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.READ_BYTES); + return readBytes; + } + + @Override + public Long getWrites() { + return writes; + } + + @Override + public Long queryWrites() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.WRITES); + return writes; + } + + @Override + public Long getWriteBytes() { + return writeBytes; + } + + @Override + public Long queryWriteBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.WRITE_BYTES); + return writeBytes; + } + + @Override + public Long getQueueLength() { + return queueLength; + } + + @Override + public Long queryQueueLength() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.QUEUE_LENGTH); + return queueLength; + } + + @Override + public Long getTransferTime() { + return transferTime; + } + + @Override + public Long queryTransferTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.TRANSFER_TIME); + return transferTime; + } + + @Override + public String getModelFamily() { + return modelFamily; + } + + @Override + public String queryModelFamily() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.MODEL_FAMILY); + return modelFamily; + } + + @Override + public String getFirmwareVersion() { + return firmwareVersion; + } + + @Override + public String queryFirmwareVersion() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.FIRMWARE_VERSION); + return firmwareVersion; + } + + @Override + public Long getRotationRate() { + return rotationRate; + } + + @Override + public Long queryRotationRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.ROTATION_RATE); + return rotationRate; + } + + @Override + public Long getReadErrorRate() { + return readErrorRate; + } + + @Override + public Long queryReadErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.READ_ERROR_RATE); + return readErrorRate; + } + + @Override + public Long getSpinUpTime() { + return spinUpTime; + } + + @Override + public Long querySpinUpTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SPIN_UP_TIME); + return spinUpTime; + } + + @Override + public Long getStartStopCycles() { + return startStopCycles; + } + + @Override + public Long queryStartStopCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.START_STOP_CYCLES); + return startStopCycles; + } + + @Override + public Long getReallocatedSectors() { + return reallocatedSectors; + } + + @Override + public Long queryReallocatedSectors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.REALLOCATED_SECTORS); + return reallocatedSectors; + } + + @Override + public Long getSeekErrorRate() { + return seekErrorRate; + } + + @Override + public Long querySeekErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SEEK_ERROR_RATE); + return seekErrorRate; + } + + @Override + public Long getPowerOnTime() { + return powerOnTime; + } + + @Override + public Long queryPowerOnTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.POWER_ON_TIME); + return powerOnTime; + } + + @Override + public Long getSpinRetries() { + return spinRetries; + } + + @Override + public Long querySpinRetries() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SPIN_RETRIES); + return spinRetries; + } + + @Override + public Long getCalibrationRetries() { + return calibrationRetries; + } + + @Override + public Long queryCalibrationRetries() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.CALIBRATION_RETRIES); + return calibrationRetries; + } + + @Override + public Long getPowerCycles() { + return powerCycles; + } + + @Override + public Long queryPowerCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.POWER_CYCLES); + return powerCycles; + } + + @Override + public Long getPoweroffRetracts() { + return poweroffRetracts; + } + + @Override + public Long queryPoweroffRetracts() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.POWEROFF_RETRACTS); + return poweroffRetracts; + } + + @Override + public Long getLoadCycles() { + return loadCycles; + } + + @Override + public Long queryLoadCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.LOAD_CYCLES); + return loadCycles; + } + + @Override + public Long getTemperature() { + return temperature; + } + + @Override + public Long queryTemperature() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.TEMPERATURE); + return temperature; + } + + @Override + public Long getReallocatedEvents() { + return reallocatedEvents; + } + + @Override + public Long queryReallocatedEvents() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.REALLOCATED_EVENTS); + return reallocatedEvents; + } + + @Override + public Long getCurrentPendingSector() { + return currentPendingSector; + } + + @Override + public Long queryCurrentPendingSector() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.CURRENT_PENDING_SECTOR); + return currentPendingSector; + } + + @Override + public Long getOfflineUncorrectable() { + return offlineUncorrectable; + } + + @Override + public Long queryOfflineUncorrectable() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.OFFLINE_UNCORRECTABLE); + return offlineUncorrectable; + } + + @Override + public Long getCrcErrors() { + return crcErrors; + } + + @Override + public Long queryCrcErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.CRC_ERRORS); + return crcErrors; + } + + @Override + public Long getMultizoneErrorRate() { + return multizoneErrorRate; + } + + @Override + public Long queryMultizoneErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.MULTIZONE_ERROR_RATE); + return multizoneErrorRate; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(DiskAttributeEnum.NAME); + driver.query(DiskAttributeEnum.PATH); + driver.query(DiskAttributeEnum.MODEL); + driver.query(DiskAttributeEnum.SERIAL); + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return null; + case NAME: + return (T) name; + case PATH: + return (T) path; + case MODEL: + return (T) model; + case SERIAL: + return (T) serial; + case SIZE: + return (T) size; + case READS: + return (T) reads; + case READ_BYTES: + return (T) readBytes; + case WRITES: + return (T) writes; + case WRITE_BYTES: + return (T) writeBytes; + case QUEUE_LENGTH: + return (T) queueLength; + case TRANSFER_TIME: + return (T) transferTime; + case MODEL_FAMILY: + return (T) modelFamily; + case FIRMWARE_VERSION: + return (T) firmwareVersion; + case ROTATION_RATE: + return (T) rotationRate; + case READ_ERROR_RATE: + return (T) readErrorRate; + case SPIN_UP_TIME: + return (T) spinUpTime; + case START_STOP_CYCLES: + return (T) startStopCycles; + case REALLOCATED_SECTORS: + return (T) reallocatedSectors; + case SEEK_ERROR_RATE: + return (T) seekErrorRate; + case POWER_ON_TIME: + return (T) powerOnTime; + case SPIN_RETRIES: + return (T) spinRetries; + case CALIBRATION_RETRIES: + return (T) calibrationRetries; + case POWER_CYCLES: + return (T) powerCycles; + case POWEROFF_RETRACTS: + return (T) poweroffRetracts; + case LOAD_CYCLES: + return (T) loadCycles; + case TEMPERATURE: + return (T) temperature; + case REALLOCATED_EVENTS: + return (T) reallocatedEvents; + case CURRENT_PENDING_SECTOR: + return (T) currentPendingSector; + case OFFLINE_UNCORRECTABLE: + return (T) offlineUncorrectable; + case CRC_ERRORS: + return (T) crcErrors; + case MULTIZONE_ERROR_RATE: + return (T) multizoneErrorRate; + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java new file mode 100644 index 0000000..a9aa7cc --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerFreeBsd extends DiskContainer implements DiskFreeBsd { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java new file mode 100644 index 0000000..f6867d3 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.DiskLinux; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerLinux extends DiskContainer implements DiskLinux { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java new file mode 100644 index 0000000..dce1f0d --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.DiskMac; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerMac extends DiskContainer implements DiskMac { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java new file mode 100644 index 0000000..a158fe8 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerSolaris extends DiskContainer implements DiskSolaris { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java new file mode 100644 index 0000000..0307f89 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.DiskWindows; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerWindows extends DiskContainer implements DiskWindows { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java new file mode 100644 index 0000000..c0ed5db --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java @@ -0,0 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface DiskQuery { + DiskAttributeEnum[] value(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java new file mode 100644 index 0000000..821d9a2 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; +import oshi.api.Container; + +@Generated("oshi.ApiGenerator") +public interface Firmware extends Container { + String getName(); + + String getManufacturer(); + + String getDescription(); + + String getVersion(); + + String getRevision(); + + String getReleaseDate(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java new file mode 100644 index 0000000..80b3e5e --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java @@ -0,0 +1,64 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.internal.FirmwareAttributeEnum; + +@Generated("oshi.ApiGenerator") +public class FirmwareAttribute { + public static final AttributeKey NAME = new AttributeKey<>(FirmwareAttributeEnum.NAME); + + /** + * The BIOS manufacturer title + */ + public static final AttributeKey MANUFACTURER = new AttributeKey<>(FirmwareAttributeEnum.MANUFACTURER); + + /** + * The BIOS description + */ + public static final AttributeKey DESCRIPTION = new AttributeKey<>(FirmwareAttributeEnum.DESCRIPTION); + + /** + * The BIOS version number + */ + public static final AttributeKey VERSION = new AttributeKey<>(FirmwareAttributeEnum.VERSION); + + /** + * The BIOS revision number + */ + public static final AttributeKey REVISION = new AttributeKey<>(FirmwareAttributeEnum.REVISION); + + /** + * The BIOS release date + */ + public static final AttributeKey RELEASE_DATE = new AttributeKey<>(FirmwareAttributeEnum.RELEASE_DATE); + + /** + * Whether the BIOS supports UEFI mode + */ + public static final AttributeKey UEFI = new AttributeKey<>(FirmwareAttributeEnum.UEFI); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java new file mode 100644 index 0000000..6a5d2e0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareFreeBsd extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java new file mode 100644 index 0000000..b6ccf3b --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java @@ -0,0 +1,32 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareLinux extends Firmware { + Boolean getUefi(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java new file mode 100644 index 0000000..a5570dd --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareMac extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java new file mode 100644 index 0000000..ec54fb9 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareSolaris extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java new file mode 100644 index 0000000..1e87df0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareWindows extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttributeEnum.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttributeEnum.java new file mode 100644 index 0000000..aa3ba0a --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttributeEnum.java @@ -0,0 +1,45 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import javax.annotation.processing.Generated; +import oshi.driver.AttributeEnum; + +@Generated("oshi.ApiGenerator") +public enum FirmwareAttributeEnum implements AttributeEnum { + NAME, + + MANUFACTURER, + + DESCRIPTION, + + VERSION, + + REVISION, + + RELEASE_DATE, + + UEFI +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java new file mode 100644 index 0000000..b66f167 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java @@ -0,0 +1,126 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.internal.AbstractContainer; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public abstract class FirmwareContainer extends AbstractContainer implements Firmware { + public String name; + + /** + * The BIOS manufacturer title + */ + public String manufacturer; + + /** + * The BIOS description + */ + public String description; + + /** + * The BIOS version number + */ + public String version; + + /** + * The BIOS revision number + */ + public String revision; + + /** + * The BIOS release date + */ + public String releaseDate; + + @Override + public String getName() { + return name; + } + + @Override + public String getManufacturer() { + return manufacturer; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getVersion() { + return version; + } + + @Override + public String getRevision() { + return revision; + } + + @Override + public String getReleaseDate() { + return releaseDate; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(FirmwareAttributeEnum.NAME); + driver.query(FirmwareAttributeEnum.MANUFACTURER); + driver.query(FirmwareAttributeEnum.DESCRIPTION); + driver.query(FirmwareAttributeEnum.VERSION); + driver.query(FirmwareAttributeEnum.REVISION); + driver.query(FirmwareAttributeEnum.RELEASE_DATE); + } + + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return null; + case NAME: + return (T) name; + case MANUFACTURER: + return (T) manufacturer; + case DESCRIPTION: + return (T) description; + case VERSION: + return (T) version; + case REVISION: + return (T) revision; + case RELEASE_DATE: + return (T) releaseDate; + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java new file mode 100644 index 0000000..109752c --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerFreeBsd extends FirmwareContainer implements FirmwareFreeBsd { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java new file mode 100644 index 0000000..e02bfb1 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java @@ -0,0 +1,64 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerLinux extends FirmwareContainer implements FirmwareLinux { + /** + * Whether the BIOS supports UEFI mode + */ + public Boolean uefi; + + @Override + public Boolean getUefi() { + return uefi; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + driver.query(FirmwareAttributeEnum.UEFI); + } + + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + case UEFI: + return (T) uefi; + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java new file mode 100644 index 0000000..4aedc9d --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerMac extends FirmwareContainer implements FirmwareMac { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java new file mode 100644 index 0000000..0e43f5d --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerSolaris extends FirmwareContainer implements FirmwareSolaris { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java new file mode 100644 index 0000000..5f1847b --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerWindows extends FirmwareContainer implements FirmwareWindows { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java new file mode 100644 index 0000000..1d218f5 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java @@ -0,0 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface FirmwareQuery { + FirmwareAttributeEnum[] value(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java new file mode 100644 index 0000000..33748ad --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java @@ -0,0 +1,123 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; +import oshi.api.Container; + +@Generated("oshi.ApiGenerator") +public interface Nic extends Container { + String getName(); + + String getDescription(); + + Integer getMtu(); + + Integer queryMtu(); + + String getMac(); + + String queryMac(); + + Boolean getVirtual(); + + Boolean queryVirtual(); + + String[] getIpv4(); + + String[] queryIpv4(); + + String[] getIpv6(); + + String[] queryIpv6(); + + String getBroadcast(); + + String queryBroadcast(); + + String getNetmask(); + + String queryNetmask(); + + Long getReadBytes(); + + Long queryReadBytes(); + + Long getWriteBytes(); + + Long queryWriteBytes(); + + Long getReadPackets(); + + Long queryReadPackets(); + + Long getWritePackets(); + + Long queryWritePackets(); + + Long getReadErrors(); + + Long queryReadErrors(); + + Long getWriteErrors(); + + Long queryWriteErrors(); + + Long getReadDrops(); + + Long queryReadDrops(); + + Long getWriteDrops(); + + Long queryWriteDrops(); + + Long getWriteCollisions(); + + Long queryWriteCollisions(); + + Long getLinkSpeed(); + + Long queryLinkSpeed(); + + Boolean getDefaultGateway(); + + Boolean queryDefaultGateway(); + + Boolean getFlagUp(); + + Boolean queryFlagUp(); + + Boolean getFlagRunning(); + + Boolean queryFlagRunning(); + + Boolean getFlagLoopback(); + + Boolean queryFlagLoopback(); + + Boolean getFlagMulticast(); + + Boolean queryFlagMulticast(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java new file mode 100644 index 0000000..4a871aa --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java @@ -0,0 +1,148 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.nic.internal.NicAttributeEnum; + +@Generated("oshi.ApiGenerator") +public class NicAttribute { + /** + * The interface's name + */ + public static final AttributeKey NAME = new AttributeKey<>(NicAttributeEnum.NAME); + + /** + * The interface's description + */ + public static final AttributeKey DESCRIPTION = new AttributeKey<>(NicAttributeEnum.DESCRIPTION); + + /** + * The maximum transmission unit + */ + public static final AttributeKey MTU = new AttributeKey<>(NicAttributeEnum.MTU); + + public static final AttributeKey MAC = new AttributeKey<>(NicAttributeEnum.MAC); + + public static final AttributeKey VIRTUAL = new AttributeKey<>(NicAttributeEnum.VIRTUAL); + + /** + * The interface's IPv4 addresses + */ + public static final AttributeKey IPV4 = new AttributeKey<>(NicAttributeEnum.IPV4); + + /** + * The interface's IPv6 addresses + */ + public static final AttributeKey IPV6 = new AttributeKey<>(NicAttributeEnum.IPV6); + + public static final AttributeKey BROADCAST = new AttributeKey<>(NicAttributeEnum.BROADCAST); + + /** + * The interface's subnet mask + */ + public static final AttributeKey NETMASK = new AttributeKey<>(NicAttributeEnum.NETMASK); + + /** + * The number of bytes read from the interface + */ + public static final AttributeKey READ_BYTES = new AttributeKey<>(NicAttributeEnum.READ_BYTES); + + /** + * The number of bytes written to the interface + */ + public static final AttributeKey WRITE_BYTES = new AttributeKey<>(NicAttributeEnum.WRITE_BYTES); + + /** + * The number of packets read from the interface + */ + public static final AttributeKey READ_PACKETS = new AttributeKey<>(NicAttributeEnum.READ_PACKETS); + + /** + * The number of packets written to the interface + */ + public static final AttributeKey WRITE_PACKETS = new AttributeKey<>(NicAttributeEnum.WRITE_PACKETS); + + /** + * The number of read errors + */ + public static final AttributeKey READ_ERRORS = new AttributeKey<>(NicAttributeEnum.READ_ERRORS); + + /** + * The number of write errors + */ + public static final AttributeKey WRITE_ERRORS = new AttributeKey<>(NicAttributeEnum.WRITE_ERRORS); + + /** + * The number of read drops + */ + public static final AttributeKey READ_DROPS = new AttributeKey<>(NicAttributeEnum.READ_DROPS); + + /** + * The number of write drops + */ + public static final AttributeKey WRITE_DROPS = new AttributeKey<>(NicAttributeEnum.WRITE_DROPS); + + /** + * The number of write collisions + */ + public static final AttributeKey WRITE_COLLISIONS = new AttributeKey<>(NicAttributeEnum.WRITE_COLLISIONS); + + /** + * The interface's maximum speed in bytes + */ + public static final AttributeKey LINK_SPEED = new AttributeKey<>(NicAttributeEnum.LINK_SPEED); + + public static final AttributeKey DEFAULT_GATEWAY = new AttributeKey<>(NicAttributeEnum.DEFAULT_GATEWAY); + + public static final AttributeKey FLAG_UP = new AttributeKey<>(NicAttributeEnum.FLAG_UP); + + public static final AttributeKey FLAG_RUNNING = new AttributeKey<>(NicAttributeEnum.FLAG_RUNNING); + + public static final AttributeKey FLAG_LOOPBACK = new AttributeKey<>(NicAttributeEnum.FLAG_LOOPBACK); + + public static final AttributeKey FLAG_MULTICAST = new AttributeKey<>(NicAttributeEnum.FLAG_MULTICAST); + + /** + * The interface's locally unique identifier + */ + public static final AttributeKey LUID = new AttributeKey<>(NicAttributeEnum.LUID); + + /** + * The interface's globally unique identifier + */ + public static final AttributeKey GUID = new AttributeKey<>(NicAttributeEnum.GUID); + + /** + * Whether the interface is in a paused state + */ + public static final AttributeKey PAUSED = new AttributeKey<>(NicAttributeEnum.PAUSED); + + /** + * Whether the interface is in a low-power state + */ + public static final AttributeKey LOWPOWER = new AttributeKey<>(NicAttributeEnum.LOWPOWER); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java new file mode 100644 index 0000000..aacf7c0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicFreeBsd extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java new file mode 100644 index 0000000..b76b590 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicLinux extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java new file mode 100644 index 0000000..b2f178b --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicMac extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java new file mode 100644 index 0000000..15f2c3b --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicSolaris extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java new file mode 100644 index 0000000..355cb5a --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java @@ -0,0 +1,46 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicWindows extends Nic { + Long getLuid(); + + Long queryLuid(); + + String getGuid(); + + String queryGuid(); + + Boolean getPaused(); + + Boolean queryPaused(); + + Boolean getLowpower(); + + Boolean queryLowpower(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttributeEnum.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttributeEnum.java new file mode 100644 index 0000000..7870c10 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttributeEnum.java @@ -0,0 +1,87 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import javax.annotation.processing.Generated; +import oshi.driver.AttributeEnum; + +@Generated("oshi.ApiGenerator") +public enum NicAttributeEnum implements AttributeEnum { + NAME, + + DESCRIPTION, + + MTU, + + MAC, + + VIRTUAL, + + IPV4, + + IPV6, + + BROADCAST, + + NETMASK, + + READ_BYTES, + + WRITE_BYTES, + + READ_PACKETS, + + WRITE_PACKETS, + + READ_ERRORS, + + WRITE_ERRORS, + + READ_DROPS, + + WRITE_DROPS, + + WRITE_COLLISIONS, + + LINK_SPEED, + + DEFAULT_GATEWAY, + + FLAG_UP, + + FLAG_RUNNING, + + FLAG_LOOPBACK, + + FLAG_MULTICAST, + + LUID, + + GUID, + + PAUSED, + + LOWPOWER +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java new file mode 100644 index 0000000..a193ab9 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java @@ -0,0 +1,516 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.DetachedContainerException; +import oshi.api.hardware.nic.Nic; +import oshi.api.internal.AbstractContainer; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public abstract class NicContainer extends AbstractContainer implements Nic { + /** + * The interface's name + */ + public String name; + + /** + * The interface's description + */ + public String description; + + /** + * The maximum transmission unit + */ + public Integer mtu; + + public String mac; + + public Boolean virtual; + + /** + * The interface's IPv4 addresses + */ + public String[] ipv4; + + /** + * The interface's IPv6 addresses + */ + public String[] ipv6; + + public String broadcast; + + /** + * The interface's subnet mask + */ + public String netmask; + + /** + * The number of bytes read from the interface + */ + public Long readBytes; + + /** + * The number of bytes written to the interface + */ + public Long writeBytes; + + /** + * The number of packets read from the interface + */ + public Long readPackets; + + /** + * The number of packets written to the interface + */ + public Long writePackets; + + /** + * The number of read errors + */ + public Long readErrors; + + /** + * The number of write errors + */ + public Long writeErrors; + + /** + * The number of read drops + */ + public Long readDrops; + + /** + * The number of write drops + */ + public Long writeDrops; + + /** + * The number of write collisions + */ + public Long writeCollisions; + + /** + * The interface's maximum speed in bytes + */ + public Long linkSpeed; + + public Boolean defaultGateway; + + public Boolean flagUp; + + public Boolean flagRunning; + + public Boolean flagLoopback; + + public Boolean flagMulticast; + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public Integer getMtu() { + return mtu; + } + + @Override + public Integer queryMtu() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.MTU); + return mtu; + } + + @Override + public String getMac() { + return mac; + } + + @Override + public String queryMac() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.MAC); + return mac; + } + + @Override + public Boolean getVirtual() { + return virtual; + } + + @Override + public Boolean queryVirtual() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.VIRTUAL); + return virtual; + } + + @Override + public String[] getIpv4() { + return ipv4; + } + + @Override + public String[] queryIpv4() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.IPV4); + return ipv4; + } + + @Override + public String[] getIpv6() { + return ipv6; + } + + @Override + public String[] queryIpv6() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.IPV6); + return ipv6; + } + + @Override + public String getBroadcast() { + return broadcast; + } + + @Override + public String queryBroadcast() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.BROADCAST); + return broadcast; + } + + @Override + public String getNetmask() { + return netmask; + } + + @Override + public String queryNetmask() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.NETMASK); + return netmask; + } + + @Override + public Long getReadBytes() { + return readBytes; + } + + @Override + public Long queryReadBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_BYTES); + return readBytes; + } + + @Override + public Long getWriteBytes() { + return writeBytes; + } + + @Override + public Long queryWriteBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_BYTES); + return writeBytes; + } + + @Override + public Long getReadPackets() { + return readPackets; + } + + @Override + public Long queryReadPackets() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_PACKETS); + return readPackets; + } + + @Override + public Long getWritePackets() { + return writePackets; + } + + @Override + public Long queryWritePackets() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_PACKETS); + return writePackets; + } + + @Override + public Long getReadErrors() { + return readErrors; + } + + @Override + public Long queryReadErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_ERRORS); + return readErrors; + } + + @Override + public Long getWriteErrors() { + return writeErrors; + } + + @Override + public Long queryWriteErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_ERRORS); + return writeErrors; + } + + @Override + public Long getReadDrops() { + return readDrops; + } + + @Override + public Long queryReadDrops() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_DROPS); + return readDrops; + } + + @Override + public Long getWriteDrops() { + return writeDrops; + } + + @Override + public Long queryWriteDrops() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_DROPS); + return writeDrops; + } + + @Override + public Long getWriteCollisions() { + return writeCollisions; + } + + @Override + public Long queryWriteCollisions() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_COLLISIONS); + return writeCollisions; + } + + @Override + public Long getLinkSpeed() { + return linkSpeed; + } + + @Override + public Long queryLinkSpeed() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.LINK_SPEED); + return linkSpeed; + } + + @Override + public Boolean getDefaultGateway() { + return defaultGateway; + } + + @Override + public Boolean queryDefaultGateway() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.DEFAULT_GATEWAY); + return defaultGateway; + } + + @Override + public Boolean getFlagUp() { + return flagUp; + } + + @Override + public Boolean queryFlagUp() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_UP); + return flagUp; + } + + @Override + public Boolean getFlagRunning() { + return flagRunning; + } + + @Override + public Boolean queryFlagRunning() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_RUNNING); + return flagRunning; + } + + @Override + public Boolean getFlagLoopback() { + return flagLoopback; + } + + @Override + public Boolean queryFlagLoopback() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_LOOPBACK); + return flagLoopback; + } + + @Override + public Boolean getFlagMulticast() { + return flagMulticast; + } + + @Override + public Boolean queryFlagMulticast() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_MULTICAST); + return flagMulticast; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(NicAttributeEnum.NAME); + driver.query(NicAttributeEnum.DESCRIPTION); + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return null; + case NAME: + return (T) name; + case DESCRIPTION: + return (T) description; + case MTU: + return (T) mtu; + case MAC: + return (T) mac; + case VIRTUAL: + return (T) virtual; + case IPV4: + return (T) ipv4; + case IPV6: + return (T) ipv6; + case BROADCAST: + return (T) broadcast; + case NETMASK: + return (T) netmask; + case READ_BYTES: + return (T) readBytes; + case WRITE_BYTES: + return (T) writeBytes; + case READ_PACKETS: + return (T) readPackets; + case WRITE_PACKETS: + return (T) writePackets; + case READ_ERRORS: + return (T) readErrors; + case WRITE_ERRORS: + return (T) writeErrors; + case READ_DROPS: + return (T) readDrops; + case WRITE_DROPS: + return (T) writeDrops; + case WRITE_COLLISIONS: + return (T) writeCollisions; + case LINK_SPEED: + return (T) linkSpeed; + case DEFAULT_GATEWAY: + return (T) defaultGateway; + case FLAG_UP: + return (T) flagUp; + case FLAG_RUNNING: + return (T) flagRunning; + case FLAG_LOOPBACK: + return (T) flagLoopback; + case FLAG_MULTICAST: + return (T) flagMulticast; + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java new file mode 100644 index 0000000..92ba4c9 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.nic.NicFreeBsd; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerFreeBsd extends NicContainer implements NicFreeBsd { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java new file mode 100644 index 0000000..f1da897 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.nic.NicLinux; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerLinux extends NicContainer implements NicLinux { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java new file mode 100644 index 0000000..9b92772 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.nic.NicMac; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerMac extends NicContainer implements NicMac { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java new file mode 100644 index 0000000..cb7b939 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.nic.NicSolaris; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerSolaris extends NicContainer implements NicSolaris { + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java new file mode 100644 index 0000000..2186a08 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java @@ -0,0 +1,136 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.DetachedContainerException; +import oshi.api.hardware.nic.NicWindows; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerWindows extends NicContainer implements NicWindows { + /** + * The interface's locally unique identifier + */ + public Long luid; + + /** + * The interface's globally unique identifier + */ + public String guid; + + /** + * Whether the interface is in a paused state + */ + public Boolean paused; + + /** + * Whether the interface is in a low-power state + */ + public Boolean lowpower; + + @Override + public Long getLuid() { + return luid; + } + + @Override + public Long queryLuid() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.LUID); + return luid; + } + + @Override + public String getGuid() { + return guid; + } + + @Override + public String queryGuid() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.GUID); + return guid; + } + + @Override + public Boolean getPaused() { + return paused; + } + + @Override + public Boolean queryPaused() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.PAUSED); + return paused; + } + + @Override + public Boolean getLowpower() { + return lowpower; + } + + @Override + public Boolean queryLowpower() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.LOWPOWER); + return lowpower; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + case LUID: + return (T) luid; + case GUID: + return (T) guid; + case PAUSED: + return (T) paused; + case LOWPOWER: + return (T) lowpower; + } + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java new file mode 100644 index 0000000..91f37da --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java @@ -0,0 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface NicQuery { + NicAttributeEnum[] value(); +} diff --git a/reference/oshi-core/src/main/java/oshi/ApiGenerator.java b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java new file mode 100644 index 0000000..68fad23 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java @@ -0,0 +1,423 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi; + +import static javax.lang.model.element.Modifier.ABSTRACT; +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.annotation.processing.Generated; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.squareup.javapoet.AnnotationSpec; +import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.CodeBlock; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.JavaFile; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeSpec; +import com.squareup.javapoet.TypeVariableName; +import com.squareup.javapoet.WildcardTypeName; + +import oshi.api.AttributeKey; +import oshi.api.Container; +import oshi.api.DetachedContainerException; +import oshi.api.internal.AbstractContainer; +import oshi.driver.AttributeEnum; + +/** + * This class generates most of the API layer according to a global + * {@code definitions.json} file in the root project directory. All generated + * sources are output to the src/gen/java directory. + */ +public final class ApiGenerator { + + /** + * The output source folder. + */ + private static final Path OUTPUT = Paths.get("src/gen/java"); + + /** + * The API package prefix. + */ + private static final String API_PACKAGE = "oshi.api"; + + /** + * The driver package prefix. + */ + private static final String DRIVER_PACKAGE = "oshi.driver"; + + /** + * A comment to appear below the license header and above the package + * declaration in all generated sources. + */ + private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; + + /** + * An annotation to be used on all generated sources. + */ + private static final AnnotationSpec GENERATOR_ANNOTATION = AnnotationSpec.builder(Generated.class) + .addMember("value", String.format("\"%s\"", ApiGenerator.class.getName())).build(); + + /** + * The supported platforms. + */ + private static final String[] PLATFORMS = { "Windows", "Mac", "Linux", "Solaris", "FreeBsd" }; + + /** + * The generator's full output which is collected and written at the end. + */ + private static List files = new ArrayList<>(); + + public static void main(String[] argv) throws Exception { + try (var in = Files.newInputStream(Paths.get("definitions.json"))) { + List json = new ObjectMapper().readValue(in, new TypeReference>() { + // The old anonymous class trick + }); + + for (var component : json) { + generateAttributeEnums(component); + + generate(component, ""); + for (var platform : PLATFORMS) { + generate(component, platform); + } + } + + generateSystemInterface(json, ""); + for (var platform : PLATFORMS) + generateSystemInterface(json, platform); + } + + // Output files if there were no errors + for (var type : files) + type.writeTo(OUTPUT); + } + + private static void generateAttributeEnums(ComponentJson component) { + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + var attributeEnum = TypeSpec.enumBuilder(baseName + "AttributeEnum").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION).addSuperinterface(ClassName.get(AttributeEnum.class)); + var attributeKey = TypeSpec.classBuilder(baseName + "Attribute").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + + for (var attribute : component.attributes) { + var type = ClassName.bestGuess(attribute.type); + + // Generate enum constant + attributeEnum.addEnumConstant(attribute.name.toUpperCase()); + + // Generate attribute key + var field = FieldSpec.builder(ParameterizedTypeName.get(ClassName.get(AttributeKey.class), type), + attribute.name.toUpperCase(), PUBLIC, STATIC, FINAL).initializer("new $T<>($T.$L)", + AttributeKey.class, ClassName.get(pkgName + ".internal", baseName + "AttributeEnum"), + attribute.name.toUpperCase()); + if (attribute.desc != null) + field.addJavadoc(attribute.desc + "\n"); + + attributeKey.addField(field.build()); + } + + files.add(JavaFile.builder(pkgName + ".internal", attributeEnum.build()).addFileComment(GENERATOR_COMMENT) + .build()); + files.add(JavaFile.builder(pkgName, attributeKey.build()).addFileComment(GENERATOR_COMMENT).build()); + } + + private static void generate(ComponentJson component, String platform) { + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + // Build classes for component + var container = TypeSpec.classBuilder(baseName + "Container" + platform).addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + var containerInterface = TypeSpec.interfaceBuilder(baseName + platform).addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + var queryAnnotation = TypeSpec.annotationBuilder(baseName + "Query").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION) + .addAnnotation( + AnnotationSpec.builder(Retention.class) + .addMember("value", "$T.RUNTIME", + ClassName.get("java.lang.annotation", "RetentionPolicy")) + .build()) + .addAnnotation(AnnotationSpec.builder(Target.class) + .addMember("value", "$T.METHOD", ClassName.get("java.lang.annotation", "ElementType")).build()); + queryAnnotation.addMethod(MethodSpec.methodBuilder("value") + .returns(ClassName.get(pkgName + ".internal", baseName + "AttributeEnum[]")) + .addModifiers(PUBLIC, ABSTRACT).build()); + + // Setup inheritance + container.addSuperinterface(ClassName.get(pkgName, baseName + platform)); + if (!platform.isEmpty()) { + container.superclass(ClassName.get(pkgName + ".internal", baseName + "Container")); + containerInterface.addSuperinterface(ClassName.get(pkgName, baseName)); + } else { + container.superclass(ClassName.get(AbstractContainer.class)); + container.addModifiers(ABSTRACT); + containerInterface.addSuperinterface(ClassName.get(Container.class)); + } + + if (component.desc != null) + container.addJavadoc(component.desc + "\n"); + + // Create attach method + var attach = MethodSpec.methodBuilder("attach") + .addParameter(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver") + .addStatement("this.driver = driver").addModifiers(PUBLIC); + if (!platform.isEmpty()) + attach.addStatement("super.attach(driver)"); + attach.addComment("Query all constant attributes:"); + + // Create get method + var getReturn = TypeVariableName.get("T"); + var containerGet = MethodSpec.methodBuilder("get").addTypeVariable(getReturn).returns(getReturn) + .addModifiers(PUBLIC) + .addParameter(ParameterizedTypeName.get(ClassName.get(AttributeKey.class), getReturn), "key") + .addAnnotation(Override.class); + containerGet.beginControlFlow("switch(($T) key.getAttributeEnum())", + ClassName.get(pkgName + ".internal", baseName + "AttributeEnum")); + if (!platform.isEmpty()) + containerGet.addStatement("default: return super.get(key)"); + else + containerGet.addStatement("default: return null"); + + // Process attributes + for (var attribute : component.attributes) { + var type = ClassName.bestGuess(attribute.type); + + if (platform.isEmpty() && attribute.compatible == null + || attribute.compatible != null && attribute.compatible.contains(platform.toLowerCase())) { + + if (attribute.constant) + attach.addStatement("driver.query($T.$L)", + ClassName.get(pkgName + ".internal", baseName + "AttributeEnum"), + attribute.name.toUpperCase()); + + // Generate container field + var containerField = FieldSpec.builder(type, camel(attribute.name), PUBLIC); + if (attribute.desc != null) + containerField.addJavadoc(attribute.desc + "\n"); + container.addField(containerField.build()); + + // Generate container getter + var containerGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) + .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) + .addAnnotation(Override.class); + container.addMethod(containerGetter.build()); + + // Generate container interface getter + var containerInterfaceGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) + .addModifiers(PUBLIC, ABSTRACT); + containerInterface.addMethod(containerInterfaceGetter.build()); + + // Generate container interface query + var containerInterfaceQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) + .addModifiers(PUBLIC, ABSTRACT); + if (!attribute.constant) + containerInterface.addMethod(containerInterfaceQuery.build()); + + // Generate container query delegate + var containerQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) + .addCode(CodeBlock.builder().beginControlFlow("if (driver == null)") + .addStatement("throw new $T()", DetachedContainerException.class).endControlFlow() + .build()) + .addStatement("driver.query($T.$L)", + ClassName.get(pkgName + ".internal", baseName + "AttributeEnum"), + attribute.name.toUpperCase()) + .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) + .addAnnotation(Override.class); + + if (!attribute.constant) + container.addMethod(containerQuery.build()); + + // + containerGet.addStatement("case $L: return (T) $L", attribute.name.toUpperCase(), + camel(attribute.name)); + } + } + + container.addMethod(attach.build()); + + containerGet.endControlFlow(); + container.addMethod(containerGet.build()); + + files.add(JavaFile.builder(pkgName + ".internal", container.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName, containerInterface.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName + ".internal", queryAnnotation.build()).addFileComment(GENERATOR_COMMENT) + .build()); + + } + + /** + * Generate an interface for top-level System classes for the given + * components and platform. + * + * @param components + * @param platform + */ + private static void generateSystemInterface(List components, String platform) { + var system = TypeSpec.interfaceBuilder((platform.isEmpty() ? "Multi" : platform) + "System") + .addModifiers(PUBLIC).addAnnotation(GENERATOR_ANNOTATION); + + if (!platform.isEmpty()) { + system.addSuperinterface(ClassName.get(API_PACKAGE, "MultiSystem")); + } + + for (var component : components) { + if (!component.root) + continue; + + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + var type = ClassName.get(pkgName, baseName + platform).box(); + + if (component.singular) { + var get = MethodSpec.methodBuilder(camel("get", baseName)).returns(type).addModifiers(PUBLIC, ABSTRACT); + + system.addMethod(get.build()); + } else { + type = ParameterizedTypeName.get(ClassName.get(Stream.class), WildcardTypeName.subtypeOf(type)); + var get = MethodSpec.methodBuilder(camel("get", baseName, "stream")).returns(type).addModifiers(PUBLIC, + ABSTRACT); + + system.addMethod(get.build()); + } + } + + files.add(JavaFile.builder(API_PACKAGE, system.build()).addFileComment(GENERATOR_COMMENT).build()); + } + + /** + * Convert the given Strings in underscore format into CamelCase format. The + * first character of the first String will always be unchanged. + * + * @param strings + * @return A CamelCase {@code String} + */ + private static String camel(String... strings) { + if (strings.length == 0) + return ""; + if (strings[0].isEmpty()) + throw new IllegalArgumentException("First component is empty"); + + return strings[0].charAt(0) + Stream.of(strings).map(String::toLowerCase) + .flatMap(s -> Arrays.stream(s.split("_"))).map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)) + .collect(Collectors.joining()).substring(1); + } + + /** + * Represents a system attribute in the definitions file. + */ + private static class AttributeJson { + /** + * The attribute's name in lowercase underscore format. + */ + public String name; + /** + * The attribute's data type. + */ + public String type; + /** + * The attribute's short description. + */ + public String desc; + /** + * Whether the attribute's value can change over the lifetime of the + * system. + */ + public boolean constant; + /** + * The attribute's extension type. + */ + public String extension; + /** + * A platform compatibility whitelist. + */ + public List compatible; + } + + /** + * Represents a system component in the definitions file. + */ + private static class ComponentJson { + /** + * The component's name in dot-path notation. + */ + public String name; + /** + * Whether the component is accessible from the root of the API. + */ + public boolean root; + /** + * Whether the system can contain only one or more than one of the + * component. + */ + public boolean singular; + /** + * The component's short description. + */ + public String desc; + /** + * The component's attributes. + */ + public List attributes; + + /** + * Parse the last element of the component's dot-path. + * + * @return The component's base name + */ + public String getBaseName() { + return name.substring(name.lastIndexOf('.') + 1); + } + + /** + * Parse the package elements from the component's dot-path. + * + * @return The component's package + */ + public String getPkgName() { + return API_PACKAGE + "." + name.substring(0, name.lastIndexOf('.')) + "." + getBaseName().toLowerCase(); + } + } + + private ApiGenerator() { + } +} \ No newline at end of file diff --git a/reference/oshi-core/src/main/java/oshi/api/AttributeKey.java b/reference/oshi-core/src/main/java/oshi/api/AttributeKey.java new file mode 100644 index 0000000..bf93073 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/AttributeKey.java @@ -0,0 +1,47 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +import java.util.Objects; + +import oshi.driver.AttributeEnum; + +/** + * {@link AttributeKey}s are used to uniquely identify attributes. + * + * @param + * The data type of the corresponding attribute + */ +public final class AttributeKey { + + private AttributeEnum attributeEnum; + + public AttributeKey(AttributeEnum attributeEnum) { + this.attributeEnum = Objects.requireNonNull(attributeEnum); + } + + public AttributeEnum getAttributeEnum() { + return attributeEnum; + } +} diff --git a/reference/oshi-core/src/main/java/oshi/api/Container.java b/reference/oshi-core/src/main/java/oshi/api/Container.java new file mode 100644 index 0000000..9b6b873 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/Container.java @@ -0,0 +1,84 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +import java.io.Serializable; + +import oshi.driver.ComponentDriver; + +/** + * A container class represents a particular instance of a general system + * component. Container classes have two main purposes: + *
    + *
  • Store the most recently fetched attribute values so the user doesn't have + * to manually.
  • + *
  • Provide a way for users to fetch (update) attribute values of the + * corresponding component.
  • + *
+ */ +public interface Container extends Serializable { + + public abstract void attach(ComponentDriver driver); + + /** + * Update the values of the attributes corresponding to the given + * {@link AttributeKey}s. Unlike sequentially calling the {@code query*} + * methods for each attribute, this method doesn't duplicate batched queries + * if possible.
+ *
+ * For example, + * + *
+     * disk.queryReadBytes();
+     * disk.queryWriteBytes();
+     * 
+ * + * causes each attribute to be updated twice because {@code READ_BYTES} and + * {@code WRITE_BYTES} are fetched at the same time (batch queries).
+ *
+ * This method prevents wasted queries with the following usage: + * + *
+     * disk.query(READ_BYTES, WRITE_BYTES);
+     * 
+ * + * + * @param keys + * One or more keys that uniquely identify the attributes to be + * updated + */ + public abstract void query(AttributeKey... keys); + + /** + * Return the last-fetched value of the attribute corresponding to the given + * {@link AttributeKey}. + * + * @param + * The attribute's data type + * @param key + * A key that uniquely identifies the requested attribute + * @return The attribute's value + */ + public abstract T get(AttributeKey key); +} diff --git a/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java b/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java new file mode 100644 index 0000000..2251f8a --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java @@ -0,0 +1,34 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +/** + * Indicates that the attempted operation requires the container to be attached + * to a driver, but no driver instance was found. + */ +public class DetachedContainerException extends IllegalStateException { + + private static final long serialVersionUID = 979546852734821377L; + +} diff --git a/reference/oshi-core/src/main/java/oshi/api/OSHI.java b/reference/oshi-core/src/main/java/oshi/api/OSHI.java new file mode 100644 index 0000000..6cfc1a9 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/OSHI.java @@ -0,0 +1,177 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +import com.sun.jna.Platform; + +import oshi.driver.system.SystemDriverFreeBsd; +import oshi.driver.system.SystemDriverLinux; +import oshi.driver.system.SystemDriverMac; +import oshi.driver.system.SystemDriverSolaris; +import oshi.driver.system.SystemDriverWindows; + +/** + * This factory class is used to build disposable {@link MultiSystem} instances + * that can be used to access everything in OSHI.
+ *
+ * Most users should call {@link #getSystem()} for a fully cross-platform handle + * on the system. If platform-specific features are desired, one of the + * platform-unsafe methods can be called instead (at your own risk).
+ *
+ * + * For example, typical usage is as follows: + * + *
+ * Firmware firmware = OSHI.getSystem().getFirmware();
+ * ...
+ * 
+ * LinuxFirmware firmware = OSHI.getLinuxSystem().getFirmware();
+ * ...
+ * 
+ */ +public final class OSHI { + + private static final PlatformEnum PLATFORM; + + static { + if (Platform.isWindows()) { + PLATFORM = PlatformEnum.WINDOWS; + } else if (Platform.isLinux()) { + PLATFORM = PlatformEnum.LINUX; + } else if (Platform.isMac()) { + PLATFORM = PlatformEnum.MACOSX; + } else if (Platform.isSolaris()) { + PLATFORM = PlatformEnum.SOLARIS; + } else if (Platform.isFreeBSD()) { + PLATFORM = PlatformEnum.FREEBSD; + } else { + PLATFORM = PlatformEnum.UNSUPPORTED; + } + } + + /** + * Get the system's platform type. + * + * @return The platform type + */ + public static PlatformEnum getPlatform() { + return PLATFORM; + } + + /** + * Build a disposable handle that provides cross-platform system + * information. + * + * @return A new {@link MultiSystem} handle + */ + public static MultiSystem getSystem() { + switch (PLATFORM) { + case FREEBSD: + return new SystemDriverFreeBsd(); + case LINUX: + return new SystemDriverLinux(); + case MACOSX: + return new SystemDriverMac(); + case SOLARIS: + return new SystemDriverSolaris(); + case WINDOWS: + return new SystemDriverWindows(); + default: + throw new UnsupportedOperationException("OSHI is not supported on this platform"); + } + } + + /** + * Build a disposable handle that provides Windows system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. + * + * @return A new {@link WindowsSystem} handle + */ + public static WindowsSystem getWindowsSystem() { + if (PLATFORM != PlatformEnum.WINDOWS) + throw new UnsupportedOperationException("Cannot obtain Windows handle on this platform"); + return new SystemDriverWindows(); + } + + /** + * Build a disposable handle that provides Linux system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. + * + * @return A new {@link LinuxSystem} handle + */ + public static LinuxSystem getLinuxSystem() { + if (PLATFORM != PlatformEnum.LINUX) + throw new UnsupportedOperationException("Cannot obtain Linux handle on this platform"); + return new SystemDriverLinux(); + } + + /** + * Build a disposable handle that provides macOS system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. + * + * @return A new {@link MacSystem} handle + */ + public static MacSystem getMacSystem() { + if (PLATFORM != PlatformEnum.MACOSX) + throw new UnsupportedOperationException("Cannot obtain MacOS handle on this platform"); + return new SystemDriverMac(); + } + + /** + * Build a disposable handle that provides Solaris system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. + * + * @return A new {@link SolarisSystem} handle + */ + public static SolarisSystem getSolarisSystem() { + if (PLATFORM != PlatformEnum.SOLARIS) + throw new UnsupportedOperationException("Cannot obtain Solaris handle on this platform"); + return new SystemDriverSolaris(); + } + + /** + * Build a disposable handle that provides FreeBSD system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. + * + * @return A new {@link FreeBsdSystem} handle + */ + public static FreeBsdSystem getFreebsdSystem() { + if (PLATFORM != PlatformEnum.FREEBSD) + throw new UnsupportedOperationException("Cannot obtain FreeBSD handle on this platform"); + return new SystemDriverFreeBsd(); + } + + private OSHI() { + } +} diff --git a/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java b/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java new file mode 100644 index 0000000..834350b --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java @@ -0,0 +1,61 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +/** + * An enumeration of supported operating systems. + */ +public enum PlatformEnum { + + /** + * Microsoft's Windows operating system. + */ + WINDOWS, + + /** + * An operating system built on the Linux kernel. + */ + LINUX, + + /** + * Apple's macOS (OS X) operating system. + */ + MACOSX, + + /** + * The Solaris (SunOS) operating system. + */ + SOLARIS, + + /** + * The FreeBSD operating system. + */ + FREEBSD, + + /** + * Any unsupported operating system such as OpenBSD, AIX, WindowsCE, + * Android, etc. + */ + UNSUPPORTED; +} diff --git a/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java b/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java new file mode 100644 index 0000000..bf7ab1b --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java @@ -0,0 +1,30 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +public class UnsupportedPlatformException extends RuntimeException { + + private static final long serialVersionUID = -5396626644287029649L; + +} diff --git a/reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java b/reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java new file mode 100644 index 0000000..960a2c8 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api.internal; + +import java.util.Arrays; + +import oshi.api.AttributeKey; +import oshi.api.Container; +import oshi.driver.AttributeEnum; +import oshi.driver.ComponentDriver; + +/** + * A superclass for all generated container classes. + */ +public abstract class AbstractContainer implements Container { + + /** + * The root driver instance associated with this container. If {@code null}, + * this container is considered to be DETACHED and all attempts to + * update its attributes will fail. Otherwise, the container is considered + * to be ATTACHED. + */ + protected transient ComponentDriver driver; + + @Override + public void query(AttributeKey... keys) { + // Translate attribute-keys into attribute-enums for the driver + driver.query(Arrays.stream(keys).map(key -> key.getAttributeEnum()).toArray(AttributeEnum[]::new)); + } +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/AttributeEnum.java b/reference/oshi-core/src/main/java/oshi/driver/AttributeEnum.java new file mode 100644 index 0000000..b854a17 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/AttributeEnum.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import oshi.api.AttributeKey; + +/** + * This interface marks a generated {@code enum} as an attribute-enum (which + * contains a constant for every attribute in a component). All + * {@link AttributeEnum}s are wrapped by {@link AttributeKey}s for use by the + * user.
+ *
+ * {@link AttributeEnum}s are primarily used to associate annotated query + * methods within driver classes to attributes. + * + * @see {@link AttributeKey} + */ +public interface AttributeEnum { +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java new file mode 100644 index 0000000..05dc16c --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java @@ -0,0 +1,244 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import oshi.driver.annotation.Fallback; + +/** + * A {@link ComponentDriver} is the root of the driver hierarchy. Containers can + * call {@link #query(AttributeEnum)} or {@link #queryAll()} to have this class + * update their state. There is a one-to-one correspondence between + * {@link ComponentDriver}s and container objects.
+ *
+ * This class automatically registers all query methods in its subclasses. Query + * methods in {@link ExtensionDriver}s can also be registered with + * {@link #register(ExtensionDriver)}. + */ +public abstract class ComponentDriver { + + private static final Logger log = LoggerFactory.getLogger(ComponentDriver.class); + + /** + * This class wraps a query method's {@link MethodHandle} with additional + * metadata that's useful for ordering query handles within a + * {@link QueryStack}.
+ *
+ * + * Note: this class has a natural ordering that is inconsistent with equals. + */ + private static final class QueryHandle implements Comparable { + + /** + * A handle on the method that performs the query. + */ + public MethodHandle handle; + + /** + * A fallback annotation for query ordering. + */ + public Fallback fallback; + + /** + * The class that contributed this query handle. + */ + public Class cls; + + /** + * The method name of the query method. + */ + public String name; + + public QueryHandle(MethodHandle handle, Class cls, Method method) { + this.handle = Objects.requireNonNull(handle); + this.cls = Objects.requireNonNull(cls); + this.name = method.getName(); + this.fallback = method.getAnnotation(Fallback.class); + } + + @Override + public int compareTo(QueryHandle other) { + if (this == other) + return 0; + + if (this.fallback != null) { + if (this.fallback.value() == other.cls) { + if (this.fallback.method() != null) { + if (this.fallback.method().equals(other.name)) { + return -1; + } + } else { + return -1; + } + } + } else if (other.fallback != null) { + if (other.fallback.value() == this.cls) { + if (other.fallback.method() != null) { + if (other.fallback.method().equals(this.name)) { + return +1; + } + } else { + return +1; + } + } + } + + // No ordering preference + return 0; + } + } + + /** + * A {@link QueryStack} is a collection of {@link QueryHandle}s that are + * invoked sequentially upon query. A query attempt always begins with the + * top handle and continues down the stack until a handle succeeds. The + * stack can be configured to pop failed query handles if they are unlikely + * to ever succeed. + */ + private static final class QueryStack extends ArrayList { + } + + /** + * An association between attribute-enums and query stacks (lists of query + * handles in descending priority order). A particular query handle can + * exist in multiple stacks, but not more than once in each. + */ + private Map handles; + + /** + * A list of extensions in case they are needed in the future. + */ + private List extensions; + + public void initialize(List extensions) { + if (this.handles != null || this.extensions != null) + throw new IllegalArgumentException("The driver has already been initialized"); + + this.extensions = Objects.requireNonNull(extensions); + this.handles = new HashMap<>(); + + registerDriver(this); + this.extensions.forEach(this::registerDriver); + + // Reorder each stack + handles.values().forEach(Collections::sort); + } + + /** + * Query the driver hierarchy for the value of the attributes corresponding + * to the given enums. + * + * @param attributes + * The attribute enums of the attributes to query + */ + public void query(AttributeEnum... attributes) { + Arrays.stream(attributes).map(handles::get).distinct().forEach(this::query); + } + + /** + * Query every attribute in the driver hierarchy. + */ + public void queryAll() { + handles.values().stream().distinct().forEach(this::query); + } + + private void query(QueryStack stack) { + if (stack == null) + // TODO + return; + + for (var queryHandle : stack) { + try { + queryHandle.handle.invoke(); + return; + } catch (Throwable e) { + // TODO log exception and continue + // TODO remove if configured + e.printStackTrace(); + continue; + } + } + } + + /** + * Iterate through the methods of the given object and build a + * {@link QueryHandle} for each one containing a query annotation. + * + * @param driver + * The driver instance + */ + private void registerDriver(Object driver) { + Class driverClass = driver.getClass(); + while (driverClass != Object.class) { + for (Method m : driverClass.getDeclaredMethods()) { + + // Build a list of attributes defined in the annotations + var attributes = Arrays.stream(m.getDeclaredAnnotations()).flatMap(annotation -> { + try { + return Arrays + .stream((AttributeEnum[]) annotation.getClass().getMethod("value").invoke(annotation)); + } catch (NoSuchMethodException e) { + // Not the annotation we're looking for + return Arrays.stream(new AttributeEnum[0]); + } catch (Exception e) { + throw new RuntimeException("Failed to read query annotation", e); + } + }).collect(Collectors.toList()); + + if (attributes.size() > 0) { + // Build query handle + try { + m.setAccessible(true); + var handle = new QueryHandle(MethodHandles.lookup().unreflect(m).bindTo(driver), driverClass, + m); + var stack = new QueryStack(); + stack.add(handle); + + for (var attribute : attributes) { + handles.put(attribute, stack); + } + } catch (IllegalAccessException e) { + throw new RuntimeException("Cannot access query method: " + m.getName(), e); + } + } + } + + driverClass = driverClass.getSuperclass(); + } + } +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java b/reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java new file mode 100644 index 0000000..8102db2 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java @@ -0,0 +1,78 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; + +import oshi.api.internal.AbstractContainer; + +public class ContainerFactory { + + public static C build(Class containerClass, + Consumer containerConfigurator, Class driverClass, + Consumer> driverConfigurator) { + + try { + // Build and configure container + C container = containerClass.getConstructor().newInstance(); + containerConfigurator.accept(container); + + // Build driver + D driver = driverClass.getConstructor().newInstance(); + var driverContainerField = driverClass.getDeclaredField("container"); + driverContainerField.setAccessible(true); + driverContainerField.set(driver, container); + + // Configure extensions + ArrayList extensions = new ArrayList<>(); + driverConfigurator.accept(extensions); + extensions.trimToSize(); + for (var extension : extensions) { + var extensionContainerField = extension.getClass().getDeclaredField("container"); + extensionContainerField.setAccessible(true); + extensionContainerField.set(extension, container); + } + + driver.initialize(Collections.unmodifiableList(extensions)); + container.attach(driver); + return container; + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + public static C build(Class containerClass, + Class driverClass) { + return build(containerClass, container -> { + // Do nothing + }, driverClass, extensions -> { + // Do nothing + }); + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java new file mode 100644 index 0000000..4679b9a --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java @@ -0,0 +1,35 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +/** + * A marker class for a driver that provides additional query methods to a + * {@link ComponentDriver}. Usually an {@link ExtensionDriver} is responsible + * for fetching a group of related attributes that depend on external software + * which may or may not be present. + */ +public abstract class ExtensionDriver { + + public abstract boolean compatible(); +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java b/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java new file mode 100644 index 0000000..6a5036a --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java @@ -0,0 +1,46 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +/** + * An indicator optionally returned by a query that describes the outcome of the + * query. If a query's return type is {@code void}, then {@link #OK} is implied. + */ +public enum QueryStatus { + + /** + * Indicates the query completed successfully and the corresponding + * container object has been updated. + */ + OK, + + /** + * Indicates the query timed-out and the corresponding container object has + * not been updated. + */ + TIMEOUT, + + // TODO + MISSED_READING, PROCESS_TERMINATED; +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/annotation/Fallback.java b/reference/oshi-core/src/main/java/oshi/driver/annotation/Fallback.java new file mode 100644 index 0000000..418557e --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/annotation/Fallback.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Indicates that the annotated query method be preferred over the query + * method(s) in the targeted class for the same attributes. + */ +@Retention(RUNTIME) +@Target(METHOD) +public @interface Fallback { + + /** + * Get the fallback class. + * + * @return The class that contains the fallback method + */ + public Class value(); + + /** + * Get the name of the fallback method for use with reflection. + * + * @return The explicit name of the fallback method + */ + public String method() default ""; +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/annotation/RequiresRoot.java b/reference/oshi-core/src/main/java/oshi/driver/annotation/RequiresRoot.java new file mode 100644 index 0000000..65cbf16 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/annotation/RequiresRoot.java @@ -0,0 +1,39 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Indicates that the annotated query method requires elevated privileges to + * complete successfully. + */ +@Retention(RUNTIME) +@Target(METHOD) +public @interface RequiresRoot { +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java b/reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java new file mode 100644 index 0000000..aa8c922 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java @@ -0,0 +1,57 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import oshi.driver.QueryStatus; + +/** + * Indicates that the annotated query method should be allowed the given amount + * of time to execute before it's cancelled. A cancelled query method will have + * a result of {@link QueryStatus#TIMEOUT}. + */ +@Retention(RUNTIME) +@Target(METHOD) +public @interface Timeout { + + /** + * Return the timeout identifier which will be used to find the explicit + * timeout value. + * + * @return The timeout identifier or "class" + */ + public String value() default ""; + + /** + * Return the query timeout. + * + * @return The timeout in milliseconds + */ + public int milliseconds() default 0; +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java new file mode 100644 index 0000000..ce40b12 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java @@ -0,0 +1,91 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.hardware.disk; + +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.*; + +import oshi.api.hardware.disk.internal.DiskContainerLinux; +import oshi.api.hardware.disk.internal.DiskQuery; +import oshi.driver.ComponentDriver; +import oshi.old.ParseUtil; +import oshi.old.Udev; + +public class DiskDriverLinux extends ComponentDriver { + + private DiskContainerLinux container; + + /** + * The size of a logical sector in bytes. + */ + private static final int SECTOR_SIZE = 512; + + // Get a list of orders to pass to ParseUtil + private static final int[] UDEV_STAT_ORDERS = new int[] { + // + 0, // Reads + 2, // Read bytes + 4, // Writes + 6, // Write bytes + 8, // Queue length + 9 // Transfer time + }; + + // There are at least 11 elements in udev stat output. Some platforms have + // 12 but we want the last 11. ParseUtil works from the right + private static final int UDEV_STAT_LENGTH = 11; + + @DiskQuery({ MODEL, SERIAL, SIZE, NAME }) + private void diskInfo() { + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); + + container.model = Udev.INSTANCE.udev_device_get_property_value(device, "ID_MODEL"); + container.serial = Udev.INSTANCE.udev_device_get_property_value(device, "ID_SERIAL_SHORT"); + container.size = ParseUtil.parseLongOrDefault(Udev.INSTANCE.udev_device_get_sysattr_value(device, "size"), 0L) + * 512; + + Udev.INSTANCE.udev_device_unref(device); + Udev.INSTANCE.udev_unref(handle); + } + + @DiskQuery({ READS, READ_BYTES, WRITES, WRITE_BYTES, QUEUE_LENGTH, TRANSFER_TIME }) + private void diskStats() { + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); + + long[] deviceStats = ParseUtil.parseStringToLongArray( + Udev.INSTANCE.udev_device_get_sysattr_value(device, "stat"), UDEV_STAT_ORDERS, UDEV_STAT_LENGTH, ' '); + + container.reads = deviceStats[0]; + container.readBytes = deviceStats[1] * SECTOR_SIZE; + container.writes = deviceStats[2]; + container.writeBytes = deviceStats[3] * SECTOR_SIZE; + container.queueLength = deviceStats[4]; + container.transferTime = deviceStats[5]; + + Udev.INSTANCE.udev_device_unref(device); + Udev.INSTANCE.udev_unref(handle); + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java new file mode 100644 index 0000000..3cee73a --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java @@ -0,0 +1,134 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.hardware.disk; + +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.CALIBRATION_RETRIES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.CRC_ERRORS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.CURRENT_PENDING_SECTOR; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.FIRMWARE_VERSION; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.LOAD_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.MODEL_FAMILY; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.MULTIZONE_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.OFFLINE_UNCORRECTABLE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.POWEROFF_RETRACTS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.POWER_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.POWER_ON_TIME; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.READ_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.REALLOCATED_EVENTS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.REALLOCATED_SECTORS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.ROTATION_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.SEEK_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.SPIN_RETRIES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.SPIN_UP_TIME; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.START_STOP_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.TEMPERATURE; + +import java.io.IOException; + +import oshi.api.hardware.disk.internal.DiskContainerLinux; +import oshi.api.hardware.disk.internal.DiskQuery; +import oshi.driver.ExtensionDriver; +import oshi.driver.annotation.RequiresRoot; +import oshi.old.ExecutingCommand; + +public class DiskDriverLinuxSMART extends ExtensionDriver { + + private DiskContainerLinux container; + + @Override + public boolean compatible() { + try { + return 127 != Runtime.getRuntime().exec("smartctl").waitFor(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + } + + @RequiresRoot + @DiskQuery({ MODEL_FAMILY, FIRMWARE_VERSION, ROTATION_RATE, READ_ERROR_RATE, SPIN_UP_TIME, START_STOP_CYCLES, + REALLOCATED_SECTORS, SEEK_ERROR_RATE, POWER_ON_TIME, SPIN_RETRIES, CALIBRATION_RETRIES, POWER_CYCLES, + POWEROFF_RETRACTS, LOAD_CYCLES, TEMPERATURE, REALLOCATED_EVENTS, CURRENT_PENDING_SECTOR, + OFFLINE_UNCORRECTABLE, CRC_ERRORS, MULTIZONE_ERROR_RATE }) + private void diskStats() throws IOException { + var output = ExecutingCommand.runNative("sudo smartctl --attributes " + container.path); + for (int i = 7; i < 24; i++) { + String[] line = output.get(i).trim().split("\\s+"); + switch (Integer.parseInt(line[0])) { + case 1: + container.readErrorRate = Long.parseLong(line[9]); + break; + case 3: + container.spinUpTime = Long.parseLong(line[9]); + break; + case 4: + container.startStopCycles = Long.parseLong(line[9]); + break; + case 5: + container.reallocatedSectors = Long.parseLong(line[9]); + break; + case 7: + container.seekErrorRate = Long.parseLong(line[9]); + break; + case 9: + container.powerOnTime = Long.parseLong(line[9]); + break; + case 10: + container.spinRetries = Long.parseLong(line[9]); + break; + case 11: + container.calibrationRetries = Long.parseLong(line[9]); + break; + case 12: + container.powerCycles = Long.parseLong(line[9]); + break; + case 192: + container.poweroffRetracts = Long.parseLong(line[9]); + break; + case 193: + container.loadCycles = Long.parseLong(line[9]); + break; + case 194: + container.temperature = Long.parseLong(line[9]); + break; + case 196: + container.reallocatedEvents = Long.parseLong(line[9]); + break; + case 197: + container.currentPendingSector = Long.parseLong(line[9]); + break; + case 198: + container.offlineUncorrectable = Long.parseLong(line[9]); + break; + case 199: + container.crcErrors = Long.parseLong(line[9]); + break; + case 200: + container.multizoneErrorRate = Long.parseLong(line[9]); + break; + } + } + } +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java new file mode 100644 index 0000000..a1cebb6 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java @@ -0,0 +1,91 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.hardware.firmware; + +import static oshi.api.hardware.firmware.internal.FirmwareAttributeEnum.*; + +import oshi.api.hardware.firmware.internal.FirmwareContainerLinux; +import oshi.api.hardware.firmware.internal.FirmwareQuery; +import oshi.driver.ComponentDriver; +import oshi.driver.annotation.RequiresRoot; +import oshi.old.ExecutingCommand; +import oshi.old.FileUtil; + +public class FirmwareDriverLinux extends ComponentDriver { + + private FirmwareContainerLinux container; + + private static final String SYSFS_SERIAL_PATH = "/sys/devices/virtual/dmi/id/"; + + @FirmwareQuery(NAME) + public void name() { + } + + @FirmwareQuery(MANUFACTURER) + private void manufacturer() { + container.manufacturer = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_vendor").trim(); + } + + @FirmwareQuery(DESCRIPTION) + private void description() { + container.description = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "modalias").trim(); + } + + @FirmwareQuery(VERSION) + private void version() { + container.version = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_version").trim(); + } + + @FirmwareQuery(RELEASE_DATE) + private void releaseDate() { + container.releaseDate = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_date").trim(); + } + + @RequiresRoot + @FirmwareQuery(REVISION) + private void revision() { + final String marker = "Bios Revision:"; + for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { + if (checkLine.contains(marker)) { + container.revision = checkLine.split(marker)[1].trim(); + return; + } + } + } + + @RequiresRoot + @FirmwareQuery(UEFI) + private void uefi() { + final String marker = "UEFI is supported"; + for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { + if (checkLine.contains(marker)) { + container.uefi = true; + return; + } + } + + container.uefi = false; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java new file mode 100644 index 0000000..e0a4eb7 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java @@ -0,0 +1,83 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.hardware.nic; + +import static oshi.api.hardware.nic.internal.NicAttributeEnum.*; + +import java.net.NetworkInterface; +import java.net.SocketException; + +import oshi.api.hardware.nic.internal.NicContainer; +import oshi.api.hardware.nic.internal.NicQuery; +import oshi.driver.ExtensionDriver; + +/** + * A driver that uses Java's built-in {@link NetworkInterface} class. + */ +public class NicDriverJava extends ExtensionDriver { + + protected NetworkInterface instance; + private NicContainer container; + + public NicDriverJava(NetworkInterface instance) { + this.instance = instance; + } + + @NicQuery(VIRTUAL) + private void virtual() { + container.virtual = instance.isVirtual(); + } + + @NicQuery(NAME) + private void name() { + container.name = instance.getName(); + } + + @NicQuery(MAC) + private void mac() throws SocketException { + } + + @NicQuery(IPV4) + private void ipv4() { + container.ipv4 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) + .filter(address -> !address.contains(":")).toArray(String[]::new); + } + + @NicQuery(IPV6) + private void ipv6() { + container.ipv6 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) + .filter(address -> address.contains(":")).toArray(String[]::new); + } + + @NicQuery(MTU) + private void mtu() throws SocketException { + container.mtu = instance.getMTU(); + } + + @Override + public boolean compatible() { + return true; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java new file mode 100644 index 0000000..29a0def --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java @@ -0,0 +1,151 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.hardware.nic; + +import static oshi.api.hardware.nic.internal.NicAttributeEnum.*; + +import oshi.api.hardware.nic.internal.NicContainerLinux; +import oshi.api.hardware.nic.internal.NicQuery; +import oshi.driver.ComponentDriver; +import oshi.old.FileUtil; + +public class NicDriverLinux extends ComponentDriver { + + private NicContainerLinux container; + + @NicQuery(READ_BYTES) + private void readBytes() { + container.readBytes = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_bytes", container.name)); + } + + @NicQuery(WRITE_BYTES) + private void writeBytes() { + container.writeBytes = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_bytes", container.name)); + } + + @NicQuery(READ_PACKETS) + private void readPackets() { + container.readPackets = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_packets", container.name)); + } + + @NicQuery(WRITE_PACKETS) + private void writePackets() { + container.writePackets = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_packets", container.name)); + } + + @NicQuery(READ_ERRORS) + private void readErrors() { + container.readErrors = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_errors", container.name)); + } + + @NicQuery(WRITE_ERRORS) + private void writeErrors() { + container.writeErrors = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_errors", container.name)); + } + + @NicQuery(DESCRIPTION) + private void description() { + // TODO Auto-generated method stub + + } + + @NicQuery(BROADCAST) + private void broadcast() { + // TODO Auto-generated method stub + + } + + @NicQuery(NETMASK) + private void netmask() { + // TODO Auto-generated method stub + + } + + @NicQuery(READ_DROPS) + private void readDrops() { + container.readDrops = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_dropped", container.name)); + + } + + @NicQuery(WRITE_DROPS) + private void writeDrops() { + container.writeDrops = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_dropped", container.name)); + } + + @NicQuery(WRITE_COLLISIONS) + private void writeCollisions() { + container.writeCollisions = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/collisions", container.name)); + } + + @NicQuery(LINK_SPEED) + private void linkSpeed() { + container.linkSpeed = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/speed", container.name)); + } + + @NicQuery(DEFAULT_GATEWAY) + private void defaultGateway() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_UP) + private void flagUp() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_RUNNING) + private void flagRunning() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_LOOPBACK) + private void flagLoopback() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_MULTICAST) + private void flagMulticast() { + // TODO Auto-generated method stub + + } + + @NicQuery(MTU) + private void mac() { + container.mtu = FileUtil.getIntFromFile(String.format("/sys/class/net/%s/mtu", container.name)); + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverFreeBsd.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverFreeBsd.java new file mode 100644 index 0000000..dd0b908 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverFreeBsd.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.system; + +import java.util.stream.Stream; + +import oshi.api.FreeBsdSystem; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.api.hardware.nic.NicFreeBsd; + +public class SystemDriverFreeBsd implements FreeBsdSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareFreeBsd getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverLinux.java new file mode 100644 index 0000000..84616ed --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverLinux.java @@ -0,0 +1,118 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.system; + +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import oshi.api.LinuxSystem; +import oshi.api.hardware.disk.DiskLinux; +import oshi.api.hardware.disk.internal.DiskContainerLinux; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.api.hardware.firmware.internal.FirmwareContainerLinux; +import oshi.api.hardware.nic.NicLinux; +import oshi.api.hardware.nic.internal.NicContainerLinux; +import oshi.driver.ContainerFactory; +import oshi.driver.hardware.disk.DiskDriverLinux; +import oshi.driver.hardware.disk.DiskDriverLinuxSMART; +import oshi.driver.hardware.firmware.FirmwareDriverLinux; +import oshi.driver.hardware.nic.NicDriverJava; +import oshi.driver.hardware.nic.NicDriverLinux; +import oshi.old.GlobalConfig; +import oshi.old.Udev; + +public class SystemDriverLinux implements LinuxSystem { + + @Override + public Stream getNicStream() { + try { + return NetworkInterface.networkInterfaces().map(nif -> { + return ContainerFactory.build(NicContainerLinux.class, container -> { + container.name = nif.getName(); + }, NicDriverLinux.class, extensions -> { + if (GlobalConfig.get("oshi.driver.extension.networkinterface", true)) + extensions.add(new NicDriverJava(nif)); + }); + }); + } catch (SocketException e) { + // No interfaces found or I/O error occurred + return Stream.empty(); + } + } + + @Override + public Stream getDiskStream() { + List results = new ArrayList<>(); + + Udev.UdevDevice device = null; + Udev.UdevListEntry entry; + Udev.UdevListEntry oldEntry; + + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevEnumerate enumerate = Udev.INSTANCE.udev_enumerate_new(handle); + Udev.INSTANCE.udev_enumerate_add_match_subsystem(enumerate, "block"); + Udev.INSTANCE.udev_enumerate_scan_devices(enumerate); + + entry = Udev.INSTANCE.udev_enumerate_get_list_entry(enumerate); + while (true) { + oldEntry = entry; + String name = Udev.INSTANCE.udev_list_entry_get_name(entry); + device = Udev.INSTANCE.udev_device_new_from_syspath(handle, name); + if (device == null) { + break; + } + + String path = Udev.INSTANCE.udev_device_get_devnode(device); + + // Ignore loopback and ram disks; do nothing + if (!path.startsWith("/dev/loop") && !path.startsWith("/dev/ram")) { + if ("disk".equals(Udev.INSTANCE.udev_device_get_devtype(device))) { + var c = ContainerFactory.build(DiskContainerLinux.class, container -> { + container.name = name; + container.path = path; + }, DiskDriverLinux.class, extensions -> { + if (GlobalConfig.get("oshi.driver.extension.smart", true)) + extensions.add(new DiskDriverLinuxSMART()); + }); + + results.add(c); + } + } + + entry = Udev.INSTANCE.udev_list_entry_get_next(oldEntry); + Udev.INSTANCE.udev_device_unref(device); + } + + return results.stream(); + } + + @Override + public FirmwareLinux getFirmware() { + return ContainerFactory.build(FirmwareContainerLinux.class, FirmwareDriverLinux.class); + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverMac.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverMac.java new file mode 100644 index 0000000..99563b8 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverMac.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.system; + +import java.util.stream.Stream; + +import oshi.api.MacSystem; +import oshi.api.hardware.disk.DiskMac; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.api.hardware.nic.NicMac; + +public class SystemDriverMac implements MacSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareMac getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverSolaris.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverSolaris.java new file mode 100644 index 0000000..6e09a2e --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverSolaris.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.system; + +import java.util.stream.Stream; + +import oshi.api.SolarisSystem; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.api.hardware.nic.NicSolaris; + +public class SystemDriverSolaris implements SolarisSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareSolaris getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverWindows.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverWindows.java new file mode 100644 index 0000000..a5e03a2 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverWindows.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.system; + +import java.util.stream.Stream; + +import oshi.api.WindowsSystem; +import oshi.api.hardware.disk.DiskWindows; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.api.hardware.nic.NicWindows; + +public class SystemDriverWindows implements WindowsSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareWindows getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/example/DiskExample.java b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java new file mode 100644 index 0000000..faadde7 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java @@ -0,0 +1,101 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.example; + +import static oshi.api.hardware.disk.DiskAttribute.POWER_CYCLES; +import static oshi.api.hardware.disk.DiskAttribute.POWER_ON_TIME; +import static oshi.api.hardware.disk.DiskAttribute.READ_BYTES; +import static oshi.api.hardware.disk.DiskAttribute.SIZE; +import static oshi.api.hardware.disk.DiskAttribute.TEMPERATURE; +import static oshi.api.hardware.disk.DiskAttribute.WRITE_BYTES; + +import oshi.api.OSHI; + +public class DiskExample { + public static void main(String[] args) { + + example1(); + example2(); + example3(); + example4(); + } + + private static void example1() { + System.out.println("Cross-platform access that makes one query"); + + OSHI.getSystem().getDiskStream().forEach(disk -> { + disk.query(SIZE, READ_BYTES, WRITE_BYTES); + + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.getSize()); + System.out.println("\tRead bytes: " + disk.getReadBytes()); + System.out.println("\tWrite bytes: " + disk.getWriteBytes()); + }); + + System.out.println(); + } + + private static void example2() { + System.out.println("Platform-specific access that makes one query"); + + OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { + disk.query(SIZE, READ_BYTES, WRITE_BYTES); + + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.getSize()); + System.out.println("\tRead bytes: " + disk.getReadBytes()); + System.out.println("\tWrite bytes: " + disk.getWriteBytes()); + }); + + System.out.println(); + } + + private static void example3() { + System.out.println("Cross-platform access that makes three queries"); + + OSHI.getSystem().getDiskStream().forEach(disk -> { + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.querySize()); + System.out.println("\tRead bytes: " + disk.queryReadBytes()); + System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); + }); + + System.out.println(); + } + + private static void example4() { + System.out.println("Cross-platform access for SMART attributes"); + + OSHI.getSystem().getDiskStream().forEach(disk -> { + disk.query(POWER_CYCLES, POWER_ON_TIME, TEMPERATURE); + + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tPower cycles: " + disk.getPowerCycles()); + System.out.println("\tPower on hours: " + disk.getPowerOnTime()); + System.out.println("\tTemperature: " + disk.getTemperature()); + }); + + System.out.println(); + } +} diff --git a/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java new file mode 100644 index 0000000..f22ce12 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java @@ -0,0 +1,58 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.example; + +import oshi.api.OSHI; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.firmware.FirmwareLinux; + +public class FirmwareExample { + + public static void main(String[] args) { + example1(); + example2(); + } + + private static void example1() { + System.out.println("Cross-platform access"); + + Firmware firmware = OSHI.getSystem().getFirmware(); + System.out.println("Name: " + firmware.getName()); + System.out.println("Description: " + firmware.getDescription()); + System.out.println("Version: " + firmware.getVersion()); + System.out.println("Revision: " + firmware.getRevision()); + System.out.println("Release: " + firmware.getReleaseDate()); + + System.out.println(); + } + + private static void example2() { + System.out.println("Platform-specific access"); + + FirmwareLinux firmware = OSHI.getLinuxSystem().getFirmware(); + System.out.println("UEFI support: " + firmware.getUefi()); + + System.out.println(); + } +} diff --git a/reference/oshi-core/src/main/java/oshi/example/NicExample.java b/reference/oshi-core/src/main/java/oshi/example/NicExample.java new file mode 100644 index 0000000..250797e --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/example/NicExample.java @@ -0,0 +1,59 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.example; + +import static oshi.api.hardware.nic.NicAttribute.IPV4; +import static oshi.api.hardware.nic.NicAttribute.LINK_SPEED; +import static oshi.api.hardware.nic.NicAttribute.MTU; +import static oshi.api.hardware.nic.NicAttribute.READ_BYTES; +import static oshi.api.hardware.nic.NicAttribute.WRITE_BYTES; + +import java.util.Arrays; + +import oshi.api.OSHI; + +public class NicExample { + + public static void main(String[] args) throws Exception { + example1(); + } + + private static void example1() { + System.out.println("Cross-platform usage that makes one query"); + + OSHI.getSystem().getNicStream().forEach(nic -> { + nic.query(READ_BYTES, WRITE_BYTES, MTU, IPV4, LINK_SPEED); + + System.out.println("NIC: " + nic.getName()); + System.out.println("\tReadBytes: " + nic.getReadBytes()); + System.out.println("\tWriteBytes: " + nic.getWriteBytes()); + System.out.println("\tMTU: " + nic.getMtu()); + System.out.println("\tIPv4: " + Arrays.toString(nic.getIpv4())); + System.out.println("\tLink Speed: " + nic.getLinkSpeed()); + }); + + System.out.println(); + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/old/ExecutingCommand.java b/reference/oshi-core/src/main/java/oshi/old/ExecutingCommand.java new file mode 100644 index 0000000..b6f90ef --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/ExecutingCommand.java @@ -0,0 +1,136 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A class for executing on the command line and returning the result of + * execution. + * + * @author alessandro[at]perucchi[dot]org + */ +public class ExecutingCommand { + + private static final Logger LOG = LoggerFactory.getLogger(ExecutingCommand.class); + + private ExecutingCommand() { + } + + /** + * Executes a command on the native command line and returns the result. + * This is a convenience method to call {@link Runtime#exec(String)} and + * capture the resulting output in a list of Strings. On Windows, built-in + * commands not associated with an executable program may require + * {@code cmd.exe /c} to be prepended to the command. + * + * @param cmdToRun + * Command to run + * @return A list of Strings representing the result of the command, or + * empty string if the command failed + */ + public static List runNative(String cmdToRun) { + String[] cmd = cmdToRun.split(" "); + return runNative(cmd); + } + + /** + * Executes a command on the native command line and returns the result line + * by line. This is a convenience method to call + * {@link Runtime#exec(String[])} and capture the resulting output in a list + * of Strings. On Windows, built-in commands not associated with an + * executable program may require the strings {@code cmd.exe} and {@code /c} + * to be prepended to the array. + * + * @param cmdToRunWithArgs + * Command to run and args, in an array + * @return A list of Strings representing the result of the command, or + * empty string if the command failed + */ + public static List runNative(String[] cmdToRunWithArgs) { + Process p = null; + try { + p = Runtime.getRuntime().exec(cmdToRunWithArgs); + } catch (SecurityException | IOException e) { + LOG.trace("Couldn't run command {}: {}", Arrays.toString(cmdToRunWithArgs), e); + return new ArrayList<>(0); + } + + ArrayList sa = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))) { + String line; + while ((line = reader.readLine()) != null) { + sa.add(line); + } + p.waitFor(); + } catch (IOException e) { + LOG.trace("Problem reading output from {}: {}", Arrays.toString(cmdToRunWithArgs), e); + return new ArrayList<>(0); + } catch (InterruptedException ie) { + LOG.trace("Interrupted while reading output from {}: {}", Arrays.toString(cmdToRunWithArgs), ie); + Thread.currentThread().interrupt(); + } + return sa; + } + + /** + * Return first line of response for selected command. + * + * @param cmd2launch + * String command to be launched + * @return String or empty string if command failed + */ + public static String getFirstAnswer(String cmd2launch) { + return getAnswerAt(cmd2launch, 0); + } + + /** + * Return response on selected line index (0-based) after running selected + * command. + * + * @param cmd2launch + * String command to be launched + * @param answerIdx + * int index of line in response of the command + * @return String whole line in response or empty string if invalid index or + * running of command fails + */ + public static String getAnswerAt(String cmd2launch, int answerIdx) { + List sa = ExecutingCommand.runNative(cmd2launch); + + if (answerIdx >= 0 && answerIdx < sa.size()) { + return sa.get(answerIdx); + } + return ""; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/old/FileUtil.java b/reference/oshi-core/src/main/java/oshi/old/FileUtil.java new file mode 100644 index 0000000..2a3c6e9 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/FileUtil.java @@ -0,0 +1,211 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * File reading methods + * + * @author widdis[at]gmail[dot]com + */ +public class FileUtil { + private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class); + + private FileUtil() { + } + + /** + * Read an entire file at one time. Intended primarily for Linux /proc + * filesystem to avoid recalculating file contents on iterative reads. + * + * @param filename + * The file to read + * + * @return A list of Strings representing each line of the file, or an empty + * list if file could not be read or is empty + */ + public static List readFile(String filename) { + return readFile(filename, true); + } + + /** + * Read an entire file at one time. Intended primarily for Linux /proc + * filesystem to avoid recalculating file contents on iterative reads. + * + * @param filename + * The file to read + * @param reportError + * Whether to log errors reading the file + * + * @return A list of Strings representing each line of the file, or an empty + * list if file could not be read or is empty + */ + public static List readFile(String filename, boolean reportError) { + if (new File(filename).canRead()) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + try { + return Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8); + } catch (IOException e) { + if (reportError) { + LOG.error("Error reading file {}. {}", filename, e); + } + } + } else if (reportError) { + LOG.warn("File not found or not readable: {}", filename); + } + return new ArrayList<>(); + } + + /** + * Read a file and return the long value contained therein. Intended + * primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static long getLongFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return ParseUtil.parseLongOrDefault(read.get(0), 0L); + } + return 0L; + } + + /** + * Read a file and return the unsigned long value contained therein as a + * long. Intended primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static long getUnsignedLongFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return ParseUtil.parseUnsignedLongOrDefault(read.get(0), 0L); + } + return 0L; + } + + /** + * Read a file and return the int value contained therein. Intended + * primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static int getIntFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + try { + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return Integer.parseInt(read.get(0)); + } + } catch (NumberFormatException ex) { + LOG.warn("Unable to read value from {}. {}", filename, ex); + } + return 0; + } + + /** + * Read a file and return the String value contained therein. Intended + * primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise empty string + */ + public static String getStringFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return read.get(0); + } + return ""; + } + + /** + * Read a file and return a map of string keys to string values contained + * therein. Intended primarily for Linux /proc/[pid]/io + * + * @param filename + * The file to read + * @param separator + * Characters in each line of the file that separate the key and + * the value + * @return The map contained in the file, if any; otherwise empty map + */ + public static Map getKeyValueMapFromFile(String filename, String separator) { + Map map = new HashMap<>(); + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List lines = FileUtil.readFile(filename, false); + for (String line : lines) { + String[] parts = line.split(separator); + if (parts.length == 2) { + map.put(parts[0], parts[1].trim()); + } + } + return map; + } +} diff --git a/reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java b/reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java new file mode 100644 index 0000000..4dab27d --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java @@ -0,0 +1,181 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The global configuration utility. See + * {@code src/main/resources/default.properties} for default values. + */ +public final class GlobalConfig { + + private static final Logger LOG = LoggerFactory.getLogger(GlobalConfig.class); + + private static final Properties configuration = new Properties(); + + static { + try (InputStream in = GlobalConfig.class.getResourceAsStream("/default.properties")) { + if (in != null) { + configuration.load(in); + } + } catch (IOException e) { + LOG.warn("Failed to load default configuration"); + } + } + + /** + * Get the {@code String} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static String get(String key, String def) { + return configuration.getProperty(key, def); + } + + /** + * Get the {@code int} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static int get(String key, int def) { + String value = configuration.getProperty(key); + return value == null ? def : ParseUtil.parseIntOrDefault(value, def); + } + + /** + * Get the {@code double} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static double get(String key, double def) { + String value = configuration.getProperty(key); + return value == null ? def : ParseUtil.parseDoubleOrDefault(value, def); + } + + /** + * Get the {@code boolean} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static boolean get(String key, boolean def) { + String value = configuration.getProperty(key); + return value == null ? def : Boolean.parseBoolean(value); + } + + /** + * Set the given property, overwriting any existing value. If the given + * value is {@code null}, the property is removed. + * + * @param key + * The property key + * @param val + * The new value + */ + public static void set(String key, Object val) { + if (val == null) { + configuration.remove(key); + } else { + configuration.setProperty(key, val.toString()); + } + } + + /** + * Reset the given property to its default value. + * + * @param key + * The property key + */ + public static void remove(String key) { + configuration.remove(key); + } + + /** + * Clear the configuration. + */ + public static void clear() { + configuration.clear(); + } + + /** + * Load the given {@link java.util.Properties} into the global + * configuration. + * + * @param properties + * The new properties + */ + public static void load(Properties properties) { + configuration.putAll(properties); + } + + /** + * Indicates that a configuration value is invalid. + */ + public static class PropertyException extends RuntimeException { + + private static final long serialVersionUID = -7482581936621748005L; + + /** + * @param property + * The property name + */ + public PropertyException(String property) { + super("Invalid property: \"" + property + "\" = " + GlobalConfig.get(property, null)); + } + + /** + * @param property + * The property name + * @param message + * An exception message + */ + public PropertyException(String property, String message) { + super("Invalid property \"" + property + "\": " + message); + } + } + + private GlobalConfig() { + } +} diff --git a/reference/oshi-core/src/main/java/oshi/old/ParseUtil.java b/reference/oshi-core/src/main/java/oshi/old/ParseUtil.java new file mode 100644 index 0000000..b272b94 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/ParseUtil.java @@ -0,0 +1,766 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * String parsing utility. + * + * @author alessio.fachechi[at]gmail[dot]com + */ +public class ParseUtil { + + private static final Logger LOG = LoggerFactory.getLogger(ParseUtil.class); + + private static final String DEFAULT_LOG_MSG = "{} didn't parse. Returning default. {}"; + /* + * Used for matching + */ + private static final Pattern HERTZ_PATTERN = Pattern.compile("(\\d+(.\\d+)?) ?([kMGT]?Hz).*"); + + /* + * Used to check validity of a hexadecimal string + */ + private static final Pattern VALID_HEX = Pattern.compile("[0-9a-fA-F]+"); + + /* + * Pattern for [dd-[hh:[mm:ss]]] + */ + private static final Pattern DHMS = Pattern.compile("(?:(\\d+)-)?(?:(\\d+):)?(\\d+):(\\d+)(?:\\.(\\d+))?"); + + /* + * Pattern for a UUID + */ + private static final Pattern UUID_PATTERN = Pattern + .compile(".*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}).*"); + + /* + * Hertz related variables. + */ + private static final String HZ = "Hz"; + private static final String KHZ = "kHz"; + private static final String MHZ = "MHz"; + private static final String GHZ = "GHz"; + private static final String THZ = "THz"; + private static final String PHZ = "PHz"; + + private static final Map multipliers; + + // PDH timestamps are 1601 epoch, local time + // Constants to convert to UTC millis + private static final long EPOCH_DIFF = 11644473600000L; + private static final int TZ_OFFSET = TimeZone.getDefault().getOffset(System.currentTimeMillis()); + + public static final Pattern whitespacesColonWhitespace = Pattern.compile("\\s+:\\s"); + + public static final Pattern whitespaces = Pattern.compile("\\s+"); + + public static final Pattern notDigits = Pattern.compile("[^0-9]+"); + + public static final Pattern startWithNotDigits = Pattern.compile("^[^0-9]*"); + + static { + multipliers = new HashMap<>(); + multipliers.put(HZ, 1L); + multipliers.put(KHZ, 1_000L); + multipliers.put(MHZ, 1_000_000L); + multipliers.put(GHZ, 1_000_000_000L); + multipliers.put(THZ, 1_000_000_000_000L); + multipliers.put(PHZ, 1_000_000_000_000_000L); + } + + // Fast decimal exponentiation: pow(10,y) --> POWERS_OF_10[y] + private static final long[] POWERS_OF_TEN = { 1L, 10L, 100L, 1_000L, 10_000L, 100_000L, 1_000_000L, 10_000_000L, + 100_000_000L, 1_000_000_000L, 10_000_000_000L, 100_000_000_000L, 1_000_000_000_000L, 10_000_000_000_000L, + 100_000_000_000_000L, 1_000_000_000_000_000L, 10_000_000_000_000_000L, 100_000_000_000_000_000L, + 1_000_000_000_000_000_000L }; + + // Fast hex character lookup + private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); + + private ParseUtil() { + } + + /** + * Parse hertz from a string, eg. "2.00MHz" in 2000000L. + * + * @param hertz + * Hertz size. + * @return {@link Long} Hertz value or -1 if not parsable. + */ + public static long parseHertz(String hertz) { + Matcher matcher = HERTZ_PATTERN.matcher(hertz.trim()); + if (matcher.find() && matcher.groupCount() == 3) { + // Regexp enforces #(.#) format so no test for NFE required + double value = Double.valueOf(matcher.group(1)) * multipliers.getOrDefault(matcher.group(3), -1L); + if (value >= 0d) { + return (long) value; + } + } + return -1L; + } + + /** + * Parse the last element of a space-delimited string to a value + * + * @param s + * The string to parse + * @param i + * Default integer if not parsable + * @return value or the given default if not parsable + */ + public static int parseLastInt(String s, int i) { + try { + return Integer.parseInt(parseLastString(s)); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return i; + } + } + + /** + * Parse the last element of a space-delimited string to a value + * + * @param s + * The string to parse + * @param li + * Default long integer if not parsable + * @return value or the given default if not parsable + */ + public static long parseLastLong(String s, long li) { + try { + return Long.parseLong(parseLastString(s)); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return li; + } + } + + /** + * Parse the last element of a space-delimited string to a value + * + * @param s + * The string to parse + * @param d + * Default double if not parsable + * @return value or the given default if not parsable + */ + public static double parseLastDouble(String s, double d) { + try { + return Double.parseDouble(parseLastString(s)); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return d; + } + } + + /** + * Parse the last element of a space-delimited string to a string + * + * @param s + * The string to parse + * @return last space-delimited element + */ + public static String parseLastString(String s) { + String[] ss = whitespaces.split(s); + if (ss.length < 1) { + return s; + } else { + return ss[ss.length - 1]; + } + } + + /** + * Parse a byte aray into a string of hexadecimal digits including leading + * zeros + * + * @param bytes + * The byte array to represent + * @return A string of hex characters corresponding to the bytes. The string + * is upper case. + */ + public static String byteArrayToHexString(byte[] bytes) { + // Solution copied from https://stackoverflow.com/questions/9655181 + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = HEX_ARRAY[v >>> 4]; + hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; + } + return new String(hexChars); + } + + /** + * Parse a string of hexadecimal digits into a byte array + * + * @param digits + * The string to be parsed + * @return a byte array with each pair of characters converted to a byte, or + * empty array if the string is not valid hex + */ + public static byte[] hexStringToByteArray(String digits) { + int len = digits.length(); + // Check if string is valid hex + if (!VALID_HEX.matcher(digits).matches() || (len & 0x1) != 0) { + LOG.warn("Invalid hexadecimal string: {}", digits); + return new byte[0]; + } + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) (Character.digit(digits.charAt(i), 16) << 4 + | Character.digit(digits.charAt(i + 1), 16)); + } + return data; + } + + /** + * Parse a human readable string into a byte array, truncating or padding + * with zeros (if necessary) so the array has the specified length. + * + * @param text + * The string to be parsed + * @param length + * Length of the returned array. + * @return A byte array of specified length, with each of the first length + * characters converted to a byte. If length is longer than the + * provided string length, will be filled with zeroes. + */ + public static byte[] stringToByteArray(String text, int length) { + return Arrays.copyOf(text.getBytes(), length); + } + + /** + * Convert a long value to a byte array using Big Endian, truncating or + * padding with zeros (if necessary) so the array has the specified length. + * + * @param value + * The value to be converted + * @param valueSize + * Number of bytes representing the value + * @param length + * Number of bytes to return + * @return A byte array of specified length representing the long in the + * first valueSize bytes + */ + public static byte[] longToByteArray(long value, int valueSize, int length) { + long val = value; + // Convert the long to 8-byte BE representation + byte[] b = new byte[8]; + for (int i = 7; i >= 0 && val != 0L; i--) { + b[i] = (byte) val; + val >>>= 8; + } + // Then copy the rightmost valueSize bytes + // e.g., for an integer we want rightmost 4 bytes + return Arrays.copyOfRange(b, 8 - valueSize, 8 + length - valueSize); + } + + /** + * Convert a string to an integer representation. + * + * @param str + * A human readable ASCII string + * @param size + * Number of characters to convert to the long. May not exceed 8. + * @return An integer representing the string where each character is + * treated as a byte + */ + public static long strToLong(String str, int size) { + return byteArrayToLong(str.getBytes(StandardCharsets.US_ASCII), size); + } + + /** + * Convert a byte array to its integer representation. + * + * @param bytes + * An array of bytes no smaller than the size to be converted + * @param size + * Number of bytes to convert to the long. May not exceed 8. + * @return An integer representing the byte array as a 64-bit number + */ + public static long byteArrayToLong(byte[] bytes, int size) { + if (size > 8) { + throw new IllegalArgumentException("Can't convert more than 8 bytes."); + } + if (size > bytes.length) { + throw new IllegalArgumentException("Size can't be larger than array length."); + } + long total = 0L; + for (int i = 0; i < size; i++) { + total = total << 8 | bytes[i] & 0xff; + } + return total; + } + + /** + * Convert a byte array to its floating point representation. + * + * @param bytes + * An array of bytes no smaller than the size to be converted + * @param size + * Number of bytes to convert to the float. May not exceed 8. + * @param fpBits + * Number of bits representing the decimal + * @return A float; the integer portion representing the byte array as an + * integer shifted by the bits specified in fpBits; with the + * remaining bits used as a decimal + */ + public static float byteArrayToFloat(byte[] bytes, int size, int fpBits) { + return byteArrayToLong(bytes, size) / (float) (1 << fpBits); + } + + /** + * Convert an unsigned integer to a long value. The method assumes that all + * bits in the specified integer value are 'data' bits, including the + * most-significant bit which Java normally considers a sign bit. The method + * must be used only when it is certain that the integer value represents an + * unsigned integer, for example when the integer is returned by JNA library + * in a structure which holds unsigned integers. + * + * @param unsignedValue + * The unsigned integer value to convert. + * @return The unsigned integer value widened to a long. + */ + public static long unsignedIntToLong(int unsignedValue) { + // use standard Java widening conversion to long which does + // sign-extension, + // then drop any copies of the sign bit, to prevent the value being + // considered a negative one by Java if it is set + long longValue = unsignedValue; + return longValue & 0xffffffffL; + } + + /** + * Convert an unsigned long to a signed long value by stripping the sign + * bit. This method "rolls over" long values greater than the max value but + * ensures the result is never negative. + * + * @param unsignedValue + * The unsigned long value to convert. + * @return The signed long value. + */ + public static long unsignedLongToSignedLong(long unsignedValue) { + return unsignedValue & 0x7fffffff_ffffffffL; + } + + /** + * Parses a string of hex digits to a string where each pair of hex digits + * represents an ASCII character + * + * @param hexString + * A sequence of hex digits + * @return The corresponding string if valid hex; otherwise the original + * hexString + */ + public static String hexStringToString(String hexString) { + // Odd length strings won't parse, return + if (hexString.length() % 2 > 0) { + return hexString; + } + int charAsInt; + StringBuilder sb = new StringBuilder(); + try { + for (int pos = 0; pos < hexString.length(); pos += 2) { + charAsInt = Integer.parseInt(hexString.substring(pos, pos + 2), 16); + if (charAsInt < 32 || charAsInt > 127) { + return hexString; + } + sb.append((char) charAsInt); + } + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, hexString, e); + // Hex failed to parse, just return the existing string + return hexString; + } + return sb.toString(); + } + + /** + * Attempts to parse a string to an int. If it fails, returns the default + * + * @param s + * The string to parse + * @param defaultInt + * The value to return if parsing fails + * @return The parsed int, or the default if parsing failed + */ + public static int parseIntOrDefault(String s, int defaultInt) { + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultInt; + } + } + + /** + * Attempts to parse a string to a long. If it fails, returns the default + * + * @param s + * The string to parse + * @param defaultLong + * The value to return if parsing fails + * @return The parsed long, or the default if parsing failed + */ + public static long parseLongOrDefault(String s, long defaultLong) { + try { + return Long.parseLong(s); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultLong; + } + } + + /** + * Attempts to parse a string to an "unsigned" long. If it fails, returns + * the default + * + * @param s + * The string to parse + * @param defaultLong + * The value to return if parsing fails + * @return The parsed long containing the same 64 bits that an unsigned long + * would contain (which may produce a negative value) + */ + public static long parseUnsignedLongOrDefault(String s, long defaultLong) { + try { + return new BigInteger(s).longValue(); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultLong; + } + } + + /** + * Attempts to parse a string to a double. If it fails, returns the default + * + * @param s + * The string to parse + * @param defaultDouble + * The value to return if parsing fails + * @return The parsed double, or the default if parsing failed + */ + public static double parseDoubleOrDefault(String s, double defaultDouble) { + try { + return Double.parseDouble(s); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultDouble; + } + } + + /** + * Attempts to parse a string of the form [DD-[hh:]]mm:ss[.ddd] to a number + * of milliseconds. If it fails, returns the default. + * + * @param s + * The string to parse + * @param defaultLong + * The value to return if parsing fails + * @return The parsed number of seconds, or the default if parsing fails + */ + public static long parseDHMSOrDefault(String s, long defaultLong) { + Matcher m = DHMS.matcher(s); + if (m.matches()) { + long milliseconds = 0L; + if (m.group(1) != null) { + milliseconds += parseLongOrDefault(m.group(1), 0L) * 86400000L; + } + if (m.group(2) != null) { + milliseconds += parseLongOrDefault(m.group(2), 0L) * 3600000L; + } + milliseconds += parseLongOrDefault(m.group(3), 0L) * 60000L; + milliseconds += parseLongOrDefault(m.group(4), 0L) * 1000L; + milliseconds += (long) (1000 * parseDoubleOrDefault("0." + m.group(5), 0d)); + return milliseconds; + } + return defaultLong; + } + + /** + * Attempts to parse a UUID. If it fails, returns the default. + * + * @param s + * The string to parse + * @param defaultStr + * The value to return if parsing fails + * @return The parsed UUID, or the default if parsing fails + */ + public static String parseUuidOrDefault(String s, String defaultStr) { + Matcher m = UUID_PATTERN.matcher(s.toLowerCase()); + if (m.matches()) { + return m.group(1); + } + return defaultStr; + } + + /** + * Parses a string key = 'value' (string) + * + * @param line + * The entire string + * @return the value contained between single tick marks + */ + public static String getSingleQuoteStringValue(String line) { + return getStringBetween(line, '\''); + } + + /** + * Parse a string key = "value" (string) + * + * @param line + * the entire string + * @return the value contained between double tick marks + */ + public static String getDoubleQuoteStringValue(String line) { + return getStringBetween(line, '"'); + } + + /** + * Gets a value between two characters having multiple same characters + * between them. Examples : + *
    + *
  • "name = 'James Gosling's Java'" returns "James Gosling's Java"
  • + *
  • "pci.name = 'Realtek AC'97 Audio Device'" returns "Realtek AC'97 + * Audio Device"
  • + *
+ * + * @param line + * The "key-value" pair line. + * @param c + * The Trailing And Leading characters of the string line + * @return : The value having the characters between them. + */ + public static String getStringBetween(String line, char c) { + int firstOcc = line.indexOf(c); + if (firstOcc < 0) { + return ""; + } + return line.substring(firstOcc + 1, line.lastIndexOf(c)).trim(); + } + + /** + * Parses a string such as "10.12.2" or "key = 1 (0x1) (int)" to find the + * integer value of the first set of one or more consecutive digits + * + * @param line + * The entire string + * @return the value of first integer if any; 0 otherwise + */ + public static int getFirstIntValue(String line) { + return getNthIntValue(line, 1); + } + + /** + * Parses a string such as "10.12.2" or "key = 1 (0x1) (int)" to find the + * integer value of the nth set of one or more consecutive digits + * + * @param line + * The entire string + * @param n + * Which set of integers to return + * @return the value of nth integer if any; 0 otherwise + */ + public static int getNthIntValue(String line, int n) { + // Split the string by non-digits, + String[] split = notDigits.split(startWithNotDigits.matcher(line).replaceFirst("")); + if (split.length >= n) { + return parseIntOrDefault(split[n - 1], 0); + } + return 0; + } + + /** + * Removes all matching sub strings from the string. More efficient than + * regexp. + * + * @param original + * source String to remove from + * @param toRemove + * the sub string to be removed + * @return The string with all matching substrings removed + */ + public static String removeMatchingString(final String original, final String toRemove) { + if (original == null || original.isEmpty() || toRemove == null || toRemove.isEmpty()) { + return original; + } + + int matchIndex = original.indexOf(toRemove, 0); + if (matchIndex == -1) { + return original; + } + + StringBuilder buffer = new StringBuilder(original.length() - toRemove.length()); + int currIndex = 0; + do { + buffer.append(original.substring(currIndex, matchIndex)); + currIndex = matchIndex + toRemove.length(); + matchIndex = original.indexOf(toRemove, currIndex); + } while (matchIndex != -1); + + buffer.append(original.substring(currIndex)); + return buffer.toString(); + } + + /** + * Parses a delimited string to an array of longs. Optimized for processing + * predictable-length arrays such as outputs of reliably formatted Linux + * proc or sys filesystem, minimizing new object creation. Users should + * perform other sanity checks of data. + * + * The indices parameters are referenced assuming the length as specified, + * and leading characters are ignored. For example, if the string is "foo 12 + * 34 5" and the length is 3, then index 0 is 12, index 1 is 34, and index 2 + * is 5. + * + * @param s + * The string to parse + * @param indices + * An array indicating which indexes should be populated in the + * final array; other values will be skipped. This idex is + * zero-referenced assuming the rightmost delimited fields of the + * string contain the array. + * @param length + * The total number of elements in the string array. It is + * permissible for the string to have more elements than this; + * leading elements will be ignored. + * @param delimiter + * The character to delimit by + * @return If successful, an array of parsed longs. If parsing errors + * occurred, will be an array of zeros. + */ + public static long[] parseStringToLongArray(String s, int[] indices, int length, char delimiter) { + long[] parsed = new long[indices.length]; + // Iterate from right-to-left of String + // Fill right to left of result array using index array + int charIndex = s.length() - 1; + int parsedIndex = indices.length - 1; + int stringIndex = length - 1; + + int power = 0; + int c; + boolean delimCurrent = false; + while (charIndex > 0 && parsedIndex >= 0) { + c = s.charAt(charIndex--); + if (c == delimiter) { + if (!delimCurrent) { + power = 0; + if (indices[parsedIndex] == stringIndex--) { + parsedIndex--; + } + delimCurrent = true; + } + } else if (indices[parsedIndex] != stringIndex || c == '+') { + // Doesn't impact parsing, ignore + delimCurrent = false; + } else if (c >= '0' && c <= '9') { + if (power > 18) { + LOG.error("Number is too big for a long parsing string '{}' to long array", s); + return new long[indices.length]; + } + parsed[parsedIndex] += (c - '0') * ParseUtil.POWERS_OF_TEN[power++]; + delimCurrent = false; + } else if (c == '-') { + parsed[parsedIndex] *= -1L; + delimCurrent = false; + } else { + // error on everything else + LOG.error("Illegal character parsing string '{}' to long array: {}", s, s.charAt(charIndex)); + return new long[indices.length]; + } + } + if (parsedIndex > 0) { + LOG.error("Not enough fields in string '{}' parsing to long array: {}", s, indices.length - parsedIndex); + return new long[indices.length]; + } + return parsed; + } + + /** + * Get a String in a line of text between two marker strings + * + * @param text + * Text to search for match + * @param before + * Start matching after this text + * @param after + * End matching before this text + * @return Text between the strings before and after, or empty string if + * either marker does not exist + */ + public static String getTextBetweenStrings(String text, String before, String after) { + + String result = ""; + + if (text.indexOf(before) >= 0 && text.indexOf(after) >= 0) { + result = text.substring(text.indexOf(before) + before.length(), text.length()); + result = result.substring(0, result.indexOf(after)); + } + return result; + } + + /** + * Convert a long representing filetime (100-ns since 1601 epoch) to ms + * since 1970 epoch + * + * @param filetime + * A 64-bit value equivalent to FILETIME + * @param local + * True if converting from a local filetime (PDH counter); false + * if already UTC (WMI PerfRawData classes) + * @return Equivalent milliseconds since the epoch + */ + public static long filetimeToUtcMs(long filetime, boolean local) { + return filetime / 10000L - EPOCH_DIFF - (local ? TZ_OFFSET : 0L); + } + + /** + * Parse a date in MM-DD-YYYY or MM/DD/YYYY to YYYY-MM-DD + * + * @param dateString + * The date in MM DD YYYY format + * @return The date in ISO YYYY-MM-DD format if parseable, or the original + * string + */ + public static String parseMmDdYyyyToYyyyMmDD(String dateString) { + try { + // Date is MM-DD-YYYY, convert to YYYY-MM-DD + return String.format("%s-%s-%s", dateString.substring(6, 10), dateString.substring(0, 2), + dateString.substring(3, 5)); + } catch (StringIndexOutOfBoundsException e) { + return dateString; + } + } +} diff --git a/reference/oshi-core/src/main/java/oshi/old/Udev.java b/reference/oshi-core/src/main/java/oshi/old/Udev.java new file mode 100644 index 0000000..2807d93 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/Udev.java @@ -0,0 +1,120 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; + +/** + * Interface for talking with Udev. + * + * @author enrico[dot]bianchi[at]gmail[dot]com + */ +public interface Udev extends Library { + + Udev INSTANCE = Native.load("udev", Udev.class); + + final class UdevHandle extends PointerType { + + public UdevHandle(Pointer address) { + super(address); + } + + public UdevHandle() { + super(); + } + } + + final class UdevDevice extends PointerType { + + public UdevDevice(Pointer address) { + super(address); + } + + public UdevDevice() { + super(); + } + } + + final class UdevEnumerate extends PointerType { + + public UdevEnumerate(Pointer address) { + super(address); + } + + public UdevEnumerate() { + super(); + } + } + + final class UdevListEntry extends PointerType { + + public UdevListEntry(Pointer address) { + super(address); + } + + public UdevListEntry() { + super(); + } + } + + Udev.UdevHandle udev_new(); + + void udev_unref(Udev.UdevHandle udev); + + void udev_device_unref(Udev.UdevDevice udev_device); + + void udev_enumerate_unref(Udev.UdevEnumerate udev_enumerate); + + Udev.UdevEnumerate udev_enumerate_new(Udev.UdevHandle udev); + + Udev.UdevDevice udev_device_get_parent_with_subsystem_devtype(Udev.UdevDevice udev_device, String subsystem, + String devtype); + + Udev.UdevDevice udev_device_new_from_syspath(Udev.UdevHandle udev, String syspath); + + Udev.UdevListEntry udev_list_entry_get_next(Udev.UdevListEntry list_entry); + + String udev_device_get_sysattr_value(Udev.UdevDevice udev_device, String sysattr); + + int udev_enumerate_add_match_subsystem(Udev.UdevEnumerate udev_enumerate, String subsystem); + + int udev_enumerate_scan_devices(Udev.UdevEnumerate udev_enumerate); + + Udev.UdevListEntry udev_enumerate_get_list_entry(Udev.UdevEnumerate udev_enumerate); + + String udev_list_entry_get_name(Udev.UdevListEntry list_entry); + + String udev_device_get_devtype(Udev.UdevDevice udev_device); + + String udev_device_get_devnode(Udev.UdevDevice udev_device); + + String udev_device_get_syspath(Udev.UdevDevice udev_device); + + String udev_device_get_property_value(Udev.UdevDevice udev_device, String key); + + String udev_device_get_sysname(UdevDevice udev_device); +} diff --git a/reference/oshi-core/src/main/java/oshi/old/WmiUtil.java b/reference/oshi-core/src/main/java/oshi/old/WmiUtil.java new file mode 100644 index 0000000..4c08c48 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/WmiUtil.java @@ -0,0 +1,296 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import com.sun.jna.platform.win32.Variant; // NOSONAR +import com.sun.jna.platform.win32.COM.Wbemcli; +import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery; +import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult; + +/** + * Helper class for WMI + * + * @author widdis[at]gmail[dot]com + */ +public class WmiUtil { + + // Not a built in namespace, failed connections are normal and don't need + // error logging + public static final String OHM_NAMESPACE = "ROOT\\OpenHardwareMonitor"; + + private static final String CLASS_CAST_MSG = "%s is not a %s type. CIM Type is %d and VT type is %d"; + + /** + * Private constructor so this class can't be instantiated from the outside. + */ + private WmiUtil() { + } + + /** + * Translate a WmiQuery to the actual query string + * + * @param + * The properties enum + * @param query + * The WmiQuery object + * @return The string that is queried in WMI + */ + public static > String queryToString(WmiQuery query) { + T[] props = query.getPropertyEnum().getEnumConstants(); + StringBuilder sb = new StringBuilder("SELECT "); + sb.append(props[0].name()); + for (int i = 1; i < props.length; i++) { + sb.append(',').append(props[i].name()); + } + sb.append(" FROM ").append(query.getWmiClassName()); + return sb.toString(); + } + + /** + * Gets a String value from a WmiResult + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, an empty-string otherwise + */ + public static > String getString(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_STRING) { + return getStr(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "String", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Date value from a WmiResult as a String + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, an empty-string otherwise + */ + public static > String getDateString(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_DATETIME) { + String date = getStr(result, property, index); + return date.substring(0, 4) + '-' + date.substring(4, 6) + '-' + date.substring(6, 8); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "DateTime", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Reference value from a WmiResult as a String + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, an empty-string otherwise + */ + public static > String getRefString(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_REFERENCE) { + return getStr(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "Reference", + result.getCIMType(property), result.getVtType(property))); + } + + private static > String getStr(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return ""; + } else if (result.getVtType(property) == Variant.VT_BSTR) { + return (String) o; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "String-mapped", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Uint64 value from a WmiResult (parsing the String). Note that + * while the CIM type is unsigned, the return type is signed and the parsing + * will exclude any return values above Long.MAX_VALUE. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null and parseable as a long, 0 otherwise + */ + public static > long getUint64(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return 0L; + } else if (result.getCIMType(property) == Wbemcli.CIM_UINT64 && result.getVtType(property) == Variant.VT_BSTR) { + return ParseUtil.parseLongOrDefault((String) o, 0L); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT64", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets an UINT32 value from a WmiResult. Note that while a UINT32 CIM type + * is unsigned, the return type is signed and requires further processing by + * the user if unsigned values are desired. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > int getUint32(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_UINT32) { + return getInt(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT32", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets an UINT32 value from a WmiResult as a long, preserving the + * unsignedness. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > long getUint32asLong(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_UINT32) { + return getInt(result, property, index) & 0xFFFFFFFFL; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT32", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Sint32 value from a WmiResult. Note that while the CIM type is + * unsigned, the return type is signed and requires further processing by + * the user if unsigned values are desired. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > int getSint32(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_SINT32) { + return getInt(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "SINT32", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Uint16 value from a WmiResult. Note that while the CIM type is + * unsigned, the return type is signed and requires further processing by + * the user if unsigned values are desired. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > int getUint16(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_UINT16) { + return getInt(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT16", + result.getCIMType(property), result.getVtType(property))); + } + + private static > int getInt(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return 0; + } else if (result.getVtType(property) == Variant.VT_I4) { + return (int) o; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "32-bit integer", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Float value from a WmiResult + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > float getFloat(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return 0f; + } else if (result.getCIMType(property) == Wbemcli.CIM_REAL32 && result.getVtType(property) == Variant.VT_R4) { + return (float) o; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "Float", + result.getCIMType(property), result.getVtType(property))); + } +} diff --git a/reference/oshi-core/src/main/resources/default.properties b/reference/oshi-core/src/main/resources/default.properties new file mode 100644 index 0000000..f181262 --- /dev/null +++ b/reference/oshi-core/src/main/resources/default.properties @@ -0,0 +1,35 @@ +# +# OSHI (https://github.com/oshi/oshi) +# +# Copyright (c) 2010 - 2019 The OSHI Project Team: +# https://github.com/oshi/oshi/graphs/contributors +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# The /proc filesystem location +oshi.util.proc.path=/proc + +# The WMI query timeout in milliseconds (where -1 indicates no timeout) +oshi.util.wmi.timeout=-1 + +# Whether the S.M.A.R.T. extension will be loaded for disk information +oshi.driver.extension.smart=true + +# Whether Java's NetworkInterface class will be loaded for network information +oshi.driver.extension.networkinterface=true \ No newline at end of file diff --git a/reference/oshi-core/src/site/site.xml b/reference/oshi-core/src/site/site.xml new file mode 100644 index 0000000..16a056a --- /dev/null +++ b/reference/oshi-core/src/site/site.xml @@ -0,0 +1,52 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reference/oshi-demo/pom.xml b/reference/oshi-demo/pom.xml new file mode 100644 index 0000000..4b0e91f --- /dev/null +++ b/reference/oshi-demo/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-demo + jar + + oshi-demo + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + ${project.parent.basedir} + 2.9.9.2 + + + + + ${project.groupId} + oshi-core + ${project.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + diff --git a/reference/oshi-dist/LICENSE_MIT b/reference/oshi-dist/LICENSE_MIT new file mode 100644 index 0000000..7500276 --- /dev/null +++ b/reference/oshi-dist/LICENSE_MIT @@ -0,0 +1,21 @@ +OSHI (https://github.com/oshi/oshi) + +Copyright (c) 2010 - 2019 The OSHI Project Team: +https://github.com/oshi/oshi/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/reference/oshi-dist/pom.xml b/reference/oshi-dist/pom.xml new file mode 100644 index 0000000..215b4d5 --- /dev/null +++ b/reference/oshi-dist/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-dist + pom + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + ${project.parent.basedir} + + + + + + ${project.groupId} + oshi-core + ${project.version} + + + ${project.groupId} + oshi-demo + ${project.version} + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + false + posix + + ${project.basedir}/src/assembly/assembly.xml + + + + + dist-assembly + package + + single + + + + + + + diff --git a/reference/oshi-dist/src/assembly/assembly.xml b/reference/oshi-dist/src/assembly/assembly.xml new file mode 100644 index 0000000..8b9e188 --- /dev/null +++ b/reference/oshi-dist/src/assembly/assembly.xml @@ -0,0 +1,76 @@ + + + + distribution + + tar.gz + tar.bz2 + zip + + + false + + + + false + true + lib + false + + ${project.groupId}:*:* + + + + + + + ${project.basedir}/LICENSE_MIT + + license.txt + + + + + + + true + + + com.github.oshi:oshi-core + com.github.oshi:oshi-demo + + + false + / + false + + + + diff --git a/reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml b/reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml new file mode 100644 index 0000000..9ca20b1 --- /dev/null +++ b/reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reference/oshi-dist/src/site/site.xml b/reference/oshi-dist/src/site/site.xml new file mode 100644 index 0000000..16a056a --- /dev/null +++ b/reference/oshi-dist/src/site/site.xml @@ -0,0 +1,52 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reference/pom.xml b/reference/pom.xml new file mode 100644 index 0000000..6a259f6 --- /dev/null +++ b/reference/pom.xml @@ -0,0 +1,1085 @@ + + + + 4.0.0 + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + pom + + Operating System and Hardware Information + A JNA-based (native) operating system information library for Java that aims to provide a cross-platform implementation to retrieve system information, such as version, memory, CPU, disk, battery, etc. + https://github.com/oshi/oshi + 2010 + + oshi + https://github.com/oshi/ + + + + MIT License + https://opensource.org/licenses/MIT + repo + + + + + + dblock + Daniel Doubrovkine + dblock@dblock.org + dblock.org + http://code.dblock.org/ + + + dbwiddis + Daniel Widdis + widdis@gmail.com + sometegroup.com + https://github.com/dbwiddis/ + + + + + oshi-core + oshi-core-shaded + oshi-demo + oshi-dist + + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + Github + https://github.com/oshi/oshi/issues + + + travis + https://travis-ci.org/oshi/oshi/ + + + + gh-pages + OSHI GitHub Pages + github:ssh://oshi.github.io/oshi/ + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + 2010 - 2019 + yyyy-MM-dd HH:mm:ss + 11 + 11 + 11 + 11 + 3.3.9 + UTF-8 + UTF-8 + UTF-8 + java18 + 1.0 + + ${project.basedir} + + 1.7.26 + 5.5.1 + + 3.1.0 + 3.8.1 + 3.0.0-M1 + 3.0.0-M2 + 1.6 + 3.0.0-M1 + 3.1.0 + 3.8.2 + 3.0.0-M3 + + 1.9 + 2.0.3 + 3.3.3 + 1.8 + + 3.0.0 + 3.0.0 + 3.1.2 + 3.2.3 + 4.2.0 + 3.2.1 + + 3.1.0 + 3.1.1 + 3.12.0 + + 1.8 + 3.1.1 + 3.1.1 + 2.5.3 + 3.1.0 + 3.1.12 + 0.8.4 + 4.3.0 + 2.3.1 + 1.1.0 + 3.0 + + 2.0 + 2.3 + 3.0.0 + 3.0.0 + 2.22.2 + 2.4 + 2.7 + + 1.11.2 + 1.11.2 + 1.1.6 + 0.1.55 + 5.4.0.201906121030-r + 3.2.1 + + 3.6.0.1398 + 2.0.0 + 1.18 + 5.2.1 + 8.23 + 1.0.0 + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-vintage-engine.version} + test + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + false + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin.version} + + + org.apache.maven.doxia + doxia-module-markdown + ${doxia-module-markdown.version} + + + net.trajano.wagon + wagon-git + ${wagon-git.version} + + + org.apache.maven.wagon + wagon-ssh + ${wagon-ssh.version} + + + org.apache.maven.skins + maven-fluido-skin + ${maven-fluido-skin.version} + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + 3 + true + -Xmx1024m -XX:MaxPermSize=256m + + + + + pl.project13.maven + git-commit-id-plugin + ${git-commit-id-plugin.version} + + + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper-maven-plugin.version} + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + true + true + + + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + true + true + + + ${buildNumber} + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + biz.aQute.bnd + bnd-maven-plugin + ${bnd-maven-plugin.version} + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + + true + true + + + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + org.apache.maven.plugins + maven-pmd-plugin + ${maven-pmd-plugin.version} + + + + org.apache.maven.plugins + maven-antrun-plugin + ${maven-antrun-plugin.version} + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven-dependency-plugin.version} + + + org.apache.maven.plugins + maven-release-plugin + ${maven-release-plugin.version} + + forked-path + false + -Prelease + true + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + + true + true + + + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + 2 + ${project.name} + ${project.groupId}.${project.artifactId}.source + ${project.organization.name} + ${parsedVersion.osgiVersion} + ${project.groupId}.${project.artifactId};version="${parsedVersion.osgiVersion}";roots:="." + + + + + + + + + + + com.github.spotbugs + spotbugs-maven-plugin + ${spotbugs-maven-plugin.version} + + + + com.github.spotbugs + spotbugs + ${spotbugs-maven-plugin.version} + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + org.eluder.coveralls + coveralls-maven-plugin + ${coveralls-maven-plugin.version} + + + org.codehaus.mojo + tidy-maven-plugin + ${tidy-maven-plugin.version} + + + com.mycila + license-maven-plugin + ${license-maven-plugin.version} + +
${main.basedir}/LICENSE_HEADER
+ + **/*test.*.txt + **/maven-wrapper.properties + **/MavenWrapperDownloader.java + mvnw + mvnw.cmd + LICENSE_* + **/OSHIJavaFormatConventions.xml + +
+
+ + + org.codehaus.mojo + jdepend-maven-plugin + ${jdepend-maven-plugin.version} + + + org.apache.maven.plugins + maven-changelog-plugin + ${maven-changelog-plugin.version} + + + org.apache.maven.plugins + maven-jxr-plugin + ${maven-jxr-plugin.version} + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${maven-project-info-reports-plugin.version} + + + org.apache.maven.plugins + maven-surefire-report-plugin + ${maven-surefire-report-plugin.version} + + + org.codehaus.mojo + taglist-maven-plugin + ${taglist-maven-plugin.version} + + + org.codehaus.mojo + versions-maven-plugin + ${versions-maven-plugin.version} + + + + org.apache.maven.plugins + maven-scm-plugin + ${maven-scm-plugin.version} + + + org.apache.maven.scm + maven-scm-provider-jgit + ${maven-scm-provider-jgit.version} + + + com.googlecode.javaewah + JavaEWAH + ${JavaEWAH.version} + + + com.jcraft + jsch + ${jsch.version} + + + org.eclipse.jgit + org.eclipse.jgit + ${jgit.version} + + + org.codehaus.plexus + plexus-utils + ${plexus-utils.version} + + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar-maven-plugin.version} + + + + org.codehaus.mojo + wagon-maven-plugin + ${wagon-maven-plugin.version} + + + org.codehaus.mojo + animal-sniffer-maven-plugin + ${animal-sniffer-maven-plugin.version} + + + org.codehaus.mojo.signature + ${signature.artifact} + ${signature.version} + + + + + org.owasp + dependency-check-maven + ${dependency-check-maven.version} + +
+
+ + + + pl.project13.maven + git-commit-id-plugin + + .git + + + true + + true + + + + git-commit-id + + revision + + validate + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + parse-version + + + + + + biz.aQute.bnd + bnd-maven-plugin + + + + bnd-process + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + ${maven.min-version} + + + + + + enforce-maven + + enforce + + + + enforce-clean + pre-clean + + enforce + + + + enforce-site + pre-site + + enforce + + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + + + test-sniffer + test + + check + + + + + + com.sun.management.OperatingSystemMXBean + + + + + com.mycila + license-maven-plugin + + + compile + + format + + + + + + org.jacoco + jacoco-maven-plugin + + + + pre-unit-test + + prepare-agent + + + surefireArgLine + + + + + post-unit-test + test + + report + + + + + + **/impl/** + **/common/** + **/Abstract*/** + **/platform/** + **/linux/** + **/mac/** + **/windows/** + **/unix/** + + + + + org.apache.maven.plugins + maven-surefire-plugin + + ${surefireArgLine} + + **/*Test.java + **/*Tests.java + + + + + run-unit-tests + + test + + + + + + org.eluder.coveralls + coveralls-maven-plugin + + + javax.xml.bind + jaxb-api + ${jaxb-api.version} + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.puppycrawl.tools + checkstyle + ${puppycrawl.checkstyle.version} + + + + + + + org.apache.maven.wagon + wagon-ssh + ${wagon-ssh.version} + + +
+ + + + + org.apache.maven.plugins + maven-changelog-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.github.spotbugs + spotbugs-maven-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + org.apache.maven.plugins + maven-jxr-plugin + + + org.apache.maven.plugins + maven-pmd-plugin + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + org.jacoco + jacoco-maven-plugin + + + org.codehaus.mojo + versions-maven-plugin + + + org.codehaus.mojo + taglist-maven-plugin + + + org.codehaus.mojo + jdepend-maven-plugin + + + org.owasp + dependency-check-maven + + + + aggregate + + + + + + + + + + checks + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + check + + + + + false + + + + org.apache.maven.plugins + maven-pmd-plugin + + + + check + cpd-check + + + + + false + true + + + + + org.jacoco + jacoco-maven-plugin + + + check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + ${jacoco.minimum.coverage} + + + + + + + + + + org.owasp + dependency-check-maven + + + + check + + + + + + + + + eclipse + + + m2e.version + + + + + + + + org.eclipse.m2e + lifecycle-mapping + ${m2e.lifecycle-mapping.version} + + + + + + com.mycila + license-maven-plugin + [3.0,) + + format + + + + + + + + + org.jacoco + jacoco-maven-plugin + [0.8.1,) + + prepare-agent + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + [3.0.0-M2,) + + enforce + + + + + + + + + + + + + + + + sort + + + + org.codehaus.mojo + tidy-maven-plugin + + + verify + + pom + + + + + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + attach-test-javadocs + + test-jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + +
\ No newline at end of file diff --git a/reference/src/site/markdown/README.md b/reference/src/site/markdown/README.md new file mode 100644 index 0000000..353f09f --- /dev/null +++ b/reference/src/site/markdown/README.md @@ -0,0 +1,223 @@ +![OSHI](https://dl.dropboxusercontent.com/s/c82qboyvvudpvdp/oshilogo.png) + +[![Maven central](https://maven-badges.herokuapp.com/maven-central/com.github.oshi/oshi-core/badge.svg?)](https://search.maven.org/search?q=com.github.oshi) +[![Build Status](https://travis-ci.org/oshi/oshi.svg)](https://travis-ci.org/oshi/oshi) +[![Coverage Status](https://coveralls.io/repos/github/oshi/oshi/badge.svg?branch=master)](https://coveralls.io/github/oshi/oshi?branch=master) +[![codecov.io](https://codecov.io/github/oshi/oshi/coverage.svg?branch=master)](https://codecov.io/github/oshi/oshi?branch=master) +[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/9332.svg)](https://scan.coverity.com/projects/dblock-oshi) +[![Codacy Grade](https://api.codacy.com/project/badge/Grade/5370178ae91d4f56b43de2f26f7c5e7a)](https://www.codacy.com/app/widdis/oshi?utm_source=github.com&utm_medium=referral&amp;utm_content=oshi/oshi&amp;utm_campaign=Badge_Grade) +[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![Join the chat at https://gitter.im/oshi/oshi](https://badges.gitter.im/oshi/oshi.svg)](https://gitter.im/oshi/oshi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![SonarQube Bugs](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=bugs)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Maintainability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Reliability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Security](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=security_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/oshi/oshi.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/oshi/oshi/context:java) +[![LGTM Stats](https://www.openhub.net/p/oshi/widgets/project_thin_badge.gif)](https://www.openhub.net/p/oshi?ref=github) +[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/) +[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/dbwiddis) + +OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java. +It doesn't require the installation of any additional native libraries and aims to provide a +cross-platform implementation to retrieve system information, such as OS version, processes, +memory & CPU usage, disks & partitions, devices, sensors, etc. + +Supported platforms +--------------------------- +Windows • Linux • Mac OS X • Unix (Solaris, FreeBSD) + +Essentials +---------- +* [API](http://oshi.github.io/oshi/apidocs/) +* [Find OSHI on Maven Central](https://search.maven.org/search?q=com.github.oshi) +* [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md) +* [Upgrading from an earlier version?](https://github.com/oshi/oshi/blob/master/UPGRADING.md) + +Supported features +-------------------------- +* Computer System and firmware, baseboard +* Operating System and Version/Build +* Physical (core) and Logical (hyperthreaded) CPUs +* System and per-processor load % and tick counters +* CPU uptime, processes, and threads +* Process uptime, cpu, memory usage +* Physical and virtual memory used/available +* Mounted filesystems (type, usable and total space) +* Disk drives (model, serial, size) and partitions +* Network interfaces (IPs, bandwidth in/out) +* Battery state (% capacity, time remaining) +* Connected displays (with EDID info) +* USB Devices +* Sensors (temperature, fan speeds, voltage) + +Downloads +--------- +| Stable Release Version | Current Development Version | Dependencies | +| ------------- | ------------- | ------------- | +| [oshi-core-3.13.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.github.oshi&a=oshi-core&v=3.13.0&e=jar) | [oshi-core-4.0.0-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.github.oshi&a=oshi-core&v=4.0.0-SNAPSHOT&e=jar) | [JNA](https://github.com/java-native-access/jna) • [SLF4J](http://www.slf4j.org/) | + +Output +------------- +OSHI provides output directly via java methods for each of its interfaces. +By periodically polling dynamic information (e.g., every second), users can calculate and track changes. + +The `main()` method of [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +provides sample code demonstrating the use of `oshi-core` interfaces to retrieve information and calculate additional metrics such as the below examples. + +General information about the operating system and computer system. +``` +Apple macOS 10.12.3 (Sierra) build 16D32 +manufacturer: Apple Inc. +model: MacBook Pro (MacBookPro8,2) +serialnumber: C02FG6XYDF71 +``` +Processor identification. +``` +Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz + 4 physical CPU(s) + 8 logical CPU(s) +Identifier: Intel64 Family 6 Model 42 Stepping 7 +ProcessorID: BFEBFBFF000206A7 +``` +By measuring ticks (user, nice, system, idle, iowait, and irq) between time intervals, percent usage can be calculated. +Java MXBean and per-processor information is also provided. +``` +CPU, IOWait, and IRQ ticks @ 0 sec:[967282, 15484, 195343, 124216619], 6176, [4054, 2702] +CPU, IOWait, and IRQ ticks @ 1 sec:[967308, 15484, 195346, 124216790], 6177, [4057, 2705] +User: 13.0% Nice: 0.0% System: 1.5% Idle: 85.5% +CPU load: 8.8% (counting ticks) +CPU load: 9.0% (OS MXBean) +CPU load averages: 2.69 2.47 2.38 +CPU load per processor: 23.6% 1.3% 18.2% 0.7% 12.9% 0.7% 12.1% 1.3% +``` +Process information including CPU and memory per process is available. +``` +Processes: 401, Threads: 1159 + PID %CPU %MEM VSZ RSS Name + 55977 27.9 0.2 6.8 GiB 34.3 MiB java + 51820 18.7 5.6 6.3 GiB 919.2 MiB eclipse + 39272 11.2 17.8 7.1 GiB 2.8 GiB prl_vm_app + 85316 6.5 2.9 5.6 GiB 471.4 MiB thunderbird + 35301 5.4 0.5 1.7 GiB 89.8 MiB Microsoft Excel + ``` +Memory and swapfile information is available. +``` +Memory: 2.9 GiB/16 GiB +Swap used: 90.8 MiB/1 GiB +``` +The EDID for each Display is provided. This can be parsed with various utilities for detailed information. OSHI provides a summary of selected data. +``` +Displays: + Display 0: + Manuf. ID=SAM, Product ID=2ad, Analog, Serial=HA19, ManufDate=3/2008, EDID v1.3 + 41 x 27 cm (16.1 x 10.6 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: H9FQ345476 + Display 1: + Manuf. ID=SAM, Product ID=226, Analog, Serial=HA19, ManufDate=4/2007, EDID v1.3 + 41 x 26 cm (16.1 x 10.2 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: HMCP431880 +``` +Disks and usage (reads, writes, transfer times) are shown, and partitions can be mapped to filesystems. +``` +Disks: + disk0: (model: SanDisk Ultra II 960GB - S/N: 161008800550) size: 960.2 GB, reads: 1053132 (23.0 GiB), writes: 243792 (11.1 GiB), xfer: 73424854 ms + |-- disk0s1: EFI (EFI System Partition) Maj:Min=1:1, size: 209.7 MB + |-- disk0s2: Macintosh HD (Macintosh SSD) Maj:Min=1:2, size: 959.3 GB @ / + disk1: (model: Disk Image - S/N: ) size: 960.0 GB, reads: 3678 (60.0 MiB), writes: 281 (8.6 MiB), xfer: 213627 ms + |-- disk1s1: EFI (EFI System Partition) Maj:Min=1:4, size: 209.7 MB + |-- disk1s2: Dropbox (disk image) Maj:Min=1:5, size: 959.7 GB @ /Volumes/Dropbox + +``` +Sensor readings are available for some hardware (see notes in the [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md)). +``` +Sensors: + CPU Temperature: 69.8°C + Fan Speeds:[4685, 4687] + CPU Voltage: 3.9V +``` +Attached USB devices can be listed: +``` +USB Devices: + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- IR Receiver (Apple Computer, Inc.) + |-- USB Receiver (Logitech) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- FaceTime HD Camera (Built-in) (Apple Inc.) [s/n: DJHB1V077FDH5HL0] + |-- IOUSBHostDevice + |-- Apple Internal Keyboard / Trackpad (Apple Inc.) + |-- BRCM2070 Hub (Apple Inc.) + |-- Bluetooth USB Host Controller (Apple Inc.) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- Apple Thunderbolt Display (Apple Inc.) [s/n: 162C0C25] + |-- Display Audio (Apple Inc.) [s/n: 162C0C25] + |-- FaceTime HD Camera (Display) (Apple Inc.) [s/n: CCGCAN000TDJ7DFX] + |-- USB2.0 Hub + |-- ANT USBStick2 (Dynastream Innovations) [s/n: 051] + |-- Fitbit Base Station (Fitbit Inc.) +``` + +You can run the [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +and see the full output for your system by cloning the project and building it with [Maven](http://maven.apache.org/index.html). + +``` +git clone https://github.com/oshi/oshi.git && cd oshi + +mvn test-compile -pl oshi-core -q exec:java \ + -Dexec.mainClass="oshi.SystemInfoTest" \ + -Dexec.classpathScope="test" +``` + +Where are we? +------------- +[OSHI originated](http://code.dblock.org/2010/06/23/introducing-oshi-operating-system-and-hardware-information-java.html) +as a platform-independent library that did not require additional software and had a license compatible with +both open source and commercial products. We've developed a strong core of features on major Operating Systems, +but we would love *you* to help by: +* Testing! Download and test the program on different software and hardware and help identify gaps that our limited development and testing may have missed. +* Contributing ports. Have an OS that's not covered? It's likely one of the existing ports can be slightly modified. +* Contributing code. See something that's not working right or could work better? Help us fix it! New contributors welcome. +* Documenting implementation. Our Wiki is blank. Want to help new users follow in your footsteps? +* Suggesting new features. Do you need OSHI to do something it doesn't currently do? Let us know. + +Acknowledgements +------------------- +Many thanks to the following companies for providing free support of Open Source projects including OSHI: +* [SonarCloud](https://sonarcloud.io/about) for a range of code quality tools +* [Travis CI](https://travis-ci.org/) for continuous integration testing +* The [jProfile Java Profiler](https://www.ej-technologies.com/products/jprofiler/overview.html) used to eliminate cpu bottlenecks + +Projects using OSHI +------------------- +* [CAS Server](https://apereo.github.io/cas) +* [JPPF](https://jppf.org/) +* [Apache Flink](https://flink.apache.org/) +* [DeepLearning4J](https://deeplearning4j.org/) +* [PSI Probe](https://github.com/psi-probe/psi-probe) +* [openHAB Systeminfo Binding](https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.systeminfo) +* [Semux](https://www.semux.org/) +* [Arthas](https://alibaba.github.io/arthas/en/) +* [Hawkular Agent](https://github.com/hawkular/hawkular-agent) +* [GeoServer](https://docs.geoserver.org/stable/en/user/community/status-monitoring/index.html) +* [UniversalMediaServer](https://github.com/UniversalMediaServer/UniversalMediaServer) +* [Dagr](https://github.com/fulcrumgenomics/dagr) +* [sys-API](https://github.com/Krillsson/sys-API) +* [NexCapMAT](http://www.nexess-solutions.com/fr/produits/application-nexcap-mat/) +* [360Suite](https://360suite.io/) +* [GoMint](https://gomint.io/) +* [Stefan's OS](https://BotCompany.de/) + +License +------- +This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/reference/src/site/site.xml b/reference/src/site/site.xml new file mode 100644 index 0000000..16a056a --- /dev/null +++ b/reference/src/site/site.xml @@ -0,0 +1,52 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + true + true + + + + + + + + + + + + + + \ No newline at end of file