Compare commits

...

32 Commits

Author SHA1 Message Date
Kekskurse 94d1f90722
ci: fix pipeline
/ Release (push) Has started running Details
2023-07-24 01:53:14 +02:00
Kekskurse 383ce965a0
ci: fix pipeline
/ Release (push) Has started running Details
2023-07-24 01:50:56 +02:00
Kekskurse 3fde27f83b
stuff
/ Release (push) Successful in 1m10s Details
2023-07-21 16:11:16 +02:00
Kekskurse 28b5ccca8e
stuff
/ Release (push) Successful in 1m14s Details
2023-07-21 16:02:35 +02:00
Kekskurse 280a9559f6
Default config
/ Release (push) Successful in 1m8s Details
2023-07-21 13:31:00 +02:00
Kekskurse a80fcb5d4c
Default config
/ Release (push) Successful in 1m7s Details
2023-07-21 13:25:35 +02:00
Kekskurse 40d601f5b4
docs: Update Readme
/ Release (push) Successful in 1m14s Details
2023-07-21 12:38:29 +02:00
Kekskurse 2ebe72790f
docs: Update Readme
/ Release (push) Successful in 1m9s Details
2023-07-21 12:38:12 +02:00
Kekskurse 1d09eef545
Publish Tag
/ Release (push) Successful in 1m11s Details
2023-07-21 12:31:36 +02:00
Kekskurse 387ba50c26
ci: release
/ Release (push) Failing after 27s Details
2023-07-21 12:26:43 +02:00
Kekskurse 8a06fe56cf
ci: run
/ Release (push) Successful in 1m6s Details
2023-07-21 12:24:07 +02:00
Kekskurse ab83e1ff5e
ci: run
/ Release (push) Failing after 1m8s Details
2023-07-21 12:19:16 +02:00
Kekskurse 1d54f47988
ci: run
/ Release (push) Successful in 1m9s Details
2023-07-21 12:05:18 +02:00
Kekskurse eaaee5c3ef
ci: run
/ Release (push) Failing after 5s Details
2023-07-21 12:04:49 +02:00
Kekskurse b65aff651c
ci: run
/ Release (push) Successful in 1m4s Details
2023-07-21 12:03:25 +02:00
Kekskurse a49ed9a9a7
ci: run
/ Release (push) Failing after 25s Details
2023-07-21 12:02:31 +02:00
Kekskurse 4a54b35510
ci: run
/ Release (push) Failing after 25s Details
2023-07-21 12:01:21 +02:00
Kekskurse ee5075f47f
ci: run 2023-07-21 12:00:41 +02:00
Kekskurse 711a0714a4
ci: trigger 2023-07-21 11:59:05 +02:00
Kekskurse 5b815e1932
ci: new pipeline 2023-07-21 11:58:08 +02:00
Kekskurse 326b2e459e
Update logging 2023-07-21 11:52:30 +02:00
Kekskurse 4b41ef1c55
Fix
continuous-integration/drone/push Build is passing Details
2022-03-10 20:05:49 +01:00
Kekskurse 6ff70bd77b
#1 fix version check
continuous-integration/drone/push Build is passing Details
2022-03-10 19:42:57 +01:00
Kekskurse b93ac4639d
Fix Versions Cehck Template issue
continuous-integration/drone/push Build is passing Details
2021-11-29 07:33:34 +01:00
Kekskurse 07cd22131f
Versions Check
continuous-integration/drone/push Build is passing Details
2021-11-29 07:31:30 +01:00
Kekskurse 2199301dc7
Update Readme
continuous-integration/drone/push Build is passing Details
2021-11-29 07:13:19 +01:00
Kekskurse 3fe3f39bea
Remove postinstall
continuous-integration/drone/push Build is passing Details
2021-11-29 07:09:13 +01:00
Kekskurse 47da117ca3
Update Readme
continuous-integration/drone/push Build is passing Details
2021-11-29 07:00:18 +01:00
Kekskurse b9188f5006
Update install script 2021-11-29 06:59:09 +01:00
Kekskurse 827b4a8fce
install python3
continuous-integration/drone/push Build is passing Details
2021-11-29 06:54:08 +01:00
Kekskurse fa4a4a6678
Remove postremove!
continuous-integration/drone/push Build is passing Details
2021-11-29 06:51:39 +01:00
Kekskurse 6d42aac7b9
Install script
continuous-integration/drone/push Build is passing Details
2021-11-29 06:50:09 +01:00
14 changed files with 187 additions and 19 deletions

