{"id":13414067,"url":"https://github.com/andygrunwald/megos","last_synced_at":"2025-03-21T11:33:43.543Z","repository":{"id":57495615,"uuid":"43557425","full_name":"andygrunwald/megos","owner":"andygrunwald","description":"Go(lang) client library for accessing information of an Apache Mesos cluster.","archived":false,"fork":false,"pushed_at":"2021-06-22T17:06:10.000Z","size":62,"stargazers_count":54,"open_issues_count":0,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-12T18:42:07.084Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/andygrunwald/megos","language":"Go","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/andygrunwald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"andygrunwald","custom":"https://paypal.me/andygrunwald"}},"created_at":"2015-10-02T14:29:20.000Z","updated_at":"2023-12-25T17:51:59.000Z","dependencies_parsed_at":"2022-08-31T13:00:23.056Z","dependency_job_id":null,"html_url":"https://github.com/andygrunwald/megos","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/andygrunwald%2Fmegos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fmegos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fmegos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fmegos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andygrunwald","download_url":"https://codeload.github.com/andygrunwald/megos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135908,"owners_count":20403798,"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":[],"created_at":"2024-07-30T20:01:56.775Z","updated_at":"2025-03-21T11:33:43.184Z","avatar_url":"https://github.com/andygrunwald.png","language":"Go","funding_links":["https://github.com/sponsors/andygrunwald","https://paypal.me/andygrunwald"],"categories":["Third-party APIs","\u003cspan id=\"第三方api-third-party-apis\"\u003e第三方API Third-party APIs\u003c/span\u003e","Other projects and Integrations","第三方api","Utility","第三方API","第三方API`第三方API 汇总`"],"sub_categories":["HTTP Clients","Utility/Miscellaneous","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","Networking","Advanced Console UIs","实用程序/Miscellaneous","查询语","交流","Fail injection"],"readme":"# megos\n\n[![GoDoc](https://godoc.org/github.com/andygrunwald/megos?status.svg)](https://godoc.org/github.com/andygrunwald/megos)\n[![Build Status](https://travis-ci.org/andygrunwald/megos.svg)](https://travis-ci.org/andygrunwald/megos)\n[![Go Report Card](https://goreportcard.com/badge/github.com/andygrunwald/megos)](https://goreportcard.com/report/github.com/andygrunwald/megos)\n[![Coverage Status](https://coveralls.io/repos/github/andygrunwald/megos/badge.svg?branch=master)](https://coveralls.io/github/andygrunwald/megos?branch=master)\n\n[Go(lang)](https://golang.org/) client library for accessing an [Apache Mesos](http://mesos.apache.org/) cluster.\n\n## Features\n\n* Determine the Mesos leader\n* Get the current state of every mesos node (master or slave)\n* Retrieve stdout and stderr of tasks\n* Covered with unit tests\n\n## Installation\n\nIt is go gettable\n\n    $ go get github.com/andygrunwald/megos\n\n(optional) to run unit / example tests:\n\n    $ cd $GOPATH/src/github.com/andygrunwald/megos\n    $ go test -v ./...\n\n## API\n\nPlease have a look at the [GoDoc documentation](https://godoc.org/github.com/andygrunwald/megos) for a detailed API description.\n\n## Examples / use cases\n\nA (small) list of usecases how this library can be used:\n\n* Determine the leader of a Mesos cluster\n* Get a list of all completed Mesos tasks\n* Get the stdout and stderr of a failed mesos task\n* Get the statistics and push it to a different backend\n\nFurther more a few examples how the API can be used and the code looks like.\n\n### Determine the leader node\n\n```go\nnode1, _ := url.Parse(\"http://192.168.1.120:5050/\")\nnode2, _ := url.Parse(\"http://192.168.1.122:5050/\")\n\nmesos := megos.NewClient([]*url.URL{node1, node2}, nil)\nleader, err := mesos.DetermineLeader()\nif err != nil {\n\tpanic(err)\n}\n\nfmt.Println(leader)\n// Output:\n// master@192.168.1.122:5050\n```\n\n### Get the version of Mesos\n\n```go\nnode1, _ := url.Parse(\"http://192.168.1.120:5050/\")\nnode2, _ := url.Parse(\"http://192.168.1.122:5050/\")\n\nmesos := megos.NewClient([]*url.URL{node1, node2}, nil)\nstate, err := mesos.GetStateFromCluster()\nif err != nil {\n\tpanic(err)\n}\n\nfmt.Printf(\"Mesos v%s\", state.Version)\n// Output:\n// Mesos v0.26.0\n```\n\n### Get stdout and stderr of a task\n\nGet stdout and stderr from a task of the [chronos](https://github.com/mesos/chronos) framework. Error checks are dropped for simplicity.\n\n```go\nnode1, _ := url.Parse(\"http://192.168.1.120:5050/\")\nnode2, _ := url.Parse(\"http://192.168.1.122:5050/\")\nmesos := megos.NewClient([]*url.URL{node1, node2}, nil)\n\nframeworkPrefix := \"chronos\"\ntaskID := \"ct:1444578480000:0:example-chronos-task:\"\n\nmesos.DetermineLeader()\nstate, _ := mesos.GetStateFromLeader()\n\nframework, _ := mesos.GetFrameworkByPrefix(state.Frameworks, frameworkPrefix)\ntask, _ := mesos.GetTaskByID(framework.CompletedTasks, taskID)\n\nslave, _ := mesos.GetSlaveByID(state.Slaves, task.SlaveID)\n\npid, _ := mesos.ParsePidInformation(slave.PID)\nslaveState, _ := mesos.GetStateFromPid(pid)\n\nframework, _ = mesos.GetFrameworkByPrefix(slaveState.CompletedFrameworks, frameworkPrefix)\nexecutor, _ := mesos.GetExecutorByID(framework.CompletedExecutors, taskID)\n\nstdOut, _ := mesos.GetStdOutOfTask(pid, executor.Directory)\nstdErr, _ := mesos.GetStdErrOfTask(pid, executor.Directory)\n\nfmt.Println(string(stdOut))\nfmt.Println(\"================\")\nfmt.Println(string(stdErr))\n// Output:\n// Registered executor on 192.168.1.123\n// Starting task ct:1444578480000:0:example-chronos-task:\n// sh -c 'MY COMMAND'\n// Forked command at 10629\n// ...\n// ================\n// I1011 17:48:00.390614 10602 exec.cpp:132] Version: 0.22.1\n// I1011 17:48:00.532158 10618 exec.cpp:206] Executor registered on slave 20150603-103119-2046951690-5050-24382-S1\n```\n\n## Version compatibility\n\nThis library was tested with Apache Mesos in version 0.26.0.\nIn theory this should work with versions \u003e= v0.25.x.\n\nIn version 0.25.x they renamed various API endpoints (like state.json to /state).\nSee [Upgrading Mesos - Upgrading from 0.24.x to 0.25.x](http://mesos.apache.org/documentation/latest/upgrades/) for details.\nThis is the reason why we support no lower versions of Mesos.\n\n## Other/Similar projects\n\n* [boldfield/go-mesos](https://github.com/boldfield/go-mesos): A client for discovering information about a Mesos exposed via HTTP API\n* [antonlindstrom/mesos_stats](https://github.com/antonlindstrom/mesos_stats): Statistics definition for Mesos /monitor/statistics.json\n* [Clever/marathon-stats](https://github.com/Clever/marathon-stats): A simple container which queries marathon and mesos for stats about their current state, and logs these stats to stderr\n* [bolcom/mesos_metrics](https://github.com/bolcom/mesos_metrics): Go definitions for the Mesos `{master}:5050/metrics/snapshot` and `{slave}:5051/metrics/snapshot` endpoints\n\n## Contribution\n\n* You have a question?\n* Don`t know if a feature is supported?\n* Want to implement a new feature, but don`t know how?\n* You like the library and use it for your implementation / use case?\n* You found a bug or incompatibility?\n* Something is not working as expected?\n\nFeel free to open a [new issue](https://github.com/andygrunwald/megos/issues/new).\nI will be happy to answer them and try to help you.\nIt might be useful to add as much information as possible into the issue like Mesos version, example URL, (parts) of your code and the expected and current behaviour.\n\n## License\n\nThis project is released under the terms of the [MIT license](http://en.wikipedia.org/wiki/MIT_License).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandygrunwald%2Fmegos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandygrunwald%2Fmegos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandygrunwald%2Fmegos/lists"}