Skip to content
Draft
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
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
GIN_MODE=release

# interval in seconds
INTERVAL=60

# ping check destinations separated by comma
PING_HOSTS=1.1.1.1,google.com
PING_TIMEOUT=5
PING_PRIVILEGED=false

# webserver mode
GIN_MODE=release
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@

## Features

- Monitor network uptime
- Pings & Speed test
- Continuously monitors network availability with Pings to configurated servers
- Web UI with interactive charts

Built with [Go](https://go.dev/) and [SQLite](https://sqlite.org/).

## Docker
## Usage (Docker)

```
docker pull ghcr.io/romanzipp/sprinter:latest
```

See [repository](https://github.com/romanzipp/Sprinter/pkgs/container/sprinter) for more information.

### Environment variables

- `INTERVAL` Ping interval in seconds (default: `60`)
- `PING_HOSTS` Destination servers, separated by comma (default: `1.1.1.1,google.com`)
- `PING_TIMEOUT` Ping timeout in seconds (default: `5`)
- `PING_PRIVILEGED` Privileged UDP ping mode (see [Troubleshooting](#troubleshooting))

---

### Local

#### Build

Expand Down Expand Up @@ -62,6 +79,9 @@ yarn install
```shell
yarn watch
```
## Roadmap

- [ ] Make ping timeout configurable

## Troubleshooting

Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package config
type Config struct {
Interval int64
PingHosts []string
PingTimeout int64
PingPrivileged bool
}
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func main() {
)

conf := makeConfig()
if len(conf.PingHosts) == 0 {
panic("no ping hosts configured")
}

db := makeDb()
router := makeRouter(db)

Expand All @@ -50,11 +54,21 @@ func main() {

func makeConfig() config.Config {
interval, _ := strconv.ParseInt(os.Getenv("INTERVAL"), 10, 64)
if interval == 0 {
interval = 60
}

timeout, _ := strconv.ParseInt(os.Getenv("PING_TIMEOUT"), 10, 64)
if timeout == 0 {
timeout = 5
}

pingHosts := strings.Split(os.Getenv("PING_HOSTS"), ",")

return config.Config{
Interval: interval,
PingHosts: pingHosts,
PingTimeout: timeout,
PingPrivileged: os.Getenv("PING_PRIVILEGED") == "true",
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ExecPingCheck(host string, id string, conf config.Config, db *gorm.DB) {
}

pinger.Count = 1
pinger.Timeout = 5 * time.Second
pinger.Timeout = time.Duration(conf.PingTimeout) * time.Second
pinger.Debug = true
err = pinger.Run()
if err != nil {
Expand Down