Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/middle indexed oid and some improvements #445

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

# Create snmpcollector-last.tar.gz, which includes the binary

FROM ubuntu:16.04 as build
WORKDIR /app/src/snmpcollector
RUN apt update -y && apt upgrade -y
RUN apt-get install -y locales
RUN apt-get install -y curl git gcc
RUN curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs
RUN curl -O https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
RUN tar -xvf go1.9.1.linux-amd64.tar.gz -C /usr/local
ENV PATH=$PATH:/usr/local/go/bin
ENV GOROOT=/usr/local/go
ENV GOPATH=/app
ENV PATH=$PATH:$GOROOT/bin
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH


COPY . /app/src/snmpcollector/


RUN go run build.go setup
# RUN go get github.com/tools/godep
# RUN godep restore

# RUN npm install
# RUN PATH=$(npm bin):$PATH
# RUN npm run build:prod

# RUN npm run build:static
RUN go run build.go build-static

RUN go run build.go pkg-min-tar



# Create the Dockerfile for the SnmpCollector

FROM alpine:latest

COPY --from=build /app/src/snmpcollector/dist/snmpcollector.tar.gz /

RUN tar zxvf snmpcollector.tar.gz -C .


WORKDIR /opt/snmpcollector

COPY ../../docker ./conf
COPY ../../docker /

# RUN mkdir ./log

