-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle errors * use DialContext * refactor dev env * server: use context for http request * server: refactor * server: create Agent client when needed * server: rename * server: rename * server: log * server: return err * server: do request with context * server: rename * server: do sequential requests to mysql and proxy * sever: define rawprocess * server: get raw processes inside a function * server: rename * server: log * add detail info * server: add cant connect case * server: omitempty * server: re-order the table * server: make detail a struct * server: define agent address early * server: save multiple details * server: create kimo processes inside server file * static: sort by id * server: convert combine method to function * config: delete unused configs * server: set metrics after process generation * server: consider tcpproxy absence * ui: group columns * server: log * server: use context * agent: move polling logic to poll.go * agent: use context * agent: convert method to func * server: remove force param * server: do polling in another file * server: define context above * server: use context * use buffered channels * agent: check only tcp connections * server: simplify metrics * server: format cmdline * use yaml config * pass only necessary config * delete unused flag * agent returns cmdline as string for the sake of simplicity * server: anonymize unknown cmdline * agent: delete unused field * show connection status * handle agent errors * server: check tcp proxy existence * server: pass IPPort to agent client * agent: rename * use mutex * server: rename * server: rename * server: define getters for simplicity * doc & organize * metric: rename * agent: create agent.go file to organize better * agent: organize
- Loading branch information
Showing
27 changed files
with
1,012 additions
and
740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
FROM golang:1.23 | ||
|
||
RUN apt-get update && apt-get -y install default-mysql-client | ||
# Install system dependencies | ||
RUN apt-get update && \ | ||
apt-get -y install default-mysql-client && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV GOPATH=/go | ||
ENV PATH=$PATH:$GOPATH/bin | ||
|
||
RUN mkdir /go/src/kimo | ||
COPY go.mod go.sum /go/src/kimo/ | ||
COPY ./server/static/ /go/src/kimo/server/static | ||
WORKDIR /go/src/kimo | ||
|
||
RUN cd /go/src/kimo && go install github.com/rakyll/statik | ||
RUN cd /go/src/kimo && /go/bin/statik -src=./server/static -include='*.html' | ||
# Copy dependency files first to leverage cache | ||
COPY go.mod go.sum ./ | ||
|
||
COPY . /go/src/kimo | ||
RUN cd /go/src/kimo && go install | ||
# Download dependencies separately | ||
RUN go mod download | ||
|
||
ADD config.toml /etc/kimo.toml | ||
# Install statik before copying other files | ||
RUN go install github.com/rakyll/statik | ||
|
||
# Copy only static files needed for statik | ||
COPY ./server/static/ ./server/static/ | ||
RUN /go/bin/statik -src=./server/static -include='*.html' | ||
|
||
# Copy remaining source code | ||
COPY . . | ||
|
||
# Build the application | ||
RUN go build -o /go/bin/kimo | ||
|
||
# Add config file | ||
COPY config.yaml /etc/kimo.yaml |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package agent | ||
|
||
import ( | ||
"context" | ||
"kimo/config" | ||
"net/http" | ||
"os" | ||
"sync" | ||
|
||
"github.com/cenkalti/log" | ||
gopsutilNet "github.com/shirou/gopsutil/v4/net" | ||
) | ||
|
||
// Agent is type for handling agent operations | ||
type Agent struct { | ||
Config *config.AgentConfig | ||
conns []gopsutilNet.ConnectionStat | ||
Hostname string | ||
mu sync.RWMutex // protects conns | ||
} | ||
|
||
// NewAgent creates an returns a new Agent | ||
func NewAgent(cfg *config.AgentConfig) *Agent { | ||
d := new(Agent) | ||
d.Config = cfg | ||
d.Hostname = getHostname() | ||
return d | ||
} | ||
|
||
// SetConns sets connections with lock. | ||
func (a *Agent) SetConns(conns []gopsutilNet.ConnectionStat) { | ||
a.mu.Lock() | ||
a.conns = conns | ||
a.mu.Unlock() | ||
} | ||
|
||
// GetConns gets connections with lock. | ||
func (a *Agent) GetConns() []gopsutilNet.ConnectionStat { | ||
a.mu.RLock() | ||
defer a.mu.RUnlock() | ||
return a.conns | ||
} | ||
|
||
// getHostname returns hostname. | ||
func getHostname() string { | ||
hostname, err := os.Hostname() | ||
if err != nil { | ||
log.Errorf("Hostname could not found") | ||
hostname = "UNKNOWN" | ||
} | ||
return hostname | ||
} | ||
|
||
// Run starts the http server and begins listening for HTTP requests. | ||
func (a *Agent) Run() error { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
go a.pollConns(ctx) | ||
|
||
http.HandleFunc("/proc", a.Process) | ||
err := http.ListenAndServe(a.Config.ListenAddress, nil) | ||
if err != nil { | ||
log.Errorln(err.Error()) | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.