{"id":15648077,"url":"https://github.com/gerg/buildpack-data-collector","last_synced_at":"2025-03-29T23:28:51.943Z","repository":{"id":66446264,"uuid":"595343114","full_name":"Gerg/buildpack-data-collector","owner":"Gerg","description":"Collect data on what buildpacks are in use (and how) on a given Cloud Foundry deployment.","archived":false,"fork":false,"pushed_at":"2023-02-15T23:20:38.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T01:24:49.479Z","etag":null,"topics":["buildpacks","cloudfoundry"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gerg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T22:12:54.000Z","updated_at":"2023-02-13T21:42:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"b78e88c4-78bf-460e-afe0-7abbe934a868","html_url":"https://github.com/Gerg/buildpack-data-collector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gerg%2Fbuildpack-data-collector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gerg%2Fbuildpack-data-collector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gerg%2Fbuildpack-data-collector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gerg%2Fbuildpack-data-collector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gerg","download_url":"https://codeload.github.com/Gerg/buildpack-data-collector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246258885,"owners_count":20748573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buildpacks","cloudfoundry"],"created_at":"2024-10-03T12:23:11.610Z","updated_at":"2025-03-29T23:28:51.917Z","avatar_url":"https://github.com/Gerg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloud Foundry Buildpack Data Collector\nCollect data on what buildpacks are in use (and how) on a given Cloud Foundry\ndeployment. This tool is intended to help understand how easy it will be to\nmigrate Cloud Foundry applications to v3 buildpacks (aka [Cloud Native\nBuildpacks](https://buildpacks.io/)).\n\n## Usage\n\n### Requirements\n\nThis script depends on the following:\n- Python 3.5+\n- `cf` CLI targeting desired Cloud Foundry deployment and logged in as an\n  `admin` or `admin_read_only` user\n- Cloud Foundry version that includes the v3 API\n\n### Running\n\n1. Clone this repo\n1. `./main.py`\n\n### Output\n\nOutput will be in `./output.json` in your current working directory.\n\nData collected for all apps with state `STARTED`:\n- guid\n- lifecycle type (buildpack or docker)\n- lifecycle buildpacks (user-requested buildpacks)\n- lifecycle stack\n- current droplet's detected buildpack\n- environment variable names (in most cases, values are not collected)\n- environment variable values for a small set of buildpack-related variables (see below)\n- app service bindings (name, label, and tags)\n- matching start command fragments from the web process (see below)\n\nThe start command fragments that will be collected are (nothing else from\nprocess start commands are collected):\n- `open_jdk_jre/bin/java `\n- `springframework.boot.loader.JarLauncher`\n- `groovy/bin/groovy `\n- `spring_boot_cli/bin/spring run`\n- `tomcat/bin/catalina.sh run`\n\nThe following fields will be anonymized by taking a sha256 hash of the values:\n- app guids\n- environment variables (excluding a small set of buildpack-related variables (see below))\n- service binding names, labels, and tags\n\nThe un-anonymized environment variable names AND values that are collected are\nas follows:\n- `BP_PIP_VERSION` used by Python Buildpack\n- `CACHE_NUGET_PACKAGES` used by .NET Core Buildpack\n- `EXTENSIONS` used by PHP Buildpack\n- `GOVERSION` used by Go Buildpack\n- `JBP_CONFIG_COMPONENTS` used by Java Buildpack\n- `JBP_CONFIG_SPRING_AUTO_RECONFIGURATION` used by Java Buildpack\n- `JBP_DEFAULT_COMPONENTS` used by Java Buildpack\n- `NODE_ENV` used by Node.js Buildpack\n- `WEBDIR` used by PHP Buildpack\n- `WEB_CONCURRENCY` used by Node.js Buildpack\n- `WEB_MEMORY` used by Node.js Buildpack\n- `WEB_SERVER` used by PHP Buildpack\n\nExample output:\n```json\n[\n  {\n    \"guid\": \"51a53d85d9546ef8bdd34d47d44b322e4f6a8b0488ccce6f1e7a8ce48d4e51e1\",\n    \"lifecycle\": {\n      \"type\": \"buildpack\",\n      \"buildpacks\": [],\n      \"stack\": \"cflinuxfs3\"\n    },\n    \"current_droplet\": {\n      \"buildpacks\": [\n        {\n          \"name\": \"java_buildpack\",\n          \"detect_output\": \"java\",\n          \"buildpack_name\": \"java\",\n          \"version\": \"v4.53-https://github.com/cloudfoundry/java-buildpack#526dbcce\"\n        }\n      ]\n    },\n    \"env\": {\n      \"vcap_services\": [\n        {\n          \"name\": \"c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2\",\n          \"label\": \"6351e758fb69733d7d4ec5faea3cf7c2b1494db263eb0c0a2c889b2578114ec4\",\n          \"tags\": [\n            \"798f012674b5b8dcab4b00114bdf6738a69a4cdcf7ca0db1149260c9f81b73f7\"\n          ]\n        },\n        {\n          \"name\": \"be9b4c9674ae3932cf382b362458d6107e9433d1d9e05bef3eef187bb7785c05\",\n          \"label\": \"6351e758fb69733d7d4ec5faea3cf7c2b1494db263eb0c0a2c889b2578114ec4\",\n          \"tags\": [\n            \"798f012674b5b8dcab4b00114bdf6738a69a4cdcf7ca0db1149260c9f81b73f7\"\n          ]\n        }\n      ],\n      \"staging_env\": [\n        \"e919a75364398a449f860aeadddc57fa0502145a4e63959ddb33c417a48dc0da\",\n        \"JBP_DEFAULT_COMPONENTS={jres: [\\\"JavaBuildpack::Jre::ZuluJRE\\\"]}\",\n        \"a11b705f50010a321815b0a0aca534ab7aa89d597f32db9ffc7df459c8d61360\",\n        \"JBP_CONFIG_COMPONENTS={jres: [\\\"JavaBuildpack::Jre::OpenJdkJRE\\\"]}\",\n        \"JBP_CONFIG_SPRING_AUTO_RECONFIGURATION={enabled: false}\"\n      ],\n      \"running_env\": [\n        \"c071cf5f5ed6f884cc70155b6f05f755fd46a302d05e4261b7e92ce878bbfed8\",\n        \"JBP_DEFAULT_COMPONENTS={jres: [\\\"JavaBuildpack::Jre::ZuluJRE\\\"]}\",\n        \"a11b705f50010a321815b0a0aca534ab7aa89d597f32db9ffc7df459c8d61360\",\n        \"JBP_CONFIG_COMPONENTS={jres: [\\\"JavaBuildpack::Jre::OpenJdkJRE\\\"]}\",\n        \"JBP_CONFIG_SPRING_AUTO_RECONFIGURATION={enabled: false}\",\n        \"e919a75364398a449f860aeadddc57fa0502145a4e63959ddb33c417a48dc0da\"\n      ]\n    },\n    \"process\": {\n      \"command_fragments\": [\n        \"tomcat/bin/catalina.sh run\"\n      ]\n    }\n  }\n]\n```\n\n### Configuration\n\nEnvironment variables (set in the shell executing the script):\n\n|Var|Effect|\n|-|-|\n| `ANON_BP_VARS` | If set, anonymize buildpack-related environment variables. |\n| `BYPASS_ANON` | If set, do not anonymize fields. |\n\nUsage example:\n```sh\nBYPASS_ANON=1 ./main.py\n```\n\n## Running on Cloud Foundry\n\nFor a controlled environment with the required dependencies (python and cf\nCLI), you can run the script on a Cloud Foundry component VM as follows:\n\n1. ssh onto a bosh instance containing the cf CLI. A good way to get the CLI is\n   via the [`cf-cli` bosh\n   release](https://github.com/bosh-packages/cf-cli-release). For example, the\n   `compute` or `clock_global` instance in\n   [TAS](https://tanzu.vmware.com/application-service) (instance name depends\n   on configuration): `bosh ssh clock_global`\n1. Switch to the \"vcap\" user: `sudo su vcap`\n1. Change into a directory owned by vcap (so we can retrieve the output file\n   later). For example: `cd /var/vcap/data/cloud_controller_clock/tmp/`.\n1. Download this script: `wget https://raw.githubusercontent.com/Gerg/buildpack-data-collector/main/main.py`\n1. Make the script executable: `chmod +x main.py`\n1. Add the cf CLI to your path: `export PATH=\"$PATH:/var/vcap/packages/cf-cli-8-linux/bin\"`\n   (The exact path for the CLI may differ, depending on your deployment.)\n1. Target the desired Cloud Foundry API with the CLI: `cf api \u003ctarget api\u003e`\n1. Log in with\n   [admin_read_only](https://downey.io/notes/dev/create-cloud-foundry-read-only-admin/)\n   or admin credentials: `cf login`\n1. Execute the script: `./main.py`\n1. The script will generate an `output.json` in your current directory\n1. Exit the bosh instance\n1. Bosh SCP the file off of the instance. For example:\n   `bosh scp clock_global:/var/vcap/data/cloud_controller_clock/tmp/output.json /tmp/output.json`\n\nAs an additional benefit, running from within the bosh deployment also reduces\nnetwork latency, which can significantly speed up execution time.\n\n## Performance\n\nPerformance for a trial against a deployment seeded with 10,000 apps (NOT app\ninstances), when run on a bosh instance (jammy stemcell), using the procedure\ndescribed above:\n- Execution time: ~40 minutes\n- Memory consumption: ~110M\n- CPU consumption: ~1.4% of 2.20GHz CPU\n- Output file size: ~8.7M\n\n## Development\n\nFor testing (or running, I suppose) on Python 3.5 via the included Dockerfile (requires Docker):\n\n1. Navigate to the `buildpack-data-collector` directory\n1. Get a Linux CF CLI in the directory. For example:\n   ```\n   $ wget https://packages.cloudfoundry.org/stable\\?release\\=linux64-binary\\\u0026version\\=8.5.0\\\u0026source\\=github-rel -O cf.tgz\n   ...\n   $ tar -xf cf.tgz\n   ...\n   $ mv cf8 cf\n   ...\n   ```\n1. `docker build -t buildpack-data-collector`\n1. `docker run --env \"CF_API=\u003ccf API here\u003e\" --env \"CF_USER=admin\" --env \"CF_PASSWORD=\u003cadmin password here\u003e\" buildpack-data-collector`\n\nThe Dockerfile is based on Ubuntu Xenial, which should be similar to the Xenial stemcell.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerg%2Fbuildpack-data-collector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgerg%2Fbuildpack-data-collector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerg%2Fbuildpack-data-collector/lists"}