mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-11 11:42:50 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12c20b928c | |||
| 2fdc0eddd3 | |||
| 18b1a0b6e3 | |||
| bf79d376f3 | |||
| 8f430b5982 |
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.11.1-alpine
|
||||
FROM golang:1.14.4-alpine3.12
|
||||
|
||||
WORKDIR /go/src/github.com/mgerb/ServerStatus
|
||||
ADD . .
|
||||
@@ -8,10 +8,9 @@ RUN dep ensure
|
||||
RUN make linux
|
||||
|
||||
|
||||
FROM alpine:3.8
|
||||
FROM alpine:3.12
|
||||
|
||||
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
|
||||
WORKDIR /server-status
|
||||
COPY --from=0 /go/src/github.com/mgerb/ServerStatus/dist/ServerStatus-linux .
|
||||
ENTRYPOINT ./ServerStatus-linux
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: "2"
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
server-status:
|
||||
|
||||
13
readme.md
13
readme.md
@@ -1,8 +1,21 @@
|
||||
# Server Status
|
||||
Monitors a list of servers and sends a chat notification when a server goes on or offline.
|
||||
|
||||
Enjoy the bot?
|
||||
|
||||
<a href="https://www.buymeacoffee.com/mgerb" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
|
||||
|
||||
## Features
|
||||
|
||||
- send channel notifications
|
||||
- track server up/down time
|
||||
- **TCP** - should work with all servers
|
||||
- **UDP** - [Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol) is supported
|
||||
- [Docker](https://hub.docker.com/r/mgerb/server-status)
|
||||
|
||||
### Want to see more features?
|
||||
|
||||
[Submit a new issue](https://github.com/mgerb/ServerStatus/issues/new/choose)
|
||||
|
||||
## Configuration
|
||||
- Download the latest release [here](https://github.com/mgerb/ServerStatus/releases)
|
||||
|
||||
@@ -57,7 +57,7 @@ func scanServers() {
|
||||
|
||||
for index := range config.Config.Servers {
|
||||
wg.Add(1)
|
||||
go worker(index, &config.Config.Servers[index], &wg)
|
||||
go worker(&config.Config.Servers[index], &wg)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
@@ -66,7 +66,7 @@ func scanServers() {
|
||||
}
|
||||
}
|
||||
|
||||
func worker(index int, server *config.Server, wg *sync.WaitGroup) {
|
||||
func worker(server *config.Server, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
prevServerUp := server.Online //set value to previous server status
|
||||
@@ -78,26 +78,28 @@ func worker(index int, server *config.Server, wg *sync.WaitGroup) {
|
||||
for {
|
||||
serverScanner := portscanner.NewPortScanner(server.Address, time.Second*2, 1)
|
||||
serverUp = serverScanner.IsOpen(server.Port) //check if the port is open
|
||||
|
||||
// if server isn't up check RCON protocol (UDP)
|
||||
if !serverUp {
|
||||
host := server.Address + ":" + strconv.Itoa(server.Port)
|
||||
steamConnection, err := steam.Connect(host)
|
||||
if err == nil {
|
||||
defer steamConnection.Close()
|
||||
_, err := steamConnection.Ping()
|
||||
if err == nil {
|
||||
serverUp = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if serverUp || retryCounter >= 5 {
|
||||
break
|
||||
}
|
||||
|
||||
retryCounter++
|
||||
time.Sleep(time.Second * 2)
|
||||
}
|
||||
|
||||
// if server isn't up check RCON protocol (UDP)
|
||||
if !serverUp {
|
||||
host := server.Address + ":" + strconv.Itoa(server.Port)
|
||||
steamConnection, err := steam.Connect(host)
|
||||
if err == nil {
|
||||
defer steamConnection.Close()
|
||||
_, err := steamConnection.Ping()
|
||||
if err == nil {
|
||||
serverUp = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if serverUp && serverUp != prevServerUp {
|
||||
server.OnlineTimestamp = time.Now()
|
||||
sendMessageToRooms(green, server.Name, "Is now online :smiley:", true)
|
||||
@@ -153,7 +155,7 @@ func MessageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
func fmtDuration(d time.Duration) string {
|
||||
|
||||
days := int(d.Hours()) / 24
|
||||
hours := int(d.Hours()) % 60
|
||||
hours := int(d.Hours()) % 24
|
||||
minutes := int(d.Minutes()) % 60
|
||||
seconds := int(d.Seconds()) % 60
|
||||
|
||||
|
||||
Reference in New Issue
Block a user