diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index 40fd8be..8f67404 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -66,6 +66,6 @@ jobs: --bare --verbose . cd ../.. # Uncomment after agent works - # cd cmd/cloud - # KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-cloud CGO_ENABLED=1 GOFLAGS="-tags=containers" ko build ... + # cd cmd/core + # KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-core CGO_ENABLED=1 GOFLAGS="-tags=containers" ko build ... # (add other components) \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea2e911..9ad571c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: run: | ./scripts/setup-deb-agent.sh ./scripts/setup-deb-poller.sh - ./scripts/setup-deb-cloud.sh + ./scripts/setup-deb-core.sh ./scripts/setup-deb-web.sh ./scripts/setup-deb-dusk-checker.sh ./scripts/setup-deb-snmp-checker.sh @@ -76,10 +76,10 @@ jobs: run: ./scripts/build-web.sh - name: Move web artifacts run: | - mkdir -p pkg/cloud/api/web/ - cp -r web/dist pkg/cloud/api/web/ - mkdir -p cmd/cloud/.kodata - cp -r web/dist cmd/cloud/.kodata/web + mkdir -p pkg/core/api/web/ + cp -r web/dist pkg/core/api/web/ + mkdir -p cmd/core/.kodata + cp -r web/dist cmd/core/.kodata/web - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -100,6 +100,6 @@ jobs: --image-refs=image-refs.txt \ ./cmd/agent \ ./cmd/poller \ - ./cmd/cloud \ + ./cmd/core \ ./cmd/checkers/dusk \ ./cmd/checkers/snmp \ No newline at end of file diff --git a/.gitignore b/.gitignore index f6edd14..955d9e3 100644 --- a/.gitignore +++ b/.gitignore @@ -145,7 +145,7 @@ elements/ # binaries ./poller ./agent -./cloud +./core ./web/dist/assets ./dist @@ -157,6 +157,8 @@ elements/ serviceradar-dusk_*/ serviceradar-poller_*/ serviceradar-cloud_*/ +serviceradar-core*/ +serviceradar-web*/ /pkg/cloud/api/web/dist/assets/ # Coverage files diff --git a/.golangci.yml b/.golangci.yml index 10002f8..11d8cea 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -150,7 +150,7 @@ issues: # exclude-use-default: false # By default, golangci-lint does not enforce comments on exported types. We want it. # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - - path: pkg/cloud/api/server\.go + - path: pkg/core/api/server\.go linters: - typecheck - path: _test\.go diff --git a/.goreleaser.yml b/.goreleaser.yml index 00023e3..8bc16e4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -55,9 +55,9 @@ builds: ldflags: - -s -w -X main.version={{.Version}} - - id: serviceradar-cloud - main: ./cmd/cloud/main.go - binary: serviceradar-cloud + - id: serviceradar-core + main: ./cmd/core/main.go + binary: serviceradar-core dir: . goos: - linux @@ -67,7 +67,7 @@ builds: - -s -w -X main.version={{.Version}} hooks: pre: - - ./scripts/build-cloud.sh {{ .Version }} + - ./scripts/build-core.sh {{ .Version }} nfpms: - id: agent @@ -118,34 +118,34 @@ nfpms: postinstall: ./packaging/poller/scripts/postinstall.sh preremove: ./packaging/poller/scripts/preremove.sh - - id: cloud - package_name: serviceradar-cloud + - id: core + package_name: serviceradar-core file_name_template: "{{ .PackageName }}_{{ .Version }}" builds: - - serviceradar-cloud + - serviceradar-core vendor: ServiceRadar homepage: https://github.com/carverauto/serviceradar maintainer: Michael Freeman - description: ServiceRadar Cloud Component + description: ServiceRadar Core Component license: MIT formats: - deb dependencies: - systemd contents: - - src: dist/cloud_linux_amd64_v1/serviceradar-cloud - dst: /usr/local/bin/serviceradar-cloud - - src: ./packaging/cloud/systemd/serviceradar-cloud.service - dst: /lib/systemd/system/serviceradar-cloud.service - - src: ./packaging/cloud/config/cloud.json - dst: /etc/serviceradar/cloud.json + - src: dist/core_linux_amd64_v1/serviceradar-core + dst: /usr/local/bin/serviceradar-core + - src: ./packaging/core/systemd/serviceradar-core.service + dst: /lib/systemd/system/serviceradar-core.service + - src: ./packaging/core/config/core.json + dst: /etc/serviceradar/core.json type: config - - src: pkg/cloud/api/web/dist - dst: /usr/local/share/serviceradar-cloud/web/dist + - src: pkg/core/api/web/dist + dst: /usr/local/share/serviceradar-core/web/dist type: "tree" scripts: - postinstall: ./packaging/cloud/scripts/postinstall.sh - preremove: ./packaging/cloud/scripts/preremove.sh + postinstall: ./packaging/core/scripts/postinstall.sh + preremove: ./packaging/core/scripts/preremove.sh - id: dusk-checker package_name: serviceradar-dusk-checker @@ -184,7 +184,7 @@ release: - serviceradar-dusk-checker: Agent package for monitoring Dusk nodes - serviceradar-agent: Agent performs checks, collects information from external checkers (dusk) - serviceradar-poller: Network poller for collecting monitoring data from Agent - - serviceradar-cloud: Cloud service with web interface and alerts + - serviceradar-core: Core service with web interface and alerts ## Installation See the [README.md](README.md) for detailed installation instructions. @@ -197,8 +197,8 @@ release: sudo dpkg -i serviceradar-dusk-checker_{{ .Version }}.deb # On monitoring host (can co-locate with agent): sudo dpkg -i serviceradar-poller_{{ .Version }}.deb - # On cloud host (can co-locate with poller+agent): - sudo dpkg -i serviceradar-cloud_{{ .Version }}.deb + # On core host (can co-locate with poller+agent): + sudo dpkg -i serviceradar-core_{{ .Version }}.deb ``` changelog: diff --git a/.ko.yaml b/.ko.yaml index 77cb9ef..ecd284e 100644 --- a/.ko.yaml +++ b/.ko.yaml @@ -35,9 +35,9 @@ builds: ldflags: - -s -w -X main.version={{.Env.VERSION}} - - id: cloud - dir: ./cmd/cloud - main: ./cmd/cloud + - id: core + dir: ./cmd/core + main: ./cmd/core env: - CGO_ENABLED=0 flags: diff --git a/Dockerfile-rpm.core b/Dockerfile-rpm.core index 47402b5..b9cf478 100644 --- a/Dockerfile-rpm.core +++ b/Dockerfile-rpm.core @@ -41,11 +41,11 @@ RUN go mod download COPY . . # Copy the built web UI from the previous stage -COPY --from=web-builder /web-build/dist ./pkg/cloud/api/web/dist +COPY --from=web-builder /web-build/dist ./pkg/core/api/web/dist -# Build the cloud service +# Build the core service RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ - go build -o serviceradar-cloud ./cmd/cloud + go build -o serviceradar-core ./cmd/core # Stage 3: Create RPM FROM --platform=linux/amd64 rockylinux:9 AS rpm-builder @@ -60,12 +60,12 @@ RUN dnf install -y \ RUN rpmdev-setuptree # Copy built artifacts and spec files -COPY --from=go-builder /src/serviceradar-cloud /root/rpmbuild/BUILD/ +COPY --from=go-builder /src/serviceradar-core /root/rpmbuild/BUILD/ COPY packaging/config/*.json /root/rpmbuild/SOURCES/config/ -# TODO: fix this, sweep.json is part of agent NOT cloud.g +# TODO: fix this, sweep.json is part of agent NOT core COPY packaging/config/checkers/sweep/sweep.json /root/rpmbuild/SOURCES/config/checkers/sweep/ -COPY packaging/specs/serviceradar-cloud.spec /root/rpmbuild/SPECS/ -COPY packaging/cloud/systemd/serviceradar-cloud.service /root/rpmbuild/SOURCES/systemd/ +COPY packaging/specs/serviceradar-core.spec /root/rpmbuild/SPECS/ +COPY packaging/core/systemd/serviceradar-core.service /root/rpmbuild/SOURCES/systemd/ COPY scripts/setup-rpm-*.sh /build/ # Set default version (can be overridden at build time) @@ -76,7 +76,7 @@ ARG RELEASE=1 RUN rpmbuild -bb \ --define "version ${VERSION}" \ --define "release ${RELEASE}" \ - /root/rpmbuild/SPECS/serviceradar-cloud.spec + /root/rpmbuild/SPECS/serviceradar-core.spec # Stage 4: Create a minimal image with just the RPM FROM --platform=linux/amd64 rockylinux:9 diff --git a/Dockerfile.build b/Dockerfile.build index d75d69a..90d1fb6 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -39,4 +39,4 @@ RUN go mod download COPY . . # Default command - but we'll override this in build.sh -CMD ["./setup-deb-cloud.sh"] \ No newline at end of file +CMD ["./setup-deb-core.sh"] \ No newline at end of file diff --git a/Dockerfile.core b/Dockerfile.core index 9616e89..e8240d8 100644 --- a/Dockerfile.core +++ b/Dockerfile.core @@ -41,8 +41,8 @@ RUN go mod download COPY . . # Copy the built web UI from the previous stage -COPY --from=web-builder /web-build/dist ./pkg/cloud/api/web/dist +COPY --from=web-builder /web-build/dist ./pkg/core/api/web/dist -# Build the cloud service +# Build the core service RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ - go build -o serviceradar-cloud ./cmd/cloud \ No newline at end of file + go build -o serviceradar-core ./cmd/core \ No newline at end of file diff --git a/Dockerfile.goreleaser.core b/Dockerfile.goreleaser.core index d7c1708..0fc9f35 100644 --- a/Dockerfile.goreleaser.core +++ b/Dockerfile.goreleaser.core @@ -37,9 +37,9 @@ COPY . . # Build web interface RUN cd web && npm install && npm run build \ - && mkdir -p /src/pkg/cloud/api/web \ - && cp -r dist /src/pkg/cloud/api/web/ + && mkdir -p /src/pkg/core/api/web \ + && cp -r dist /src/pkg/core/api/web/ -# Build the cloud service +# Build the core service RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ - go build -o serviceradar-cloud ./cmd/cloud + go build -o serviceradar-core ./cmd/core diff --git a/Makefile b/Makefile index 959534a..e4d1f00 100644 --- a/Makefile +++ b/Makefile @@ -103,30 +103,23 @@ build: ## Build all binaries @$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-agent cmd/agent/main.go @$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-poller cmd/poller/main.go @$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-dusk-checker cmd/checkers/dusk/main.go - @$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-cloud cmd/cloud/main.go + @$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-core cmd/core/main.go @$(GO) build -ldflags "-X main.version=$(VERSION)" -o bin/serviceradar-snmp-checker cmd/checkers/snmp/main.go -.PHONY: build-web -build-web: ## Build web UI - @echo "$(COLOR_BOLD)Building web UI$(COLOR_RESET)" - @./scripts/build-web.sh - @mkdir -p pkg/cloud/api/web/ - @cp -r web/dist pkg/cloud/api/web/ - .PHONY: kodata-prep kodata-prep: build-web ## Prepare kodata directories @echo "$(COLOR_BOLD)Preparing kodata directories$(COLOR_RESET)" - @mkdir -p cmd/cloud/.kodata - @cp -r pkg/cloud/api/web/dist cmd/cloud/.kodata/web + @mkdir -p cmd/core/.kodata + @cp -r pkg/core/api/web/dist cmd/core/.kodata/web .PHONY: container-build container-build: kodata-prep ## Build container images with ko @echo "$(COLOR_BOLD)Building container images with ko$(COLOR_RESET)" @cd cmd/agent && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-agent GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION) --bare . @cd cmd/poller && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-poller GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION) --bare . - @echo "$(COLOR_BOLD)Building cloud container with CGO using Docker (amd64 only)$(COLOR_RESET)" + @echo "$(COLOR_BOLD)Building core container with CGO using Docker (amd64 only)$(COLOR_RESET)" @docker buildx build --platform=linux/amd64 -f Dockerfile.build \ - -t $(KO_DOCKER_REPO)/serviceradar-cloud:$(VERSION) \ + -t $(KO_DOCKER_REPO)/serviceradar-core:$(VERSION) \ --build-arg VERSION=$(VERSION) \ --build-arg BUILD_TAGS=containers \ --push . @@ -138,10 +131,10 @@ container-push: kodata-prep ## Build and push container images with ko @echo "$(COLOR_BOLD)Building and pushing container images with ko$(COLOR_RESET)" @cd cmd/agent && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-agent GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION),latest --bare . @cd cmd/poller && KO_DOCKER_REPO=$(KO_DOCKER_REPO)/serviceradar-poller GOFLAGS="-tags=containers" ko build --platform=$(PLATFORMS) --tags=$(VERSION),latest --bare . - @echo "$(COLOR_BOLD)Building and pushing cloud container with CGO using Docker (amd64 only)$(COLOR_RESET)" + @echo "$(COLOR_BOLD)Building and pushing core container with CGO using Docker (amd64 only)$(COLOR_RESET)" @docker buildx build --platform=linux/amd64 -f Dockerfile.build \ - -t $(KO_DOCKER_REPO)/serviceradar-cloud:$(VERSION) \ - -t $(KO_DOCKER_REPO)/serviceradar-cloud:latest \ + -t $(KO_DOCKER_REPO)/serviceradar-core:$(VERSION) \ + -t $(KO_DOCKER_REPO)/serviceradar-core:latest \ --build-arg VERSION=$(VERSION) \ --build-arg BUILD_TAGS=containers \ --push . @@ -159,15 +152,15 @@ deb-poller: build-web ## Build the poller Debian package @echo "$(COLOR_BOLD)Building poller Debian package$(COLOR_RESET)" @./scripts/setup-deb-poller.sh -.PHONY: deb-cloud -deb-cloud: build-web ## Build the cloud Debian package (standard) - @echo "$(COLOR_BOLD)Building cloud Debian package$(COLOR_RESET)" - @VERSION=$(VERSION) ./scripts/setup-deb-cloud.sh +.PHONY: deb-core +deb-core: build-web ## Build the core Debian package (standard) + @echo "$(COLOR_BOLD)Building core Debian package$(COLOR_RESET)" + @VERSION=$(VERSION) ./scripts/setup-deb-core.sh -.PHONY: deb-cloud-container -deb-cloud-container: build-web ## Build the cloud Debian package with container support - @echo "$(COLOR_BOLD)Building cloud Debian package with container support$(COLOR_RESET)" - @VERSION=$(VERSION) BUILD_TAGS=containers ./scripts/setup-deb-cloud.sh +.PHONY: deb-core-container +deb-core-container: build-web ## Build the core Debian package with container support + @echo "$(COLOR_BOLD)Building core Debian package with container support$(COLOR_RESET)" + @VERSION=$(VERSION) BUILD_TAGS=containers ./scripts/setup-deb-core.sh .PHONY: deb-dusk deb-dusk: ## Build the Dusk checker Debian package @@ -180,12 +173,12 @@ deb-snmp: ## Build the SNMP checker Debian package @./scripts/setup-deb-snmp-checker.sh .PHONY: deb-all -deb-all: deb-agent deb-poller deb-cloud deb-dusk deb-snmp ## Build all Debian packages +deb-all: deb-agent deb-poller deb-core deb-dusk deb-snmp ## Build all Debian packages @echo "$(COLOR_BOLD)All Debian packages built$(COLOR_RESET)" .PHONY: deb-all-container -deb-all-container: deb-agent deb-poller deb-cloud-container deb-dusk deb-snmp ## Build all Debian packages with container support for cloud - @echo "$(COLOR_BOLD)All Debian packages built (with container support for cloud)$(COLOR_RESET)" +deb-all-container: deb-agent deb-poller deb-core-container deb-dusk deb-snmp ## Build all Debian packages with container support for core + @echo "$(COLOR_BOLD)All Debian packages built (with container support for core)$(COLOR_RESET)" # Docusaurus commands .PHONY: docs-start diff --git a/README.md b/README.md index 0387c5f..2ddbab2 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,9 @@ sudo dpkg -i serviceradar-agent_1.0.20.deb serviceradar-poller_1.0.20.deb On a separate machine (recommended) or the same host: ```bash -# Download and install cloud service -curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-cloud_1.0.20.deb -sudo dpkg -i serviceradar-cloud_1.0.20.deb +# Download and install core service +curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-core_1.0.20.deb +sudo dpkg -i serviceradar-core_1.0.20.deb ``` #### Optional: SNMP Polling @@ -89,10 +89,10 @@ curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/ser sudo dpkg -i serviceradar-poller_1.0.20.deb ``` -3. On cloud host: +3. On core host: ```bash -curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-cloud_1.0.20.deb -sudo dpkg -i serviceradar-cloud_1.0.20.deb +curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-core.0.20.deb +sudo dpkg -i serviceradar-core.0.20.deb ``` ## Security @@ -128,7 +128,7 @@ graph TD end subgraph "Cloud/Internet" - P --> CS[Cloud Service] + P --> CS[Core Service] CS --> WH[Webhook Alerts] WH --> Discord[Discord] WH --> Custom[Custom Webhooks] @@ -153,10 +153,10 @@ graph TD - Coordinates monitoring activities - Can run on the same host as an agent or separately - Polls agents at configurable intervals - - Reports status to cloud service - - Multiple pollers can report to the same cloud service + - Reports status to core service + - Multiple pollers can report to the same core service -3. **Cloud Service** (runs on a reliable host) +3. **Core Service** (runs on a reliable host) - Receives reports from pollers - Provides web dashboard - Sends alerts via webhooks (Discord, etc.) @@ -184,9 +184,9 @@ cd serviceradar ./scripts/setup-deb-poller.sh ``` -4. Build the cloud package: +4. Build the core package: ```bash -./scripts/setup-deb-cloud.sh +./scripts/setup-deb-core.sh ``` 5. Build the dusk provisioner node package (optional): @@ -215,7 +215,7 @@ sudo dpkg -i serviceradar-poller_1.0.20.deb 3. **Cloud Installation** (on a reliable host): ```bash -sudo dpkg -i serviceradar-cloud_1.0.20.deb +sudo dpkg -i serviceradar-core.0.20.deb ``` 4. **SNMP Poller** (Optional): @@ -383,7 +383,7 @@ Default location: `/etc/serviceradar/poller.json` ] } }, - "cloud_address": "changeme:50052", + "core_address": "changeme:50052", "listen_addr": ":50053", "poll_interval": "30s", "poller_id": "dusk", @@ -398,17 +398,17 @@ Default location: `/etc/serviceradar/poller.json` } ``` -**Note**: Make sure you update the `cloud_address` to the hostname/IP address of the cloud service. +**Note**: Make sure you update the `core_address` to the hostname/IP address of the core service. For mTLS Security: * Change `mode` to `mtls` -* Change `server_name` to the hostname/IP address of the cloud service, eg. `172.233.208.110` +* Change `server_name` to the hostname/IP address of the core service, eg. `172.233.208.110` * Change `local_agent/address` to the hostname/IP address of the agent, eg. `192.168.2.22:50051` * Change `listen_addr` to the hostname/IP address, eg. `192.168.2.22:50053` -### Cloud Configuration +### Core Configuration -Default location: `/etc/serviceradar/cloud.json` +Default location: `/etc/serviceradar/core.json` ```json { @@ -424,7 +424,7 @@ Default location: `/etc/serviceradar/cloud.json` "security": { "mode": "none", "cert_dir": "/etc/serviceradar/certs", - "role": "cloud" + "role": "core" }, "webhooks": [ { @@ -462,11 +462,11 @@ For mTLS Security: 2. **Poller Deployment**: - Can run on the same host as an agent or separately - Must be able to reach all agents - - Must be able to reach the cloud service - - Multiple pollers can report to the same cloud service + - Must be able to reach the core service + - Multiple pollers can report to the same core service - Each poller needs a unique poller_id -3. **Cloud Service Deployment**: +3. **Core Service Deployment**: - Should run on a reliable host outside your network - Needs to be accessible by all pollers - Provides web interface on port 8090 @@ -481,14 +481,14 @@ If you're using UFW (Ubuntu's Uncomplicated Firewall), here are the required rul sudo ufw allow 50051/tcp # For agent gRPC server sudo ufw allow 50052/tcp # For Dusk checker (if applicable) -# On cloud host +# On core host sudo ufw allow 50052/tcp # For poller connections sudo ufw allow 8090/tcp # For web interface ``` ## Web Interface -The web interface is available at `http://cloud-host:8090` and provides: +The web interface is available at `http://core-host:8090` and provides: - Overall system status - Individual node status - Service status for each node diff --git a/cmd/core/main.go b/cmd/core/main.go index ed52653..8c9d961 100644 --- a/cmd/core/main.go +++ b/cmd/core/main.go @@ -36,7 +36,7 @@ func main() { func run() error { // Parse command line flags - configPath := flag.String("config", "/etc/serviceradar/cloud.json", "Path to cloud config file") + configPath := flag.String("config", "/etc/serviceradar/core.json", "Path to core config file") flag.Parse() // Load configuration @@ -48,7 +48,7 @@ func run() error { // Create root context for lifecycle management ctx := context.Background() - // Create cloud server + // Create core server server, err := core.NewServer(ctx, &cfg) if err != nil { return err diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index 6b48407..2849679 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -42,7 +42,7 @@ Edit `/etc/serviceradar/poller.json`: ] } }, - "cloud_address": "changeme:50052", + "core_address": "changeme:50052", "listen_addr": ":50053", "poll_interval": "30s", "poller_id": "my-poller", @@ -50,12 +50,12 @@ Edit `/etc/serviceradar/poller.json`: } ``` -* Set `cloud_address` to your cloud service’s hostname/IP. +* Set `core_address` to your core service’s hostname/IP. * Adjust `agents` to list your monitored hosts. ## Cloud Configuration -Edit `/etc/serviceradar/cloud.json`: +Edit `/etc/serviceradar/core.json`: ```json { diff --git a/docs/docs/installation.md b/docs/docs/installation.md index c2a148a..eb803fa 100644 --- a/docs/docs/installation.md +++ b/docs/docs/installation.md @@ -18,11 +18,11 @@ curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/ser sudo dpkg -i serviceradar-agent_1.0.20.deb serviceradar-poller_1.0.20.deb ``` -On a separate machine (recommended) or the same host for the cloud service: +On a separate machine (recommended) or the same host for the core service: ```bash -curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-cloud_1.0.20.deb -sudo dpkg -i serviceradar-cloud_1.0.20.deb +curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-core.0.20.deb +sudo dpkg -i serviceradar-core.0.20.deb ``` ## Optional Components @@ -63,9 +63,9 @@ curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/ser sudo dpkg -i serviceradar-poller_1.0.20.deb ``` -3. On cloud host: +3. On core host: ```bash -curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-cloud_1.0.20.deb -sudo dpkg -i serviceradar-cloud_1.0.20.deb +curl -LO https://github.com/carverauto/serviceradar/releases/download/1.0.20/serviceradar-core.0.20.deb +sudo dpkg -i serviceradar-core.0.20.deb ``` \ No newline at end of file diff --git a/packaging/cloud/config/cloud.json b/packaging/cloud/config/core.json similarity index 98% rename from packaging/cloud/config/cloud.json rename to packaging/cloud/config/core.json index 977c1b9..b5bbf2b 100644 --- a/packaging/cloud/config/cloud.json +++ b/packaging/cloud/config/core.json @@ -11,7 +11,7 @@ "security": { "mode": "none", "cert_dir": "/etc/serviceradar/certs", - "role": "cloud" + "role": "core" }, "webhooks": [ { diff --git a/packaging/cloud/scripts/package.sh b/packaging/cloud/scripts/package.sh index 530b8fc..5bc30b5 100755 --- a/packaging/cloud/scripts/package.sh +++ b/packaging/cloud/scripts/package.sh @@ -1,5 +1,5 @@ #!/bin/bash -# setup-deb-cloud.sh +# setup-deb-core.sh set -e # Exit on any error echo "Setting up package structure..." @@ -7,7 +7,7 @@ echo "Setting up package structure..." VERSION=${VERSION:-1.0.12} # Create package directory structure -PKG_ROOT="serviceradar-cloud_${VERSION}" +PKG_ROOT="serviceradar-core${VERSION}" mkdir -p "${PKG_ROOT}/DEBIAN" mkdir -p "${PKG_ROOT}/usr/local/bin" mkdir -p "${PKG_ROOT}/etc/serviceradar" @@ -22,48 +22,48 @@ npm run build cd .. # Create a directory for the embedded content -mkdir -p pkg/cloud/api/web -cp -r web/dist pkg/cloud/api/web/ +mkdir -p pkg/core/api/web +cp -r web/dist pkg/core/api/web/ echo "Building Go binary..." # Build Go binary with embedded web content -cd cmd/cloud -#GOOS=linux GOARCH=amd64 go build -o "../../${PKG_ROOT}/usr/local/bin/serviceradar-cloud" -CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o "../../${PKG_ROOT}/usr/local/bin/serviceradar-cloud" +cd cmd/core +#GOOS=linux GOARCH=amd64 go build -o "../../${PKG_ROOT}/usr/local/bin/serviceradar-core" +CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o "../../${PKG_ROOT}/usr/local/bin/serviceradar-core" cd ../.. echo "Creating package files..." # Create control file cat > "${PKG_ROOT}/DEBIAN/control" << EOF -Package: serviceradar-cloud +Package: serviceradar-core Version: ${VERSION} Section: utils Priority: optional Architecture: amd64 Depends: systemd Maintainer: Michael Freeman -Description: ServiceRadar cloud service with web interface +Description: ServiceRadar core service with web interface Provides centralized monitoring and web dashboard for ServiceRadar. -Config: /etc/serviceradar/cloud.json +Config: /etc/serviceradar/core.json EOF # Create conffiles to mark configuration files cat > "${PKG_ROOT}/DEBIAN/conffiles" << EOF -/etc/serviceradar/cloud.json +/etc/serviceradar/core.json EOF # Create systemd service file -cat > "${PKG_ROOT}/lib/systemd/system/serviceradar-cloud.service" << EOF +cat > "${PKG_ROOT}/lib/systemd/system/serviceradar-core.service" << EOF [Unit] -Description=ServiceRadar Cloud Service +Description=ServiceRadar Core Service After=network.target [Service] Type=simple User=serviceradar -ExecStart=/usr/local/bin/serviceradar-cloud -config /etc/serviceradar/cloud.json +ExecStart=/usr/local/bin/serviceradar-core -config /etc/serviceradar/core.json Restart=always RestartSec=10 TimeoutStopSec=20 @@ -75,9 +75,9 @@ WantedBy=multi-user.target EOF # Create default config only if we're creating a fresh package -if [ ! -f "/etc/serviceradar/cloud.json" ]; then +if [ ! -f "/etc/serviceradar/core.json" ]; then # Create default config file - cat > "${PKG_ROOT}/etc/serviceradar/cloud.json" << EOF + cat > "${PKG_ROOT}/etc/serviceradar/core.json" << EOF { "listen_addr": ":8090", "grpc_addr": ":50052", @@ -123,7 +123,7 @@ fi # Set permissions chown -R serviceradar:serviceradar /etc/serviceradar -chmod 755 /usr/local/bin/serviceradar-cloud +chmod 755 /usr/local/bin/serviceradar-core mkdir -p "${PKG_ROOT}/var/lib/serviceradar" chown -R serviceradar:serviceradar "${PKG_ROOT}/var/lib/serviceradar" @@ -131,8 +131,8 @@ chmod 755 "${PKG_ROOT}/var/lib/serviceradar" # Enable and start service systemctl daemon-reload -systemctl enable serviceradar-cloud -systemctl start serviceradar-cloud +systemctl enable serviceradar-core +systemctl start serviceradar-core exit 0 EOF @@ -145,8 +145,8 @@ cat > "${PKG_ROOT}/DEBIAN/prerm" << EOF set -e # Stop and disable service -systemctl stop serviceradar-cloud -systemctl disable serviceradar-cloud +systemctl stop serviceradar-core +systemctl disable serviceradar-core exit 0 EOF diff --git a/packaging/cloud/systemd/serviceradar-cloud.service b/packaging/cloud/systemd/serviceradar-cloud.service index f540d92..16274c4 100644 --- a/packaging/cloud/systemd/serviceradar-cloud.service +++ b/packaging/cloud/systemd/serviceradar-cloud.service @@ -1,11 +1,11 @@ [Unit] -Description=ServiceRadar Cloud Service +Description=ServiceRadar Core Service After=network.target [Service] Type=simple User=serviceradar -ExecStart=/usr/local/bin/serviceradar-cloud -config /etc/serviceradar/cloud.json +ExecStart=/usr/local/bin/serviceradar-core -config /etc/serviceradar/core.json Restart=always RestartSec=10 TimeoutStopSec=20 diff --git a/packaging/config/poller.json b/packaging/config/poller.json index 538fa56..5b4ddb5 100644 --- a/packaging/config/poller.json +++ b/packaging/config/poller.json @@ -21,7 +21,7 @@ ] } }, - "cloud_address": "127.0.0.1:50052", + "core_address": "127.0.0.1:50052", "listen_addr": ":50053", "poll_interval": "30s", "poller_id": "default-poller", diff --git a/packaging/poller/config/poller.json b/packaging/poller/config/poller.json index fd7ba8e..7ae6777 100644 --- a/packaging/poller/config/poller.json +++ b/packaging/poller/config/poller.json @@ -35,7 +35,7 @@ ] } }, - "cloud_address": "changeme:50052", + "core_address": "changeme:50052", "listen_addr": ":50053", "poll_interval": "30s", "poller_id": "dusk", diff --git a/packaging/poller/scripts/package.sh b/packaging/poller/scripts/package.sh index 7fedbca..ea23f42 100755 --- a/packaging/poller/scripts/package.sh +++ b/packaging/poller/scripts/package.sh @@ -31,7 +31,7 @@ Depends: systemd Maintainer: Michael Freeman Description: ServiceRadar poller service Poller component for ServiceRadar monitoring system. - Collects and forwards monitoring data from agents to cloud service. + Collects and forwards monitoring data from agents to core service. Config: /etc/serviceradar/poller.json EOF @@ -94,7 +94,7 @@ cat > "${PKG_ROOT}/etc/serviceradar/poller.json" << EOF ] } }, - "cloud_address": "changeme:50052", + "core_address": "changeme:50052", "listen_addr": ":50053", "poll_interval": "30s", "poller_id": "dusk", diff --git a/packaging/setup.sh b/packaging/setup.sh index 936c9a2..d72dc8a 100755 --- a/packaging/setup.sh +++ b/packaging/setup.sh @@ -20,7 +20,7 @@ set -e echo "Creating packaging structure..." # Create packaging structure -mkdir -p packaging/{agent,poller,cloud,dusk}/{config,systemd,scripts} +mkdir -p packaging/{agent,poller,core,dusk}/{config,systemd,scripts} # Function to get component directory name get_component_dir() { @@ -57,12 +57,12 @@ for script in setup-deb-*.sh; do awk '/cat > "\${PKG_ROOT}\/lib\/systemd\/system\/serviceradar-poller.service"/,/^EOF/' "$script" | sed '1d;$d' > "packaging/poller/systemd/serviceradar-poller.service" ;; - "cloud") - # Extract cloud configuration - awk '/cat > "\${PKG_ROOT}\/etc\/serviceradar\/cloud.json"/,/^EOF/' "$script" | sed '1d;$d' > "packaging/cloud/config/cloud.json" + "core") + # Extract core configuration + awk '/cat > "\${PKG_ROOT}\/etc\/serviceradar\/core.json"/,/^EOF/' "$script" | sed '1d;$d' > "packaging/core/config/core.json" # Extract systemd service - awk '/cat > "\${PKG_ROOT}\/lib\/systemd\/system\/serviceradar-cloud.service"/,/^EOF/' "$script" | sed '1d;$d' > "packaging/cloud/systemd/serviceradar-cloud.service" + awk '/cat > "\${PKG_ROOT}\/lib\/systemd\/system\/serviceradar-core.service"/,/^EOF/' "$script" | sed '1d;$d' > "packaging/core/systemd/serviceradar-core.service" ;; "dusk-checker") @@ -73,7 +73,7 @@ for script in setup-deb-*.sh; do done # Create postinstall and preremove scripts for each component -for component_dir in agent poller cloud dusk; do +for component_dir in agent poller core dusk; do echo "Creating install scripts for $component_dir..." # Create postinstall script diff --git a/packaging/specs/serviceradar-cloud.spec b/packaging/specs/serviceradar-core.spec similarity index 67% rename from packaging/specs/serviceradar-cloud.spec rename to packaging/specs/serviceradar-core.spec index 6f34665..bb25e90 100644 --- a/packaging/specs/serviceradar-cloud.spec +++ b/packaging/specs/serviceradar-core.spec @@ -1,14 +1,14 @@ -Name: serviceradar-cloud +Name: serviceradar-core Version: %{version} Release: %{release}%{?dist} -Summary: ServiceRadar cloud service with web interface +Summary: ServiceRadar core service with web interface License: Proprietary BuildRequires: systemd Requires: systemd %{?systemd_requires} -Source: systemd/serviceradar-cloud.service # Corrected: Added Source tag +Source: systemd/serviceradar-core.service %description Provides centralized monitoring and web dashboard for ServiceRadar. @@ -21,17 +21,17 @@ mkdir -p %{buildroot}/lib/systemd/system mkdir -p %{buildroot}/var/lib/serviceradar -install -m 755 %{_builddir}/serviceradar-cloud %{buildroot}/usr/local/bin/ -install -m 644 %{_sourcedir}/systemd/serviceradar-cloud.service %{buildroot}/lib/systemd/system/serviceradar-cloud.service -install -m 644 %{_sourcedir}/config/cloud.json %{buildroot}/etc/serviceradar/ +install -m 755 %{_builddir}/serviceradar-core %{buildroot}/usr/local/bin/ +install -m 644 %{_sourcedir}/systemd/serviceradar-core.service %{buildroot}/lib/systemd/system/serviceradar-core.service +install -m 644 %{_sourcedir}/config/core.json %{buildroot}/etc/serviceradar/ install -m 644 %{_sourcedir}/config/checkers/sweep/sweep.json %{buildroot}/etc/serviceradar/checkers/sweep/ %files -%attr(0755, root, root) /usr/local/bin/serviceradar-cloud -%config(noreplace) %attr(0644, serviceradar, serviceradar) /etc/serviceradar/cloud.json +%attr(0755, root, root) /usr/local/bin/serviceradar-core +%config(noreplace) %attr(0644, serviceradar, serviceradar) /etc/serviceradar/core.json %config(noreplace) %attr(0644, serviceradar, serviceradar) /etc/serviceradar/checkers/sweep/sweep.json -%attr(0644, root, root) /lib/systemd/system/serviceradar-cloud.service +%attr(0644, root, root) /lib/systemd/system/serviceradar-core.service %dir %attr(0755, root, root) /etc/serviceradar %dir %attr(0755, serviceradar, serviceradar) /var/lib/serviceradar @@ -42,7 +42,7 @@ if ! id -u serviceradar >/dev/null 2>&1; then fi %post -%systemd_post serviceradar-cloud.service +%systemd_post serviceradar-core.service # Check if firewalld is running if systemctl is-active firewalld.service >/dev/null 2>&1; then @@ -56,12 +56,12 @@ fi # SELinux (if needed) if getenforce | grep -q "Enforcing"; then semanage -a -t http_port_t -p tcp 8090 >/dev/null 2>&1 - restorecon -Rv /usr/local/bin/serviceradar-cloud # Adjust path + restorecon -Rv /usr/local/bin/serviceradar-core logger "Configured SELinux for ServiceRadar (port 8090/tcp)." fi %preun -%systemd_preun serviceradar-cloud.service +%systemd_preun serviceradar-core.service %postun -%systemd_postun_with_restart serviceradar-cloud.service \ No newline at end of file +%systemd_postun_with_restart serviceradar-core.service \ No newline at end of file diff --git a/packaging/specs/serviceradar-poller.spec b/packaging/specs/serviceradar-poller.spec index fb45a56..e4a87ca 100644 --- a/packaging/specs/serviceradar-poller.spec +++ b/packaging/specs/serviceradar-poller.spec @@ -10,7 +10,7 @@ Requires: systemd %description Poller component for ServiceRadar monitoring system. -Collects and forwards monitoring data from agents to cloud service. +Collects and forwards monitoring data from agents to core service. %install mkdir -p %{buildroot}/usr/local/bin diff --git a/pkg/core/api/server.go b/pkg/core/api/server.go index 73e21a8..44d3d6d 100644 --- a/pkg/core/api/server.go +++ b/pkg/core/api/server.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// pkg/cloud/api/server.go +// pkg/core/api/server.go package api diff --git a/pkg/core/interfaces.go b/pkg/core/interfaces.go index 51a08a3..f640af5 100644 --- a/pkg/core/interfaces.go +++ b/pkg/core/interfaces.go @@ -34,7 +34,7 @@ type NodeService interface { CheckNodeHealth(nodeID string) (bool, error) } -// CoreService represents the main cloud service functionality. +// CoreService represents the main core service functionality. type CoreService interface { Start(ctx context.Context) error Stop(ctx context.Context) error diff --git a/pkg/core/server.go b/pkg/core/server.go index e652cd0..ec4f22a 100644 --- a/pkg/core/server.go +++ b/pkg/core/server.go @@ -115,7 +115,7 @@ func (s *Server) initializeWebhooks(configs []alerts.WebhookConfig) { // Start implements the lifecycle.Service interface. func (s *Server) Start(ctx context.Context) error { - log.Printf("Starting cloud service...") + log.Printf("Starting core service...") // Clean up any unknown pollers first if err := s.cleanupUnknownPollers(ctx); err != nil { @@ -272,10 +272,10 @@ func (s *Server) sendStartupNotification(ctx context.Context) error { alert := &alerts.WebhookAlert{ Level: alerts.Info, - Title: "Cloud Service Started", - Message: fmt.Sprintf("ServiceRadar cloud service initialized at %s", time.Now().Format(time.RFC3339)), + Title: "Core Service Started", + Message: fmt.Sprintf("ServiceRadar core service initialized at %s", time.Now().Format(time.RFC3339)), Timestamp: time.Now().UTC().Format(time.RFC3339), - NodeID: "cloud", + NodeID: "core", Details: map[string]any{ "version": "1.0.20", "hostname": getHostname(), @@ -292,10 +292,10 @@ func (s *Server) sendShutdownNotification(ctx context.Context) error { alert := &alerts.WebhookAlert{ Level: alerts.Warning, - Title: "Cloud Service Stopping", - Message: fmt.Sprintf("ServiceRadar cloud service shutting down at %s", time.Now().Format(time.RFC3339)), + Title: "Core Service Stopping", + Message: fmt.Sprintf("ServiceRadar core service shutting down at %s", time.Now().Format(time.RFC3339)), Timestamp: time.Now().UTC().Format(time.RFC3339), - NodeID: "cloud", + NodeID: "core", Details: map[string]any{ "hostname": getHostname(), }, @@ -315,10 +315,10 @@ func (s *Server) Shutdown(ctx context.Context) { if len(s.webhooks) > 0 { alert := alerts.WebhookAlert{ Level: alerts.Warning, - Title: "Cloud Service Stopping", - Message: fmt.Sprintf("ServiceRadar cloud service shutting down at %s", time.Now().Format(time.RFC3339)), + Title: "Core Service Stopping", + Message: fmt.Sprintf("ServiceRadar core service shutting down at %s", time.Now().Format(time.RFC3339)), Timestamp: time.Now().UTC().Format(time.RFC3339), - NodeID: "cloud", + NodeID: "core", Details: map[string]any{ "hostname": getHostname(), "pid": os.Getpid(), @@ -740,7 +740,7 @@ func (s *Server) checkNeverReportedNodes(ctx context.Context) error { Level: alerts.Warning, Title: "Pollers Never Reported", Message: fmt.Sprintf("%d poller(s) have not reported since startup", len(unreportedNodes)), - NodeID: "cloud", + NodeID: "core", Timestamp: time.Now().UTC().Format(time.RFC3339), Details: map[string]any{ "hostname": getHostname(), @@ -800,7 +800,7 @@ func (s *Server) sendUnreportedNodesAlert(ctx context.Context, nodeIDs []string) Level: alerts.Warning, Title: "Pollers Never Reported", Message: fmt.Sprintf("%d poller(s) have not reported since startup", len(nodeIDs)), - NodeID: "cloud", + NodeID: "core", Timestamp: time.Now().UTC().Format(time.RFC3339), Details: map[string]any{ "hostname": getHostname(), diff --git a/pkg/grpc/security.go b/pkg/grpc/security.go index a5794d0..7e262f7 100644 --- a/pkg/grpc/security.go +++ b/pkg/grpc/security.go @@ -79,12 +79,12 @@ func NewMTLSProvider(config *models.SecurityConfig) (*MTLSProvider, error) { // Determine which credentials are needed based on role switch config.Role { case models.RolePoller: - provider.needsClient = true // For connecting to Agent and Cloud + provider.needsClient = true // For connecting to Agent and Core provider.needsServer = true // For health check endpoints case models.RoleAgent: provider.needsClient = true // For connecting to checkers provider.needsServer = true // For accepting poller connections - case models.RoleCloud: + case models.RoleCore: provider.needsServer = true // Only accepts connections case models.RoleChecker: provider.needsServer = true // Only accepts connections diff --git a/pkg/models/grpc.go b/pkg/models/grpc.go index cdc09c6..269ba66 100644 --- a/pkg/models/grpc.go +++ b/pkg/models/grpc.go @@ -27,7 +27,7 @@ type ServiceRole string const ( RolePoller ServiceRole = "poller" // Client and Server RoleAgent ServiceRole = "agent" // Server only - RoleCloud ServiceRole = "cloud" // Server only + RoleCore ServiceRole = "core" // Server only RoleChecker ServiceRole = "checker" // Server only (for SNMP, Dusk checkers) ) diff --git a/pkg/poller/config.go b/pkg/poller/config.go index 82fbcde..46e5c8e 100644 --- a/pkg/poller/config.go +++ b/pkg/poller/config.go @@ -27,7 +27,7 @@ import ( var ( errAgentAddressRequired = fmt.Errorf("agent address is required") errPollerIDRequired = fmt.Errorf("poller id is required") - errCloudAddressRequired = fmt.Errorf("cloud address is required") + errCoreAddressRequired = fmt.Errorf("core address is required") ) const ( @@ -54,7 +54,7 @@ type Config struct { Agents map[string]AgentConfig `json:"agents"` ListenAddr string `json:"listen_addr"` ServiceName string `json:"service_name"` - CloudAddress string `json:"cloud_address"` + CoreAddress string `json:"core_address"` PollInterval config.Duration `json:"poll_interval"` PollerID string `json:"poller_id"` Security *models.SecurityConfig `json:"security"` @@ -62,8 +62,8 @@ type Config struct { // Validate implements config.Validator interface. func (c *Config) Validate() error { - if c.CloudAddress == "" { - return errCloudAddressRequired + if c.CoreAddress == "" { + return errCoreAddressRequired } if c.PollerID == "" { diff --git a/pkg/poller/poller.go b/pkg/poller/poller.go index 3353144..7d60e73 100644 --- a/pkg/poller/poller.go +++ b/pkg/poller/poller.go @@ -55,13 +55,13 @@ type AgentConnection struct { // Poller represents the monitoring poller. type Poller struct { proto.UnimplementedPollerServiceServer - config Config - cloudClient proto.PollerServiceClient - grpcClient *grpc.ClientConn - mu sync.RWMutex - agents map[string]*AgentConnection - done chan struct{} - closeOnce sync.Once + config Config + coreClient proto.PollerServiceClient + grpcClient *grpc.ClientConn + mu sync.RWMutex + agents map[string]*AgentConnection + done chan struct{} + closeOnce sync.Once } // ServiceCheck manages a single service check operation. @@ -78,9 +78,9 @@ func New(ctx context.Context, config *Config) (*Poller, error) { done: make(chan struct{}), } - // Connect to cloud service - if err := p.connectToCloud(ctx); err != nil { - return nil, fmt.Errorf("failed to connect to cloud service: %w", err) + // Connect to core service + if err := p.connectToCore(ctx); err != nil { + return nil, fmt.Errorf("failed to connect to core service: %w", err) } // Initialize agent connections @@ -156,10 +156,10 @@ func (p *Poller) Stop(ctx context.Context) error { p.mu.Lock() defer p.mu.Unlock() - // Close cloud client first - if p.cloudClient != nil { + // Close core client first + if p.coreClient != nil { if err := p.grpcClient.Close(); err != nil { - log.Printf("Error closing cloud client: %v", err) + log.Printf("Error closing core client: %v", err) } } @@ -174,7 +174,7 @@ func (p *Poller) Stop(ctx context.Context) error { // Clear the maps to prevent any lingering references p.agents = make(map[string]*AgentConnection) - p.cloudClient = nil + p.coreClient = nil return nil } @@ -188,10 +188,10 @@ func (p *Poller) Close() error { p.mu.Lock() defer p.mu.Unlock() - // Close cloud client + // Close core client if p.grpcClient != nil { if err := p.grpcClient.Close(); err != nil { - errs = append(errs, fmt.Errorf("error closing cloud client: %w", err)) + errs = append(errs, fmt.Errorf("error closing core client: %w", err)) } } @@ -371,32 +371,32 @@ func (p *Poller) reconnectAgent(ctx context.Context, agentName string, config *A return nil } -func (p *Poller) connectToCloud(ctx context.Context) error { - // Create connection config for cloud service - cloudConfig := &grpc.ConnectionConfig{ - Address: p.config.CloudAddress, +func (p *Poller) connectToCore(ctx context.Context) error { + // Create connection config for core service + coreConfig := &grpc.ConnectionConfig{ + Address: p.config.CoreAddress, Security: models.SecurityConfig{ Mode: p.config.Security.Mode, CertDir: p.config.Security.CertDir, - ServerName: p.config.Security.ServerName, // Use main server name for cloud + ServerName: p.config.Security.ServerName, // Use main server name for core Role: "poller", }, } - log.Printf("Connecting to cloud service at %s (server name: %s)", - p.config.CloudAddress, p.config.Security.ServerName) + log.Printf("Connecting to core service at %s (server name: %s)", + p.config.CoreAddress, p.config.Security.ServerName) client, err := grpc.NewClient( ctx, - cloudConfig, + coreConfig, grpc.WithMaxRetries(grpcRetries), ) if err != nil { - return fmt.Errorf("failed to create cloud client: %w", err) + return fmt.Errorf("failed to create core client: %w", err) } p.grpcClient = client - p.cloudClient = proto.NewPollerServiceClient(client.GetConnection()) + p.coreClient = proto.NewPollerServiceClient(client.GetConnection()) return nil } @@ -473,7 +473,7 @@ func (p *Poller) poll(ctx context.Context) error { allStatuses = append(allStatuses, statuses...) } - return p.reportToCloud(ctx, allStatuses) + return p.reportToCore(ctx, allStatuses) } func (p *Poller) pollAgent(ctx context.Context, agentName string, agentConfig *AgentConfig) ([]*proto.ServiceStatus, error) { @@ -494,21 +494,15 @@ func (p *Poller) pollAgent(ctx context.Context, agentName string, agentConfig *A return statuses, nil } -func (p *Poller) reportToCloud(ctx context.Context, statuses []*proto.ServiceStatus) error { - if p == nil && p.grpcClient == nil { - log.Println("Poller or client is nil") - } - - log.Printf("Reporting to cloud: PollerID=%s, Timestamp=%d, Services=%d", p.config.PollerID, time.Now().Unix(), len(statuses)) - - _, err := p.cloudClient.ReportStatus(ctx, &proto.PollerStatusRequest{ +func (p *Poller) reportToCore(ctx context.Context, statuses []*proto.ServiceStatus) error { + _, err := p.coreClient.ReportStatus(ctx, &proto.PollerStatusRequest{ Services: statuses, PollerId: p.config.PollerID, Timestamp: time.Now().Unix(), }) if err != nil { - return fmt.Errorf("failed to report status to cloud: %w", err) + return fmt.Errorf("failed to report status to core: %w", err) } return nil diff --git a/pkg/sweeper/interfaces.go b/pkg/sweeper/interfaces.go index d34af8a..a0418d5 100644 --- a/pkg/sweeper/interfaces.go +++ b/pkg/sweeper/interfaces.go @@ -69,7 +69,7 @@ type Store interface { // Reporter defines how to report sweep results. type Reporter interface { - // Report sends a summary somewhere (e.g., to a cloud service) + // Report sends a summary somewhere (e.g., to a core service) Report(context.Context, *models.SweepSummary) error } diff --git a/scripts/build-cloud.sh b/scripts/build-core.sh similarity index 67% rename from scripts/build-cloud.sh rename to scripts/build-core.sh index 682e79f..e1e707f 100755 --- a/scripts/build-cloud.sh +++ b/scripts/build-core.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# build-cloud.sh - Build the cloud package for ServiceRadar +# build-core.sh - Build the core package for ServiceRadar set -e VERSION=$1 @@ -22,19 +22,19 @@ if [ -z "$VERSION" ]; then VERSION="dev" fi -echo "Building cloud component version ${VERSION}" +echo "Building core component version ${VERSION}" # Ensure output directory exists -mkdir -p ./dist/cloud_linux_amd64_v1 +mkdir -p ./dist/core_linux_amd64_v1 # Build using Docker -docker build -f ./Dockerfile.cloud \ +docker build -f ./Dockerfile.core \ --build-arg VERSION="${VERSION}" \ - -t serviceradar-cloud-build:${VERSION} . + -t serviceradar-core-build:${VERSION} . # Extract binary -CONTAINER_ID=$(docker create serviceradar-cloud-build:${VERSION}) -docker cp ${CONTAINER_ID}:/src/serviceradar-cloud dist/cloud_linux_amd64_v1/ +CONTAINER_ID=$(docker create serviceradar-core-build:${VERSION}) +docker cp ${CONTAINER_ID}:/src/serviceradar-core dist/core_linux_amd64_v1/ docker rm ${CONTAINER_ID} -echo "Cloud build complete" \ No newline at end of file +echo "Core build complete" \ No newline at end of file diff --git a/scripts/buildCloud.sh b/scripts/buildCore.sh similarity index 85% rename from scripts/buildCloud.sh rename to scripts/buildCore.sh index 19d8e77..e8da2ad 100755 --- a/scripts/buildCloud.sh +++ b/scripts/buildCore.sh @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# buildCloud.sh - Build the cloud package for ServiceRadar +# buildCore.sh - Build the core package for ServiceRadar set -e export VERSION=${VERSION} @@ -23,7 +23,7 @@ export VERSION=${VERSION} # Build the builder image docker build -t serviceradar-builder -f ./Dockerfile.build . -# Run just the cloud package build in the container -docker run --rm -v $(pwd):/build serviceradar-builder ./scripts/setup-deb-cloud.sh +# Run just the core package build in the container +docker run --rm -v $(pwd):/build serviceradar-builder ./scripts/setup-deb-core.sh -echo "Build completed. Check release-artifacts/ directory for the cloud package." \ No newline at end of file +echo "Build completed. Check release-artifacts/ directory for the core package." \ No newline at end of file diff --git a/scripts/buildRpms.sh b/scripts/buildRpms.sh index d8fb554..9f24b9d 100755 --- a/scripts/buildRpms.sh +++ b/scripts/buildRpms.sh @@ -27,7 +27,7 @@ mkdir -p release-artifacts/${VERSION}/rpm usage() { echo "Usage: $0 [component]" echo "Components:" - echo " cloud - Build cloud service RPM" + echo " core - Build core service RPM" echo " agent - Build agent service RPM" echo " poller - Build poller service RPM" echo " dusk-checker - Build dusk checker RPM" @@ -35,20 +35,20 @@ usage() { exit 1 } -# Function to build cloud component (uses full Dockerfile) -build_cloud() { - echo "Building cloud component..." +# Function to build core component (uses full Dockerfile) +build_core() { + echo "Building core component..." docker build \ --platform linux/amd64 \ --build-arg VERSION="${VERSION}" \ --build-arg RELEASE="${RELEASE}" \ - -f Dockerfile-rpm.cloud \ - -t serviceradar-rpm-cloud \ + -f Dockerfile-rpm.core \ + -t serviceradar-rpm-core \ . # Extract RPM from the container tmp_dir=$(mktemp -d) - container_id=$(docker create serviceradar-rpm-cloud) + container_id=$(docker create serviceradar-rpm-core) docker cp $container_id:/rpms/. "$tmp_dir/" docker rm $container_id @@ -109,14 +109,14 @@ fi # Process build request case $1 in - cloud) - build_cloud + core) + build_core ;; agent|poller|dusk-checker) build_component "$1" ;; all) - build_cloud + build_core build_component "agent" build_component "poller" build_component "dusk-checker" diff --git a/scripts/buildServiceRadar.sh b/scripts/buildServiceRadar.sh index 4dca9f3..56c7f82 100755 --- a/scripts/buildServiceRadar.sh +++ b/scripts/buildServiceRadar.sh @@ -38,7 +38,7 @@ usage() { echo " --host HOST Install to remote host (requires SSH access)" echo echo "Components:" - echo " cloud Build cloud API service" + echo " core Build core API service" echo " web Build web UI" echo " poller Build poller service" echo " agent Build agent service" @@ -47,9 +47,9 @@ usage() { echo echo "Examples:" echo " $0 --all Build all components" - echo " $0 cloud web Build cloud and web components" + echo " $0 core web Build core and web components" echo " $0 --all --install Build and install all components locally" - echo " $0 cloud web --install --host user@server Build and install on remote host" + echo " $0 core web --install --host user@server Build and install on remote host" echo exit 1 } @@ -80,7 +80,7 @@ while [[ $# -gt 0 ]]; do TARGET_HOST="$2" shift 2 ;; - cloud|web|poller|agent|dusk-checker|snmp-checker) + core|web|poller|agent|dusk-checker|snmp-checker) COMPONENTS+=("$1") shift ;; @@ -93,7 +93,7 @@ done # Check if we should build all components if [ "$BUILD_ALL" = true ]; then - COMPONENTS=("cloud" "web" "poller" "agent" "dusk-checker" "snmp-checker") + COMPONENTS=("core" "web" "poller" "agent" "dusk-checker" "snmp-checker") fi # If no components specified, show usage @@ -114,8 +114,8 @@ build_component() { echo "=========================================" case $component in - cloud) - ./scripts/setup-deb-cloud.sh + core) + ./scripts/setup-deb-core.sh ;; web) ./scripts/setup-deb-web.sh @@ -153,8 +153,8 @@ install_packages() { local package_name case $component in - cloud) - package_name="serviceradar-cloud_${VERSION}.deb" + core) + package_name="serviceradar-core${VERSION}.deb" ;; web) package_name="serviceradar-web_${VERSION}.deb" diff --git a/scripts/setup-build-env.sh b/scripts/setup-build-env.sh index a877fe3..a33c8c4 100644 --- a/scripts/setup-build-env.sh +++ b/scripts/setup-build-env.sh @@ -73,7 +73,6 @@ cd .. echo "Creating necessary directories..." mkdir -p release-artifacts mkdir -p bin -mkdir -p pkg/cloud/api/web # Build web UI echo "Building web UI..." @@ -81,15 +80,10 @@ cd web pnpm run build cd .. -# Copy web UI to embedded location -echo "Setting up web assets for embedding..." -cp -r web/dist pkg/cloud/api/web/ - if [[ "$1" == "containers" ]]; then # Set up kodata directory echo "Setting up kodata directory for container builds..." - mkdir -p cmd/cloud/.kodata - cp -r web/dist cmd/cloud/.kodata/web + mkdir -p cmd/core/.kodata echo "Build environment for containerized builds is ready!" else @@ -100,10 +94,10 @@ echo "You can now run:" if [[ "$1" == "containers" ]]; then echo " - 'make container-build' to build container images" echo " - 'make container-push' to build and push container images" - echo " - 'make deb-cloud-container' to build the cloud Debian package with container support" + echo " - 'make deb-core-container' to build the core Debian package with container support" echo " - 'make deb-all-container' to build all Debian packages with container support" else echo " - 'make build' to build all binaries" - echo " - 'make deb-cloud' to build the cloud Debian package" + echo " - 'make deb-core' to build the core Debian package" echo " - 'make deb-all' to build all Debian packages" fi \ No newline at end of file diff --git a/scripts/setup-deb-cloud.sh b/scripts/setup-deb-core.sh similarity index 85% rename from scripts/setup-deb-cloud.sh rename to scripts/setup-deb-core.sh index ea648e8..f4f2dfa 100755 --- a/scripts/setup-deb-cloud.sh +++ b/scripts/setup-deb-core.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# setup-deb-cloud.sh +# setup-deb-core.sh set -e # Exit on any error echo "Setting up package structure..." @@ -23,7 +23,7 @@ VERSION=${VERSION:-1.0.20} BUILD_TAGS=${BUILD_TAGS:-""} # Create package directory structure -PKG_ROOT="serviceradar-cloud_${VERSION}" +PKG_ROOT="serviceradar-core_${VERSION}" mkdir -p "${PKG_ROOT}/DEBIAN" mkdir -p "${PKG_ROOT}/usr/local/bin" mkdir -p "${PKG_ROOT}/etc/serviceradar" @@ -37,10 +37,10 @@ BUILD_CMD="CGO_ENABLED=1 GOOS=linux GOARCH=amd64" if [[ ! -z "$BUILD_TAGS" ]]; then BUILD_CMD="$BUILD_CMD GOFLAGS=\"-tags=$BUILD_TAGS\"" fi -BUILD_CMD="$BUILD_CMD go build -o \"../../${PKG_ROOT}/usr/local/bin/serviceradar-cloud\"" +BUILD_CMD="$BUILD_CMD go build -o \"../../${PKG_ROOT}/usr/local/bin/serviceradar-core\"" # Build Go binary -cd cmd/cloud +cd cmd/core eval $BUILD_CMD cd ../.. @@ -48,7 +48,7 @@ echo "Creating package files..." # Create control file cat > "${PKG_ROOT}/DEBIAN/control" << EOF -Package: serviceradar-cloud +Package: serviceradar-core Version: ${VERSION} Section: utils Priority: optional @@ -56,28 +56,28 @@ Architecture: amd64 Depends: systemd, nginx Recommends: serviceradar-web Maintainer: Michael Freeman -Description: ServiceRadar cloud API service +Description: ServiceRadar core API service Provides centralized monitoring and API server for ServiceRadar monitoring system. Includes Nginx configuration for API access. -Config: /etc/serviceradar/cloud.json +Config: /etc/serviceradar/core.json EOF # Create conffiles to mark configuration files cat > "${PKG_ROOT}/DEBIAN/conffiles" << EOF -/etc/serviceradar/cloud.json +/etc/serviceradar/core.json EOF # Create systemd service file -cat > "${PKG_ROOT}/lib/systemd/system/serviceradar-cloud.service" << EOF +cat > "${PKG_ROOT}/lib/systemd/system/serviceradar-core.service" << EOF [Unit] -Description=ServiceRadar Cloud API Service +Description=ServiceRadar Core API Service After=network.target [Service] Type=simple User=serviceradar EnvironmentFile=/etc/serviceradar/api.env -ExecStart=/usr/local/bin/serviceradar-cloud -config /etc/serviceradar/cloud.json +ExecStart=/usr/local/bin/serviceradar-core -config /etc/serviceradar/core.json Restart=always RestartSec=10 TimeoutStopSec=20 @@ -89,7 +89,7 @@ WantedBy=multi-user.target EOF # Create default config file -cat > "${PKG_ROOT}/etc/serviceradar/cloud.json" << EOF +cat > "${PKG_ROOT}/etc/serviceradar/core.json" << EOF { "listen_addr": ":8090", "grpc_addr": ":50052", @@ -103,7 +103,7 @@ cat > "${PKG_ROOT}/etc/serviceradar/cloud.json" << EOF "security": { "mode": "none", "cert_dir": "/etc/serviceradar/certs", - "role": "cloud" + "role": "core" }, "webhooks": [ { @@ -145,7 +145,7 @@ fi # Set permissions chown -R serviceradar:serviceradar /etc/serviceradar -chmod 755 /usr/local/bin/serviceradar-cloud +chmod 755 /usr/local/bin/serviceradar-core # Create data directory mkdir -p /var/lib/serviceradar @@ -164,10 +164,10 @@ fi # Enable and start service systemctl daemon-reload -systemctl enable serviceradar-cloud -systemctl start serviceradar-cloud || echo "Failed to start service, please check the logs" +systemctl enable serviceradar-core +systemctl start serviceradar-core || echo "Failed to start service, please check the logs" -echo "ServiceRadar Cloud API service installed successfully!" +echo "ServiceRadar Core API service installed successfully!" echo "API is running on port 8090" echo "Accessible via Nginx at http://localhost/api/" echo "For a complete UI experience, install the serviceradar-web package." @@ -183,8 +183,8 @@ cat > "${PKG_ROOT}/DEBIAN/prerm" << EOF set -e # Stop and disable service -systemctl stop serviceradar-cloud || true -systemctl disable serviceradar-cloud || true +systemctl stop serviceradar-core || true +systemctl disable serviceradar-core || true EOF @@ -203,7 +203,7 @@ mv "${PKG_ROOT}.deb" "./release-artifacts/" if [[ ! -z "$BUILD_TAGS" ]]; then # For tagged builds, add the tag to the filename - PACKAGE_NAME="serviceradar-cloud_${VERSION}-${BUILD_TAGS//,/_}.deb" + PACKAGE_NAME="serviceradar-core_${VERSION}-${BUILD_TAGS//,/_}.deb" mv "./release-artifacts/${PKG_ROOT}.deb" "./release-artifacts/$PACKAGE_NAME" echo "Package built: release-artifacts/$PACKAGE_NAME" else diff --git a/scripts/setup-deb-poller.sh b/scripts/setup-deb-poller.sh index 994ad4a..0f0f8c1 100755 --- a/scripts/setup-deb-poller.sh +++ b/scripts/setup-deb-poller.sh @@ -46,7 +46,7 @@ Depends: systemd Maintainer: Michael Freeman Description: ServiceRadar poller service Poller component for ServiceRadar monitoring system. - Collects and forwards monitoring data from agents to cloud service. + Collects and forwards monitoring data from agents to core service. Config: /etc/serviceradar/poller.json EOF @@ -118,7 +118,7 @@ cat > "${PKG_ROOT}/etc/serviceradar/poller.json" << EOF ] } }, - "cloud_address": "localhost:50052", + "core_address": "localhost:50052", "listen_addr": ":50053", "poll_interval": "30s", "poller_id": "dusk", diff --git a/tls/README.md b/tls/README.md index 37fb040..69d3f99 100644 --- a/tls/README.md +++ b/tls/README.md @@ -19,8 +19,8 @@ SweepCheck[Network Sweep] PL[Poller
Role: Client+Server
:50053] end - subgraph "Cloud Service" - CL[Cloud Service
Role: Server
:50052] + subgraph "Core Service" + CL[Core Service
Role: Server
:50052] DB[(Database)] API[HTTP API
:8090] @@ -135,13 +135,13 @@ ServiceRadar components need different certificates based on their role: - **Poller** (RolePoller) - Needs all certificates (client + server) - - Acts as both client (connecting to agents/cloud) and server (health checks) + - Acts as both client (connecting to agents/core) and server (health checks) - **Agent** (RoleAgent) - Needs all certificates (client + server) - Acts as server (accepting poller connections) and client (connecting to checkers) -- **Cloud** (RoleCloud) +- **Core** (RoleCore) - Needs only server certificates - Acts as server only (accepting connections) @@ -160,7 +160,7 @@ sudo chmod 700 /etc/serviceradar/certs 2. Install certificates based on role: -For cloud/checker (server-only): +For core/checker (server-only): ```bash sudo cp root.pem server*.pem /etc/serviceradar/certs/ ``` @@ -179,7 +179,7 @@ sudo chmod 600 /etc/serviceradar/certs/*-key.pem ### Expected Directory Structure -Server-only deployment (Cloud/Checker): +Server-only deployment (Core/Checker): ```bash /etc/serviceradar/certs/ ├── root.pem (644) @@ -204,7 +204,7 @@ Verify your installation with: ls -la /etc/serviceradar/certs/ ``` -Example output (cloud instance): +Example output (Core instance): ``` total 20 drwx------ 2 serviceradar serviceradar 4096 Feb 21 20:46 .