Giter Site home page Giter Site logo

groundcontrol's Introduction

Ground Control

Ground Control is a Go based daemon that runs on your Pi and lets you manage and monitor it with ease.

See a screenshot of the management UI and my Pi's temperature on Librato.

See FAQ for some common question that got asked on the Hacker News thread.

Update: I just pushed groundcontrol-ui if you want to hack on the UI part of groundcontrol.

Usage

Download the Ground Control package, or build from source (see Development).

Then, transfer it to your Pi.

$ scp groundcontrol-v0.0.1.tar.gz pi-user@PI_HOST:

or download it directly on your Pi

$ wget http://jondot.github.io/groundcontrol/groundcontrol-0.0.1.tar.gz

On the Pi, extract and change directories.

$ tar zxvf groundcontrol-0.0.1.tar.gz
$ cd groundcontrol-0.0.1/

Run Ground Control with a simple command (you should have config.json.sample there for a quick start).

$ ./groundcontrol -config myconfig.json

You can access the UI from your browser on port 4571.

http://PI_HOST:4571/

For configuration, use groundcontrol.json.sample as a basis and make sure to customize these fields:

  • librato - You can make a free account at Librato and then drop the key and user there.

  • tempodb - You can make a free account at TempoDB and then drop the key and user there.

  • Graphite or hostedgraphite - You can use your own standard Graphite server, or you can make a 14-day trial account at Hosted Graphite and then drop the key as a prefix. Important: for prefix specify a trailing dot . and postfix a leading dot ., if you want them.

Here's a typical graphite config:

  "graphite" : {
    "prefix"  : "prefix-or-key.",
    "postfix" : ".ip-pi",
    "linerec": "localhost:2003"
  },

Make sure to go over the plans (paid and free) and see what fits you best.

Both Librato and TempoDB were included because they have different retention and resolution and features for the free plans.

Next up, set up your "controls". This is where you input a label, and an "on", "off", "once" commands to automatically build a GUI around it.

Here is an example of having an xbmc control. It allows for shutting down and turning on XBMC.

  "controls" : {
    "xbmc": {
      "on" : "/etc/init.d/xbmc start",
      "off" : "/etc/init.d/xbmc stop"
    }
  }

init.d

You might want to use an init.d or upstart script to keep groundcontrol up at all times.

An default init.d script is included here support/init.d/groundcontrol.

Place your groundcontrol folder at:

/opt/groundcontrol/

And configuration should be at:

/etc/groundcontrol.json

You can edit your support/init.d/groundcontrol if you want to modify these paths.

After you've verified /etc/init.d/groundcontrol start to be working, to set up the default run order you can use:

$ update-rc.d groundcontrol defaults

FAQ

Q: Is this specific to the RaspberryPi?
A: Nope. Mechanically, it was built to work on any Unix like environment - just in case. However, the fact that Go makes such a slim resource profile, and a cross-compilation toolkit that works well makes it perfect for it (takes very little resource).

Q: Why was this made?
A: So here we go:

  • For fun (as said here)
  • Scratching my own itch - I needed a way to remotely run commands though a nice UI, and a way to see how my Pi is doing when I'm not at home.
  • For lack of better tooling - every thing I evaluated needed a combination of things, no other tool gave me all-in-one. This made the resources bloated. With GC, you get a few megabytes of memory usage.
  • To prove to myself that Go can be as great for development on the Pi as Python (which many people use there) I also like the idea of Internet of Things http://en.wikipedia.org/wiki/Internet_of_Things

Q: Does it need root?
A: Not necessarily. Since it runs shell commands for you exposed through REST, it boils down to whether your commands require root (example for these is starting/stopping services)

Q: Does it work on Windows?
A: No. For health collection it uses the production grade library sigar which support unixy environments. Thankfully, there was a go port of it.

Q: Can you do the same thing with other tools
A: Yes. I would opt for Collectd with a good set of plugins and which is C based. You'll have to make sure there's a plugin for your choice of metrics database. Then write some kind of Web endpoint in Python to execute shell commands. However as I mentioned before, sum up the resources of those, and you'll get a bigger consumption.

More Details

There's plenty more to Ground Control under the hood, let's list out a few things.

Temperature Monitoring

Ground control will read a file containing a temperature reading to update its own health records.

This is made so the mechanism is flexible -- you can use Ground Control on any machine (not just a Pi) as long as it will expose a temperature reading in a file-like device.

Controls

You can add and remove controls (commands that your Ground Control can run) by editing or specifying them with your configuration file..

Here's a full description of the format:

