├── .gitignore ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── docs ├── elastic.md ├── json.md ├── sql.md └── wavefront.md ├── pom.xml ├── samples ├── all-metrics.yaml ├── bm_ucs.yaml ├── diskspace.yaml ├── elasticsearch.yaml ├── grandparent.yaml ├── horizonview.yaml ├── json.yaml ├── latest-faster.yaml ├── latest.yaml ├── manymetrics.yaml ├── mssql-export.yaml ├── noheader.yaml ├── pg-export.yaml ├── simple.yaml ├── space-in-names.yaml ├── sqlexportbig.yaml ├── tags.yaml ├── vmfields.yaml ├── wavefront-direct.yaml └── wavefront.yaml ├── spotbugs-exclude.xml ├── src ├── .gitignore ├── assembly │ └── bin.xml ├── bin │ ├── exporttool.bat │ └── exporttool.sh ├── main │ ├── java │ │ └── com │ │ │ └── vmware │ │ │ └── vropsexport │ │ │ ├── CSVConfig.java │ │ │ ├── Client.java │ │ │ ├── Config.java │ │ │ ├── ConfigLoader.java │ │ │ ├── DataProvider.java │ │ │ ├── EpochDateFormat.java │ │ │ ├── Exporter.java │ │ │ ├── LRUCache.java │ │ │ ├── Main.java │ │ │ ├── NameSanitizer.java │ │ │ ├── Patterns.java │ │ │ ├── ProgressMonitor.java │ │ │ ├── ReplacingNameSanitizer.java │ │ │ ├── Row.java │ │ │ ├── RowMetadata.java │ │ │ ├── Rowset.java │ │ │ ├── RowsetProcessor.java │ │ │ ├── RowsetProcessorFacotry.java │ │ │ ├── SelfDeletingFileInputStream.java │ │ │ ├── StatsProcessor.java │ │ │ ├── Validatable.java │ │ │ ├── elasticsearch │ │ │ └── ElasticSearchConfig.java │ │ │ ├── exceptions │ │ │ ├── ExporterException.java │ │ │ └── ValidationException.java │ │ │ ├── json │ │ │ ├── JsonConfig.java │ │ │ └── JsonProducer.java │ │ │ ├── models │ │ │ ├── AdapterKind.java │ │ │ ├── AdapterKindResponse.java │ │ │ ├── AuthRequest.java │ │ │ ├── AuthResponse.java │ │ │ ├── MetricsRequest.java │ │ │ ├── NamedResource.java │ │ │ ├── PageInfo.java │ │ │ ├── PageOfResources.java │ │ │ ├── PropertiesResponse.java │ │ │ ├── ResourceKind.java │ │ │ ├── ResourceKindResponse.java │ │ │ ├── ResourceStatKeysResponse.java │ │ │ ├── StatKeysResponse.java │ │ │ └── TokenAuthResponse.java │ │ │ ├── opsql │ │ │ └── opsql.g4 │ │ │ ├── processors │ │ │ ├── CSVPrinter.java │ │ │ ├── ElasticSearchIndexer.java │ │ │ ├── JsonPrinter.java │ │ │ ├── ParentSplicer.java │ │ │ ├── SQLDumper.java │ │ │ └── WavefrontPusher.java │ │ │ ├── security │ │ │ ├── CertUtils.java │ │ │ ├── ExtendableTrustStrategy.java │ │ │ └── RecoverableCertificateException.java │ │ │ ├── sql │ │ │ ├── NamedParameterStatement.java │ │ │ └── SQLConfig.java │ │ │ └── wavefront │ │ │ └── WavefrontConfig.java │ └── resources │ │ ├── .gitignore │ │ ├── log4j.xml │ │ ├── logo-140px.png │ │ ├── logo-full-res.png │ │ └── logo.pptx └── test │ ├── java │ └── com │ │ └── vmware │ │ └── vropsexport │ │ ├── NameSanitizerTest.java │ │ └── StatsProcessorTest.java │ └── resources │ ├── chatty-all-output.json │ ├── chatty-all.yaml │ ├── chatty-output.json │ ├── chatty.yaml │ ├── compact-all-output.json │ ├── compact-all.yaml │ ├── compact-output.json │ ├── compact.yaml │ ├── csv-output.csv │ ├── elastic-all-output.json │ ├── elastic-all.yaml │ ├── elastic-output.json │ ├── elastic.yaml │ ├── hostprops.json │ ├── hostresource.json │ ├── hoststats.json │ ├── invalid.yaml │ ├── statkeys.json │ ├── vmfields.yaml │ ├── vmprops.json │ └── vmstats.json └── vrops-export.iml /.gitignore: -------------------------------------------------------------------------------- 1 | dependency-reduced-pom.xml 2 | target/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in [INSERT YOUR PROJECT NAME] project and our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at oss-coc@vmware.com. 63 | All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series 85 | of actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or 92 | permanent ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within 112 | the community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.0, available at 118 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 119 | 120 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 121 | enforcement ladder](https://github.com/mozilla/diversity). 122 | 123 | [homepage]: https://www.contributor-covenant.org 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | https://www.contributor-covenant.org/faq. Translations are available at 127 | https://www.contributor-covenant.org/translations. 128 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contributing to vrops-export 4 | 5 | The vrops-export project team welcomes contributions from the community. If you wish to contribute code and you have not 6 | signed our contributor license agreement (CLA), our bot will update the issue when you open a Pull Request. For any 7 | questions about the CLA process, please refer to our [FAQ](https://cla.vmware.com/faq). 8 | 9 | ## Community 10 | 11 | ## Getting Started 12 | 13 | ## Contribution Flow 14 | 15 | This is a rough outline of what a contributor's workflow looks like: 16 | 17 | - Create a topic branch from where you want to base your work 18 | - Make commits of logical units 19 | - Make sure your commit messages are in the proper format (see below) 20 | - Push your changes to a topic branch in your fork of the repository 21 | - Submit a pull request 22 | 23 | Example: 24 | 25 | ``` shell 26 | git remote add upstream https://github.com/vmware/vrops-export.git 27 | git checkout -b my-new-feature master 28 | git commit -a 29 | git push origin my-new-feature 30 | ``` 31 | 32 | ### Staying In Sync With Upstream 33 | 34 | When your branch gets out of sync with the vmware/master branch, use the following to update: 35 | 36 | ``` shell 37 | git checkout my-new-feature 38 | git fetch -a 39 | git pull --rebase upstream master 40 | git push --force-with-lease origin my-new-feature 41 | ``` 42 | 43 | ### Updating pull requests 44 | 45 | If your PR fails to pass CI or needs changes based on code review, you'll most likely want to squash these changes into 46 | existing commits. 47 | 48 | If your pull request contains a single commit or your changes are related to the most recent commit, you can simply 49 | amend the commit. 50 | 51 | ``` shell 52 | git add . 53 | git commit --amend 54 | git push --force-with-lease origin my-new-feature 55 | ``` 56 | 57 | If you need to squash changes into an earlier commit, you can use: 58 | 59 | ``` shell 60 | git add . 61 | git commit --fixup 62 | git rebase -i --autosquash master 63 | git push --force-with-lease origin my-new-feature 64 | ``` 65 | 66 | Be sure to add a comment to the PR indicating your new changes are ready to review, as GitHub does not generate a 67 | notification when you git push. 68 | 69 | ### Code Style 70 | 71 | ### Formatting Commit Messages 72 | 73 | We follow the conventions on [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/). 74 | 75 | Be sure to include any related GitHub issue references in the commit message. See 76 | [GFM syntax](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) for referencing issues 77 | and commits. 78 | 79 | ## Reporting Bugs and Creating Issues 80 | 81 | When opening a new issue, try to roughly follow the commit message format conventions above. 82 | 83 | ## Repository Structure 84 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/vrops-export/e75f0c1b5593708e2680700e2e49c08ca8aced1d/LICENSE -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | vRealize Operations Export Tool 2 | 3 | Copyright 2017-2021 VMware, Inc. All Rights Reserved. 4 | 5 | This product is licensed to you under the Apache 2.0 license (the "License"). You may not use this product except in compliance with the Apache 2.0 License. 6 | 7 | This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. 8 | 9 | -------------------------------------------------------------------------------- /docs/elastic.md: -------------------------------------------------------------------------------- 1 | # ElasticSearch 2 | 3 | The ElasticSearch plugin allows you to feed vRealize Operations metrics directly into an ElasticSearch cluster. Data is 4 | formatted into a simple key-value JSON document that's easy to index with ElasticSearch. 5 | 6 | ## Configuration 7 | 8 | ElasticSearch is enabled by specifying the ElasticSearch output format. In addition, the ```elasticSearchConfig``` 9 | sub-configuration has to contain at least the URL and the index. 10 | 11 | ```yaml 12 | resourceType: VMWARE:VirtualMachine 13 | rollupType: AVG 14 | rollupMinutes: 5 15 | outputFormat: elasticsearch 16 | dateFormat: "yyyy/MM/dd HH:mm:ss" 17 | elasticSearchConfig: 18 | urls: 19 | - https://elastic.something:9200 20 | index: vrops 21 | bulkSize: 10 22 | apiKey: "ABCDEF12345" 23 | # type: vm # Deprecated 24 | allMetrics: true 25 | ``` 26 | 27 | ### Authentication 28 | 29 | Currently, we only support ApiKey authentication and no authentication. To add authentication, simply add 30 | an ```apiKey``` entry to the ElasticSearch sub-configuration. 31 | 32 | ### Date format 33 | 34 | The date format specified in the specification file is obeyed for ElasticSearch exports. ElasticSearch supports a wide 35 | range of date formats, but the "yyyy/MM/dd HH:mm:ss" is the default and allows ElasticSearch to automatically map date 36 | fields to native timestamps that can be used for time-series analysis. 37 | 38 | ### Bulk size 39 | 40 | Indexing requests are sent in bulk for maximum performance. The bulk size is configurable through the 41 | ```bulkSize``` setting. The default is 10, which is rather conservative. Keep in mind that specifying a very large bulk 42 | size can lead to failures and timeout, so use this setting with caution! 43 | 44 | ### Types 45 | 46 | The "type" feature of ElasticSearch has been deprecated as of version 7 and completely removed in version 8. While 47 | the ```type``` is available as a configuration setting, it is not recommended that you use it. 48 | 49 | ## Request Throttling 50 | 51 | When an ElasticSearch cluster becomes overloaded, it may reject indexing requests as part of a throttling mechanism. 52 | When this happens, the plugin resorts to an exponentially growing wait algorithm until the throttling is lifted. 53 | Throttling severely impacts performance, so make sure you configure the number of working threads in the vRealize 54 | Operations Export Tool to a reasonable number that will avoid overloading the cluster. 55 | -------------------------------------------------------------------------------- /docs/json.md: -------------------------------------------------------------------------------- 1 | # JSON output format 2 | 3 | ## Sample definition file 4 | 5 | ```yaml 6 | resourceType: VMWARE:VirtualMachine 7 | rollupType: AVG 8 | rollupMinutes: 5 9 | outputFormat: json 10 | dateFormat: "yyyy-MM-dd HH:mm:ss" 11 | jsonConfig: 12 | format: elastic 13 | fields: 14 | - alias: resourceId 15 | prop: $resId 16 | # CPU fields 17 | - alias: cpuDemand 18 | metric: cpu|demandPct 19 | - alias: cpuReady 20 | metric: cpu|readyPct 21 | - alias: cpuCostop 22 | metric: cpu|costopPct 23 | # Memory fields 24 | - alias: memDemand 25 | metric: mem|guest_demand 26 | - alias: memSwapOut 27 | metric: mem|swapoutRate_average 28 | - alias: memSwapIn 29 | metric: mem|swapinRate_average 30 | ``` 31 | 32 | ## Formats 33 | 34 | When exporting to JSON, the format can be specified using the ```jsonConfig``` section. Currently, the only valid option 35 | is ```format``` which selects the formatting of the JSON output. The following formats are available: 36 | 37 | #### compact 38 | 39 | The most compact format. One record per resource, one sub-record per metric and a list of samples. 40 | 41 | ```json 42 | { 43 | "resources": [ 44 | { 45 | "metrics": [ 46 | { 47 | "name": "virtualDisk:scsi0:1|totalReadLatency_average", 48 | "samples": [ 49 | { 50 | "t": 1616713319999, 51 | "v": 0.7333333492279053 52 | }, 53 | { 54 | "t": 1616713619999, 55 | "v": 2.066666603088379 56 | }, 57 | { 58 | "t": 1616713919999, 59 | "v": 0.6000000238418579 60 | }, 61 | { 62 | "t": 1616714219999, 63 | "v": 1.0714285373687744 64 | }, 65 | { 66 | "t": 1616714519999, 67 | "v": 0.5333333611488342 68 | }, 69 | { 70 | "t": 1616714819999, 71 | "v": 1.3333333730697632 72 | }, 73 | { 74 | "t": 1616715119999, 75 | "v": 0.8666666746139526 76 | }, 77 | { 78 | "t": 1616715419999, 79 | "v": 0.2666666805744171 80 | }, 81 | { 82 | "t": 1616715719999, 83 | "v": 0.46666666865348816 84 | }, 85 | { 86 | "t": 1616716019999, 87 | "v": 0.6000000238418579 88 | }, 89 | { 90 | "t": 1616716319999, 91 | "v": 0.3333333432674408 92 | }, 93 | { 94 | "t": 1616716619999, 95 | "v": 0.6000000238418579 96 | } 97 | ] 98 | }, 99 | ... 100 | ``` 101 | 102 | #### chatty 103 | 104 | A more verbose format that's useful for some application. Each sample is emitted as a record containing resource name, 105 | timestamp, metric name and value. 106 | 107 | ```json 108 | { 109 | "data": [ 110 | { 111 | "metric": "virtualDisk:scsi0:1|totalReadLatency_average", 112 | "resourceName": "vrops-02", 113 | "t": 1616678999999, 114 | "v": 0.3333333432674408 115 | }, 116 | { 117 | "metric": "virtualDisk:Aggregate of all instances|commandsAveraged_average", 118 | "resourceName": "vrops-02", 119 | "t": 1616678999999, 120 | "v": 11.466666221618652 121 | }, 122 | ... 123 | ``` 124 | 125 | ### elastic 126 | 127 | This format is optimized for ElasticSearch. Each record represents a timestamp and a resource with the metrics emitted 128 | as a key-value pair. 129 | 130 | ```json 131 | { 132 | "data": [ 133 | { 134 | "timestamp": 1616682479999, 135 | "resourceName": "vrops-02", 136 | "OnlineCapacityAnalytics|capacityRemainingPercentage": 0.0, 137 | "OnlineCapacityAnalytics|cpu|capacityRemaining": 3138.409912109375, 138 | "OnlineCapacityAnalytics|cpu|recommendedSize": 1899.99853515625, 139 | "OnlineCapacityAnalytics|cpu|timeRemaining": 366.0, 140 | "OnlineCapacityAnalytics|diskspace|capacityRemaining": 222.54217529296875, 141 | "OnlineCapacityAnalytics|diskspace|recommendedSize": 130.2505340576172, 142 | "OnlineCapacityAnalytics|diskspace|timeRemaining": 366.0, 143 | "OnlineCapacityAnalytics|mem|capacityRemaining": 0.0, 144 | "OnlineCapacityAnalytics|mem|recommendedSize": 8546993.0, 145 | "OnlineCapacityAnalytics|mem|timeRemaining": 0.0, 146 | "OnlineCapacityAnalytics|timeRemaining": 0.0, 147 | "System Attributes|alert_count_critical": 0.0, 148 | "System Attributes|alert_count_immediate": 0.0, 149 | "System Attributes|alert_count_info": 0.0, 150 | ... 151 | ``` 152 | -------------------------------------------------------------------------------- /docs/sql.md: -------------------------------------------------------------------------------- 1 | # Using the SQL export option 2 | As of version 2.0, there is an option to export the data to a SQL database rather than a CSV file. For this reason, we have added a few new settings to the configuration file. 3 | 4 | ## Configuration file settings 5 | These are the new configuration file settings: 6 | * outputFormat - Must be set to "sql" for SQL export. 7 | * connectionString - A JDBC connection string. The format depends on the database vendor. 8 | * username - An optional database username. 9 | * password - An optional database password. 10 | * databaseType - Type of database. Currently supports postgres, mysql, mssql and oracle. Additional databases can be supported by using the driver option. Note that "driver" and "databaseType" are mutually exclusive. 11 | * driver - The class name of the JDBC driver. Use this setting, along with the JDBC_JAR environment variable to export to a database type that's not included in the choices for "databaseType". 12 | * sql - The SQL statement to use for inserting data into the database. See below for a full description. 13 | 14 | ## Specifying the SQL statement 15 | The data is inserted into the database using a user-specified SQL statement (typically an INSERT statement). Variable substitution is done using the metric or property alias preceded by a colon. For example: 16 | 17 | ``` 18 | sql = "INSERT INTO metrics(timestamp, resname, resId, cpuDemand, memDemand, hostCpuDemand) VALUES (:timestamp, :resName, :resId, :cpuDemand, :memDemand, :hostCPUDemand) ON CONFLICT DO NOTHING" 19 | . 20 | . 21 | . 22 | # Resource ID 23 | - alias: resId 24 | prop: $resId 25 | # CPU fields 26 | - alias: cpuDemand 27 | metric: cpu|demandPct 28 | # Memory fields 29 | - alias: memDemand 30 | metric: mem|guest_demand 31 | # Host CPU 32 | - alias: hostCPUDemand 33 | metric: $parent:HostSystem.cpu|demandmhz 34 | ``` 35 | Notice how the names in the VALUES clause map to the aliases in the list of fields. The fields "timestamp" and "resName" are always available by default. If you need the resource id, you can define that as a property field mapped to the internal property $resId as shown above. You typically want to use some kind of "upsert" semantics if your database supports it. In the example above, we're using the "ON CONFLICT DO NOTHING" option available in PostgreSQL. 36 | 37 | ## Configuring JDBC drivers 38 | The pre-built binaries come with JDBC drivers for PostgreSQL and MySQL. Due to licensing issues, you will have to download the JDBC drivers for any other datbase separately. When using a non-bundled database, you need to specify the location of the JDBC jar file in the JDBC_JAR environment variable. For example, to use a MS SQL database driver you haev previously downloaded, simply type: 39 | 40 | ``` 41 | $ export JDBC_JAR=~/tmp/sqljdbc42.jar 42 | $ ./exporttool.sh -u demouser -p demopassword -H https://10.140.46.21 -i -d ../samples/sqlexport.yaml 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /docs/wavefront.md: -------------------------------------------------------------------------------- 1 | # Wavefront integration 2 | 3 | The Wavefront output plugin allows vRealize Operations to be exported to Wavefront by VMware. 4 | 5 | The usage is very simple: All metrics exported become metrics in Wavefront and any properties become tags in Wavefront. Take care when exporting properties, since the Wavefront tags become part of the unique identity of an object. Thus, if you export a property that changes frequently, you will create multiple objects, which is probably not what you want. 6 | 7 | It is highly recommended to use the "align" directive to round to the nearest five minutes. Otherwise, overlapping export of the same time range may show up as multiple data points. 8 | 9 | The export can run in two different modes: Direct ingest, were data is sent directly to the Wavefront servers in the cloud or proxy ingest, where data is sent to a local proxy before being transmitted to Wavefront. 10 | 11 | Here is an example of a simple definition file for direct ingest: 12 | 13 | resourceType: VirtualMachine 14 | rollupType: AVG 15 | rollupMinutes: 5 16 | align: 300 17 | outputFormat: wavefront 18 | wavefrontConfig: 19 | wavefrontURL: "https://try.wavefront.com" 20 | token: "some-secret-stuff" 21 | dateFormat: "yyyy-MM-dd HH:mm:ss" 22 | fields: 23 | # CPU fields 24 | - alias: vrops.cpu.demand 25 | metric: cpu|demandPct 26 | - alias: vrops.cpu.ready 27 | metric: cpu|readyPct 28 | - alias: vrops.cpu.costop 29 | metric: cpu|costopPct 30 | # Memory fields 31 | - alias: vrops.mem.demand 32 | metric: mem|guest_demand 33 | - alias: vrops.mem.swapOut 34 | metric: mem|swapoutRate_average 35 | - alias: vrops.mem.swapIn 36 | metric: mem|swapinRate_average 37 | # Storage fields 38 | - alias: vrops.storage.demandKbps 39 | metric: storage|demandKBps 40 | # Network fields 41 | - alias: vrops.net.bytesRx 42 | metric: net|bytesRx_average 43 | - alias: vrops.net.bytesTx 44 | metric: net|bytesTx_average 45 | # Host CPU 46 | - alias: vrops.host.cpu.demand 47 | metric: $parent:HostSystem.cpu|demandmhz 48 | # Host name 49 | - alias: esxiHost 50 | prop: summary|parentHost 51 | 52 | Another example, this time featuring proxy-based ingest: 53 | 54 | ``` 55 | resourceType: VirtualMachine 56 | rollupType: AVG 57 | rollupMinutes: 5 58 | align: 300 59 | outputFormat: wavefront 60 | wavefrontConfig: 61 | proxyHost: localhost 62 | proxyPort: 2878 63 | dateFormat: "yyyy-MM-dd HH:mm:ss" 64 | fields: 65 | # CPU fields 66 | - alias: vrops.cpu.demand 67 | metric: cpu|demandPct 68 | - alias: vrops.cpu.ready 69 | metric: cpu|readyPct 70 | - alias: vrops.cpu.costop 71 | metric: cpu|costopPct 72 | # Memory fields 73 | - alias: vrops.mem.demand 74 | metric: mem|guest_demand 75 | - alias: vrops.mem.swapOut 76 | metric: mem|swapoutRate_average 77 | - alias: vrops.mem.swapIn 78 | metric: mem|swapinRate_average 79 | # Storage fields 80 | - alias: vrops.storage.demandKbps 81 | metric: storage|demandKBps 82 | # Network fields 83 | - alias: vrops.net.bytesRx 84 | metric: net|bytesRx_average 85 | - alias: vrops.net.bytesTx 86 | metric: net|bytesTx_average 87 | # Host CPU 88 | - alias: vrops.host.cpu.demand 89 | metric: $parent:HostSystem.cpu|demandmhz 90 | # Host name 91 | - alias: esxiHost 92 | prop: summary|parentHost 93 | ``` 94 | 95 | -------------------------------------------------------------------------------- /samples/all-metrics.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | outputFormat: json 21 | dateFormat: "yyyy-MM-dd HH:mm:ss" 22 | allMetrics: true 23 | jsonConfig: 24 | format: elastic 25 | -------------------------------------------------------------------------------- /samples/bm_ucs.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # Using the BlueMedora UCS plugin and navigate from a VM to the chassis it's 18 | # it's running on. 19 | # 20 | resourceType: VMWARE:VirtualMachine 21 | rollupType: AVG 22 | rollupMinutes: 5 23 | dateFormat: "yyyy-MM-dd HH:mm:ss" 24 | fields: 25 | - alias: cpuDemand 26 | metric: cpu|demandPct 27 | - alias: hostCpu 28 | metric: $parent:HostSystem.cpu|demandmhz 29 | - alias: bladeMemorySpeed 30 | metric: $parent:HostSystem.$parent:bm_ucs_blade.compute_blade|memorySpeed 31 | - alias: bladeName 32 | prop: $parent:HostSystem.$parent:bm_ucs_blade.$resName 33 | - alias: chassisPower 34 | metric: $parent:HostSystem.$parent:bm_ucs_blade.$parent:bm_ucs_chassis.equipment_chassis|powerState 35 | - alias: chassisName 36 | prop: $parent:HostSystem.$parent:bm_ucs_blade.$parent:bm_ucs_chassis.$resName 37 | 38 | -------------------------------------------------------------------------------- /samples/diskspace.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 1440 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | fields: 22 | # Diskspace fields 23 | - alias: vmUsed 24 | metric: diskspace|used 25 | - alias: iops 26 | metric: virtualDisk:Aggregate of all instances|commandsAveraged_average 27 | - alias: latency 28 | metric: virtualDisk:Aggregate of all instances|totalLatency 29 | - alias: THROUGHPUT_KBPS_AVG 30 | metric: virtualDisk:Aggregate of all instances|usage 31 | - alias: OUTSTANDING_IO_REQUESTS_AVG 32 | metric: virtualDisk:Aggregate of all instances|vDiskOIO 33 | - alias: TRANSMITTED_PACKETS_DROPPED_AVG 34 | metric: net|droppedTx_summation 35 | # Host name 36 | - alias: hostName 37 | prop: summary|parentHost 38 | -------------------------------------------------------------------------------- /samples/elasticsearch.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | outputFormat: elasticsearch 21 | dateFormat: "yyyy/MM/dd HH:mm:ss" 22 | elasticSearchConfig: 23 | urls: 24 | - https://elastic.something 25 | index: vrops 26 | type: vm 27 | # allMetrics: true 28 | fields: 29 | - alias: resourceId 30 | prop: $resId 31 | # CPU fields 32 | - alias: cpuDemand 33 | metric: cpu|demandPct 34 | - alias: cpuReady 35 | metric: cpu|readyPct 36 | - alias: cpuCostop 37 | metric: cpu|costopPct 38 | # Memory fields 39 | - alias: memDemand 40 | metric: mem|guest_demand 41 | - alias: memSwapOut 42 | metric: mem|swapoutRate_average 43 | - alias: memSwapIn 44 | metric: mem|swapinRate_average 45 | # Storage fields 46 | - alias: storageDemandKbps 47 | metric: storage|demandKBps 48 | # Diskspace fields 49 | - alias: vmUsed 50 | metric: diskspace|used 51 | # Network fields 52 | - alias: netBytesRx 53 | metric: net|bytesRx_average 54 | - alias: netBytesTx 55 | metric: net|bytesTx_average 56 | # Host CPU 57 | - alias: hostCPUDemand 58 | metric: $parent:HostSystem.cpu|demandmhz 59 | # Guest OS 60 | - alias: guestOS 61 | prop: config|guestFullName 62 | # Host CPU type 63 | - alias: hostCPUType 64 | prop: $parent:HostSystem.cpu|cpuModel 65 | # Host name 66 | - alias: hostName 67 | prop: summary|parentHost 68 | # Host name a different way 69 | - alias: hostName2 70 | prop: $parent:HostSystem.$resName 71 | -------------------------------------------------------------------------------- /samples/grandparent.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | fields: 22 | # CPU fields 23 | - alias: cpuDemand 24 | metric: cpu|demandPct 25 | - alias: cpuReady 26 | metric: cpu|readyPct 27 | - alias: cpuCostop 28 | metric: cpu|costopPct 29 | # Memory fields 30 | - alias: memDemand 31 | metric: mem|guest_demand 32 | - alias: memSwapOut 33 | metric: mem|swapoutRate_average 34 | - alias: memSwapIn 35 | metric: mem|swapinRate_average 36 | # Storage fields 37 | - alias: storageDemandKbps 38 | metric: storage|demandKBps 39 | # Network fields 40 | - alias: netBytesRx 41 | metric: net|bytesRx_average 42 | - alias: netBytesTx 43 | metric: net|bytesTx_average 44 | # Host CPU 45 | - alias: hostCPUDemand 46 | metric: $parent:HostSystem.cpu|demandmhz 47 | # Guest OS 48 | - alias: guestOS 49 | prop: config|guestFullName 50 | # Host CPU type 51 | - alias: hostCPUType 52 | prop: $parent:HostSystem.cpu|cpuModel 53 | # Host name (parent) 54 | - alias: hostName 55 | prop: summary|parentHost 56 | # Host name a different way 57 | - alias: hostName2 58 | prop: $parent:HostSystem.$resName 59 | # Cluster Name (grandparent) 60 | - alias: clusterCPU 61 | prop: $parent:HostSystem.$parent:ClusterComputeResource.$resName 62 | # Cluster CPU 63 | - alias: clusterCPU 64 | metric: $parent:HostSystem.$parent:ClusterComputeResource.cpu|demandmhz 65 | # Datacenter cpu (great grandparent) 66 | - alias: dcCpu 67 | metric: $parent:HostSystem.$parent:ClusterComputeResource.$parent:Datacenter.cpu|demandPct 68 | # Datacenter name 69 | - alias: dcName 70 | prop: $parent:HostSystem.$parent:ClusterComputeResource.$parent:Datacenter.$resName 71 | -------------------------------------------------------------------------------- /samples/horizonview.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: HorizonAdapter:User 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | outputFormat: csv 21 | dateFormat: "yyyy-MM-dd HH:mm:ss" 22 | 23 | fields: 24 | - alias: connectedTime 25 | metric: connectedTime 26 | -------------------------------------------------------------------------------- /samples/json.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | outputFormat: json 21 | dateFormat: "yyyy-MM-dd HH:mm:ss" 22 | jsonConfig: 23 | format: elastic 24 | fields: 25 | - alias: resourceId 26 | prop: $resId 27 | # CPU fields 28 | - alias: cpuDemand 29 | metric: cpu|demandPct 30 | - alias: cpuReady 31 | metric: cpu|readyPct 32 | - alias: cpuCostop 33 | metric: cpu|costopPct 34 | # Memory fields 35 | - alias: memDemand 36 | metric: mem|guest_demand 37 | - alias: memSwapOut 38 | metric: mem|swapoutRate_average 39 | - alias: memSwapIn 40 | metric: mem|swapinRate_average 41 | # Storage fields 42 | - alias: storageDemandKbps 43 | metric: storage|demandKBps 44 | # Diskspace fields 45 | - alias: vmUsed 46 | metric: diskspace|used 47 | # Network fields 48 | - alias: netBytesRx 49 | metric: net|bytesRx_average 50 | - alias: netBytesTx 51 | metric: net|bytesTx_average 52 | # Host CPU 53 | - alias: hostCPUDemand 54 | metric: $parent:HostSystem.cpu|demandmhz 55 | # Guest OS 56 | - alias: guestOS 57 | prop: config|guestFullName 58 | # Host CPU type 59 | - alias: hostCPUType 60 | prop: $parent:HostSystem.cpu|cpuModel 61 | # Host name 62 | - alias: hostName 63 | prop: summary|parentHost 64 | # Host name a different way 65 | - alias: hostName2 66 | prop: $parent:HostSystem.$resName -------------------------------------------------------------------------------- /samples/latest-faster.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | compact: true 21 | outputFormat: csv 22 | dateFormat: "yyyy-MM-dd HH:mm:ss" 23 | fields: 24 | - alias: resourceId 25 | prop: $resId 26 | # CPU fields 27 | - alias: cpuDemand 28 | metric: cpu|demandPct 29 | 30 | -------------------------------------------------------------------------------- /samples/latest.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: LATEST 19 | rollupMinutes: 5 20 | compact: true 21 | outputFormat: csv 22 | dateFormat: "yyyy-MM-dd HH:mm:ss" 23 | fields: 24 | - alias: resourceId 25 | prop: $resId 26 | # CPU fields 27 | - alias: cpuDemand 28 | metric: cpu|demandPct 29 | 30 | -------------------------------------------------------------------------------- /samples/manymetrics.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: LATEST 19 | #rollupMinutes: 5 20 | compact: true 21 | dateFormat: "yyyy-MM-dd HH:mm:ssZ" 22 | fields: 23 | - alias: CPU_Util_Resources|CPU_Active_1min_avg 24 | metric: rescpu|actav1_latest 25 | - alias: CPU|Contention 26 | metric: cpu|capacity_contentionPct 27 | - alias: CPU|Demand_mhz 28 | metric: cpu|demandmhz 29 | - alias: CPU|Demand_pct 30 | metric: cpu|demandPct 31 | - alias: CPU|Eftv_limit 32 | metric: cpu|effective_limit 33 | - alias: CPU|IOWait_pct 34 | metric: cpu|iowaitPct 35 | - alias: CPU|Overlap 36 | metric: cpu|overlap_summation 37 | - alias: CPU|Provisioned_vCPU 38 | metric: cpu|corecount_provisioned 39 | - alias: CPU|Ready_pct 40 | metric: cpu|readyPct 41 | - alias: CPU|Run 42 | metric: cpu|run_summation 43 | - alias: CPU|Total_pvsnd 44 | metric: cpu|vm_capacity_provisioned 45 | - alias: CPU|Usage_avg 46 | metric: cpu|usage_average 47 | - alias: CPU|Use_mhzavg 48 | metric: cpu|usagemhz_average 49 | - alias: CPU|Used 50 | metric: cpu|used_summation 51 | - alias: CPU|Workload 52 | metric: cpu|workload 53 | - alias: Configuration|Hardware|Disk_Space 54 | metric: config|hardware|disk_Space 55 | - alias: Configuration|Hardware|Number_CPUs 56 | metric: config|hardware|num_Cpu 57 | - alias: Datastore|Outstanding_IO_reqs 58 | metric: datastore|demand_oio 59 | - alias: Datastore|Read_IOPS 60 | metric: datastore|numberReadAveraged_average 61 | - alias: Datastore|Read_Throughput 62 | metric: datastore|read_average 63 | - alias: Datastore|Write_IOPS 64 | metric: datastore|numberWriteAveraged_average 65 | - alias: Datastore|Write_Throughput 66 | metric: datastore|write_average 67 | - alias: DiskSpace|VM_used 68 | metric: diskspace|used 69 | - alias: Disk_Space|Active_not_shared 70 | metric: diskspace|activeNotShared 71 | - alias: Disk_Space|Not_Shared 72 | metric: diskspace|notshared 73 | - alias: Guest_FS|Total_Capacity 74 | metric: guestfilesystem|capacity_total 75 | - alias: Guest_FS|Utlztn_pctttl 76 | metric: guestfilesystem|percentage_total 77 | - alias: Guest_FS|Utlztn_ttl 78 | metric: guestfilesystem|usage_total 79 | - alias: Memory|Consumed_pct 80 | metric: mem|consumedPct 81 | - alias: Memory|Guest Demand 82 | metric: mem|guest_demand 83 | - alias: Memory|Guest Usage 84 | metric: mem|guest_usage 85 | - alias: Memory|Host_Demand 86 | metric: mem|host_demand 87 | - alias: Memory|SwapOut_Rate 88 | metric: mem|swapoutRate_average 89 | - alias: Memory|Swap_In_Rate 90 | metric: mem|swapinRate_average 91 | - alias: Memory|Swapped 92 | metric: mem|swapped_average 93 | - alias: Memory|Total_pvsnd 94 | metric: mem|guest_provisioned 95 | - alias: Memory|Usage 96 | metric: mem|usage_average 97 | - alias: Memory|Utilization 98 | metric: mem|vmMemoryDemand 99 | - alias: Network|Broadcast_Transm 100 | metric: net|broadcastTx_summation 101 | - alias: Network|Data_Rec_Rate 102 | metric: net|received_average 103 | - alias: Network|Data_Trans_Rate 104 | metric: net|transmitted_average 105 | - alias: Network|Multicast_Pkts_Transmitted 106 | metric: net|multicastTx_summation 107 | - alias: Network|Trans_Packets_Dropped 108 | metric: net|droppedTx_summation 109 | - alias: Network|Usage_Rate 110 | metric: net|usage_average 111 | - alias: Phys_Disk|Read_Throughput 112 | metric: disk|read_average 113 | - alias: Phys_Disk|Write_Throughput 114 | metric: disk|write_average 115 | - alias: Physical_Disk|Total_Throughput 116 | metric: disk|usage_average 117 | - alias: Storage|Read_Latency 118 | metric: storage|totalReadLatency_average 119 | - alias: Storage|Write_Latency 120 | metric: storage|totalWriteLatency_average 121 | - alias: Summary|Number_Datastores 122 | metric: summary|number_datastore 123 | - alias: Summary|Running 124 | metric: summary|running 125 | - alias: System|OS_Uptime 126 | metric: sys|osUptime_latest 127 | - alias: System|Powered_ON 128 | metric: sys|poweredOn 129 | - alias: Virtual Disk|Write Throughput 130 | metric: virtualDisk|write_average 131 | - alias: Virtual_Disk|Read_Throughput 132 | metric: virtualDisk|read_average -------------------------------------------------------------------------------- /samples/mssql-export.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | outputFormat: sql 22 | sqlConfig: 23 | sql: "INSERT INTO metrics(timestamp, resname, resId, cpuDemand, memDemand, hostCpuDemand) VALUES (:timestamp, :resName, :resId, :cpuDemand, :memDemand, :hostCPUDemand)" 24 | connectionString: jdbc:sqlserver://hostname:1433 25 | username: user 26 | password: "secret" 27 | databaseType: mssql 28 | fields: 29 | # Resource ID 30 | - alias: resId 31 | prop: $resId 32 | # CPU fields 33 | - alias: cpuDemand 34 | metric: cpu|demandPct 35 | # Memory fields 36 | - alias: memDemand 37 | metric: mem|guest_demand 38 | # Host CPU 39 | - alias: hostCPUDemand 40 | metric: $parent:HostSystem.cpu|demandmhz 41 | -------------------------------------------------------------------------------- /samples/noheader.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | outputFormat: csv 21 | dateFormat: "yyyy-MM-dd HH:mm:ss" 22 | csvConfig: 23 | header: false 24 | delimiter: ";" 25 | fields: 26 | - alias: resourceId 27 | prop: $resId 28 | # CPU fields 29 | - alias: cpuDemand 30 | metric: cpu|demandPct 31 | 32 | -------------------------------------------------------------------------------- /samples/pg-export.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | outputFormat: sql 22 | sqlConfig: 23 | sql: "INSERT INTO metrics(timestamp, resname, resId, cpuDemand, memDemand, hostCpuDemand) VALUES (:timestamp, :resName, :resId, :cpuDemand, :memDemand, :hostCPUDemand) ON CONFLICT DO NOTHING" 24 | connectionString: jdbc:postgresql:prydin 25 | databaseType: postgres 26 | fields: 27 | # Resource ID 28 | - alias: resId 29 | prop: $resId 30 | # CPU fields 31 | - alias: cpuDemand 32 | metric: cpu|demandPct 33 | # Memory fields 34 | - alias: memDemand 35 | metric: mem|guest_demand 36 | # Host CPU 37 | - alias: hostCPUDemand 38 | metric: $parent:HostSystem.cpu|demandmhz 39 | 40 | -------------------------------------------------------------------------------- /samples/simple.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | outputFormat: csv 21 | dateFormat: "yyyy-MM-dd HH:mm:ss" 22 | fields: 23 | - alias: resourceId 24 | prop: $resId 25 | # CPU fields 26 | - alias: cpuDemand 27 | metric: cpu|demandPct 28 | 29 | -------------------------------------------------------------------------------- /samples/space-in-names.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: "vCenter Operations Adapter:vC-Ops-Analytics" 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | fields: 22 | - alias: PrimaryResourcesCount 23 | metric: PrimaryResourcesCount -------------------------------------------------------------------------------- /samples/sqlexportbig.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | outputFormat: sql 22 | sqlConfig: 23 | sql: "INSERT INTO metrics(timestamp, resname, resId, cpuDemand, memDemand, hostCpuDemand) VALUES (:timestamp, :resName, :resId, :cpuDemand, :memDemand, :hostCPUDemand) ON CONFLICT DO NOTHING" 24 | connectionString: jdbc:postgresql:prydin 25 | databaseType: postgres 26 | fields: 27 | # Resource ID 28 | - alias: resId 29 | prop: $resId 30 | # CPU fields 31 | - alias: cpuDemand 32 | metric: cpu|demandPct 33 | - alias: cpuReady 34 | metric: cpu|readyPct 35 | - alias: cpuCostop 36 | metric: cpu|costopPct 37 | # Memory fields 38 | - alias: memDemand 39 | metric: mem|guest_demand 40 | - alias: memSwapOut 41 | metric: mem|swapoutRate_average 42 | - alias: memSwapIn 43 | metric: mem|swapinRate_average 44 | # Storage fields 45 | - alias: storageDemandKbps 46 | metric: storage|demandKBps 47 | # Network fields 48 | - alias: netBytesRx 49 | metric: net|bytesRx_average 50 | - alias: netBytesTx 51 | metric: net|bytesTx_average 52 | # Host CPU 53 | - alias: hostCPUDemand 54 | metric: $parent:HostSystem.cpu|demandmhz 55 | # Guest OS 56 | - alias: guestOS 57 | prop: config|guestFullName 58 | # Host CPU type 59 | - alias: hostCPUType 60 | prop: $parent:HostSystem.cpu|cpuModel 61 | -------------------------------------------------------------------------------- /samples/tags.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 1440 # 24 hours 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | fields: 22 | # CPU fields 23 | - alias: cpuDemand 24 | metric: cpu|demandPct 25 | # Memory fields 26 | - alias: memDemand 27 | metric: mem|guest_demand 28 | # Diskspace fields 29 | - alias: vmUsed 30 | metric: diskspace|used 31 | # Daily price 32 | - alias: dailyPrice 33 | metric: summary|metering|value 34 | # Guest OS 35 | - alias: guestOS 36 | prop: config|guestFullName 37 | # Host name 38 | - alias: hostName 39 | prop: summary|parentHost 40 | # Cost center tag 41 | - alias: costcenter 42 | tag: costcenter 43 | # Cost center tag 44 | - alias: owner 45 | tag: owner 46 | 47 | 48 | -------------------------------------------------------------------------------- /samples/vmfields.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | dateFormat: "yyyy-MM-dd HH:mm:ss" 21 | fields: 22 | # CPU fields 23 | - alias: cpuDemand 24 | metric: cpu|demandPct 25 | - alias: cpuReady 26 | metric: cpu|readyPct 27 | - alias: cpuCostop 28 | metric: cpu|costopPct 29 | # Memory fields 30 | - alias: memDemand 31 | metric: mem|guest_demand 32 | - alias: memSwapOut 33 | metric: mem|swapoutRate_average 34 | - alias: memSwapIn 35 | metric: mem|swapinRate_average 36 | # Storage fields 37 | - alias: storageDemandKbps 38 | metric: storage|demandKBps 39 | # Diskspace fields 40 | - alias: vmUsed 41 | metric: diskspace|used 42 | # Network fields 43 | - alias: netBytesRx 44 | metric: net|bytesRx_average 45 | - alias: netBytesTx 46 | metric: net|bytesTx_average 47 | # Host CPU 48 | - alias: hostCPUDemand 49 | metric: $parent:HostSystem.cpu|demandmhz 50 | # Guest OS 51 | - alias: guestOS 52 | prop: config|guestFullName 53 | # Host CPU type 54 | - alias: hostCPUType 55 | prop: $parent:HostSystem.cpu|cpuModel 56 | # Host name 57 | - alias: hostName 58 | prop: summary|parentHost 59 | # Host name a different way 60 | - alias: hostName2 61 | prop: $parent:HostSystem.$resName 62 | 63 | -------------------------------------------------------------------------------- /samples/wavefront-direct.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | align: 300 21 | outputFormat: wavefront 22 | wavefrontConfig: 23 | wavefrontURL: "https://try.wavefront.com" 24 | token: "your token" 25 | dateFormat: "yyyy-MM-dd HH:mm:ss" 26 | fields: 27 | # CPU fields 28 | - alias: vrops.cpu.demand 29 | metric: cpu|demandPct 30 | - alias: vrops.cpu.ready 31 | metric: cpu|readyPct 32 | - alias: vrops.cpu.costop 33 | metric: cpu|costopPct 34 | # Memory fields 35 | - alias: vrops.mem.demand 36 | metric: mem|guest_demand 37 | - alias: vrops.mem.swapOut 38 | metric: mem|swapoutRate_average 39 | - alias: vrops.mem.swapIn 40 | metric: mem|swapinRate_average 41 | # Storage fields 42 | - alias: vrops.storage.demandKbps 43 | metric: storage|demandKBps 44 | # Network fields 45 | - alias: vrops.net.bytesRx 46 | metric: net|bytesRx_average 47 | - alias: vrops.net.bytesTx 48 | metric: net|bytesTx_average 49 | # Host CPU 50 | - alias: vrops.host.cpu.demand 51 | metric: $parent:HostSystem.cpu|demandmhz 52 | # Host name 53 | - alias: esxiHost 54 | prop: summary|parentHost 55 | -------------------------------------------------------------------------------- /samples/wavefront.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | resourceType: VMWARE:VirtualMachine 18 | rollupType: AVG 19 | rollupMinutes: 5 20 | align: 300 21 | outputFormat: wavefront 22 | wavefrontConfig: 23 | proxyHost: localhost 24 | proxyPort: 2878 25 | dateFormat: "yyyy-MM-dd HH:mm:ss" 26 | fields: 27 | # CPU fields 28 | - alias: vrops.cpu.demand 29 | metric: cpu|demandPct 30 | - alias: vrops.cpu.ready 31 | metric: cpu|readyPct 32 | - alias: vrops.cpu.costop 33 | metric: cpu|costopPct 34 | # Memory fields 35 | - alias: vrops.mem.demand 36 | metric: mem|guest_demand 37 | - alias: vrops.mem.swapOut 38 | metric: mem|swapoutRate_average 39 | - alias: vrops.mem.swapIn 40 | metric: mem|swapinRate_average 41 | # Storage fields 42 | - alias: vrops.storage.demandKbps 43 | metric: storage|demandKBps 44 | # Network fields 45 | - alias: vrops.net.bytesRx 46 | metric: net|bytesRx_average 47 | - alias: vrops.net.bytesTx 48 | metric: net|bytesTx_average 49 | # Host CPU 50 | - alias: vrops.host.cpu.demand 51 | metric: $parent:HostSystem.cpu|demandmhz 52 | # Host name 53 | - alias: esxiHost 54 | prop: summary|parentHost 55 | -------------------------------------------------------------------------------- /spotbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | RV_RETURN_VALUE_IGNORED_BAD_PRACTICE 20 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/vrops-export/e75f0c1b5593708e2680700e2e49c08ca8aced1d/src/.gitignore -------------------------------------------------------------------------------- /src/assembly/bin.xml: -------------------------------------------------------------------------------- 1 | 4 | bin 5 | 6 | zip 7 | 8 | 9 | 10 | ${project.basedir} 11 | 12 | README* 13 | LICENSE* 14 | NOTICE* 15 | resources/log4j.xml 16 | 17 | 18 | 19 | ${project.build.directory} 20 | bin 21 | 22 | *.jar 23 | *.sh 24 | *.yaml 25 | *.bat 26 | 27 | 28 | 29 | ${project.build.directory} 30 | 31 | samples/*.yaml 32 | 33 | 34 | 35 | ${project.build.directory}/site 36 | docs 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/bin/exporttool.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | REM 4 | REM SPDX-License-Identifier: Apache-2.0 5 | REM 6 | REM Licensed under the Apache License, Version 2.0 (the "License"); 7 | REM you may not use this file except in compliance with the License. 8 | REM You may obtain a copy of the License at 9 | REM 10 | REM http://www.apache.org/licenses/LICENSE-2.0 11 | REM 12 | REM Unless required by applicable law or agreed to in writing, software 13 | REM distributed under the License is distributed on an "AS IS" BASIS, 14 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | REM See the License for the specific language governing permissions and 16 | REM limitations under the License. 17 | 18 | SET DIR=%~dp0 19 | SET VERSION=${project.version} 20 | SET JAVA=java 21 | IF [%JAVA_HOME%] == [] GOTO :NO_JAVA_HOME 22 | SET JAVA="%JAVA_HOME%\bin\java" 23 | :NO_JAVA_HOME 24 | SET CP=%DIR%\vrops-export-%VERSION%.jar 25 | IF [%JDBC_JAR%] == [] GOTO :NO_JDBC_JAR 26 | SET CP=%CP%;%JDBC_JAR% 27 | :NO_JDBC_JAR 28 | JAVA -cp %CP% com.vmware.vropsexport.Main %* 29 | -------------------------------------------------------------------------------- /src/bin/exporttool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 19 | VERSION=${project.version} 20 | if [ -z "$JAVA_HOME" ] 21 | then 22 | JAVA=java 23 | else 24 | JAVA="$JAVA_HOME/bin/java" 25 | fi 26 | CP=$DIR/vrops-export-$VERSION.jar 27 | if [ -n "$JDBC_JAR" ] 28 | then 29 | CP=$CP:$JDBC_JAR 30 | fi 31 | $JAVA -cp $CP com.vmware.vropsexport.Main "$@" 32 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/CSVConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | @SuppressWarnings("unused") 21 | public class CSVConfig { 22 | private boolean header = true; 23 | 24 | private String delimiter = ","; 25 | 26 | public boolean isHeader() { 27 | return header; 28 | } 29 | 30 | public void setHeader(final boolean header) { 31 | this.header = header; 32 | } 33 | 34 | public String getDelimiter() { 35 | return delimiter; 36 | } 37 | 38 | public void setDelimiter(final String delimiter) { 39 | this.delimiter = delimiter; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/ConfigLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import com.vmware.vropsexport.exceptions.ValidationException; 21 | import java.io.Reader; 22 | 23 | import org.yaml.snakeyaml.LoaderOptions; 24 | import org.yaml.snakeyaml.Yaml; 25 | import org.yaml.snakeyaml.constructor.Constructor; 26 | 27 | public class ConfigLoader { 28 | public static Config parse(final Reader rdr) throws ValidationException { 29 | final Yaml yaml = new Yaml(new Constructor(Config.class, new LoaderOptions())); 30 | final Config conf = yaml.load(rdr); 31 | if (conf.getOutputFormat() == null) { 32 | conf.setOutputFormat("csv"); 33 | } 34 | conf.validate(); 35 | return conf; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/DataProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import com.vmware.vropsexport.models.NamedResource; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.util.List; 24 | import java.util.Map; 25 | import org.apache.http.HttpException; 26 | 27 | public interface DataProvider { 28 | Map fetchProps(String id) throws IOException, HttpException; 29 | 30 | NamedResource getParentOf(String id, String parentType) throws IOException, HttpException; 31 | 32 | InputStream fetchMetricStream(NamedResource[] resList, RowMetadata meta, long begin, long end) 33 | throws IOException, HttpException; 34 | 35 | String getResourceName(String resourceId) throws IOException, HttpException; 36 | 37 | List getStatKeysForResource(final String resourceId) throws IOException, HttpException; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/EpochDateFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import java.text.DateFormat; 21 | import java.text.FieldPosition; 22 | import java.text.ParsePosition; 23 | import java.util.Date; 24 | 25 | public class EpochDateFormat extends DateFormat { 26 | private static final long serialVersionUID = 5610899332126331037L; 27 | 28 | @Override 29 | public StringBuffer format( 30 | final Date date, final StringBuffer toAppendTo, final FieldPosition fieldPosition) { 31 | return toAppendTo.append(date.getTime()); 32 | } 33 | 34 | @Override 35 | public Date parse(final String source, final ParsePosition pos) { 36 | throw new UnsupportedOperationException("Parsing is not supported"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/LRUCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import java.util.LinkedHashMap; 21 | import java.util.Map; 22 | 23 | public class LRUCache extends LinkedHashMap { 24 | private static final long serialVersionUID = 1689404735863505762L; 25 | private final int cacheSize; 26 | 27 | public LRUCache(final int cacheSize) { 28 | super(cacheSize, 0.75F, true); 29 | this.cacheSize = cacheSize; 30 | } 31 | 32 | @Override 33 | protected boolean removeEldestEntry(final Map.Entry eldest) { 34 | return size() >= cacheSize; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/NameSanitizer.java: -------------------------------------------------------------------------------- 1 | package com.vmware.vropsexport; 2 | 3 | public interface NameSanitizer { 4 | String transform(final String s); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/Patterns.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import java.util.regex.Pattern; 21 | 22 | public class Patterns { 23 | 24 | public static final Pattern parentPattern = 25 | Pattern.compile("^\\$parent:([_A-Za-z][_A-Za-z0-9\\s]*)\\.(.+)$"); 26 | 27 | public static final Pattern parentSpecPattern = 28 | Pattern.compile("^([_\\-A-Za-z][_\\-A-Za-z0-9\\s]*):(.+)$"); 29 | 30 | public static final Pattern adapterAndResourceKindPattern = 31 | Pattern.compile("^([_\\-A-Za-z][_\\-A-Za-z0-9\\s]*):(.+)$"); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/ProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | public interface ProgressMonitor { 21 | void reportProgress(int n); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/ReplacingNameSanitizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | public class ReplacingNameSanitizer implements NameSanitizer { 21 | private final boolean[] flags; 22 | 23 | private final char replacement; 24 | 25 | private final int min; 26 | 27 | private final int max; 28 | 29 | public ReplacingNameSanitizer(final String forbidden, final char replacement) { 30 | this.replacement = replacement; 31 | max = forbidden.chars().max().orElse(0); 32 | min = forbidden.chars().min().orElse(0); 33 | flags = new boolean[max - min + 1]; 34 | forbidden.chars().forEach(c -> flags[c - min] = true); 35 | } 36 | 37 | @Override 38 | public String transform(final String s) { 39 | StringBuilder sb = null; 40 | for (int i = 0; i < s.length(); ++i) { 41 | final char c = s.charAt(i); 42 | if (c >= min && c <= max && flags[c - min]) { 43 | if (sb == null) { 44 | sb = new StringBuilder(s.substring(0, i)); 45 | } 46 | sb.append(replacement); 47 | } else { 48 | if (sb != null) { 49 | sb.append(c); 50 | } 51 | } 52 | } 53 | return sb != null ? sb.toString() : s; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/Row.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import java.util.BitSet; 21 | import java.util.NoSuchElementException; 22 | 23 | @SuppressWarnings("WeakerAccess") 24 | public class Row { 25 | private final long timestamp; 26 | 27 | private final BitSet definedMetrics; 28 | 29 | private final double[] metrics; 30 | 31 | private final String[] props; 32 | 33 | public Row(final long timestamp, final int nMetrics, final int nProps) { 34 | super(); 35 | this.timestamp = timestamp; 36 | metrics = new double[nMetrics]; 37 | props = new String[nProps]; 38 | definedMetrics = new BitSet(nMetrics); 39 | } 40 | 41 | public long getTimestamp() { 42 | return timestamp; 43 | } 44 | 45 | public Double getMetric(final int i) { 46 | return definedMetrics.get(i) ? metrics[i] : null; 47 | } 48 | 49 | public String getProp(final int i) { 50 | return props[i]; 51 | } 52 | 53 | public void setMetric(final int i, final double m) { 54 | metrics[i] = m; 55 | definedMetrics.set(i); 56 | } 57 | 58 | public void setProp(final int i, final String prop) { 59 | props[i] = prop; 60 | } 61 | 62 | public java.util.Iterator iterator(final RowMetadata meta) { 63 | return new Iterator(meta); 64 | } 65 | 66 | public int getNumProps() { 67 | return props.length; 68 | } 69 | 70 | public int getNumMetrics() { 71 | return metrics.length; 72 | } 73 | 74 | private class Iterator implements java.util.Iterator { 75 | private int mc; 76 | 77 | private int pc; 78 | 79 | private final RowMetadata meta; 80 | 81 | public Iterator(final RowMetadata meta) { 82 | this.meta = meta; 83 | } 84 | 85 | @Override 86 | public boolean hasNext() { 87 | return pc < props.length || mc < metrics.length; 88 | } 89 | 90 | @Override 91 | public Object next() { 92 | if (!hasNext()) { 93 | throw new NoSuchElementException(); 94 | } 95 | if (pc < props.length && meta.getPropInsertionPoints()[pc] == mc) { 96 | return getProp(pc++); 97 | } 98 | return getMetric(mc++); 99 | } 100 | } 101 | 102 | public void merge(final Row r) { 103 | // Merge metrics 104 | // 105 | for (int i = 0; i < r.getNumMetrics(); ++i) { 106 | final Double d = r.getMetric(i); 107 | if (d != null) { 108 | setMetric(i, d); // Don't be tempted to just set metrics[i]! Won't update the bitmap. 109 | } 110 | } 111 | 112 | // Merge properties 113 | // 114 | for (int i = 0; i < r.getNumProps(); ++i) { 115 | final String p = r.getProp(i); 116 | if (p != null) { 117 | props[i] = p; 118 | } 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/RowMetadata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import com.vmware.vropsexport.exceptions.ExporterException; 21 | import java.util.ArrayList; 22 | import java.util.HashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | import java.util.regex.Matcher; 26 | 27 | public class RowMetadata { 28 | private final String resourceKind; 29 | 30 | private final String adapterKind; 31 | 32 | private final Map metricMap = new HashMap<>(); 33 | 34 | private final Map propMap = new HashMap<>(); 35 | 36 | private final Map propNameToAlias = new HashMap<>(); 37 | 38 | private final Map metricAliasMap = new HashMap<>(); 39 | 40 | private final Map metricNameToAlias = new HashMap<>(); 41 | 42 | private final Map propAliasMap = new HashMap<>(); 43 | 44 | private final int[] propInsertionPoints; 45 | 46 | public RowMetadata(final Config conf, final List metricNames) throws ExporterException { 47 | resourceKind = conf.getResourceKind(); 48 | adapterKind = conf.getAdapterKind(); 49 | final NameSanitizer ns = conf.createNameSanitizer(); 50 | int mp = 0; 51 | for (final String metricName : metricNames) { 52 | metricMap.put(metricName, mp); 53 | metricAliasMap.put(metricName, mp++); 54 | metricNameToAlias.put(metricName, ns.transform(metricName)); 55 | } 56 | propInsertionPoints = new int[0]; 57 | } 58 | 59 | public RowMetadata(final Config conf) throws ExporterException { 60 | resourceKind = conf.getResourceKind(); 61 | adapterKind = conf.getAdapterKind(); 62 | int mp = 0; 63 | int pp = 0; 64 | final List pip = new ArrayList<>(); 65 | for (final Config.Field fld : conf.getFields()) { 66 | if (fld.hasMetric()) { 67 | final String metricKey = fld.getMetric(); 68 | if (metricMap.containsKey(metricKey)) { 69 | throw new ExporterException( 70 | "Repeated metrics are not supported. Offending metric: " + metricKey); 71 | } 72 | metricMap.put(metricKey, mp); 73 | metricAliasMap.put(fld.getAlias(), mp++); 74 | metricNameToAlias.put(fld.getMetric(), fld.getAlias()); 75 | } else { 76 | if (fld.hasProp()) { 77 | final String propKey = fld.getProp(); 78 | if (metricMap.containsKey(propKey)) { 79 | throw new ExporterException( 80 | "Repeated properties are not supported. Offending property: " + propKey); 81 | } 82 | propMap.put(fld.getProp(), pp); 83 | propAliasMap.put(fld.getAlias(), pp++); 84 | propNameToAlias.put(fld.getProp(), fld.getAlias()); 85 | pip.add(mp); 86 | } 87 | } 88 | } 89 | propInsertionPoints = new int[pip.size()]; 90 | for (int i = 0; i < pip.size(); ++i) { 91 | propInsertionPoints[i] = pip.get(i); 92 | } 93 | } 94 | 95 | private RowMetadata(final RowMetadata child) throws ExporterException { 96 | propInsertionPoints = child.propInsertionPoints; 97 | String t = null; 98 | for (final Map.Entry e : child.propMap.entrySet()) { 99 | final String p = e.getKey(); 100 | final Matcher m = Patterns.parentPattern.matcher(p); 101 | if (m.matches()) { 102 | if (t == null) { 103 | t = m.group(1); 104 | } else if (!t.equals(m.group(1))) { 105 | throw new ExporterException("Only one parent type is currently supported"); 106 | } 107 | propMap.put(m.group(2), e.getValue()); 108 | } else { 109 | propMap.put("_placeholder_" + p, e.getValue()); 110 | } 111 | } 112 | for (final Map.Entry e : child.metricMap.entrySet()) { 113 | final String mt = e.getKey(); 114 | final Matcher m = Patterns.parentPattern.matcher(mt); 115 | if (m.matches()) { 116 | if (t == null) { 117 | t = m.group(1); 118 | } else if (!t.equals(m.group(1))) { 119 | throw new ExporterException("Only one parent type is currently supported"); 120 | } 121 | metricMap.put(m.group(2), e.getValue()); 122 | } else { 123 | metricMap.put("_placholder_" + mt, e.getValue()); 124 | } 125 | } 126 | resourceKind = t; 127 | adapterKind = null; // TODO: It should be possible to specify adapter type as well! 128 | } 129 | 130 | public RowMetadata forParent() throws ExporterException { 131 | return new RowMetadata(this); 132 | } 133 | 134 | public Map getMetricMap() { 135 | return metricMap; 136 | } 137 | 138 | public Map getPropMap() { 139 | return propMap; 140 | } 141 | 142 | public int[] getPropInsertionPoints() { 143 | return propInsertionPoints; 144 | } 145 | 146 | public int getMetricIndex(final String metric) { 147 | return metricMap.getOrDefault(metric, -1); 148 | } 149 | 150 | public int getPropertyIndex(final String property) { 151 | return propMap.getOrDefault(property, -1); 152 | } 153 | 154 | public int getTagIndex(final String tag) { 155 | return getPropertyIndex(Config.Field.TAG_PROP_PREFIX + tag); 156 | } 157 | 158 | public int getMetricIndexByAlias(final String metric) { 159 | return metricAliasMap.getOrDefault(metric, -1); 160 | } 161 | 162 | public int getPropertyIndexByAlias(final String property) { 163 | return propAliasMap.getOrDefault(property, -1); 164 | } 165 | 166 | public String getAliasForProp(final String name) { 167 | return propNameToAlias.get(name); 168 | } 169 | 170 | public String getAliasForMetric(final String name) { 171 | return metricNameToAlias.get(name); 172 | } 173 | 174 | public Row newRow(final long timestamp) { 175 | return new Row(timestamp, metricMap.size(), propMap.size()); 176 | } 177 | 178 | public String getResourceKind() { 179 | return resourceKind; 180 | } 181 | 182 | public String getAdapterKind() { 183 | return adapterKind; 184 | } 185 | 186 | public boolean hasProperties() { 187 | return propMap.size() > 0; 188 | } 189 | 190 | public boolean needsPropertyLoad() { 191 | if (!hasProperties()) { 192 | return false; 193 | } 194 | for (final String key : propMap.keySet()) { 195 | if (!(key.equals("$resId") || key.equals("$resName"))) { 196 | return true; 197 | } 198 | } 199 | return false; 200 | } 201 | 202 | public boolean isValid() { 203 | return resourceKind != null; 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/Rowset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import java.util.TreeMap; 21 | 22 | public class Rowset { 23 | private final String resourceId; 24 | 25 | private final TreeMap rows; 26 | 27 | public Rowset(final String resourceId, final TreeMap rows) { 28 | super(); 29 | this.resourceId = resourceId; 30 | this.rows = rows; 31 | } 32 | 33 | public String getResourceId() { 34 | return resourceId; 35 | } 36 | 37 | public TreeMap getRows() { 38 | return rows; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/RowsetProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import com.vmware.vropsexport.exceptions.ExporterException; 21 | 22 | public interface RowsetProcessor { 23 | void preamble(RowMetadata meta, Config conf) throws ExporterException; 24 | 25 | void process(Rowset rowset, RowMetadata meta) throws ExporterException; 26 | 27 | void close() throws ExporterException; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/RowsetProcessorFacotry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import com.vmware.vropsexport.exceptions.ExporterException; 21 | import java.io.OutputStream; 22 | 23 | public interface RowsetProcessorFacotry { 24 | RowsetProcessor makeFromConfig(OutputStream out, Config config, DataProvider dp) 25 | throws ExporterException; 26 | 27 | boolean isProducingOutput(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/SelfDeletingFileInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import java.io.File; 21 | import java.io.FileDescriptor; 22 | import java.io.FileInputStream; 23 | import java.io.FileNotFoundException; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.nio.channels.FileChannel; 27 | 28 | public class SelfDeletingFileInputStream extends InputStream { 29 | 30 | private final FileInputStream backer; 31 | 32 | private final File file; 33 | 34 | public SelfDeletingFileInputStream(final String filename) throws FileNotFoundException { 35 | file = new File(filename); 36 | backer = new FileInputStream(file); 37 | } 38 | 39 | public SelfDeletingFileInputStream(final File file) throws FileNotFoundException { 40 | this.file = file; 41 | backer = new FileInputStream(this.file); 42 | } 43 | 44 | @Override 45 | public int read() throws IOException { 46 | return backer.read(); 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | return backer.hashCode(); 52 | } 53 | 54 | @Override 55 | public boolean equals(final Object obj) { 56 | return obj == this; 57 | } 58 | 59 | @Override 60 | public int read(final byte[] b) throws IOException { 61 | return backer.read(b); 62 | } 63 | 64 | @Override 65 | public int read(final byte[] b, final int off, final int len) throws IOException { 66 | return backer.read(b, off, len); 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return backer.toString(); 72 | } 73 | 74 | @Override 75 | public long skip(final long n) throws IOException { 76 | return backer.skip(n); 77 | } 78 | 79 | @Override 80 | public int available() throws IOException { 81 | return backer.available(); 82 | } 83 | 84 | @Override 85 | public void mark(final int readlimit) { 86 | backer.mark(readlimit); 87 | } 88 | 89 | @Override 90 | public void close() throws IOException { 91 | backer.close(); 92 | file.delete(); 93 | } 94 | 95 | public final FileDescriptor getFD() throws IOException { 96 | return backer.getFD(); 97 | } 98 | 99 | public FileChannel getChannel() { 100 | return backer.getChannel(); 101 | } 102 | 103 | @Override 104 | public void reset() throws IOException { 105 | backer.reset(); 106 | } 107 | 108 | @Override 109 | public boolean markSupported() { 110 | return backer.markSupported(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/Validatable.java: -------------------------------------------------------------------------------- 1 | package com.vmware.vropsexport; 2 | 3 | import com.vmware.vropsexport.exceptions.ValidationException; 4 | 5 | public interface Validatable { 6 | void validate() throws ValidationException; 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/elasticsearch/ElasticSearchConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.elasticsearch; 19 | 20 | import com.vmware.vropsexport.Validatable; 21 | import com.vmware.vropsexport.exceptions.ValidationException; 22 | import java.util.List; 23 | 24 | public class ElasticSearchConfig implements Validatable { 25 | private List urls; 26 | 27 | private String index; 28 | 29 | private String type; 30 | 31 | private int bulkSize = 10; 32 | 33 | private String apiKey; 34 | 35 | private String username; 36 | 37 | private String password; 38 | 39 | public int getBulkSize() { 40 | return bulkSize; 41 | } 42 | 43 | public void setBulkSize(final int bulkSize) { 44 | this.bulkSize = bulkSize; 45 | } 46 | 47 | public String getApiKey() { 48 | return apiKey; 49 | } 50 | 51 | public void setApiKey(final String apiKey) { 52 | this.apiKey = apiKey; 53 | } 54 | 55 | public List getUrls() { 56 | return urls; 57 | } 58 | 59 | public void setUrls(final List urls) { 60 | this.urls = urls; 61 | } 62 | 63 | public String getIndex() { 64 | return index; 65 | } 66 | 67 | public void setIndex(final String index) { 68 | this.index = index; 69 | } 70 | 71 | public String getType() { 72 | return type; 73 | } 74 | 75 | public void setType(final String type) { 76 | this.type = type; 77 | } 78 | 79 | public String getUsername() { 80 | return username; 81 | } 82 | 83 | public void setUsername(final String username) { 84 | this.username = username; 85 | } 86 | 87 | public String getPassword() { 88 | return password; 89 | } 90 | 91 | public void setPassword(final String password) { 92 | this.password = password; 93 | } 94 | 95 | @Override 96 | public void validate() throws ValidationException { 97 | if (urls == null || urls.size() == 0) { 98 | throw new ValidationException("ElasticSearch URL must be specified"); 99 | } 100 | if (index == null) { 101 | throw new ValidationException("ElasticSearch index must be specified"); 102 | } 103 | if (bulkSize <= 0) { 104 | throw new ValidationException("Bulksize must be greater than zero"); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/exceptions/ExporterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.exceptions; 19 | 20 | public class ExporterException extends Exception { 21 | 22 | private static final long serialVersionUID = -5847302957038136704L; 23 | 24 | public ExporterException(final String message, final Throwable cause) { 25 | super(message, cause); 26 | } 27 | 28 | public ExporterException(final String message) { 29 | super(message); 30 | } 31 | 32 | public ExporterException(final Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/exceptions/ValidationException.java: -------------------------------------------------------------------------------- 1 | package com.vmware.vropsexport.exceptions; 2 | 3 | public class ValidationException extends Exception { 4 | private static final long serialVersionUID = -1701704085247220998L; 5 | 6 | public ValidationException(final String message) { 7 | super(message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/json/JsonConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.json; 19 | 20 | public class JsonConfig { 21 | public enum JsonFormat { 22 | chatty, 23 | compact, 24 | elastic, 25 | } 26 | 27 | private JsonFormat format = JsonFormat.compact; 28 | 29 | public JsonFormat getFormat() { 30 | return format; 31 | } 32 | 33 | public void setFormat(final JsonFormat format) { 34 | this.format = format; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/json/JsonProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.json; 19 | 20 | import com.fasterxml.jackson.core.JsonGenerator; 21 | import com.vmware.vropsexport.DataProvider; 22 | import com.vmware.vropsexport.Row; 23 | import com.vmware.vropsexport.RowMetadata; 24 | import com.vmware.vropsexport.Rowset; 25 | import com.vmware.vropsexport.exceptions.ExporterException; 26 | import java.io.IOException; 27 | import java.text.DateFormat; 28 | import java.util.Date; 29 | import java.util.Map; 30 | import org.apache.http.HttpException; 31 | 32 | public class JsonProducer { 33 | private final JsonGenerator generator; 34 | 35 | private final DataProvider dp; 36 | 37 | private final DateFormat dateFormat; 38 | 39 | public JsonProducer( 40 | final JsonGenerator generator, final DataProvider dp, final DateFormat dateFormat) { 41 | this.generator = generator; 42 | this.dp = dp; 43 | this.dateFormat = dateFormat; 44 | } 45 | 46 | public void produce( 47 | final Rowset rowset, final RowMetadata meta, final JsonConfig.JsonFormat format) 48 | throws ExporterException { 49 | synchronized (generator) { 50 | try { 51 | switch (format) { 52 | case compact: 53 | produceCompact(rowset, meta); 54 | break; 55 | case chatty: 56 | produceChatty(rowset, meta); 57 | break; 58 | case elastic: 59 | produceElastic(rowset, meta); 60 | break; 61 | } 62 | } catch (final IOException | HttpException e) { 63 | throw new ExporterException(e); 64 | } 65 | } 66 | } 67 | 68 | public void produceCompact(final Rowset rowset, final RowMetadata meta) 69 | throws IOException, HttpException { 70 | generator.writeStartObject(); // { 71 | generator.writeStringField("resourceName", dp.getResourceName(rowset.getResourceId())); 72 | 73 | // Properties 74 | if (!rowset.getRows().isEmpty()) { 75 | final Row firstRow = rowset.getRows().firstEntry().getValue(); 76 | generator.writeArrayFieldStart("properties"); 77 | for (final String propertyName : meta.getPropMap().keySet()) { 78 | final int propIndex = meta.getPropertyIndex(propertyName); 79 | final String v = firstRow.getProp(propIndex); 80 | if (v == null) { 81 | continue; 82 | } 83 | generator.writeStartObject(); 84 | generator.writeStringField("k", meta.getAliasForProp(propertyName)); 85 | generator.writeStringField("v", v); 86 | generator.writeEndObject(); 87 | } 88 | generator.writeEndArray(); 89 | } 90 | 91 | // Metrics 92 | generator.writeArrayFieldStart("metrics"); 93 | for (final String metricName : meta.getMetricMap().keySet()) { 94 | generator.writeStartObject(); 95 | final int metricIndex = meta.getMetricIndex(metricName); 96 | generator.writeStringField("name", meta.getAliasForMetric(metricName)); 97 | generator.writeArrayFieldStart("samples"); 98 | for (final Map.Entry row : rowset.getRows().entrySet()) { 99 | final Double v = row.getValue().getMetric(metricIndex); 100 | if (v == null) { 101 | continue; 102 | } 103 | generator.writeStartObject(); 104 | generator.writeStringField("t", toDate(row.getKey())); 105 | generator.writeNumberField("v", v); 106 | generator.writeEndObject(); 107 | } 108 | generator.writeEndArray(); 109 | generator.writeEndObject(); 110 | } 111 | generator.writeEndArray(); 112 | generator.writeEndObject(); 113 | } 114 | 115 | public void produceChatty(final Rowset rowset, final RowMetadata meta) 116 | throws IOException, HttpException { 117 | for (final Map.Entry row : rowset.getRows().entrySet()) { 118 | for (final String metricName : meta.getMetricMap().keySet()) { 119 | final int metricIndex = meta.getMetricIndex(metricName); 120 | final Double v = row.getValue().getMetric(metricIndex); 121 | if (v == null) { 122 | continue; 123 | } 124 | generator.writeStartObject(); 125 | generator.writeStringField("t", toDate(row.getKey())); 126 | generator.writeStringField("resourceName", dp.getResourceName(rowset.getResourceId())); 127 | generator.writeStringField("metric", meta.getAliasForMetric(metricName)); 128 | generator.writeNumberField("v", v); 129 | generator.writeEndObject(); 130 | } 131 | } 132 | } 133 | 134 | public void produceElastic(final Rowset rowset, final RowMetadata meta) 135 | throws IOException, HttpException { 136 | for (final Map.Entry row : rowset.getRows().entrySet()) { 137 | produceSingleElastic(row.getValue(), row.getKey(), rowset.getResourceId(), meta); 138 | } 139 | } 140 | 141 | public void produceSingleElastic( 142 | final Row row, final long timestamp, final String resourceId, final RowMetadata meta) 143 | throws IOException, HttpException { 144 | generator.writeStartObject(); 145 | generator.writeStringField("resourceName", dp.getResourceName(resourceId)); 146 | generator.writeStringField("t", toDate(timestamp)); 147 | for (final String metricName : meta.getMetricMap().keySet()) { 148 | final int metricIndex = meta.getMetricIndex(metricName); 149 | final Double v = row.getMetric(metricIndex); 150 | if (v == null) { 151 | continue; 152 | } 153 | generator.writeNumberField(meta.getAliasForMetric(metricName), v); 154 | } 155 | generator.writeEndObject(); 156 | } 157 | 158 | private String toDate(final long l) { 159 | return dateFormat.format(new Date(l)); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/AdapterKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class AdapterKind { 21 | private String key; 22 | private String name; 23 | private String description; 24 | private String adapterKindType; 25 | private Integer describeVersion; 26 | 27 | public String getKey() { 28 | return key; 29 | } 30 | 31 | public void setKey(String key) { 32 | this.key = key; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public String getDescription() { 44 | return description; 45 | } 46 | 47 | public void setDescription(String description) { 48 | this.description = description; 49 | } 50 | 51 | public String getAdapterKindType() { 52 | return adapterKindType; 53 | } 54 | 55 | public void setAdapterKindType(String adapterKindType) { 56 | this.adapterKindType = adapterKindType; 57 | } 58 | 59 | public Integer getDescribeVersion() { 60 | return describeVersion; 61 | } 62 | 63 | public void setDescribeVersion(Integer describeVersion) { 64 | this.describeVersion = describeVersion; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/AdapterKindResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import com.fasterxml.jackson.annotation.JsonAlias; 21 | 22 | import java.util.List; 23 | 24 | public class AdapterKindResponse { 25 | @JsonAlias("adapter-kind") 26 | private List adapterKind; 27 | 28 | public List getAdapterKind() { 29 | return adapterKind; 30 | } 31 | 32 | public void setAdapterKind(List adapterKind) { 33 | this.adapterKind = adapterKind; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/AuthRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class AuthRequest { 21 | private final String authSource; 22 | private final String username; 23 | private final String password; 24 | 25 | public AuthRequest(final String authSource, final String username, final String password) { 26 | this.authSource = authSource; 27 | this.username = username; 28 | this.password = password; 29 | } 30 | 31 | public String getAuthSource() { 32 | return authSource; 33 | } 34 | 35 | public String getUsername() { 36 | return username; 37 | } 38 | 39 | public String getPassword() { 40 | return password; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/AuthResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class AuthResponse { 21 | private String token; 22 | 23 | public String getToken() { 24 | return token; 25 | } 26 | 27 | public void setToken(final String token) { 28 | this.token = token; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/MetricsRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import java.util.List; 21 | 22 | public class MetricsRequest { 23 | 24 | private final List resourceId; 25 | 26 | private final boolean currentOnly; 27 | 28 | private final String rollUpType; 29 | 30 | private final String intervalType; 31 | 32 | private final int intervalQuantifier; 33 | 34 | private final Integer maxSamples; 35 | 36 | private final Long begin; 37 | 38 | private final Long end; 39 | 40 | private final List stat; 41 | 42 | public MetricsRequest( 43 | final List resourceId, 44 | final boolean currentOnly, 45 | final String rollupType, 46 | final String intervalType, 47 | final int intervalQuantifier, 48 | final Integer maxSamples, 49 | final Long begin, 50 | final Long end, 51 | final List stat) { 52 | this.resourceId = resourceId; 53 | this.currentOnly = currentOnly; 54 | this.rollUpType = rollupType; 55 | this.intervalType = intervalType; 56 | this.maxSamples = maxSamples; 57 | this.begin = begin; 58 | this.end = end; 59 | this.stat = stat; 60 | this.intervalQuantifier = intervalQuantifier; 61 | } 62 | 63 | public List getResourceId() { 64 | return resourceId; 65 | } 66 | 67 | public boolean isCurrentOnly() { 68 | return currentOnly; 69 | } 70 | 71 | public String getRollUpType() { 72 | return rollUpType; 73 | } 74 | 75 | public String getIntervalType() { 76 | return intervalType; 77 | } 78 | 79 | public Integer getMaxSamples() { 80 | return maxSamples; 81 | } 82 | 83 | public List getStat() { 84 | return stat; 85 | } 86 | 87 | public Long getBegin() { 88 | return begin; 89 | } 90 | 91 | public Long getEnd() { 92 | return end; 93 | } 94 | 95 | public int getIntervalQuantifier() { 96 | return intervalQuantifier; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/NamedResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import java.util.Map; 21 | 22 | public class NamedResource { 23 | private String identifier; 24 | 25 | private Map resourceKey; 26 | 27 | public String getIdentifier() { 28 | return identifier; 29 | } 30 | 31 | public void setIdentifier(final String identifier) { 32 | this.identifier = identifier; 33 | } 34 | 35 | public Map getResourceKey() { 36 | return resourceKey; 37 | } 38 | 39 | public void setResourceKey(final Map resourceKey) { 40 | this.resourceKey = resourceKey; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/PageInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class PageInfo { 21 | private int totalCount; 22 | 23 | public int getTotalCount() { 24 | return totalCount; 25 | } 26 | 27 | public void setTotalCount(final int totalCount) { 28 | this.totalCount = totalCount; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/PageOfResources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import java.util.List; 21 | 22 | public class PageOfResources { 23 | private PageInfo pageInfo; 24 | 25 | private List resourceList; 26 | 27 | public PageInfo getPageInfo() { 28 | return pageInfo; 29 | } 30 | 31 | public void setPageInfo(final PageInfo pageInfo) { 32 | this.pageInfo = pageInfo; 33 | } 34 | 35 | public List getResourceList() { 36 | return resourceList; 37 | } 38 | 39 | public void setResourceList(final List resourceList) { 40 | this.resourceList = resourceList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/PropertiesResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class PropertiesResponse { 21 | public static class Property { 22 | String name; 23 | 24 | String value; 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(final String name) { 31 | this.name = name; 32 | } 33 | 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(final String value) { 39 | this.value = value; 40 | } 41 | } 42 | 43 | private Property[] property; 44 | 45 | public Property[] getProperty() { 46 | return property; 47 | } 48 | 49 | public void setProperty(final Property[] property) { 50 | this.property = property; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/ResourceKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class ResourceKind { 21 | String key; 22 | 23 | String name; 24 | 25 | public String getKey() { 26 | return key; 27 | } 28 | 29 | public void setKey(final String key) { 30 | this.key = key; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(final String name) { 38 | this.name = name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/ResourceKindResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import com.fasterxml.jackson.annotation.JsonAlias; 21 | import java.util.List; 22 | 23 | public class ResourceKindResponse { 24 | @JsonAlias("resource-kind") 25 | private List resourceKinds; 26 | 27 | public List getResourceKinds() { 28 | return resourceKinds; 29 | } 30 | 31 | public void setResourceKinds(final List resourceKinds) { 32 | this.resourceKinds = resourceKinds; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/ResourceStatKeysResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import com.fasterxml.jackson.annotation.JsonAlias; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | public class ResourceStatKeysResponse { 25 | @JsonAlias({"stat-key"}) 26 | private List> statKeys; 27 | 28 | public List> getStatKeys() { 29 | return statKeys; 30 | } 31 | 32 | public void setStatKeys(final List> statKeys) { 33 | this.statKeys = statKeys; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/StatKeysResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | import com.fasterxml.jackson.annotation.JsonAlias; 21 | import java.util.List; 22 | 23 | public class StatKeysResponse { 24 | public static class StatKey { 25 | String key; 26 | 27 | String name; 28 | 29 | public String getKey() { 30 | return key; 31 | } 32 | 33 | public void setKey(final String key) { 34 | this.key = key; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(final String name) { 42 | this.name = name; 43 | } 44 | } 45 | 46 | @JsonAlias("resourceTypeAttributes") 47 | private List statKeys; 48 | 49 | public List getStatKeys() { 50 | return statKeys; 51 | } 52 | 53 | public void setStatKeys(final List statKeys) { 54 | this.statKeys = statKeys; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/models/TokenAuthResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.models; 19 | 20 | public class TokenAuthResponse { 21 | private String id_token; 22 | 23 | private String expires_in; 24 | 25 | private String scope; 26 | 27 | private String access_token; 28 | 29 | private String refresh_token; 30 | 31 | public String getId_token() { 32 | return id_token; 33 | } 34 | 35 | public void setId_token(final String id_token) { 36 | this.id_token = id_token; 37 | } 38 | 39 | public String getExpires_in() { 40 | return expires_in; 41 | } 42 | 43 | public void setExpires_in(final String expires_in) { 44 | this.expires_in = expires_in; 45 | } 46 | 47 | public String getScope() { 48 | return scope; 49 | } 50 | 51 | public void setScope(final String scope) { 52 | this.scope = scope; 53 | } 54 | 55 | public String getAccess_token() { 56 | return access_token; 57 | } 58 | 59 | public void setAccess_token(final String access_token) { 60 | this.access_token = access_token; 61 | } 62 | 63 | public String getRefresh_token() { 64 | return refresh_token; 65 | } 66 | 67 | public void setRefresh_token(final String refresh_token) { 68 | this.refresh_token = refresh_token; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/opsql/opsql.g4: -------------------------------------------------------------------------------- 1 | grammar opsql; 2 | 3 | query 4 | : Select fieldList From resourceSpecifier (Where filterSpecifier) 5 | ; 6 | 7 | fieldList 8 | : field 9 | | fieldList ',' field 10 | ; 11 | 12 | field 13 | : Identifier 14 | ; 15 | 16 | resourceSpecifier 17 | : Identifier 18 | | Identifier ':' Identifier 19 | ; 20 | 21 | filterSpecifier 22 | : andExpression 23 | | orExpression 24 | ; 25 | 26 | andExpression: 27 | andExpression (And andExpression) 28 | | booleanExpression 29 | ; 30 | 31 | orExpression: 32 | orExpression (And orExpression) 33 | | booleanExpression 34 | ; 35 | 36 | booleanExpression 37 | : simpleBooleanExpression 38 | | Not simpleBooleanExpression 39 | ; 40 | 41 | simpleBooleanExpression 42 | : Identifier BooleanOperator Literal 43 | ; 44 | 45 | /// Reserved words 46 | Select: 'select' 'hello'; 47 | From: 'from'; 48 | Where: 'where'; 49 | And: 'and'; 50 | Or: 'or'; 51 | Not: 'not'; 52 | Parent: 'parent'; 53 | Child: 'child'; 54 | Prop: '$prop'; 55 | 56 | BooleanOperator 57 | 58 | : '=' 59 | | '!=' 60 | | '>' 61 | | '<' 62 | | '>=' 63 | | '<=' 64 | | 'contains' 65 | ; 66 | 67 | Literal: 68 | StringLiteral 69 | | Number 70 | ; 71 | 72 | Identifier: 73 | ValidIdStart ValidIdChar* 74 | ; 75 | 76 | fragment EscapeSequence 77 | : SimpleEscapeSequence 78 | | OctalEscapeSequence 79 | | HexadecimalEscapeSequence 80 | ; 81 | 82 | fragment SimpleEscapeSequence 83 | : '\\' ['"?abfnrtv\\] 84 | ; 85 | 86 | fragment OctalEscapeSequence 87 | : '\\' OctalDigit OctalDigit? OctalDigit? 88 | ; 89 | fragment HexadecimalEscapeSequence 90 | : '\\x' HexadecimalDigit+ 91 | ; 92 | 93 | fragment 94 | OctalDigit 95 | : [0-7] 96 | ; 97 | 98 | fragment 99 | HexadecimalDigit 100 | : [0-9a-fA-F] 101 | ; 102 | 103 | StringLiteral 104 | : '"' SCharSequence? '"' 105 | ; 106 | 107 | fragment SCharSequence 108 | : SChar+ 109 | ; 110 | 111 | fragment SChar 112 | : ~["\\\r\n] 113 | | EscapeSequence 114 | | '\\\n' // Added line 115 | | '\\\r\n' // Added line 116 | ; 117 | 118 | fragment ValidIdStart 119 | : ('a' .. 'z') | ('A' .. 'Z') | '_' 120 | ; 121 | 122 | fragment ValidIdChar 123 | : ValidIdStart | ('0' .. '9') 124 | ; 125 | 126 | WS 127 | : [ \r\n\t] + -> skip 128 | ; 129 | 130 | ScientificNumber 131 | : Sign? Number ((E1 | E2) Sign? Number)? 132 | ; 133 | 134 | 135 | fragment Number 136 | : ('0' .. '9') + ('.' ('0' .. '9') +)? 137 | ; 138 | 139 | fragment E1 140 | : 'E' 141 | ; 142 | 143 | 144 | fragment E2 145 | : 'e' 146 | ; 147 | 148 | fragment Sign 149 | : ('+' | '-') 150 | ; -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/processors/CSVPrinter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.processors; 19 | 20 | import com.vmware.vropsexport.CSVConfig; 21 | import com.vmware.vropsexport.Config; 22 | import com.vmware.vropsexport.DataProvider; 23 | import com.vmware.vropsexport.Row; 24 | import com.vmware.vropsexport.RowMetadata; 25 | import com.vmware.vropsexport.Rowset; 26 | import com.vmware.vropsexport.RowsetProcessor; 27 | import com.vmware.vropsexport.RowsetProcessorFacotry; 28 | import com.vmware.vropsexport.exceptions.ExporterException; 29 | import java.io.BufferedWriter; 30 | import java.io.IOException; 31 | import java.io.OutputStream; 32 | import java.io.OutputStreamWriter; 33 | import java.nio.charset.StandardCharsets; 34 | import java.text.DateFormat; 35 | import java.text.SimpleDateFormat; 36 | import java.util.Date; 37 | import java.util.Iterator; 38 | import org.apache.http.HttpException; 39 | 40 | @SuppressWarnings("WeakerAccess") 41 | public class CSVPrinter implements RowsetProcessor { 42 | 43 | public static class Factory implements RowsetProcessorFacotry { 44 | @Override 45 | public RowsetProcessor makeFromConfig( 46 | final OutputStream out, final Config config, final DataProvider dp) { 47 | return new CSVPrinter( 48 | new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)), 49 | new SimpleDateFormat(config.getDateFormat()), 50 | config.getCsvConfig(), 51 | dp); 52 | } 53 | 54 | @Override 55 | public boolean isProducingOutput() { 56 | return true; 57 | } 58 | } 59 | 60 | private final BufferedWriter bw; 61 | 62 | private final DateFormat df; 63 | 64 | private final DataProvider dp; 65 | 66 | private final CSVConfig csvConfig; 67 | 68 | public CSVPrinter( 69 | final BufferedWriter bw, 70 | final DateFormat df, 71 | final CSVConfig csvConfig, 72 | final DataProvider dp) { 73 | this.bw = bw; 74 | this.df = df; 75 | this.dp = dp; 76 | 77 | // Create a default CSVConfig if none was specified. 78 | // 79 | this.csvConfig = csvConfig != null ? csvConfig : new CSVConfig(); 80 | } 81 | 82 | @Override 83 | public void close() { 84 | // Nothing to do 85 | } 86 | 87 | @Override 88 | public void preamble(final RowMetadata meta, final Config conf) throws ExporterException { 89 | // If header is suppressed, do nothing... 90 | // If all metrics are exported, header is pointless. 91 | // 92 | if (!csvConfig.isHeader() || conf.isAllMetrics()) { 93 | return; 94 | } 95 | try { 96 | // Output table header 97 | // 98 | bw.write("timestamp,resName"); 99 | for (final Config.Field fld : conf.getFields()) { 100 | bw.write(","); 101 | bw.write(fld.getAlias()); 102 | } 103 | bw.newLine(); 104 | } catch (final IOException e) { 105 | throw new ExporterException(e); 106 | } 107 | } 108 | 109 | @Override 110 | public void process(final Rowset rowset, final RowMetadata meta) throws ExporterException { 111 | try { 112 | synchronized (bw) { 113 | for (final Row row : rowset.getRows().values()) { 114 | final long t = row.getTimestamp(); 115 | if (df != null) { 116 | bw.write("\"" + df.format(new Date(t)) + "\""); 117 | } else { 118 | bw.write("\"" + t + "\""); 119 | } 120 | bw.write(csvConfig.getDelimiter()); 121 | bw.write("\""); 122 | bw.write(dp.getResourceName(rowset.getResourceId())); 123 | bw.write("\""); 124 | final Iterator itor = row.iterator(meta); 125 | while (itor.hasNext()) { 126 | final Object o = itor.next(); 127 | bw.write(csvConfig.getDelimiter()); 128 | bw.write("\""); 129 | bw.write(o != null ? o.toString() : ""); 130 | bw.write('"'); 131 | } 132 | bw.newLine(); 133 | bw.flush(); 134 | } 135 | } 136 | } catch (final IOException | HttpException e) { 137 | throw new ExporterException(e); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/processors/JsonPrinter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.processors; 19 | 20 | import com.fasterxml.jackson.core.JsonEncoding; 21 | import com.fasterxml.jackson.core.JsonFactory; 22 | import com.fasterxml.jackson.core.JsonGenerator; 23 | import com.vmware.vropsexport.Config; 24 | import com.vmware.vropsexport.DataProvider; 25 | import com.vmware.vropsexport.RowMetadata; 26 | import com.vmware.vropsexport.Rowset; 27 | import com.vmware.vropsexport.RowsetProcessor; 28 | import com.vmware.vropsexport.RowsetProcessorFacotry; 29 | import com.vmware.vropsexport.exceptions.ExporterException; 30 | import com.vmware.vropsexport.json.JsonConfig; 31 | import com.vmware.vropsexport.json.JsonProducer; 32 | import java.io.IOException; 33 | import java.io.OutputStream; 34 | import java.text.DateFormat; 35 | 36 | public class JsonPrinter implements RowsetProcessor { 37 | public static class Factory implements RowsetProcessorFacotry { 38 | 39 | @Override 40 | public RowsetProcessor makeFromConfig( 41 | final OutputStream out, final Config config, final DataProvider dp) 42 | throws ExporterException { 43 | return new JsonPrinter( 44 | out, 45 | dp, 46 | config.getJsonConfig() != null 47 | ? config.getJsonConfig().getFormat() 48 | : JsonConfig.JsonFormat.compact, 49 | config.getDateFormatter()); 50 | } 51 | 52 | @Override 53 | public boolean isProducingOutput() { 54 | return true; 55 | } 56 | } 57 | 58 | private final JsonGenerator generator; 59 | 60 | private final JsonConfig.JsonFormat format; 61 | 62 | private final JsonProducer produder; 63 | 64 | public JsonPrinter( 65 | final OutputStream out, 66 | final DataProvider dp, 67 | final JsonConfig.JsonFormat format, 68 | final DateFormat dateFormat) 69 | throws ExporterException { 70 | try { 71 | this.format = format; 72 | final JsonFactory jf = new JsonFactory(); 73 | generator = jf.createGenerator(out, JsonEncoding.UTF8); 74 | produder = new JsonProducer(generator, dp, dateFormat); 75 | } catch (final IOException e) { 76 | throw new ExporterException(e); 77 | } 78 | } 79 | 80 | @Override 81 | public void preamble(final RowMetadata meta, final Config conf) throws ExporterException { 82 | try { 83 | generator.writeStartObject(); 84 | generator.writeArrayFieldStart("data"); 85 | } catch (final IOException e) { 86 | throw new ExporterException(e); 87 | } 88 | } 89 | 90 | @Override 91 | public void process(final Rowset rowset, final RowMetadata meta) throws ExporterException { 92 | produder.produce(rowset, meta, format); 93 | } 94 | 95 | @Override 96 | public void close() throws ExporterException { 97 | try { 98 | 99 | generator.writeEndArray(); 100 | generator.writeEndObject(); 101 | generator.close(); 102 | } catch (final IOException e) { 103 | throw new ExporterException(e); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/processors/ParentSplicer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.processors; 19 | 20 | import com.vmware.vropsexport.Config; 21 | import com.vmware.vropsexport.LRUCache; 22 | import com.vmware.vropsexport.Row; 23 | import com.vmware.vropsexport.RowMetadata; 24 | import com.vmware.vropsexport.Rowset; 25 | import com.vmware.vropsexport.RowsetProcessor; 26 | import com.vmware.vropsexport.exceptions.ExporterException; 27 | 28 | public class ParentSplicer implements RowsetProcessor { 29 | 30 | private final Rowset childRowset; 31 | 32 | private final LRUCache rowsetCache; 33 | 34 | private final String cacheKey; 35 | 36 | public ParentSplicer( 37 | final Rowset childRowset, final LRUCache rowsetCache, final String cacheKey) { 38 | super(); 39 | this.childRowset = childRowset; 40 | this.rowsetCache = rowsetCache; 41 | this.cacheKey = cacheKey; 42 | } 43 | 44 | @Override 45 | public void preamble(final RowMetadata meta, final Config conf) { 46 | // Nothing to do... 47 | } 48 | 49 | @Override 50 | public void process(final Rowset rowset, final RowMetadata meta) throws ExporterException { 51 | spliceRows(childRowset, rowset); 52 | synchronized (rowsetCache) { 53 | rowsetCache.put(cacheKey, rowset); 54 | } 55 | } 56 | 57 | @Override 58 | public void close() { 59 | // Nothing to do 60 | } 61 | 62 | public static void spliceRows(final Rowset child, final Rowset parent) { 63 | for (final Row pRow : parent.getRows().values()) { 64 | final Row cRow = child.getRows().get(pRow.getTimestamp()); 65 | if (cRow != null) { 66 | for (int j = 0; j < pRow.getNumMetrics(); ++j) { 67 | final Double d = pRow.getMetric(j); 68 | if (d != null) { 69 | cRow.setMetric(j, d); 70 | } 71 | } 72 | for (int j = 0; j < pRow.getNumProps(); ++j) { 73 | final String s = pRow.getProp(j); 74 | if (s != null) { 75 | cRow.setProp(j, s); 76 | } 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/processors/SQLDumper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.processors; 19 | 20 | import com.vmware.vropsexport.Config; 21 | import com.vmware.vropsexport.DataProvider; 22 | import com.vmware.vropsexport.Row; 23 | import com.vmware.vropsexport.RowMetadata; 24 | import com.vmware.vropsexport.Rowset; 25 | import com.vmware.vropsexport.RowsetProcessor; 26 | import com.vmware.vropsexport.RowsetProcessorFacotry; 27 | import com.vmware.vropsexport.exceptions.ExporterException; 28 | import com.vmware.vropsexport.sql.NamedParameterStatement; 29 | import com.vmware.vropsexport.sql.SQLConfig; 30 | import java.io.IOException; 31 | import java.io.OutputStream; 32 | import java.sql.Connection; 33 | import java.sql.SQLException; 34 | import java.util.HashMap; 35 | import java.util.Map; 36 | import javax.sql.DataSource; 37 | import org.apache.commons.dbcp2.BasicDataSource; 38 | import org.apache.http.HttpException; 39 | 40 | @SuppressWarnings("WeakerAccess") 41 | public class SQLDumper implements RowsetProcessor { 42 | private static final int DEFAULT_BATCH_SIZE = 1000; 43 | 44 | private static final Map drivers = new HashMap<>(); 45 | 46 | private final int batchSize; 47 | 48 | static { 49 | drivers.put("postgres", "org.postgresql.Driver"); 50 | drivers.put("mssql", "com.microsoft.sqlserver.jdbc.SQLServerDriver"); 51 | drivers.put("mysql", "com.mysql.jdbc.Driver"); 52 | drivers.put("oracle", "oracle.jdbc.driver.OracleDriver"); 53 | } 54 | 55 | public static class Factory implements RowsetProcessorFacotry { 56 | private BasicDataSource ds; 57 | 58 | @Override 59 | public synchronized RowsetProcessor makeFromConfig( 60 | final OutputStream out, final Config config, final DataProvider dp) 61 | throws ExporterException { 62 | final SQLConfig sqlc = config.getSqlConfig(); 63 | if (sqlc == null) { 64 | throw new ExporterException("SQL section must be present in the definition file"); 65 | } 66 | 67 | // Determine batchsize 68 | // 69 | int batchSize = sqlc.getBatchSize(); 70 | if (batchSize == 0) { 71 | batchSize = DEFAULT_BATCH_SIZE; 72 | } 73 | 74 | // The driver can be either read directly or derived from the database type 75 | // 76 | String driver = sqlc.getDriver(); 77 | if (driver == null) { 78 | final String dbType = sqlc.getDatabaseType(); 79 | if (dbType == null) { 80 | throw new ExporterException("Database type or driver name must be specified"); 81 | } 82 | driver = drivers.get(dbType); 83 | if (driver == null) { 84 | throw new ExporterException( 85 | "Database type " 86 | + dbType 87 | + " is not recognized. Check spelling or try to specifying the driver class instead!"); 88 | } 89 | 90 | // Make sure we can load the driver 91 | // 92 | try { 93 | Class.forName(driver); 94 | } catch (final ClassNotFoundException e) { 95 | throw new ExporterException( 96 | "Could not load JDBC driver " 97 | + driver 98 | + ". Make sure you have set the JDBC_JAR env variable correctly"); 99 | } 100 | } 101 | if (ds == null) { 102 | ds = new BasicDataSource(); 103 | if (sqlc.getConnectionString() == null) { 104 | throw new ExporterException("SQL connection URL must be specified"); 105 | } 106 | 107 | // Use either database type or driver. 108 | // 109 | ds.setDefaultAutoCommit(false); 110 | ds.setDriverClassName(driver); 111 | ds.setUrl(sqlc.getConnectionString()); 112 | if (sqlc.getUsername() != null) { 113 | ds.setUsername(sqlc.getUsername()); 114 | } 115 | if (sqlc.getPassword() != null) { 116 | ds.setPassword(sqlc.getPassword()); 117 | } 118 | } 119 | if (sqlc.getSql() == null) { 120 | throw new ExporterException("SQL statement must be specified"); 121 | } 122 | return new SQLDumper(ds, dp, sqlc.getSql(), batchSize); 123 | } 124 | 125 | @Override 126 | public boolean isProducingOutput() { 127 | return false; 128 | } 129 | } 130 | 131 | private final DataSource ds; 132 | 133 | private final DataProvider dp; 134 | 135 | private final String sql; 136 | 137 | public SQLDumper( 138 | final DataSource ds, final DataProvider dp, final String sql, final int batchSize) { 139 | super(); 140 | this.ds = ds; 141 | this.dp = dp; 142 | this.sql = sql; 143 | this.batchSize = batchSize; 144 | } 145 | 146 | @Override 147 | public void preamble(final RowMetadata meta, final Config conf) { 148 | // Nothing to do... 149 | } 150 | 151 | @Override 152 | public void process(final Rowset rowset, final RowMetadata meta) throws ExporterException { 153 | try { 154 | final NamedParameterStatement stmt; 155 | try (final Connection conn = ds.getConnection()) { 156 | stmt = new NamedParameterStatement(conn, sql); 157 | int rowsInBatch = 0; 158 | for (final Row row : rowset.getRows().values()) { 159 | for (final String fld : stmt.getParameterNames()) { 160 | // Deal with special cases 161 | // 162 | if ("timestamp".equals(fld)) { 163 | stmt.setObject("timestamp", new java.sql.Timestamp(row.getTimestamp())); 164 | } else if ("resName".equals(fld)) { 165 | stmt.setString("resName", dp.getResourceName(rowset.getResourceId())); 166 | } else { 167 | // Does the name refer to a metric? 168 | // 169 | int p = meta.getMetricIndexByAlias(fld); 170 | if (p != -1) { 171 | stmt.setObject(fld, row.getMetric(p)); 172 | } else { 173 | // Not a metric, so it must be a property then. 174 | // 175 | p = meta.getPropertyIndexByAlias(fld); 176 | if (p == -1) { 177 | throw new ExporterException("Field " + fld + " is not defined"); 178 | } 179 | stmt.setString(fld, row.getProp(p)); 180 | } 181 | } 182 | } 183 | stmt.addBatch(); 184 | if (++rowsInBatch > batchSize) { 185 | stmt.executeBatch(); 186 | rowsInBatch = 0; 187 | } 188 | } 189 | // Push dangling batch 190 | // 191 | if (rowsInBatch > 0) { 192 | stmt.executeBatch(); 193 | } 194 | conn.commit(); 195 | } 196 | } catch (final SQLException | HttpException | IOException e) { 197 | throw new ExporterException(e); 198 | } 199 | } 200 | 201 | @Override 202 | public void close() throws ExporterException { 203 | // Nothing to do 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/processors/WavefrontPusher.java: -------------------------------------------------------------------------------- 1 | package com.vmware.vropsexport.processors; 2 | 3 | import com.vmware.vropsexport.Config; 4 | import com.vmware.vropsexport.DataProvider; 5 | import com.vmware.vropsexport.Row; 6 | import com.vmware.vropsexport.RowMetadata; 7 | import com.vmware.vropsexport.Rowset; 8 | import com.vmware.vropsexport.RowsetProcessor; 9 | import com.vmware.vropsexport.RowsetProcessorFacotry; 10 | import com.vmware.vropsexport.exceptions.ExporterException; 11 | import com.vmware.vropsexport.wavefront.WavefrontConfig; 12 | import com.wavefront.sdk.common.WavefrontSender; 13 | import com.wavefront.sdk.direct.ingestion.WavefrontDirectIngestionClient; 14 | import com.wavefront.sdk.proxy.WavefrontProxyClient; 15 | import java.io.IOException; 16 | import java.io.OutputStream; 17 | import java.util.HashMap; 18 | import java.util.Map; 19 | import org.apache.http.HttpException; 20 | 21 | @SuppressWarnings("WeakerAccess") 22 | public class WavefrontPusher implements RowsetProcessor { 23 | 24 | public static class Factory implements RowsetProcessorFacotry { 25 | @Override 26 | public RowsetProcessor makeFromConfig( 27 | final OutputStream out, final Config config, final DataProvider dp) 28 | throws ExporterException { 29 | if (config.getWavefrontConfig() == null) { 30 | throw new ExporterException("Wavefront config must be specified for Wavefront output"); 31 | } 32 | final WavefrontConfig wfc = config.getWavefrontConfig(); 33 | WavefrontSender sender = null; 34 | if (wfc.getProxyHost() != null) { 35 | if (wfc.getWavefrontURL() != null || wfc.getToken() != null) { 36 | throw new ExporterException( 37 | "The 'wavefrontURL' and 'token' config items are not compatible with proxy"); 38 | } 39 | final WavefrontProxyClient.Builder b = new WavefrontProxyClient.Builder(wfc.getProxyHost()); 40 | if (wfc.getProxyPort() != 0) { 41 | b.metricsPort(wfc.getProxyPort()); 42 | } 43 | sender = b.build(); 44 | } else { 45 | if (wfc.getWavefrontURL() == null && wfc.getToken() == null) { 46 | throw new ExporterException( 47 | "The 'wavefrontURL' and 'token' must be specified if proxy is not used"); 48 | } 49 | final WavefrontDirectIngestionClient.Builder b = 50 | new WavefrontDirectIngestionClient.Builder(wfc.getWavefrontURL(), wfc.getToken()); 51 | sender = b.build(); 52 | } 53 | return new WavefrontPusher(sender, dp); 54 | } 55 | 56 | @Override 57 | public boolean isProducingOutput() { 58 | return false; 59 | } 60 | } 61 | 62 | private final DataProvider dp; 63 | 64 | private final WavefrontSender sender; 65 | 66 | public WavefrontPusher(final WavefrontSender sender, final DataProvider dp) { 67 | this.sender = sender; 68 | this.dp = dp; 69 | } 70 | 71 | @Override 72 | public void preamble(final RowMetadata meta, final Config conf) throws ExporterException { 73 | // Nothing to do here 74 | } 75 | 76 | @Override 77 | public void process(final Rowset rowset, final RowMetadata meta) throws ExporterException { 78 | try { 79 | for (final Row r : rowset.getRows().values()) { 80 | final long ts = r.getTimestamp(); 81 | final String resourceName = dp.getResourceName(rowset.getResourceId()); 82 | for (final Map.Entry metric : meta.getMetricMap().entrySet()) { 83 | 84 | // Build string on the format [] source= 85 | // [pointTags] 86 | // 87 | final Double d = r.getMetric(metric.getValue()); 88 | if (d == null) { 89 | continue; 90 | } 91 | final Map tags = new HashMap<>(meta.getPropMap().size()); 92 | for (final Map.Entry prop : meta.getPropMap().entrySet()) { 93 | final Integer p = prop.getValue(); 94 | if (p == null) { 95 | continue; 96 | } 97 | tags.put(meta.getAliasForProp(prop.getKey()), r.getProp(p)); 98 | } 99 | sender.sendMetric( 100 | meta.getAliasForMetric(metric.getKey()), d, ts / 1000, resourceName, tags); 101 | } 102 | } 103 | } catch (final IOException | HttpException e) { 104 | throw new ExporterException(e); 105 | } 106 | } 107 | 108 | @Override 109 | public void close() throws ExporterException { 110 | try { 111 | sender.flush(); 112 | sender.close(); 113 | } catch (final IOException e) { 114 | throw new ExporterException(e); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/security/CertUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.security; 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileNotFoundException; 23 | import java.io.FileOutputStream; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.io.OutputStream; 27 | import java.security.KeyStore; 28 | import java.security.KeyStoreException; 29 | import java.security.MessageDigest; 30 | import java.security.NoSuchAlgorithmException; 31 | import java.security.cert.CertificateEncodingException; 32 | import java.security.cert.CertificateException; 33 | import java.security.cert.X509Certificate; 34 | 35 | public class CertUtils { 36 | public static KeyStore loadExtendedTrust(final String filename, String password) 37 | throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException { 38 | if (password == null) { 39 | password = "changeit"; 40 | } 41 | try { 42 | final KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); 43 | try (final InputStream is = new FileInputStream(getActualTruststoreFilename(filename))) { 44 | ks.load(is, password.toCharArray()); 45 | return ks; 46 | } 47 | } catch (final FileNotFoundException e) { 48 | return null; 49 | } 50 | } 51 | 52 | public static String getThumbprint(final X509Certificate cert, final boolean space) 53 | throws NoSuchAlgorithmException, CertificateEncodingException { 54 | final MessageDigest md = MessageDigest.getInstance("SHA-1"); 55 | final byte[] der = cert.getEncoded(); 56 | md.update(der); 57 | final byte[] digest = md.digest(); 58 | return hexify(digest, space); 59 | } 60 | 61 | public static void storeCert(final X509Certificate cert, String filename, String password) 62 | throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException { 63 | filename = getActualTruststoreFilename(filename); 64 | final String alias = getThumbprint(cert, false); 65 | if (password == null) { 66 | password = "changeit"; 67 | } 68 | KeyStore ks = loadExtendedTrust(filename, password); 69 | if (ks == null) { 70 | ks = KeyStore.getInstance(KeyStore.getDefaultType()); 71 | ks.load(null, password.toCharArray()); 72 | } 73 | ks.setCertificateEntry(alias, cert); 74 | final File f = new File(filename); 75 | final File dir = f.getParentFile(); 76 | if (dir != null && !dir.exists()) { 77 | dir.mkdirs(); 78 | } 79 | try (final OutputStream os = new FileOutputStream(filename)) { 80 | ks.store(os, password.toCharArray()); 81 | } 82 | } 83 | 84 | private static String getActualTruststoreFilename(final String filename) { 85 | return filename != null 86 | ? filename 87 | : System.getProperty("user.home") 88 | + File.separator 89 | + ".vropsexport" 90 | + File.separator 91 | + "truststore"; 92 | } 93 | 94 | private static String hexify(final byte[] bytes, final boolean space) { 95 | final char[] hexDigits = { 96 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 97 | }; 98 | final StringBuilder buf = new StringBuilder(bytes.length * 2 + (space ? bytes.length - 1 : 0)); 99 | for (int i = 0; i < bytes.length; ++i) { 100 | if (space && i > 0) { 101 | buf.append(' '); 102 | } 103 | buf.append(hexDigits[(bytes[i] & 0xf0) >> 4]); 104 | buf.append(hexDigits[bytes[i] & 0x0f]); 105 | } 106 | return buf.toString(); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/security/ExtendableTrustStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.security; 19 | 20 | import java.security.KeyStore; 21 | import java.security.KeyStoreException; 22 | import java.security.NoSuchAlgorithmException; 23 | import java.security.cert.CertificateException; 24 | import java.security.cert.X509Certificate; 25 | import javax.net.ssl.TrustManager; 26 | import javax.net.ssl.TrustManagerFactory; 27 | import javax.net.ssl.X509TrustManager; 28 | import org.apache.http.conn.ssl.TrustStrategy; 29 | 30 | public class ExtendableTrustStrategy implements TrustStrategy, org.apache.http.ssl.TrustStrategy { 31 | private final TrustManager[] trustManagers; 32 | 33 | private X509Certificate[] capturedCerts; 34 | 35 | public ExtendableTrustStrategy(final KeyStore extendedTrust) 36 | throws NoSuchAlgorithmException, KeyStoreException { 37 | if (extendedTrust != null) { 38 | final TrustManagerFactory tmf = 39 | TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); 40 | tmf.init(extendedTrust); 41 | trustManagers = tmf.getTrustManagers(); 42 | } else { 43 | trustManagers = null; 44 | } 45 | } 46 | 47 | @Override 48 | public boolean isTrusted(final X509Certificate[] certs, final String authType) { 49 | capturedCerts = certs; 50 | if (trustManagers == null) { 51 | return false; 52 | } 53 | try { 54 | for (final TrustManager trustManager : trustManagers) { 55 | ((X509TrustManager) trustManager).checkServerTrusted(certs, authType); 56 | } 57 | } catch (final CertificateException e) { 58 | return false; 59 | } 60 | return true; 61 | } 62 | 63 | public X509Certificate[] getCapturedCerts() { 64 | return capturedCerts; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/security/RecoverableCertificateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.security; 19 | 20 | import com.vmware.vropsexport.exceptions.ExporterException; 21 | import java.security.cert.X509Certificate; 22 | 23 | public class RecoverableCertificateException extends ExporterException { 24 | private static final long serialVersionUID = 6702660675940528780L; 25 | private final X509Certificate[] capturedCerts; 26 | 27 | public RecoverableCertificateException( 28 | final X509Certificate[] capturedCerts, final Throwable cause) { 29 | super(cause); 30 | this.capturedCerts = capturedCerts; 31 | } 32 | 33 | public X509Certificate[] getCapturedCerts() { 34 | return capturedCerts; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/sql/SQLConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport.sql; 19 | 20 | import com.vmware.vropsexport.Validatable; 21 | import com.vmware.vropsexport.exceptions.ValidationException; 22 | 23 | public class SQLConfig implements Validatable { 24 | private String connectionString; 25 | 26 | private String username; 27 | 28 | private String password; 29 | 30 | private String databaseType; 31 | 32 | private String driver; 33 | 34 | private String sql; 35 | 36 | private int batchSize; 37 | 38 | public SQLConfig() {} 39 | 40 | public String getConnectionString() { 41 | return connectionString; 42 | } 43 | 44 | public void setConnectionString(final String connectionString) { 45 | this.connectionString = connectionString; 46 | } 47 | 48 | public String getUsername() { 49 | return username; 50 | } 51 | 52 | public void setUsername(final String username) { 53 | this.username = username; 54 | } 55 | 56 | public String getPassword() { 57 | return password; 58 | } 59 | 60 | public void setPassword(final String password) { 61 | this.password = password; 62 | } 63 | 64 | public String getDriver() { 65 | return driver; 66 | } 67 | 68 | public void setDriver(final String driver) { 69 | this.driver = driver; 70 | } 71 | 72 | public String getDatabaseType() { 73 | return databaseType; 74 | } 75 | 76 | public void setDatabaseType(final String databaseType) { 77 | this.databaseType = databaseType; 78 | } 79 | 80 | public String getSql() { 81 | return sql; 82 | } 83 | 84 | public void setSql(final String sql) { 85 | this.sql = sql; 86 | } 87 | 88 | public int getBatchSize() { 89 | return batchSize; 90 | } 91 | 92 | public void setBatchSize(final int batchSize) { 93 | this.batchSize = batchSize; 94 | } 95 | 96 | @Override 97 | public void validate() throws ValidationException { 98 | if (sql == null) { 99 | throw new ValidationException("'sql' must be specified"); 100 | } 101 | if (connectionString == null) { 102 | throw new ValidationException("'connectionString' must be specified"); 103 | } 104 | if (databaseType == null && driver == null) { 105 | throw new ValidationException("'databaseType' or 'driver' must be specified"); 106 | } 107 | if (databaseType != null && driver != null) { 108 | throw new ValidationException("'databaseType' and 'driver' are mutually exclusive"); 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/vmware/vropsexport/wavefront/WavefrontConfig.java: -------------------------------------------------------------------------------- 1 | package com.vmware.vropsexport.wavefront; 2 | 3 | import com.vmware.vropsexport.Validatable; 4 | import com.vmware.vropsexport.exceptions.ValidationException; 5 | 6 | public class WavefrontConfig implements Validatable { 7 | private String proxyHost; 8 | 9 | private int proxyPort = 2878; 10 | 11 | private String wavefrontURL; 12 | 13 | private String token; 14 | 15 | public String getProxyHost() { 16 | return proxyHost; 17 | } 18 | 19 | public void setProxyHost(final String proxyHost) { 20 | this.proxyHost = proxyHost; 21 | } 22 | 23 | public int getProxyPort() { 24 | return proxyPort; 25 | } 26 | 27 | public void setProxyPort(final int proxyPort) { 28 | this.proxyPort = proxyPort; 29 | } 30 | 31 | public String getWavefrontURL() { 32 | return wavefrontURL; 33 | } 34 | 35 | public void setWavefrontURL(final String wavefrontURL) { 36 | this.wavefrontURL = wavefrontURL; 37 | } 38 | 39 | public String getToken() { 40 | return token; 41 | } 42 | 43 | public void setToken(final String token) { 44 | this.token = token; 45 | } 46 | 47 | @Override 48 | public void validate() throws ValidationException { 49 | if (proxyHost != null) { 50 | if (wavefrontURL != null) { 51 | throw new ValidationException("'proxyHost' and 'wavefrontURL' are mutually exclusive"); 52 | } 53 | } else if (wavefrontURL != null) { 54 | if (token == null) { 55 | throw new ValidationException("'token' must be specified"); 56 | } 57 | } else { 58 | throw new ValidationException("Either 'proxyHos' or 'wavefrontURL' must be specified"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/resources/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/vrops-export/e75f0c1b5593708e2680700e2e49c08ca8aced1d/src/main/resources/.gitignore -------------------------------------------------------------------------------- /src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/logo-140px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/vrops-export/e75f0c1b5593708e2680700e2e49c08ca8aced1d/src/main/resources/logo-140px.png -------------------------------------------------------------------------------- /src/main/resources/logo-full-res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/vrops-export/e75f0c1b5593708e2680700e2e49c08ca8aced1d/src/main/resources/logo-full-res.png -------------------------------------------------------------------------------- /src/main/resources/logo.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/vrops-export/e75f0c1b5593708e2680700e2e49c08ca8aced1d/src/main/resources/logo.pptx -------------------------------------------------------------------------------- /src/test/java/com/vmware/vropsexport/NameSanitizerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2021 VMware, Inc. All Rights Reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import org.junit.Assert; 21 | import org.junit.Test; 22 | 23 | public class NameSanitizerTest { 24 | @Test 25 | public void testReplacingNameSanitizer() { 26 | final NameSanitizer ns = new ReplacingNameSanitizer("$|^%!?", 'p'); 27 | Assert.assertEquals( 28 | "peter piper picked a peck of pickled peppers", 29 | ns.transform("$eter |iper ^icked a %eck of !ickled !e??ers")); 30 | Assert.assertEquals( 31 | "peter piper picked a peck of pickled peppers", 32 | ns.transform("peter piper picked a peck of pickled peppers")); 33 | Assert.assertTrue( // When no replacements are needed, the same object should be returned. 34 | "peter piper picked a peck of pickled peppers" 35 | == ns.transform("peter piper picked a peck of pickled peppers")); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/vmware/vropsexport/StatsProcessorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 VMware, Inc. All Rights Reserved 3 | * 4 | * SPDX-License-Identifier: Apache-2.0. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package com.vmware.vropsexport; 19 | 20 | import static org.mockito.ArgumentMatchers.any; 21 | import static org.mockito.ArgumentMatchers.anyLong; 22 | import static org.mockito.ArgumentMatchers.eq; 23 | import static org.mockito.Mockito.mock; 24 | import static org.mockito.Mockito.when; 25 | 26 | import com.fasterxml.jackson.databind.DeserializationFeature; 27 | import com.fasterxml.jackson.databind.ObjectMapper; 28 | import com.vmware.vropsexport.exceptions.ExporterException; 29 | import com.vmware.vropsexport.exceptions.ValidationException; 30 | import com.vmware.vropsexport.models.NamedResource; 31 | import com.vmware.vropsexport.processors.CSVPrinter; 32 | import com.vmware.vropsexport.processors.JsonPrinter; 33 | import java.io.ByteArrayOutputStream; 34 | import java.io.File; 35 | import java.io.FileInputStream; 36 | import java.io.FileReader; 37 | import java.io.IOException; 38 | import java.io.InputStream; 39 | import java.util.HashMap; 40 | import java.util.List; 41 | import java.util.Map; 42 | import java.util.TimeZone; 43 | 44 | import org.apache.commons.io.FileUtils; 45 | import org.apache.http.HttpException; 46 | import org.junit.Assert; 47 | import org.junit.Before; 48 | import org.junit.Test; 49 | 50 | public class StatsProcessorTest { 51 | 52 | private static final String VM_ID = "60508ea6-287b-42be-953c-1554e506cdc1"; 53 | private static final String HOST_ID = "e21f1a97-40a4-4e14-ada8-d7ec659f0cf1"; 54 | private static final long START = 1617321169385L; 55 | private static final long END = 1617323869402L; 56 | 57 | private static class Properties { 58 | private String resourceId; 59 | 60 | private List> property; 61 | 62 | public String getResourceId() { 63 | return resourceId; 64 | } 65 | 66 | public void setResourceId(final String resourceId) { 67 | this.resourceId = resourceId; 68 | } 69 | 70 | public List> getProperty() { 71 | return property; 72 | } 73 | 74 | public void setProperty(final List> property) { 75 | this.property = property; 76 | } 77 | } 78 | 79 | private NamedResource hostResource; 80 | private Map hostProperties; 81 | private Map vmProperties; 82 | private List statKeys; 83 | 84 | @Before 85 | public void init() throws IOException { 86 | TimeZone.setDefault(TimeZone.getTimeZone("America/New_York")); 87 | hostResource = 88 | new ObjectMapper() 89 | .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) 90 | .readValue(new File("src/test/resources/hostresource.json"), NamedResource.class); 91 | 92 | hostProperties = loadProps("src/test/resources/hostprops.json"); 93 | vmProperties = loadProps("src/test/resources/vmprops.json"); 94 | statKeys = 95 | new ObjectMapper() 96 | .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) 97 | .readValue(new File("src/test/resources/statkeys.json"), List.class); 98 | } 99 | 100 | private static Map loadProps(final String file) throws IOException { 101 | try (final InputStream in = new FileInputStream(file)) { 102 | final Properties props = new ObjectMapper().readValue(in, Properties.class); 103 | final Map result = new HashMap<>(); 104 | for (final Map prop : props.property) { 105 | result.put(prop.get("name"), prop.get("value")); 106 | } 107 | return result; 108 | } 109 | } 110 | 111 | @Test 112 | public void testCSV() throws HttpException, IOException, ExporterException, ValidationException { 113 | final byte[] data = runTest("vmfields.yaml", new CSVPrinter.Factory()); 114 | final byte[] wanted = 115 | FileUtils.readFileToByteArray(new File("src/test/resources/csv-output.csv")); 116 | Assert.assertArrayEquals(wanted, data); 117 | } 118 | 119 | @Test 120 | public void testCompactJSON() 121 | throws HttpException, IOException, ExporterException, ValidationException { 122 | runJSONTest("compact"); 123 | } 124 | 125 | @Test 126 | public void testCompactJSONAll() 127 | throws HttpException, IOException, ExporterException, ValidationException { 128 | runJSONTest("compact-all"); 129 | } 130 | 131 | @Test 132 | public void testChattyJSON() 133 | throws HttpException, IOException, ExporterException, ValidationException { 134 | runJSONTest("chatty"); 135 | } 136 | 137 | @Test 138 | public void testChattyJSONAll() 139 | throws HttpException, IOException, ExporterException, ValidationException { 140 | runJSONTest("chatty-all"); 141 | } 142 | 143 | @Test 144 | public void testElasticJSON() 145 | throws HttpException, IOException, ExporterException, ValidationException { 146 | runJSONTest("elastic"); 147 | } 148 | 149 | @Test 150 | public void testElasticJSONAll() 151 | throws HttpException, IOException, ExporterException, ValidationException { 152 | runJSONTest("elastic-all"); 153 | } 154 | 155 | private void runJSONTest(final String name) 156 | throws HttpException, IOException, ExporterException, ValidationException { 157 | final byte[] data = runTest(name + ".yaml", new JsonPrinter.Factory()); 158 | final Map wanted = 159 | new ObjectMapper() 160 | .readValue(new File("src/test/resources/" + name + "-output.json"), Map.class); 161 | final Map actual = new ObjectMapper().readValue(data, Map.class); 162 | Assert.assertEquals(wanted, actual); 163 | } 164 | 165 | private byte[] runTest(final String definition, final RowsetProcessorFacotry factory) 166 | throws IOException, ExporterException, HttpException, ValidationException { 167 | final DataProvider dp = mock(DataProvider.class); 168 | when(dp.getResourceName(any())).thenReturn("vm-01"); 169 | when(dp.getParentOf(eq(VM_ID), eq("HostSystem"))).thenReturn(hostResource); 170 | when(dp.fetchMetricStream(any(), any(RowMetadata.class), anyLong(), anyLong())) 171 | .then((inv) -> new FileInputStream("src/test/resources/hoststats.json")); 172 | when(dp.fetchProps(eq(HOST_ID))).thenReturn(hostProperties); 173 | when(dp.fetchProps(eq(VM_ID))).thenReturn(vmProperties); 174 | when(dp.getStatKeysForResource(eq(VM_ID))).thenReturn(statKeys); 175 | 176 | final Config conf = ConfigLoader.parse(new FileReader("src/test/resources/" + definition)); 177 | final ByteArrayOutputStream out = new ByteArrayOutputStream(); 178 | final RowMetadata meta = 179 | conf.isAllMetrics() 180 | ? new RowMetadata(conf, dp.getStatKeysForResource(VM_ID)) 181 | : new RowMetadata(conf); 182 | final StatsProcessor sp = new StatsProcessor(conf, meta, dp, new LRUCache<>(1000), null, false); 183 | final RowsetProcessor rp = factory.makeFromConfig(out, conf, dp); 184 | rp.preamble(meta, conf); 185 | sp.process(new FileInputStream("src/test/resources/vmstats.json"), rp, START, END); 186 | rp.close(); 187 | return out.toByteArray(); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/test/resources/chatty-all.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VMWARE:VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | outputFormat: json 5 | dateFormat: "yyyy-MM-dd HH:mm:ss" 6 | jsonConfig: 7 | format: chatty 8 | allMetrics: true -------------------------------------------------------------------------------- /src/test/resources/chatty.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VMWARE:VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | outputFormat: json 5 | dateFormat: "yyyy-MM-dd HH:mm:ss" 6 | jsonConfig: 7 | format: chatty 8 | fields: 9 | - alias: resourceId 10 | prop: $resId 11 | # CPU fields 12 | - alias: cpuDemand 13 | metric: cpu|demandPct 14 | - alias: cpuReady 15 | metric: cpu|readyPct 16 | - alias: cpuCostop 17 | metric: cpu|costopPct 18 | # Memory fields 19 | - alias: memDemand 20 | metric: mem|guest_demand 21 | - alias: memSwapOut 22 | metric: mem|swapoutRate_average 23 | - alias: memSwapIn 24 | metric: mem|swapinRate_average 25 | # Storage fields 26 | - alias: storageDemandKbps 27 | metric: storage|demandKBps 28 | # Diskspace fields 29 | - alias: vmUsed 30 | metric: diskspace|used 31 | # Network fields 32 | - alias: netBytesRx 33 | metric: net|bytesRx_average 34 | - alias: netBytesTx 35 | metric: net|bytesTx_average 36 | # Host CPU 37 | - alias: hostCPUDemand 38 | metric: $parent:HostSystem.cpu|demandmhz 39 | # Guest OS 40 | - alias: guestOS 41 | prop: config|guestFullName 42 | # Host CPU type 43 | - alias: hostCPUType 44 | prop: $parent:HostSystem.cpu|cpuModel -------------------------------------------------------------------------------- /src/test/resources/compact-all.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VMWARE:VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | outputFormat: json 5 | dateFormat: "yyyy-MM-dd HH:mm:ss" 6 | jsonConfig: 7 | format: compact 8 | allMetrics: true -------------------------------------------------------------------------------- /src/test/resources/compact.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VMWARE:VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | outputFormat: json 5 | dateFormat: "yyyy-MM-dd HH:mm:ss" 6 | jsonConfig: 7 | format: compact 8 | fields: 9 | - alias: resourceId 10 | prop: $resId 11 | # CPU fields 12 | - alias: cpuDemand 13 | metric: cpu|demandPct 14 | - alias: cpuReady 15 | metric: cpu|readyPct 16 | - alias: cpuCostop 17 | metric: cpu|costopPct 18 | # Memory fields 19 | - alias: memDemand 20 | metric: mem|guest_demand 21 | - alias: memSwapOut 22 | metric: mem|swapoutRate_average 23 | - alias: memSwapIn 24 | metric: mem|swapinRate_average 25 | # Storage fields 26 | - alias: storageDemandKbps 27 | metric: storage|demandKBps 28 | # Diskspace fields 29 | - alias: vmUsed 30 | metric: diskspace|used 31 | # Network fields 32 | - alias: netBytesRx 33 | metric: net|bytesRx_average 34 | - alias: netBytesTx 35 | metric: net|bytesTx_average 36 | # Host CPU 37 | - alias: hostCPUDemand 38 | metric: $parent:HostSystem.cpu|demandmhz 39 | # Guest OS 40 | - alias: guestOS 41 | prop: config|guestFullName 42 | # Host CPU type 43 | - alias: hostCPUType 44 | prop: $parent:HostSystem.cpu|cpuModel -------------------------------------------------------------------------------- /src/test/resources/csv-output.csv: -------------------------------------------------------------------------------- 1 | timestamp,resName,cpuDemand,cpuReady,cpuCostop,memDemand,memSwapOut,memSwapIn,storageDemandKbps,netBytesRx,netBytesTx,hostCPUDemand,guestOS,hostCPUType 2 | "2021-04-01 19:52:49","vm-01","11.801763534545898","0.3231666684150696","0.0","","0.0","0.0","","","","4360.72412109375","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 3 | "2021-04-01 19:57:49","vm-01","13.871940612792969","0.32100000977516174","0.0","","0.0","0.0","","","","4541.5908203125","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 4 | "2021-04-01 20:02:49","vm-01","11.545622825622559","0.32466667890548706","0.0","","0.0","0.0","","","","4386.72412109375","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 5 | "2021-04-01 20:07:49","vm-01","12.421062469482422","0.3269999921321869","0.0","","0.0","0.0","","","","4382.92431640625","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 6 | "2021-04-01 20:12:49","vm-01","13.043869972229004","0.3386666774749756","0.0","","0.0","0.0","","","","4495.45751953125","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 7 | "2021-04-01 20:17:49","vm-01","13.250887870788574","0.3333333432674408","0.0","","0.0","0.0","","","","4432.65771484375","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 8 | "2021-04-01 20:22:49","vm-01","11.89299201965332","0.31933334469795227","0.0","","0.0","0.0","","","","4389.5244140625","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 9 | "2021-04-01 20:27:49","vm-01","17.008785247802734","0.312333345413208","0.0","","0.0","0.0","","","","4702.45751953125","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 10 | "2021-04-01 20:32:49","vm-01","13.140361785888672","0.32633334398269653","0.0","","0.0","0.0","","","","4451.1240234375","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 11 | "2021-04-01 20:37:49","vm-01","12.540360450744629","0.31583333015441895","0.0","","0.0","0.0","","","","4406.39111328125","Other 3.x or later Linux (64-bit)","Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 12 | -------------------------------------------------------------------------------- /src/test/resources/elastic-all.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VMWARE:VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | outputFormat: json 5 | dateFormat: "yyyy-MM-dd HH:mm:ss" 6 | jsonConfig: 7 | format: elastic 8 | allMetrics: true -------------------------------------------------------------------------------- /src/test/resources/elastic-output.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "resourceName": "vm-01", 5 | "t": "2021-04-01 19:52:49", 6 | "cpuReady": 0.3231666684150696, 7 | "memDemand": 2325319.0, 8 | "vmUsed": 25.214244842529297, 9 | "cpuDemand": 11.801763534545898, 10 | "cpuCostop": 0.0, 11 | "memSwapOut": 0.0, 12 | "hostCPUDemand": 4360.72412109375, 13 | "memSwapIn": 0.0 14 | }, 15 | { 16 | "resourceName": "vm-01", 17 | "t": "2021-04-01 19:57:49", 18 | "cpuReady": 0.32100000977516174, 19 | "memDemand": 2522173.5, 20 | "vmUsed": 25.214569091796875, 21 | "cpuDemand": 13.871940612792969, 22 | "cpuCostop": 0.0, 23 | "memSwapOut": 0.0, 24 | "hostCPUDemand": 4541.5908203125, 25 | "memSwapIn": 0.0 26 | }, 27 | { 28 | "resourceName": "vm-01", 29 | "t": "2021-04-01 20:02:49", 30 | "cpuReady": 0.32466667890548706, 31 | "memDemand": 2762087.0, 32 | "vmUsed": 25.214569091796875, 33 | "cpuDemand": 11.545622825622559, 34 | "cpuCostop": 0.0, 35 | "memSwapOut": 0.0, 36 | "hostCPUDemand": 4386.72412109375, 37 | "memSwapIn": 0.0 38 | }, 39 | { 40 | "resourceName": "vm-01", 41 | "t": "2021-04-01 20:07:49", 42 | "cpuReady": 0.3269999921321869, 43 | "memDemand": 2602143.75, 44 | "vmUsed": 25.214569091796875, 45 | "cpuDemand": 12.421062469482422, 46 | "cpuCostop": 0.0, 47 | "memSwapOut": 0.0, 48 | "hostCPUDemand": 4382.92431640625, 49 | "memSwapIn": 0.0 50 | }, 51 | { 52 | "resourceName": "vm-01", 53 | "t": "2021-04-01 20:12:49", 54 | "cpuReady": 0.3386666774749756, 55 | "memDemand": 2977395.5, 56 | "vmUsed": 25.215293884277344, 57 | "cpuDemand": 13.043869972229004, 58 | "cpuCostop": 0.0, 59 | "memSwapOut": 0.0, 60 | "hostCPUDemand": 4495.45751953125, 61 | "memSwapIn": 0.0 62 | }, 63 | { 64 | "resourceName": "vm-01", 65 | "t": "2021-04-01 20:17:49", 66 | "cpuReady": 0.3333333432674408, 67 | "memDemand": 2866666.0, 68 | "vmUsed": 25.215293884277344, 69 | "cpuDemand": 13.250887870788574, 70 | "cpuCostop": 0.0, 71 | "memSwapOut": 0.0, 72 | "hostCPUDemand": 4432.65771484375, 73 | "memSwapIn": 0.0 74 | }, 75 | { 76 | "resourceName": "vm-01", 77 | "t": "2021-04-01 20:22:49", 78 | "cpuReady": 0.31933334469795227, 79 | "memDemand": 2405292.0, 80 | "vmUsed": 25.215293884277344, 81 | "cpuDemand": 11.89299201965332, 82 | "cpuCostop": 0.0, 83 | "memSwapOut": 0.0, 84 | "hostCPUDemand": 4389.5244140625, 85 | "memSwapIn": 0.0 86 | }, 87 | { 88 | "resourceName": "vm-01", 89 | "t": "2021-04-01 20:27:49", 90 | "cpuReady": 0.312333345413208, 91 | "memDemand": 2842058.5, 92 | "vmUsed": 25.214988708496094, 93 | "cpuDemand": 17.008785247802734, 94 | "cpuCostop": 0.0, 95 | "memSwapOut": 0.0, 96 | "hostCPUDemand": 4702.45751953125, 97 | "memSwapIn": 0.0 98 | }, 99 | { 100 | "resourceName": "vm-01", 101 | "t": "2021-04-01 20:32:49", 102 | "cpuReady": 0.32633334398269653, 103 | "memDemand": 3377251.75, 104 | "vmUsed": 25.214988708496094, 105 | "cpuDemand": 13.140361785888672, 106 | "cpuCostop": 0.0, 107 | "memSwapOut": 0.0, 108 | "hostCPUDemand": 4451.1240234375, 109 | "memSwapIn": 0.0 110 | }, 111 | { 112 | "resourceName": "vm-01", 113 | "t": "2021-04-01 20:37:49", 114 | "cpuReady": 0.31583333015441895, 115 | "memDemand": 2731329.0, 116 | "vmUsed": 25.214988708496094, 117 | "cpuDemand": 12.540360450744629, 118 | "cpuCostop": 0.0, 119 | "memSwapOut": 0.0, 120 | "hostCPUDemand": 4406.39111328125, 121 | "memSwapIn": 0.0 122 | } 123 | ] 124 | } -------------------------------------------------------------------------------- /src/test/resources/elastic.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VMWARE:VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | outputFormat: json 5 | dateFormat: "yyyy-MM-dd HH:mm:ss" 6 | jsonConfig: 7 | format: elastic 8 | fields: 9 | - alias: resourceId 10 | prop: $resId 11 | # CPU fields 12 | - alias: cpuDemand 13 | metric: cpu|demandPct 14 | - alias: cpuReady 15 | metric: cpu|readyPct 16 | - alias: cpuCostop 17 | metric: cpu|costopPct 18 | # Memory fields 19 | - alias: memDemand 20 | metric: mem|guest_demand 21 | - alias: memSwapOut 22 | metric: mem|swapoutRate_average 23 | - alias: memSwapIn 24 | metric: mem|swapinRate_average 25 | # Storage fields 26 | - alias: storageDemandKbps 27 | metric: storage|demandKBps 28 | # Diskspace fields 29 | - alias: vmUsed 30 | metric: diskspace|used 31 | # Network fields 32 | - alias: netBytesRx 33 | metric: net|bytesRx_average 34 | - alias: netBytesTx 35 | metric: net|bytesTx_average 36 | # Host CPU 37 | - alias: hostCPUDemand 38 | metric: $parent:HostSystem.cpu|demandmhz 39 | # Guest OS 40 | - alias: guestOS 41 | prop: config|guestFullName 42 | # Host CPU type 43 | - alias: hostCPUType 44 | prop: $parent:HostSystem.cpu|cpuModel -------------------------------------------------------------------------------- /src/test/resources/hostprops.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceId": "e21f1a97-40a4-4e14-ada8-d7ec659f0cf1", 3 | "property": [ 4 | { 5 | "name": "config|diskSpace", 6 | "value": "1.697517678592E12" 7 | }, 8 | { 9 | "name": "config|hyperThread|active", 10 | "value": "true" 11 | }, 12 | { 13 | "name": "config|hyperThread|available", 14 | "value": "true" 15 | }, 16 | { 17 | "name": "config|name", 18 | "value": "192.168.1.214" 19 | }, 20 | { 21 | "name": "config|network|dnsserver", 22 | "value": "[192.168.1.150]" 23 | }, 24 | { 25 | "name": "config|network|linkspeed", 26 | "value": "1000.0" 27 | }, 28 | { 29 | "name": "config|network|nnic", 30 | "value": "4.0" 31 | }, 32 | { 33 | "name": "config|product|apiVersion", 34 | "value": "7.0.0.0" 35 | }, 36 | { 37 | "name": "config|product|productLineId", 38 | "value": "embeddedEsx" 39 | }, 40 | { 41 | "name": "config|security|enable_mob", 42 | "value": "false" 43 | }, 44 | { 45 | "name": "config|security|service:ESXi Shell|isRunning", 46 | "value": "false" 47 | }, 48 | { 49 | "name": "config|security|service:NTP Daemon|isRunning", 50 | "value": "true" 51 | }, 52 | { 53 | "name": "config|security|service:SNMP Server|isRunning", 54 | "value": "false" 55 | }, 56 | { 57 | "name": "config|security|service:SSH|isRunning", 58 | "value": "false" 59 | }, 60 | { 61 | "name": "config|security|tlsDisabledProtocols", 62 | "value": "sslv3,tlsv1,tlsv1.1" 63 | }, 64 | { 65 | "name": "config|storageDevice|multipathInfo|multipathPolicy", 66 | "value": "[LUN-0562e6d1de699a55bacf60af3ce58ba34f79c2efc94f9df875aaabfb37d9198e49 : VMW_PSP_FIXED, LUN-0000000000766d68626133323a303a30 : VMW_PSP_FIXED, LUN-0005010000766d68626133323a303a31 : VMW_PSP_FIXED, LUN-0100000000533252454e58304a3630353631314b202020202053616d73756e : VMW_PSP_FIXED]" 67 | }, 68 | { 69 | "name": "config|storageDevice|multipathInfo|numberofActivePath", 70 | "value": "4.0" 71 | }, 72 | { 73 | "name": "config|storageDevice|plugStoreTopology|numberofPath", 74 | "value": "4.0" 75 | }, 76 | { 77 | "name": "cost|remainingDepreciationMonths", 78 | "value": "42" 79 | }, 80 | { 81 | "name": "cost|serverIsLeased", 82 | "value": "false" 83 | }, 84 | { 85 | "name": "cost|serverPurchaseCost", 86 | "value": "3849.970427967449" 87 | }, 88 | { 89 | "name": "cost|serverPurchaseDate", 90 | "value": "2019-10-01" 91 | }, 92 | { 93 | "name": "cpu|cpuModel", 94 | "value": "Intel(R) Xeon(R) CPU D-1528 @ 1.90GHz" 95 | }, 96 | { 97 | "name": "cpu|speed", 98 | "value": "11399.990886" 99 | }, 100 | { 101 | "name": "hardware|biosVersion", 102 | "value": "1.2a" 103 | }, 104 | { 105 | "name": "hardware|cpuInfo|hz", 106 | "value": "1.899998481E9" 107 | }, 108 | { 109 | "name": "hardware|cpuInfo|numCpuCores", 110 | "value": "6.0" 111 | }, 112 | { 113 | "name": "hardware|cpuInfo|numCpuPackages", 114 | "value": "1.0" 115 | }, 116 | { 117 | "name": "hardware|enclosureSerialNumberTag", 118 | "value": "C101FAG09050410" 119 | }, 120 | { 121 | "name": "hardware|memorySize", 122 | "value": "6.70035E7" 123 | }, 124 | { 125 | "name": "hardware|powerManagementPolicy", 126 | "value": "Balanced" 127 | }, 128 | { 129 | "name": "hardware|powerManagementTechnoloy", 130 | "value": "ACPI P-states" 131 | }, 132 | { 133 | "name": "hardware|serialNumberTag", 134 | "value": "S243907X7643867" 135 | }, 136 | { 137 | "name": "hardware|serviceTag", 138 | "value": "S243907X7643867" 139 | }, 140 | { 141 | "name": "hardware|vendor", 142 | "value": "Supermicro" 143 | }, 144 | { 145 | "name": "hardware|vendorModel", 146 | "value": "Supermicro SYS-E200-8D" 147 | }, 148 | { 149 | "name": "net:vmk0|ip_address", 150 | "value": "192.168.1.214" 151 | }, 152 | { 153 | "name": "net:vmnic0|nicDriver", 154 | "value": "igbn" 155 | }, 156 | { 157 | "name": "net:vmnic0|speed", 158 | "value": "1000.0" 159 | }, 160 | { 161 | "name": "net:vmnic1|nicDriver", 162 | "value": "igbn" 163 | }, 164 | { 165 | "name": "net:vmnic1|speed", 166 | "value": "1000.0" 167 | }, 168 | { 169 | "name": "net:vmnic2|nicDriver", 170 | "value": "ixgben" 171 | }, 172 | { 173 | "name": "net:vmnic3|nicDriver", 174 | "value": "ixgben" 175 | }, 176 | { 177 | "name": "net|mgmt_address", 178 | "value": "192.168.1.214" 179 | }, 180 | { 181 | "name": "runtime|connectionState", 182 | "value": "connected" 183 | }, 184 | { 185 | "name": "runtime|maintenanceState", 186 | "value": "notInMaintenance" 187 | }, 188 | { 189 | "name": "runtime|memoryCap", 190 | "value": "1.15237996E8" 191 | }, 192 | { 193 | "name": "runtime|powerState", 194 | "value": "Powered On" 195 | }, 196 | { 197 | "name": "storageAdapter:vmhba0|hbaDriver", 198 | "value": "vmw_ahci" 199 | }, 200 | { 201 | "name": "storageAdapter:vmhba1|hbaDriver", 202 | "value": "nvme_pcie" 203 | }, 204 | { 205 | "name": "storageAdapter:vmhba32|hbaDriver", 206 | "value": "vmkusb" 207 | }, 208 | { 209 | "name": "summary|folder", 210 | "value": "" 211 | }, 212 | { 213 | "name": "summary|hostuuid", 214 | "value": "00000000-0000-0000-0000-ac1f6b149ee0" 215 | }, 216 | { 217 | "name": "summary|parentCluster", 218 | "value": "Workload" 219 | }, 220 | { 221 | "name": "summary|parentDatacenter", 222 | "value": "PONTUS.LAB" 223 | }, 224 | { 225 | "name": "summary|parentVcenter", 226 | "value": "vc-01" 227 | }, 228 | { 229 | "name": "summary|tag", 230 | "value": "none" 231 | }, 232 | { 233 | "name": "summary|tagJson", 234 | "value": "none" 235 | }, 236 | { 237 | "name": "summary|version", 238 | "value": "7.0.0-15843807" 239 | }, 240 | { 241 | "name": "System Properties|resource_kind_subtype", 242 | "value": "GENERAL" 243 | }, 244 | { 245 | "name": "System Properties|resource_kind_type", 246 | "value": "GENERAL" 247 | }, 248 | { 249 | "name": "sys|build", 250 | "value": "15843807" 251 | }, 252 | { 253 | "name": "sys|productString", 254 | "value": "VMware ESXi" 255 | } 256 | ] 257 | } -------------------------------------------------------------------------------- /src/test/resources/hostresource.json: -------------------------------------------------------------------------------- 1 | { 2 | "creationTime": 1607549811918, 3 | "resourceKey": { 4 | "name": "MyHost", 5 | "adapterKindKey": "VMWARE", 6 | "resourceKindKey": "HostSystem", 7 | "resourceIdentifiers": [ 8 | { 9 | "identifierType": { 10 | "name": "isPingEnabled", 11 | "dataType": "STRING", 12 | "isPartOfUniqueness": false 13 | }, 14 | "value": "" 15 | }, 16 | { 17 | "identifierType": { 18 | "name": "VMEntityName", 19 | "dataType": "STRING", 20 | "isPartOfUniqueness": false 21 | }, 22 | "value": "MyHost" 23 | }, 24 | { 25 | "identifierType": { 26 | "name": "VMEntityObjectID", 27 | "dataType": "STRING", 28 | "isPartOfUniqueness": true 29 | }, 30 | "value": "host-29" 31 | }, 32 | { 33 | "identifierType": { 34 | "name": "VMEntityVCID", 35 | "dataType": "STRING", 36 | "isPartOfUniqueness": true 37 | }, 38 | "value": "e72d25a1-2fb9-4d94-9a3d-6c5db7e9efc0" 39 | } 40 | ] 41 | }, 42 | "resourceStatusStates": [ 43 | { 44 | "adapterInstanceId": "8eca2eac-aa9d-4b5d-88b8-df28f53dce27", 45 | "resourceStatus": "DATA_RECEIVING", 46 | "resourceState": "STARTED", 47 | "statusMessage": "" 48 | } 49 | ], 50 | "resourceHealth": "GREEN", 51 | "resourceHealthValue": 100, 52 | "dtEnabled": true, 53 | "badges": [ 54 | { 55 | "type": "COMPLIANCE", 56 | "color": "GREY", 57 | "score": -1 58 | }, 59 | { 60 | "type": "WORKLOAD", 61 | "color": "GREEN", 62 | "score": 59.292086930782226 63 | }, 64 | { 65 | "type": "HEALTH", 66 | "color": "GREEN", 67 | "score": 100 68 | }, 69 | { 70 | "type": "RISK", 71 | "color": "GREEN", 72 | "score": 0 73 | }, 74 | { 75 | "type": "CAPACITY_REMAINING", 76 | "color": "GREEN", 77 | "score": 10.015440353829069 78 | }, 79 | { 80 | "type": "TIME_REMAINING", 81 | "color": "GREEN", 82 | "score": 366 83 | }, 84 | { 85 | "type": "EFFICIENCY", 86 | "color": "GREEN", 87 | "score": 100 88 | } 89 | ], 90 | "relatedResources": [], 91 | "identifier": "e21f1a97-40a4-4e14-ada8-d7ec659f0cf1" 92 | } -------------------------------------------------------------------------------- /src/test/resources/invalid.yaml: -------------------------------------------------------------------------------- 1 | rollupType: AVG 2 | rollupMinutes: 5 3 | dateFormat: "yyyy-MM-dd HH:mm:ss" 4 | fields: 5 | # CPU fields 6 | - alias: cpuDemand 7 | metric: cpu|demandPct 8 | - alias: cpuReady 9 | metric: cpu|readyPct 10 | - alias: cpuCostop 11 | metric: cpu|costopPct 12 | # Memory fields 13 | - alias: memDemand 14 | metric: mem|guestDemand 15 | - alias: memSwapOut 16 | metric: mem|swapoutRate_average 17 | - alias: memSwapIn 18 | metric: mem|swapinRate_average 19 | # Storage fields 20 | - alias: storageDemandKbps 21 | metric: storage|demandKBps 22 | # Network fields 23 | - alias: netBytesRx 24 | metric: net|bytesRx_average 25 | - alias: netBytesTx 26 | metric: net|bytesTx_average 27 | # Host CPU 28 | - alias: hostCPUDemand 29 | metric: $parent:HostSystem.cpu|demandmhz 30 | # Guest OS 31 | - alias: guestOS 32 | prop: config|guestFullName 33 | # Host CPU type 34 | - alias: hostCPUType 35 | prop: $parent:HostSystem.cpu|cpuModel 36 | -------------------------------------------------------------------------------- /src/test/resources/statkeys.json: -------------------------------------------------------------------------------- 1 | [ 2 | "performance|number_of_kpis_breached", 3 | "mem|host_contentionPct", 4 | "mem|guest_usage", 5 | "guestfilesystem|usage_total", 6 | "mem|vmMemoryDemand", 7 | "guest|page.inRate_latest", 8 | "mem|workload", 9 | "cost|effectiveTotalCost", 10 | "cost|monthlyProjectedCost", 11 | "cpu|usage_average", 12 | "cost|directCost", 13 | "cpu|demandPct", 14 | "diskspace:46|perDsUsed", 15 | "cost|effectiveDailyStorageCost", 16 | "virtualDisk:scsi0:1|numberReadAveraged_average", 17 | "diskspace|snapshot", 18 | "cost|dailyAdditionalCost", 19 | "cost|effectiveDailyCpuCost", 20 | "cpu|capacity_contentionPct", 21 | "cost|effectiveDailyMemoryCost", 22 | "cost|effectiveProjectedTotalCost", 23 | "virtualDisk:Aggregate of all instances|numberReadAveraged_average", 24 | "cost|monthlyTotalCost", 25 | "net|transmitted_average", 26 | "virtualDisk:Aggregate of all instances|totalWriteLatency_average", 27 | "guestfilesystem:/storage/log|percentage", 28 | "mem|overhead_average", 29 | "guestfilesystem:/boot|usage", 30 | "guestfilesystem:/storage/core|capacity", 31 | "net|received_average", 32 | "sys|osUptime_latest", 33 | "virtualDisk:Aggregate of all instances|usage", 34 | "guestfilesystem:/|usage", 35 | "net:Aggregate of all instances|packetsRxPerSec", 36 | "mem|balloonPct", 37 | "virtualDisk:scsi0:0|numberWriteAveraged_average", 38 | "OnlineCapacityAnalytics|mem|timeRemaining", 39 | "guestfilesystem|capacity_total", 40 | "OnlineCapacityAnalytics|mem|recommendedSize", 41 | "datastore:Aggregate of all instances|totalWriteLatency_average", 42 | "OnlineCapacityAnalytics|mem|capacityRemaining", 43 | "OnlineCapacityAnalytics|timeRemaining", 44 | "diskspace|notshared", 45 | "mem|consumed_average_daily", 46 | "diskspace|workload", 47 | "virtualDisk:scsi0:0|read_average", 48 | "diskspace-total|workload", 49 | "cpu|usagemhz_average_daily", 50 | "mem-host|workload", 51 | "guestfilesystem|percentage_total", 52 | "sys|poweredOn", 53 | "summary|running", 54 | "net|droppedTx_summation", 55 | "virtualDisk|peak_vDisk_iops", 56 | "net|broadcastTx_summation", 57 | "guest|contextSwapRate_latest", 58 | "cpu|iowaitPct", 59 | "guestfilesystem:/boot|capacity", 60 | "virtualDisk|write_average", 61 | "summary|poweredOff", 62 | "virtualDisk|peak_vDisk_readLatency", 63 | "summary|idle", 64 | "summary|snapshotSpace", 65 | "guest|mem.physUsable_latest", 66 | "net|broadcastTx_summation_sum", 67 | "cpu|readyPct", 68 | "config|hardware|disk_Space", 69 | "System Attributes|health", 70 | "System Attributes|all_metrics", 71 | "datastore|numberWriteAveraged_average", 72 | "System Attributes|child_all_metrics", 73 | "cpu|effective_limit", 74 | "System Attributes|total_alarms", 75 | "summary|oversized", 76 | "System Attributes|availability", 77 | "summary|oversized|memory", 78 | "System Attributes|alert_count_critical", 79 | "summary|undersized|vcpus", 80 | "System Attributes|alert_count_immediate", 81 | "summary|undersized|memory", 82 | "System Attributes|alert_count_warning", 83 | "summary|oversized|vcpus", 84 | "rescpu|actav5_latest", 85 | "System Attributes|alert_count_info", 86 | "summary|undersized", 87 | "System Attributes|total_alert_count", 88 | "System Attributes|self_alert_count", 89 | "rescpu|actav1_latest", 90 | "badge|health", 91 | "mem|usage_average", 92 | "virtualDisk:scsi0:2|numberReadAveraged_average", 93 | "mem|swapped_average", 94 | "mem|guest_provisioned", 95 | "datastore:Aggregate of all instances|usage_average", 96 | "datastore:Aggregate of all instances|totalLatency_average", 97 | "badge|workload", 98 | "guestfilesystem:/storage/log|capacity", 99 | "guestfilesystem:/storage/db|percentage", 100 | "guest|tools_running_status", 101 | "virtualDisk:scsi0:1|numberWriteAveraged_average", 102 | "cost|effectiveDailyCost", 103 | "mem|nonzero_active", 104 | "virtualDisk:scsi0:2|numberWriteAveraged_average", 105 | "guestfilesystem:/storage/core|percentage", 106 | "cpu|peak_vcpu_ready", 107 | "config|hardware|num_Cpu", 108 | "mem|swapinRate_average", 109 | "guestfilesystem:/storage/log|usage", 110 | "net|multicastTx_summation", 111 | "datastore:Aggregate of all instances|commandsAveraged_average", 112 | "mem|consumed_average", 113 | "cost|allocation|allocationBasedTotalCost", 114 | "cost|allocation|allocationBasedTotalMTDCost", 115 | "virtualDisk:scsi0:1|write_average", 116 | "virtualDisk:scsi0:1|totalReadLatency_average", 117 | "badge|compliance", 118 | "storage|totalReadLatency_average", 119 | "badge|risk", 120 | "guest|mem.needed_latest", 121 | "badge|efficiency", 122 | "guestfilesystem:/storage/db|usage", 123 | "cpu|overlap_summation", 124 | "guest|page.size_latest", 125 | "cpu|usagemhz_average", 126 | "net|multicastTx_summation_sum", 127 | "virtualDisk|peak_vDisk_writeLatency", 128 | "guestfilesystem:/|capacity", 129 | "virtualDisk|read_average", 130 | "virtualDisk:Aggregate of all instances|commandsAveraged_average", 131 | "net|droppedTx_summation_sum", 132 | "guestfilesystem:/storage/core|usage", 133 | "net:Aggregate of all instances|packetsTxPerSec", 134 | "mem|swapoutRate_average", 135 | "datastore|read_average", 136 | "storage|totalWriteLatency_average", 137 | "mem|host_demand", 138 | "datastore|write_average", 139 | "mem|effective_limit", 140 | "mem|reservation_used", 141 | "virtualDisk:scsi0:2|totalWriteLatency_average", 142 | "cpu|run_summation", 143 | "cpu|corecount_provisioned", 144 | "virtualDisk:scsi0:2|write_average", 145 | "virtualDisk:scsi0:1|totalWriteLatency_average", 146 | "virtualDisk:scsi0:2|read_average", 147 | "diskspace|activeNotShared", 148 | "guestfilesystem:/|percentage", 149 | "mem|compressed_average", 150 | "net|usage_average", 151 | "cpu|vm_capacity_provisioned", 152 | "virtualDisk:scsi0:0|totalWriteLatency_average", 153 | "virtualDisk:scsi0:0|totalReadLatency_average", 154 | "datastore:Aggregate of all instances|totalReadLatency_average", 155 | "virtualDisk:Aggregate of all instances|vDiskOIO", 156 | "cpu|swapwaitPct", 157 | "guest|swap.spaceRemaining_latest", 158 | "cpu|demandmhz", 159 | "cpu|vcpu_usage_disparity", 160 | "virtualDisk:scsi0:2|totalReadLatency_average", 161 | "virtualDisk:scsi0:0|numberReadAveraged_average", 162 | "mem|guest_demand", 163 | "guest|cpu_queue", 164 | "guest|disk_queue", 165 | "guest|mem.free_latest", 166 | "cpu|workload", 167 | "OnlineCapacityAnalytics|capacityRemainingPercentage", 168 | "OnlineCapacityAnalytics|cpu|timeRemaining", 169 | "OnlineCapacityAnalytics|cpu|recommendedSize", 170 | "OnlineCapacityAnalytics|cpu|capacityRemaining", 171 | "OnlineCapacityAnalytics|diskspace|timeRemaining", 172 | "OnlineCapacityAnalytics|diskspace|recommendedSize", 173 | "virtualDisk:Aggregate of all instances|numberWriteAveraged_average", 174 | "OnlineCapacityAnalytics|diskspace|capacityRemaining", 175 | "virtualDisk:Aggregate of all instances|totalLatency", 176 | "diskspace|snapshot|used", 177 | "cpu|peak_vcpu_usage", 178 | "cpu|costopPct", 179 | "datastore|demand_oio", 180 | "diskspace|used", 181 | "mem|consumedPct", 182 | "virtualDisk:scsi0:0|write_average", 183 | "guest|page.outRate_latest", 184 | "virtualDisk:Aggregate of all instances|totalReadLatency_average", 185 | "virtualDisk:scsi0:1|read_average", 186 | "guestfilesystem:/boot|percentage", 187 | "diskspace|provisionedSpace", 188 | "mem|overheadMax_average", 189 | "datastore|numberReadAveraged_average", 190 | "net:Aggregate of all instances|droppedPct", 191 | "guestfilesystem:/storage/db|capacity" 192 | ] -------------------------------------------------------------------------------- /src/test/resources/vmfields.yaml: -------------------------------------------------------------------------------- 1 | resourceType: VirtualMachine 2 | rollupType: AVG 3 | rollupMinutes: 5 4 | dateFormat: "yyyy-MM-dd HH:mm:ss" 5 | fields: 6 | # CPU fields 7 | - alias: cpuDemand 8 | metric: cpu|demandPct 9 | - alias: cpuReady 10 | metric: cpu|readyPct 11 | - alias: cpuCostop 12 | metric: cpu|costopPct 13 | # Memory fields 14 | - alias: memDemand 15 | metric: mem|guestDemand 16 | - alias: memSwapOut 17 | metric: mem|swapoutRate_average 18 | - alias: memSwapIn 19 | metric: mem|swapinRate_average 20 | # Storage fields 21 | - alias: storageDemandKbps 22 | metric: storage|demandKBps 23 | # Network fields 24 | - alias: netBytesRx 25 | metric: net|bytesRx_average 26 | - alias: netBytesTx 27 | metric: net|bytesTx_average 28 | # Host CPU 29 | - alias: hostCPUDemand 30 | metric: $parent:HostSystem.cpu|demandmhz 31 | # Guest OS 32 | - alias: guestOS 33 | prop: config|guestFullName 34 | # Host CPU type 35 | - alias: hostCPUType 36 | prop: $parent:HostSystem.cpu|cpuModel 37 | -------------------------------------------------------------------------------- /src/test/resources/vmprops.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceId": "60508ea6-287b-42be-953c-1554e506cdc1", 3 | "property": [ 4 | { 5 | "name": "config|cpuAllocation|limit", 6 | "value": "-1.0" 7 | }, 8 | { 9 | "name": "config|cpuAllocation|reservation", 10 | "value": "0.0" 11 | }, 12 | { 13 | "name": "config|cpuAllocation|shares|shares", 14 | "value": "2000.0" 15 | }, 16 | { 17 | "name": "config|createDate", 18 | "value": "1.605638984865E12" 19 | }, 20 | { 21 | "name": "config|extraConfig|mem_hotadd", 22 | "value": "false" 23 | }, 24 | { 25 | "name": "config|extraConfig|vcpu_hotadd", 26 | "value": "false" 27 | }, 28 | { 29 | "name": "config|extraConfig|vcpu_hotremove", 30 | "value": "false" 31 | }, 32 | { 33 | "name": "config|guestFullName", 34 | "value": "Other 3.x or later Linux (64-bit)" 35 | }, 36 | { 37 | "name": "config|hardware|diskSpace", 38 | "value": "274.0" 39 | }, 40 | { 41 | "name": "config|hardware|memoryKB", 42 | "value": "8388608.0" 43 | }, 44 | { 45 | "name": "config|hardware|numCoresPerSocket", 46 | "value": "1.0" 47 | }, 48 | { 49 | "name": "config|hardware|numCpu", 50 | "value": "2.0" 51 | }, 52 | { 53 | "name": "config|hardware|numSockets", 54 | "value": "2.0" 55 | }, 56 | { 57 | "name": "config|hardware|thinEnabled", 58 | "value": "true" 59 | }, 60 | { 61 | "name": "config|memoryAllocation|limit", 62 | "value": "-1.0" 63 | }, 64 | { 65 | "name": "config|memoryAllocation|reservation", 66 | "value": "0.0" 67 | }, 68 | { 69 | "name": "config|memoryAllocation|shares|shares", 70 | "value": "81920.0" 71 | }, 72 | { 73 | "name": "config|name", 74 | "value": "vrops-02" 75 | }, 76 | { 77 | "name": "config|numVMDKs", 78 | "value": "3.0" 79 | }, 80 | { 81 | "name": "config|version", 82 | "value": "vmx-11" 83 | }, 84 | { 85 | "name": "cpu|limit", 86 | "value": "-1.0" 87 | }, 88 | { 89 | "name": "cpu|reservation", 90 | "value": "0.0" 91 | }, 92 | { 93 | "name": "cpu|speed", 94 | "value": "3.799996962E9" 95 | }, 96 | { 97 | "name": "mem|guestOSMemNotCollecting", 98 | "value": "0.0" 99 | }, 100 | { 101 | "name": "mem|host_limit", 102 | "value": "-1.0" 103 | }, 104 | { 105 | "name": "net:4000|ip_address", 106 | "value": "192.168.1.178" 107 | }, 108 | { 109 | "name": "net:4000|mac_address", 110 | "value": "00:50:56:a2:80:3e" 111 | }, 112 | { 113 | "name": "runtime|memoryCap", 114 | "value": "8388608.0" 115 | }, 116 | { 117 | "name": "summary|config|appliance", 118 | "value": "false" 119 | }, 120 | { 121 | "name": "summary|config|isSrmPlaceholder", 122 | "value": "false" 123 | }, 124 | { 125 | "name": "summary|config|isTemplate", 126 | "value": "false" 127 | }, 128 | { 129 | "name": "summary|config|numEthernetCards", 130 | "value": "1.0" 131 | }, 132 | { 133 | "name": "summary|config|productName", 134 | "value": "vRealize Operations Manager Appliance" 135 | }, 136 | { 137 | "name": "summary|config|type", 138 | "value": "default" 139 | }, 140 | { 141 | "name": "summary|datastore", 142 | "value": "freenas" 143 | }, 144 | { 145 | "name": "summary|folder", 146 | "value": "" 147 | }, 148 | { 149 | "name": "summary|guest|fullName", 150 | "value": "VMware Photon OS (64-bit)" 151 | }, 152 | { 153 | "name": "summary|guest|hostName", 154 | "value": "vrops-02.pontus.lab" 155 | }, 156 | { 157 | "name": "summary|guest|ipAddress", 158 | "value": "192.168.1.178" 159 | }, 160 | { 161 | "name": "summary|guest|toolsRunningStatus", 162 | "value": "Guest Tools Running" 163 | }, 164 | { 165 | "name": "summary|guest|toolsVersion", 166 | "value": "11.1.0" 167 | }, 168 | { 169 | "name": "summary|guest|toolsVersionStatus2", 170 | "value": "Guest Tools Unmanaged" 171 | }, 172 | { 173 | "name": "summary|MOID", 174 | "value": "vm-7068" 175 | }, 176 | { 177 | "name": "summary|parentCluster", 178 | "value": "Workload" 179 | }, 180 | { 181 | "name": "summary|parentDatacenter", 182 | "value": "PONTUS.LAB" 183 | }, 184 | { 185 | "name": "summary|parentFolder", 186 | "value": "vm" 187 | }, 188 | { 189 | "name": "summary|parentHost", 190 | "value": "192.168.1.214" 191 | }, 192 | { 193 | "name": "summary|parentVcenter", 194 | "value": "vc-01" 195 | }, 196 | { 197 | "name": "summary|runtime|connectionState", 198 | "value": "connected" 199 | }, 200 | { 201 | "name": "summary|runtime|isIdle", 202 | "value": "0.0" 203 | }, 204 | { 205 | "name": "summary|runtime|powerState", 206 | "value": "Powered On" 207 | }, 208 | { 209 | "name": "summary|tag", 210 | "value": "none" 211 | }, 212 | { 213 | "name": "summary|tagJson", 214 | "value": "none" 215 | }, 216 | { 217 | "name": "summary|UUID", 218 | "value": "5022b9df-05d9-cd8e-7f4e-5dbecd5ef95c" 219 | }, 220 | { 221 | "name": "System Properties|resource_kind_subtype", 222 | "value": "GENERAL" 223 | }, 224 | { 225 | "name": "System Properties|resource_kind_type", 226 | "value": "GENERAL" 227 | }, 228 | { 229 | "name": "virtualDisk:scsi0:0|configuredGB", 230 | "value": "20.0" 231 | }, 232 | { 233 | "name": "virtualDisk:scsi0:0|datastore", 234 | "value": "freenas" 235 | }, 236 | { 237 | "name": "virtualDisk:scsi0:0|label", 238 | "value": "Hard disk 1" 239 | }, 240 | { 241 | "name": "virtualDisk:scsi0:1|configuredGB", 242 | "value": "250.0" 243 | }, 244 | { 245 | "name": "virtualDisk:scsi0:1|datastore", 246 | "value": "freenas" 247 | }, 248 | { 249 | "name": "virtualDisk:scsi0:1|label", 250 | "value": "Hard disk 2" 251 | }, 252 | { 253 | "name": "virtualDisk:scsi0:2|configuredGB", 254 | "value": "4.0" 255 | }, 256 | { 257 | "name": "virtualDisk:scsi0:2|datastore", 258 | "value": "freenas" 259 | }, 260 | { 261 | "name": "virtualDisk:scsi0:2|label", 262 | "value": "Hard disk 3" 263 | } 264 | ] 265 | } -------------------------------------------------------------------------------- /vrops-export.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | --------------------------------------------------------------------------------