README.md 2.99 KB
Newer Older
Kevin Lyda's avatar
Kevin Lyda committed
1 2 3 4 5 6 7 8 9 10 11 12
# GQ GMC

This is a web service interface for GQ GMC geiger counters.

## Installation

Note this is not yet complete.

```bash
go get -u gitlab.com/lyda/gqgmc/cmd/gqgmcd
```

Kevin Lyda's avatar
Kevin Lyda committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
## Configuring

Command line:

```
Usage of gqgmcd:
      --config string           Config file (default "gqgmc.conf")
      --device string           Device for Geiger Counter (default "/dev/gqgmc")
      --listen-address string   Address for HTTP requests (default ":8080")
      --model string            Model of Geiger Counter (default "gqgmc")
      --sleep-cycle int         Seconds to sleep per cycle. (default 5)
      --static-dir string       Static files directory (default "static")
      --template-dir string     Template directory (default "templates")
```

The config file uses the same variables (not `config` obviously)
but with any dashes replaced with underscores. So
`static_dir = /var/lib/gqgmcd/static` for instance.

Kevin Lyda's avatar
Kevin Lyda committed
32 33
## Prometheus variables

Kevin Lyda's avatar
Kevin Lyda committed
34
There is a sample `prometheus.yml` configuration in the `docs/prometheus/`
Kevin Lyda's avatar
Kevin Lyda committed
35 36 37 38 39 40 41
directory.  See the Prometheus
[getting started](https://prometheus.io/docs/introduction/getting_started/)
docs for more information.

* `gqgmc_geiger_cpm` (histogram) CPM readings.
* `gqgmc_geiger_cps` (histogram) CPS readings.
* `gqgmc_power_volts` (histogram) Voltage readings.
Kevin Lyda's avatar
Kevin Lyda committed
42
* `gqgmc_sys_errors` (gauge) Error counts. Records problems
Kevin Lyda's avatar
Kevin Lyda committed
43 44
  communicating with the device.

Kevin Lyda's avatar
Kevin Lyda committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
There are also sample consoles in the `docs/prometheus/` directory. Add this
to the left hand side menu in `menu.lib` your prometheus install:

```
{{ if query "up{job='gqgmc'}" }}
{{ template "_menuItem" (args . "gqgmc.html" "GQGMC") }}
{{ if match "^gqgmc" .Path }}
  {{ if .Params.instance }}
  <ul>
    <li {{ if eq .Path "gqgmc-overview.html" }}class="prom_lhs_menu_selected"{{ end }}>
      <a href="gqgmc-overview.html?instance={{ .Params.instance }}">{{.Params.instance }}</a>
    </li>
  </ul>
  {{ end }}
{{ end }}
{{ end }}
```

![Prometheus Console](/docs/gqgmc.png)

Kevin Lyda's avatar
Kevin Lyda committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
## Configuring udev

Copy the `linux/51-gqgmc.rules` file to the `/etc/udev/rules.d`
directory and force the reload of udev rules:

```bash
sudo cp ./51-gqgmc.rules /etc/udev/rules.d/51-gqgmc.rules sudo
udevadm control --reload-rules
```

Disconnect the GQ GMC-300 from the computer and then reconnect.
Verify that there exists a `/dev/gqgmc` in the `/dev` directory
with read/write permission for all users.

```bash
ls -la /dev/gqgmc
```
Kevin Lyda's avatar
Kevin Lyda committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

## Development Resources

There's a GQ Electronics [forum](https://www.gqelectronicsllc.com/forum/) which
isn't hugely active, but some really good info and helpful people
there. If you follow the git log on this project you'll see this
is based off a C++ implementation which is
[over on sourceforge](https://sourceforge.net/projects/gqgmc/)

## TODO

There's still a fair bit to do. This works good enough for my purposes so
I'm not likely to do much more. I've seeded the
[issue tracker](https://gitlab.com/lyda/gqgmc/issues) with the obvious
issues.
[Merge Requests](https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html)
welcome!