{"action":"created","issue":{"url":"https://api.github.com/repos/abrander/agento/issues/1","labels_url":"https://api.github.com/repos/abrander/agento/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/abrander/agento/issues/1/comments","events_url":"https://api.github.com/repos/abrander/agento/issues/1/events","html_url":"https://github.com/abrander/agento/issues/1","id":86934274,"number":1,"title":"Restructure/plugin interface discussion","user":{"login":"klauspost","id":5663952,"avatar_url":"https://avatars.githubusercontent.com/u/5663952?v=3","gravatar_id":"","url":"https://api.github.com/users/klauspost","html_url":"https://github.com/klauspost","followers_url":"https://api.github.com/users/klauspost/followers","following_url":"https://api.github.com/users/klauspost/following{/other_user}","gists_url":"https://api.github.com/users/klauspost/gists{/gist_id}","starred_url":"https://api.github.com/users/klauspost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klauspost/subscriptions","organizations_url":"https://api.github.com/users/klauspost/orgs","repos_url":"https://api.github.com/users/klauspost/repos","events_url":"https://api.github.com/users/klauspost/events{/privacy}","received_events_url":"https://api.github.com/users/klauspost/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-10T11:25:48Z","updated_at":"2015-06-11T11:21:23Z","closed_at":null,"body":"Looking at the current structure, it would perhaps ease the future development process to make some simple changes.\r\n\r\n# Overall\r\n* ~~Move client to main folder (so agento is buildable with a simple `go get`).~~ (second thought no - we would have two package names.\r\n* Move data collection to a system specific folder.\r\n* Make all data collection register itself in init().\r\n* All data collection plugins must satisfy a simple interface to get a reading.\r\n \r\n# Server\r\n* Isn't \"server\" more of a proxy. Forwarding json data to influx?\r\n* Beside potential data cleaning, is there a reason for the server to unmarshal to `agento.MachineStats`. Would it make sense to simply keep it as map[string]interface{} and just blindly forward whatever data it gets?\r\n\r\n# Agento package\r\n\r\nAs mentioned everything currently in the package is moved to a `agento/linux` package.\r\n\r\nThe following is then the only exported functions in the `agento` package:\r\n```Go\r\ntype Plugin interface {\r\n    // Gather the information.\r\n    Gather() error\r\n\r\n   // Return the latest reading.\r\n    Map() map[string]interface{}\r\n\r\n    // Doc - not sure if needed?\r\n    Doc(map[string]string)\r\n}\r\n\r\n// Register a plugin.\r\nfunc Register(name string,p Plugin) {\r\n  ....\r\n}\r\n```\r\n\r\nA plugin would then look like this:\r\n```Go\r\nfunc init() {\r\n  agento.Register(\"Dickstats\", new(DiskStats))\r\n}\r\n\r\n// Diskstat is self-contained. This isn't required, but Gather() needs \r\n// to update the internal stats there is no need for it not to do so\r\ntype DiskStats struct {\r\n\tsampletime time.Time\r\n\tDisks      map[string]*SingleDiskStats `json:\"disks\"`\r\n\r\n        // Diskstats now keeps track of its own history\r\n\tlast      map[string]*SingleDiskStats\r\n\tlastSample time.Time\r\n}\r\n\r\n// func GetDiskStats() *DiskStats { is now changed to update itself.\r\nfunc (d *DiskStats) Gather()  error {\r\n    d.last = d.Disks\r\n    d.Disks = make(map[string]*SingleDiskStats)\r\n    ...\r\n}\r\n// The rest of the functions are adjusted to reflect the new place of\r\n// the previous data, otherwise pretty much remain the same.\r\n```\r\n\r\nAdding a package with any number of plugins can now be done with a `import _ \"github.com/abrander/agento/linux\"`, etc. That will make it very easy to add arbitrary plugins, and plugins can be done any way that makes sense for them.\r\n\r\nThe main thing is that the agento (and subsequent server) doesn't know anything about what it will receive. It is simply an arbitrary map[string]interface{} that can be JSON marshalled.\r\n\r\nDoes that make any kind of sense?"},"comment":{"url":"https://api.github.com/repos/abrander/agento/issues/comments/111089112","html_url":"https://github.com/abrander/agento/issues/1#issuecomment-111089112","issue_url":"https://api.github.com/repos/abrander/agento/issues/1","id":111089112,"user":{"login":"abrander","id":3726205,"avatar_url":"https://avatars.githubusercontent.com/u/3726205?v=3","gravatar_id":"","url":"https://api.github.com/users/abrander","html_url":"https://github.com/abrander","followers_url":"https://api.github.com/users/abrander/followers","following_url":"https://api.github.com/users/abrander/following{/other_user}","gists_url":"https://api.github.com/users/abrander/gists{/gist_id}","starred_url":"https://api.github.com/users/abrander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abrander/subscriptions","organizations_url":"https://api.github.com/users/abrander/orgs","repos_url":"https://api.github.com/users/abrander/repos","events_url":"https://api.github.com/users/abrander/events{/privacy}","received_events_url":"https://api.github.com/users/abrander/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T11:21:23Z","updated_at":"2015-06-11T11:21:23Z","body":"I think the most important part is the overall structure of the code base. Define an interface for gatherers and making sure it's easy to add additional gatherers. We need a simple way of adding new gatherers without much work and without the client->server payload exploding.\r\n\r\nIt would also be nice to be able to do `go get github.com/abrander/agento` and compile. You cannot do that now."}}