├── .gitignore ├── .travis.yml ├── Makefile ├── main_test.go ├── Vagrantfile ├── error.go ├── stats.go ├── keyfile.go ├── keys └── linux_keys.conf ├── zabbix_get.go ├── README.md ├── itemkey.go └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | *.tar.gz 3 | *.rpm 4 | *.deb 5 | zabbix_agent_bench 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | 6 | install: make get-deps 7 | 8 | script: make test 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | APP = zabbix_agent_bench 2 | APPVER = 0.4.0 3 | ARCH = $(shell uname -m) 4 | TARBALL = $(APP)-$(APPVER).$(ARCH) 5 | 6 | GO = go 7 | GFLAGS = -x -a -v -x 8 | RM = rm -f 9 | FPM = fpm 10 | TAR = tar 11 | INSTALL = install -c 12 | 13 | all: $(APP) 14 | 15 | $(APP): main.go zabbix_get.go keyfile.go itemkey.go error.go stats.go 16 | $(GO) build $(GFLAGS) -o $(APP) 17 | 18 | get-deps: 19 | $(GO) get -u github.com/mitchellh/colorstring 20 | 21 | test: 22 | $(GO) test -x -v 23 | 24 | install: $(APP) 25 | $(INSTALL) $(APP) /usr/local/bin/$(APP) 26 | 27 | packages: tar deb rpm 28 | 29 | tar: $(APP) README.md keys/ 30 | mkdir $(TARBALL) 31 | cp -vr $(APP) README.md keys/ $(TARBALL)/ 32 | $(TAR) -czf $(TARBALL).tar.gz $(TARBALL)/ 33 | rm -rf $(TARBALL)/ 34 | 35 | deb: $(APP) 36 | $(FPM) -f -s dir -t deb -n $(APP) -v $(APPVER) $(APP)=/usr/bin/$(APP) 37 | 38 | rpm: $(APP) 39 | $(FPM) -f -s dir -t rpm -n $(APP) -v $(APPVER) $(APP)=/usr/bin/$(APP) 40 | 41 | clean: 42 | $(GO) clean -i -x 43 | $(RM) -f $(APP) $(TARBALL).tar.gz $(APP)-$(APPVER)-1.$(ARCH).rpm zabbix-agent-bench_$(APPVER)_amd64.deb 44 | 45 | docker-run: 46 | docker run -it --rm -v $(PWD):/go/src/github.com/cavaliercoder/zabbix_agent_bench -w /go/src/github.com/cavaliercoder/zabbix_agent_bench golang 47 | 48 | .PHONY: all get-deps test install packages tar deb rpm clean docker-run 49 | 50 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Zabbix Agent Bench (C) 2014 Ryan Armstrong 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package main 18 | 19 | import ( 20 | "os" 21 | "testing" 22 | ) 23 | 24 | func TestEnvVarExpansion(t *testing.T) { 25 | os.Setenv("VAR1", "Atom Eve") 26 | os.Setenv("VAR2", "Black Samson") 27 | os.Setenv("VAR3", "Cecil Stedman") 28 | os.Setenv("VAR4", "Darkwing") 29 | 30 | expected := "some.key[Atom Eve,Black Samson,,,]" 31 | input := " some.key[{%VAR1},{%VAR2},{%Var3},{%var4},{%VAR5}]" 32 | 33 | key := NewItemKey(input) 34 | 35 | if key.Key != expected { 36 | t.Errorf("Environment variable subsitution failed.\nExpected: %s\nGot: %s", expected, key.Key) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | script = <