{
  "control_name": {
    "on" : "cmd for on, normally a 'start' for a service",
    "off" : "cmd for off, normally a 'stop' for a service",
    "status" : "A command that returns the status of the process",
    "once" : "a one time command, a cleanup, a shutdown etc."
  }
}

By convention control_name is snake_case and we turn it into "Control Name" on the UI.

The name should be nice for using in a REST API, in this case the commands turn into:

POST controls/control_name/on
POST controls/control_name/off
POST controls/control_name/once
GET controls/control_name/status

The on, off, and once commands are async, and we return a 202 OK for success. The status command are async, and we return a 200 OK for success.

And you can easily build an app (mobile?) yourself that makes use of those.

Development

Here's a short guide if you want to experiment with Ground Control yourself.

In each case, start off by taking a Ground Control repo clone.

Compiling

Set up dependencies and build:

$ go get github.com/jondot/gosigar
& go build

Cross Compiling

You probably want to build on your own (much more powerful) system rather than on the Pi itself to save time.

In my case I'll be compiling a Go binary on a Mac (OSX, x64), for a Raspberry PI (Linux, ARMv5/6).

Here's how to do it on a Mac and brew:

$ brew install go --devel --cross-compile-all    # I usually take --devel with Go, drop if you don't.

If you've got ZShell, or a nice alias-supporting shell, this is a nice alias:

alias go-pi='GOARCH=arm GOARM=5 GOOS=linux go'

and then I just

$ go-pi build

If you don't want to use an alias then this is the command to cross-compile for the Pi:

$ GOARCH=arm GOARM=5 GOOS=linux go build

Implementation Details

Ground control surrounds around several concepts:

  • Reporter - an entity that takes a Health, and reports it to somewhere.
  • Health - the entity that's responsible to gather all of the important health metrics.
  • Control - a switchboard-like entity that runs commands on request.

They are sorted by the level of fun/hackability you can get from it, but YMMV :).

Note, that go-metrics for example, could have replaced the entire reporter stack here using its various pluggable reporters, however, it only supports integers out of the box.

At the worst case, go-metrics itself can be implemented as a reporter (in fact it will be an aggregate reporter of reporters :).

Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).

Copyright

Copyright (c) 2013 Dotan Nahum @jondot. See MIT-LICENSE for further details.

groundcontrol's People

Contributors

brejoc avatar darrenolivier avatar derpston avatar jondot avatar matthiasleitner avatar nikai3d avatar tanner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

groundcontrol's Issues

tempo-db issues

I am a bit new to this so bear with me...

In my groundcontrol.json I have

"tempodb" :{
"user": "[email protected]",
"key": "api key given my tempo-db"
},

I created a new database on tempodb, and then it gives me 2 keys .. API key and API secret. I have tried both api key and api secret for the "key" parameter, but no data seems to be getting posted to the database I created.

"Built with Go" description

On the website it says:

Ground Control was built with Go and strikes a very small resource profile (under 3MB RSS).

This is a bit unclear to me. What is meant by "resource profile"? I'm guessing you mean CPU/memory usage. But if that is true, then the "3MB RSS" makes no sense to me (unless that is referring to memory usage/binary size). Though then I'm not sure what "RSS" means in this use.

Ground Control on OpenELEC?

Is it possible to install Ground Control on OpenELEC?
After reading your installation readme, I realize there's no /etc/init.d folder in openelec.

librato config

Hi, I m just starting using your program.

I have made a account on librato, but which info am I supposed to write in "user"?
The mail adress I gave to librato? The token name? Or the name I edited? (Or something else?)

In stdout, I have:

