Skip to content

Commit

Permalink
Merge pull request #1 from heacat/unstable
Browse files Browse the repository at this point in the history
Merge files
  • Loading branch information
mt190502 authored Aug 8, 2024
2 parents ed39d4f + 0698f5e commit 20a2d10
Show file tree
Hide file tree
Showing 28 changed files with 1,826 additions and 14 deletions.
44 changes: 44 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "./src/"
testdata_dir = "./.testdata/"
tmp_dir = "./.tmp"

[build]
args_bin = []
bin = "./.tmp/main"
cmd = "go build -o ./.tmp/main src/main.go"
delay = 100
exclude_dir = ["assets", ".tmp", ".testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "../.tmp/build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ config.yml

# tempararily disable workflow and releaser
.github/workflows
.goreleaser.yml
.goreleaser.yml
.tmp
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,37 @@
HeaCat-API is a system monitoring API that provides information about the system's health and performance. It is designed to be used by system administrators and developers to monitor the system's health and performance. The API provides information about the system's CPU usage, memory usage, disk usage, network usage and more. It also provides information about the system's uptime, load average, and other system metrics.

## Features
coming soon...
- CPU monitoring
- Memory monitoring
- Disk monitoring (W.I.P)
- System Information API

## Installation
coming soon...
1. Clone the repository
```bash
git clone https://github.com/heacat/heacat-api.git
```
2. Install the dependencies
```bash
cd heacat-api
go mod tidy
```
3. Build the project
```bash
go build src/main.go
```
4. Run the project
```bash
./main
```

## Usage
coming soon...

## TODO
- [ ] Create a config parser and example config template
- [ ] Create a logger
- [ ] Create a notifier for anormally states
- [ ] Create an api endpoint (or socket)
- [ ] Add disk monitoring
- [ ] Add system load average monitoring
- [ ] Add network monitoring
- [ ] Add system uptime monitoring
1. Create a config file
```bash
cp config-example.yaml config.yaml
nano config.yaml # or use your favorite text editor
```
2. Run the program
```bash
./main
```
29 changes: 29 additions & 0 deletions config-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
alarm: # Alarm configuration
servernickname: "server1" # Server nickname for alarm message
telegram: # Telegram configuration
enabled: false # Enable or disable telegram alarm
token: "123456789:ABCDEF" # Telegram bot token (from BotFather)
chatid: "-123456789" # Telegram chat id
messagethreadid: 1 # Telegram message thread id
slack: # Slack configuration
enabled: true # Enable or disable slack alarm
webhookurl: "https://example.com/" # Slack webhook url

api: # API configuration
host: localhost # API host
port: 8080 # API port

disk: # Disk configuration
filesystems: ["ext2", "ext3", "ext4", "xfs", "btrfs", "zfs", "nfs"] # Filesystems to monitor
partuselimit: 90 # Partition use limit (percentage)
checkinterval: 5 # Check interval (minutes)
unit: "GB" # Conversion unit

cpu: # CPU configuration
loadlimit: 20 # CPU load limit (percentage)
checkinterval: 5 # Check interval (minutes)

memory: # Memory configuration
uselimit: 50 # Memory use limit (percentage)
checkinterval: 5 # Check interval (minutes)
unit: "MB" # Conversion unit
Empty file removed config-example.yml
Empty file.
63 changes: 63 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module github.com/heacat/heacat-api

go 1.22.2

require (
github.com/dlclark/regexp2 v1.11.4
github.com/gin-gonic/gin v1.10.0
github.com/go-telegram/bot v1.6.1
github.com/shirou/gopsutil/v4 v4.24.7
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.19.0
)

require (
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 20a2d10

Please sign in to comment.