ENTRYPOINT ["/start.sh"]
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func createMinTar() {
runPrint("cp", "bin/snmpcollector", filepath.Join(packageRoot, "/opt/snmpcollector/bin"))
runPrint("cp", "bin/snmpcollector.md5", filepath.Join(packageRoot, "/opt/snmpcollector/bin"))
runPrint("cp", "-a", filepath.Join(workingDir, "public")+"/.", filepath.Join(packageRoot, "/opt/snmpcollector/public"))
tarname := fmt.Sprintf("dist/snmpcollector-%s-%s_%s_%s.tar.gz", version, getGitSha(), runtime.GOOS, runtime.GOARCH)
tarname := "dist/snmpcollector.tar.gz"
runPrint("tar", "zcvf", tarname, "-C", packageRoot, ".")
runPrint("rm", "-rf", packageRoot)
}
Expand Down Expand Up @@ -366,9 +366,9 @@ func build(pkg string, tags []string, flags []string) {
func ldflags(flags []string) string {
var b bytes.Buffer
b.WriteString("-w")
b.WriteString(fmt.Sprintf(" -X github.com/toni-moreno/snmpcollector/pkg/agent.Version=%s", version))
b.WriteString(fmt.Sprintf(" -X github.com/toni-moreno/snmpcollector/pkg/agent.Commit=%s", getGitSha()))
b.WriteString(fmt.Sprintf(" -X github.com/toni-moreno/snmpcollector/pkg/agent.BuildStamp=%d", buildStamp()))
b.WriteString(fmt.Sprintf(" -X snmpcollector/pkg/agent.Version=%s", version))
b.WriteString(fmt.Sprintf(" -X snmpcollector/pkg/agent.Commit=%s", getGitSha()))
b.WriteString(fmt.Sprintf(" -X snmpcollector/pkg/agent.BuildStamp=%d", buildStamp()))
for _, f := range flags {
b.WriteString(fmt.Sprintf(" %s", f))
}
Expand All @@ -384,9 +384,9 @@ func rmr(paths ...string) {

func clean() {
// rmr("bin", "Godeps/_workspace/pkg", "Godeps/_workspace/bin")
rmr("public")
// disable ui: rmr("public")
//rmr("tmp")
rmr(filepath.Join(os.Getenv("GOPATH"), fmt.Sprintf("pkg/%s_%s/github.com/toni-moreno/snmpcollector", goos, goarch)))
rmr(filepath.Join(os.Getenv("GOPATH"), fmt.Sprintf("pkg/%s_%s/snmpcollector", goos, goarch)))
}

func setBuildEnv() {
Expand Down
14 changes: 0 additions & 14 deletions docker/Dockerfile

This file was deleted.

3 changes: 2 additions & 1 deletion docker/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if [ ! -f dist/snmpcollector-${VERSION}-${COMMIT}_${GOOS:-linux}_${GOARCH:-amd64
then
echo "building binary...."
npm run build:static
# npm run build
go run build.go pkg-min-tar
else
echo "skiping build..."
Expand All @@ -26,7 +27,7 @@ cp conf/sample.config.toml docker/config.toml

cd docker

sudo docker build --label version="${VERSION}" --label commitid="${COMMIT}" -t tonimoreno/snmpcollector:${VERSION} -t tonimoreno/snmpcollector:latest .
docker build --label version="${VERSION}" --label commitid="${COMMIT}" -t tonimoreno/snmpcollector:${VERSION} -t tonimoreno/snmpcollector:latest .
rm snmpcollector-last.tar.gz
rm config.toml
rm /tmp/goenv.tmp
82 changes: 82 additions & 0 deletions docker/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

############################
# General Config
############################

[general]
# InstanceID will be a string identifying the collector , It will be useful when
# more than one running on the same server, this ID will be shown in the WebUI.
instanceID = "WAN Communicactions"
# datadir set the directory where the data will be placed , also sqlite db if set as db engine
# if not set the default datadir will be placed in the configuration directory
# datadir = "/var/lib/snmpcollector"

# there are as many logs as devices configured
# logdir set the Directory path for each device individual log, default is /var/log/snmpcollector
# logdir = "/var/log/somelogpath"
# NOTE: main process log is now sent to standard output
# logLevel set the main process log level
# valid values: panic,fatal,error,warn,info,debug
logLevel = "warn"

############################
# DataBase Config
############################

[database]
#type sets the sql backend
#valid values sqlite3,mysql
type = "sqlite3"
# these parameters are only for mysql (use mysql_setup.sql before)
# host = 127.0.0.1:3306
# user = "snmpcoluser"
# password = "snmpcolpass"
# name sets the database name
name = "snmpcollector"
#sqllogfile sets the name for a file in the log/ directory where sql backend will write all SQL transactions
#sqllogfile = "sql.log"
# debug adds extra verbosity to the SQL log
debug = false



############################
# Self Monitorig Config
############################
#config for sending self monitoring metrics to our default influx db
# Sent Measurements will be <prefix>selfmon_gvm with the following fields
# runtime_goroutines
# *mem.alloc
# *mem.mallocs
# *mem.frees
# *gc.total_pause_ns
# *memory.heap
# *gc.pause_per_second
# *gc.pause_per_interval
# *gc.gc_per_second
# *gc.gc_per_interval

[selfmon]
#enable true/false enable/disable self monitoring
enabled = true
#send data Frequency
freq = 60
#prefix for measurement naming
prefix = ""
#inherit device tags
inheritdevicetags = true
#adds extra tags to the measurement config should be set as a csv - tag=value1,tag2=value2,...,tagN=valN
extratags = [ "instance=snmpcollector01" ]

############################
# Embedded WebServer Config
############################

[http]
#port where webserver will listen waiting for connections
port = 8090
#Admin credentials to access to the SnmpCollector agent
adminuser = "adm1"
adminpassword = "adm1pass"
#When more than one instance you will need customize the cookie_id allowing navigate to all instances
cookieid ="my_instance_cookie"
24 changes: 24 additions & 0 deletions docker/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:16.04 as build
WORKDIR /app/src/snmpcollector

RUN apt update -y && apt upgrade -y
RUN apt-get install -y locales
RUN apt-get install -y curl git gcc
RUN curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs
RUN curl -O https://storage.googleapis.com/golang/go1.12.1.linux-amd64.tar.gz
RUN tar -xvf go1.12.1.linux-amd64.tar.gz -C /usr/local
RUN rm go1.12.1.linux-amd64.tar.gz
ENV PATH=$PATH:/usr/local/go/bin
ENV GOROOT=/usr/local/go
ENV GOPATH=/app
ENV PATH=$PATH:$GOROOT/bin
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
COPY ./setup.sh .
RUN bash setup.sh
COPY . .
RUN mv docker/start-dev.sh /

ENTRYPOINT [ "/start-dev.sh" ]

55 changes: 55 additions & 0 deletions docker/production/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

# Create snmpcollector-last.tar.gz, which includes the binary

FROM ubuntu:16.04 as build
WORKDIR /app/src/snmpcollector
RUN apt update -y && apt upgrade -y
RUN apt-get install -y locales
RUN apt-get install -y curl git gcc
RUN curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs
RUN curl -O https://storage.googleapis.com/golang/go1.12.1.linux-amd64.tar.gz
RUN tar -xvf go1.12.1.linux-amd64.tar.gz -C /usr/local
ENV PATH=$PATH:/usr/local/go/bin
ENV GOROOT=/usr/local/go
ENV GOPATH=/app
ENV PATH=$PATH:$GOROOT/bin
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH

COPY ./setup.sh .
RUN bash setup.sh

COPY . /app/src/snmpcollector/

# RUN go get github.com/tools/godep
# RUN godep restore

RUN npm install
RUN PATH=$(npm bin):$PATH
#RUN npm run build:prod

RUN npm run build:static
# RUN go run build.go build-static

RUN go run build.go pkg-min-tar



# Create the Dockerfile for the SnmpCollector

FROM alpine:latest

COPY --from=build /app/src/snmpcollector/dist/snmpcollector.tar.gz /

RUN tar zxvf snmpcollector.tar.gz -C .


WORKDIR /opt/snmpcollector

COPY ./docker/config.toml ./conf
COPY ./docker/start.sh /

# RUN mkdir ./log

ENTRYPOINT ["/start.sh"]
8 changes: 8 additions & 0 deletions docker/start-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

rm ./conf/snmpcollector.db
go run build.go build



./bin/snmpcollector > ./log/stdout.log 2> ./log/stderr.log
19 changes: 19 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
#!/bin/sh

if [ "$APP_ENV" = "development" ]
then
echo "MODE: Developement"
if [ -f "./conf/snmpcollector.db" ]
then
rm ./conf/snmpcollector.db
fi
fi


if ! [ -x "./bin/snmpcollector" ]
then
go run build.go build
echo "Status: build complete"
fi



./bin/snmpcollector > ./log/stdout.log 2> ./log/stderr.log
30 changes: 30 additions & 0 deletions docker/toni-moreno/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@


FROM ubuntu:16.04

COPY .. /app
RUN apt-get update && apt-get install -y locales
RUN apt-get install -y golang curl
RUN curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN apt-get install -y nodejs
RUN npm install
RUN PATH=$(npm bin):$PATH
RUN npm run build:prod


FROM alpine:latest

MAINTAINER Toni Moreno <[email protected]>

ADD ./docker/snmpcollector-last.tar.gz /

VOLUME ["/opt/snmpcollector/conf", "/opt/snmpcollector/log"]

EXPOSE 8090

WORKDIR /opt/snmpcollector
COPY ./docker/config.toml ./conf
COPY ./docker/start.sh /

ENTRYPOINT ["/start.sh"]
4 changes: 0 additions & 4 deletions log/.gitignore

This file was deleted.

Loading