View File

@ -0,0 +1,36 @@
run-name: ${{ github.actor }} is testing
on: ["push"]
jobs:
Release:
runs-on: docker
#container:
# image: goreleaser/goreleaser
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
#- run: goreleaser release --skip-publish --snapshot --rm-dist --debug
- name: Setup Go environment
uses: https://github.com/actions/setup-go@v2.1.3
with:
go-version: 1.20
- name: Run GoReleaser
uses: https://github.com/goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --skip-publish --snapshot --rm-dist --debug --clean
env:
GORELEASER_FORCE_TOKEN: "gitea"
- name: Copy deb to publish folder
run: mkdir publish; cp dist/*deb publish/last.deb
- name: Upload to s3
uses: https://github.com/shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: 'kekscloud-releases'
source_dir: 'publish/'
destination_dir: 'http-server-status/'
endpoint: 's3.eu-central-003.backblazeb2.com'

View File

@ -0,0 +1,40 @@
run-name: ${{ github.actor }} is testing
on:
push:
tags:
- '*'
jobs:
Release:
runs-on: docker
#container:
# image: goreleaser/goreleaser
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
#- run: goreleaser release --skip-publish --snapshot --rm-dist --debug
- name: Setup Go environment
uses: https://github.com/actions/setup-go@v2.1.3
with:
go-version: 1.20
- name: Run GoReleaser
uses: https://github.com/goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GORELEASER_FORCE_TOKEN: "gitea"
GITEA_TOKEN: "${{ secrets.GITEA }}"
- name: Copy deb to publish folder
run: mkdir publish; cp dist/*deb publish/stable.deb; cp dist/*deb publish/
- name: Upload to s3
uses: https://github.com/shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: 'kekscloud-releases'
source_dir: 'publish/'
destination_dir: 'http-server-status/'
endpoint: 's3.eu-central-003.backblazeb2.com'

View File

@ -17,11 +17,6 @@ builds:
- amd64
ldflags:
- -X main.version={{ .Version }}
archives:
- replacements:
darwin: Darwin
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
changelog:
@ -54,5 +49,4 @@ nfpms:
dst: /etc/http-server-status/config.yml.sample
scripts:
postinstall: "scripts/postinstall.sh"
preinstall: "scripts/preinstall.sh"
postremove: "scripts/postremove.sh"
preinstall: "scripts/preinstall.sh"

View File

@ -1,19 +1,32 @@
# HTTP Server Status
Status Page for your VM or HDD Server to montiro with an external tool like uptimerobot.com
Status Page with your Server informations (HDD usage, ram usage, load, systemd) which returns a http Status 500 if a limit is reached. With this Service you can monitor your Server with a external tool like uptimerobot.com.
# Installation
To Install the Server Montiroing download the last .deb File from the Release page and save it as http-server-status.deb on your server. Than install the package with dpkg
## Dowanload URLs:
* Last Dev Build: `https://kekscloud-releases.s3.eu-central-003.backblazeb2.com/http-server-status/last.deb`
* Last Release Build: `https://kekscloud-releases.s3.eu-central-003.backblazeb2.com/http-server-status/stable.deb`
* Special Version: `https://kekscloud-releases.s3.eu-central-003.backblazeb2.com/http-server-status/http-server-status_1.0.7_linux_amd64.deb` (Bigger than 1.0.7)
To Install the Server Montiroing download the last .deb File from the Release page or the links above and save it as http-server-status.deb on your server. Than install the package with dpkg
```
dpkg -i http-server-status.deb
```
# Config
Copy the config sample and edit the config.
```bigquery
cp /etc/http-server-status/config.yml.sample /etc/http-server-status/config.yml
nano /etc/http-server-status/config.yml
```
# Run
After this start the server
```

View File

@ -24,6 +24,7 @@ type Config struct {
Load checks.LoadConfig `yaml:"load"`
Memory checks.MemoryConfig `yaml:"memory"`
Systemd checks.SystemdConf `yaml:"systemd"`
Version checks.VersionConfig `yaml:"version"`
} `yaml:"checks"`
}
@ -43,4 +44,6 @@ func readConfig() {
if err != nil {
log.Fatal().Err(err).Msg("Cant parse yaml file")
}
c.Checks.Version.Version = version
}

View File

@ -17,11 +17,11 @@ checks:
max_load_15: 5
memory:
enabled: true
max: 100
max: 80
max_swap: 80
systemd:
enabled: true
services:
- sshd
- test
- docker
version:
enabled: true

View File

@ -1,11 +1,11 @@
[Unit]
Description=Go Mail Admin
Description=HTTP Status Server
After=syslog.target
[Service]
Type=simple
User=http-server-status
ExecStart=/usr/local/bin/http-server-status
ExecStart=/usr/bin/http-server-status
SyslogIdentifier=http-server-status
StandardOutput=syslog
StandardError=syslog

5
install.sh Normal file
View File

@ -0,0 +1,5 @@
URL=`python3 -c 'import urllib.request;import json;f = urllib.request.urlopen("https://git.keks.cloud/api/v1/repos/kekskurse/http-server-status/releases?limit=1");d = json.loads(f.read().decode("utf-8"));
for asset in d[0]["assets"]: x = asset["browser_download_url"] if asset["name"][-4:] == ".deb" else ""; print(x, end="");'`
wget -O hss.deb $URL
dpkg -i hss.deb
rm hss.deb

View File

@ -0,0 +1,45 @@
package checks
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type VersionConfig struct {
Enabled bool `yaml:"enabled"`
Version string
}
type Version struct {
Config VersionConfig
}
func (h Version) Execute() (ok bool, data interface{}, err error) {
if h.Config.Enabled == false {
return true, nil, nil
}
resp, err := http.Get("https://git.keks.cloud/api/v1/repos/kekskurse/http-server-status/releases?limit=1")
defer resp.Body.Close()
var g []struct {
TagName string `json:"tag_name"`
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return false, nil, err
}
json.Unmarshal(body, &g)
if g[0].TagName == fmt.Sprintf("v%v", h.Config.Version) {
return true, map[string]string{"version": g[0].TagName}, nil
}
return false, map[string]string{"version": g[0].TagName}, nil
}
func (h Version) Name() string {
return "Version"
}

View File

@ -3,9 +3,11 @@ package main
import (
_ "embed"
"encoding/json"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
checks "http-server-status/internal/pkg/checks"
"net/http"
"os"
"sync"
"text/template"
)
@ -21,8 +23,10 @@ var checkList []checks.Check
func init() {
readConfig()
log.Debug().Int("max_percent", c.Checks.HDD.MaxPercent).Msg("HDD CHECK")
checkList = append(checkList, checks.HDD{c.Checks.HDD}, checks.Memory{Config: c.Checks.Memory}, checks.Load{Config: c.Checks.Load}, checks.Systemd{Config: c.Checks.Systemd})
pp := log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
multi := zerolog.MultiLevelWriter(pp)
log.Logger = zerolog.New(multi).With().Timestamp().Caller().Logger()
checkList = append(checkList, checks.HDD{c.Checks.HDD}, checks.Memory{Config: c.Checks.Memory}, checks.Load{Config: c.Checks.Load}, checks.Systemd{Config: c.Checks.Systemd}, checks.Version{Config: c.Checks.Version})
}
func auth(fn http.HandlerFunc) http.HandlerFunc {

View File

@ -1,2 +1,12 @@
if [ -f "/etc/http-server-status/config.yml" ]; then
echo "Config exists"
else
cp /etc/http-server-status/config.yml.sample /etc/http-server-status/config.yml
fi
systemctl daemon-reload
systemctl is-active --quiet http-server-status && systemctl restart http-server-status && echo "Restart Service"
STATUS="$(systemctl is-active tomcat.service)"
if [ "${STATUS}" = "active" ]; then
systemctl restart http-server-status
echo "Restart Service"
fi

View File

@ -1 +0,0 @@
deluser --remove-home http-server-status

View File

@ -1,4 +1,4 @@
#/bin/sh
if ! id -u http-server-status > /dev/null 2>&1; then
adduser --system http-server-status
fi
fi

View File

@ -116,7 +116,26 @@
</div>
</div>
</div>
<div class="row" style="margin-top: 20px;">
<div class="col-md-6">
<div class="card">
<div class="card-header {{if .checks.Version.Success }}bg-success{{else}}bg-danger{{end}}" id="loadtitle">
Version
</div>
<div class="card-body">
{{ if .checks.Version.Data }}
Newest Version: {{ .checks.Version.Data.version }}
{{ end }}
</div>
</div>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
<div class="container">