...
Reporters: Librato OK
...
Error: Librato API Error : &{401 Unauthorized 401 HTTP/1.1 1 1...

Silent mode?

I need to keep the screen clear of all console message, and starting groundcontrol (with other script).
So in my starting script I ve wrote:

groundcontrol -config myconfig.json & > /dev/null

But I still get logs (at least at the start). How can I put them in a file or in /dev/null too so they don t appear on the screen?

Or is there a way to silent groundcontrol?

CAN HAS GRAPHITE?

I know you know graphite, graphene is one of the best things to happen to the project. Can support for it be added?

Cannot read from AMD Chips

Compiled for Ubuntu Server 12.04, the default shows 40 C, while the built in /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input doesn't seem to be supported.

I made sure to change it to /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input to keep it from crashing, however it doesn't read the temps:

Cannot read sensor data at /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input: open /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input: no such file or directory.

Using the command 'cat /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input' from the command line works, what could be the problem?

Choosing series to record

Is there a way to edit which series are recorded (avg1, avg5, avg15, disk_used, disk_used_pcnt, memfree, memused, etc....). Can we control which ones are recorded and not recorded?

My main issue is, I don't need/want disk_used or disk_used_pcnt being calculated because one of them is a mounted 2TB network drive and I think it takes quite a bit of resources to calculate that.

default init.d?

Would be nice to have a default init.d in the repo, since most will be on raspbian anyways.

Groundcontrol crashes

My groundcontrol seems to crash after running for a day or two, using the init.d script. Is there any log that i can check?

Status feature

Hi,

I was under the impression that the "status" command on a control would let you show the result of this status command on the Web interface.

But it does not seem to work that way. I defined the following control:

    "nginx": {
      "on" : "/etc/init.d/nginx start",
      "off" : "/etc/init.d/nginx stop",
      "status" : "/etc/init.d/nginx status"
    }

And all I get is a status button on the UI without any value/indication/feedback except "Command sent" when I click it.

Did I miss something?

Thank you for this wonderful tool!

Crashes complaining about invalid memory address

Terminal output is as follows:

`sudo ./groundcontrol -config groundcontrol.json
2019/12/01 11:55:21 Reporters: No TempoDB credentials, skipping.
2019/12/01 11:55:21 Reporters: Librato OK.
2019/12/01 11:55:21 Lauching Health
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x12ac4]

goroutine 1 [running]:
main.(*LibratoReporter).ReportHealth(0x10474540, 0x10472340)
/Users/dotan/projects/groundcontrol/librato_reporter.go:55 +0x5a4
main.report(0x10475230, 0x104744e0)
/Users/dotan/projects/groundcontrol/main.go:105 +0x15c
main.main()
/Users/dotan/projects/groundcontrol/main.go:76 +0xb98`

Doesn't sound like a configuration issue, so I guess it's something to be fixed in the code. (Not running as sudo throws the same error, btw.)

Raspberry Pi 2B
Ubuntu Mate 18.04.2

running script

I have an item in my config.json file

"run script": {
"on/off led": "sh /root/myscript.sh"
}

and it's supposed to turn on a GPIO pin and light up an LED. when I do this from the terminal, it works fine but when I try to run the script through groundcontrol, it does nothing.

I tried nohup to log but I see nothing in the logs .. any ideas?
fyi running all as root

init.d file, update-rc.d problem?

I installed the support/init.d/groundcontrol file into my /etc/init.d/groundcontrol and I can start and stop it. I also did update-rc.d groundcontrol defaults.

However, when I boot up my Pi, I check the status after logging in (/etc/init.d/groundcontrol status) and it says fail, it's not running and I have to manually start it by /etc/init.d/groundcontrol start

Maybe somehow my update-rc.d groundcontrol defaults
isn't doing what it's supposed to?

gofmt

Hi,

The code isn't gofmt'd. This is a big turn-off for people wanting to contribute as usually a regular Go user will have their editor auto-gofmt-on-save and thus causing them to either need to turn it off or have a massive diff of gofmt'd code before contributing.

UI Screenshot

On the projects github.io webpage, there is an image of the mobile UI.

Website UI Badge

However, when you click on it to view the entire UI, the UI is a bit different: the graph is different and the white text is not on the same line anymore.

Entire Website UI

I think it would be better if the both pictures were the same and if the entire UI screenshot had the iPhone mockup border. The reason for the iPhone border is that since the UI is pretty minimalistic/flat, it looks bad when it's just hanging out against the white browser background.

In writing this, it might even be better to just have the image get larger (modal/lightbox-style) and have arrows pointing to different parts of the UI (e.g. what is the graph showing, what is the search box for). It wouldn't be a huge in-depth UI explanation, but just a teaser informational kind of thing.

Program crashed

Where are the logs stored so I can find out why groundcontrol suddently stopped working after a few days?

Build failure on ubuntu 12.04: control.go:54: undefined: strings.TrimPrefix

Is it possible for this to build on Ubuntu? I'm attempting this on 12.04 with golang-stable 1.03 installed:

$ sudo go get github.com/jondot/gosigar
$ go build
# _/home/me/src/git/groundcontrol
./control.go:54: undefined: strings.TrimPrefix
./main.go:102: method control.Handler is not an expression, must be called
./main.go:103: method webreporter.Handler is not an expression, must be called

Make available via apt-get?

Hello,

Is it possible to make this available via apt-get to install it as a service?

If not, how do I install it on a Raspberry Pi running Raspbian as a service properly as mine is running in init.d but it uses some sort of default config file and ignores mine for some reason.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.