mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-12 04:02:48 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92d94ed4d4 | |||
| d0cf0eae78 | |||
| 642ccc7bf5 | |||
| bcb57c72a3 | |||
| 1cd9f139c2 | |||
| 8d26fba95d |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/vendor
|
||||||
|
/dist
|
||||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM golang:1.11.1-alpine
|
||||||
|
|
||||||
|
WORKDIR /go/src/github.com/mgerb/ServerStatus
|
||||||
|
ADD . .
|
||||||
|
RUN apk add --no-cache git alpine-sdk
|
||||||
|
RUN go get -u github.com/golang/dep/cmd/dep
|
||||||
|
RUN dep ensure
|
||||||
|
RUN make linux
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:3.8
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
54
Gopkg.lock
generated
54
Gopkg.lock
generated
@@ -1,41 +1,89 @@
|
|||||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||||
|
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:87c2e02fb01c27060ccc5ba7c5a407cc91147726f8f40b70cceeedbc52b1f3a8"
|
||||||
|
name = "github.com/Sirupsen/logrus"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "e1e72e9de974bd926e5c56f83753fba2df402ce5"
|
||||||
|
version = "v1.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
digest = "1:b7e05c8da029b985907b15e126cde5f42f2814b08211a184dac436eeec6fe780"
|
||||||
name = "github.com/anvie/port-scanner"
|
name = "github.com/anvie/port-scanner"
|
||||||
packages = [
|
packages = [
|
||||||
".",
|
".",
|
||||||
"predictors",
|
"predictors",
|
||||||
"predictors/webserver"
|
"predictors/webserver",
|
||||||
]
|
]
|
||||||
|
pruneopts = "UT"
|
||||||
revision = "8159197d3770eb6dbf3a9706a6d40462ebb69cec"
|
revision = "8159197d3770eb6dbf3a9706a6d40462ebb69cec"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
digest = "1:4fd5ce7844c22e194005b9e12fee8adc70fb5ba0bbba9e1964d2e3d1f301d789"
|
||||||
name = "github.com/bwmarrin/discordgo"
|
name = "github.com/bwmarrin/discordgo"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
revision = "4a33b9bc7c56cfdb9bb244e33e83cb3941fe2bdc"
|
revision = "4a33b9bc7c56cfdb9bb244e33e83cb3941fe2bdc"
|
||||||
version = "v0.18.0"
|
version = "v0.18.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
digest = "1:43dd08a10854b2056e615d1b1d22ac94559d822e1f8b6fcc92c1a1057e85188e"
|
||||||
name = "github.com/gorilla/websocket"
|
name = "github.com/gorilla/websocket"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
|
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
|
||||||
version = "v1.2.0"
|
version = "v1.2.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
digest = "1:50993a8fbb3042b88dfecb8f4473a42f13ac70d6fd86f64df525a28b357c2d5b"
|
||||||
|
name = "github.com/kidoman/go-steam"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "2e40e0d508cbac591bab4ae18b231153295f3a0a"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
|
||||||
|
name = "github.com/konsorten/go-windows-terminal-sequences"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242"
|
||||||
|
version = "v1.0.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:e035fb07be76ce6e4ce005add75491d9f0749403f595f153d6e2823a71c24149"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = [
|
packages = [
|
||||||
"nacl/secretbox",
|
"nacl/secretbox",
|
||||||
"poly1305",
|
"poly1305",
|
||||||
"salsa20/salsa"
|
"salsa20/salsa",
|
||||||
|
"ssh/terminal",
|
||||||
]
|
]
|
||||||
|
pruneopts = "UT"
|
||||||
revision = "c4a91bd4f524f10d064139674cf55852e055ad01"
|
revision = "c4a91bd4f524f10d064139674cf55852e055ad01"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
digest = "1:43cde116ff48f299eddb7e6515677e6d0a2c915854bb05a333877f07c3bb3033"
|
||||||
|
name = "golang.org/x/sys"
|
||||||
|
packages = [
|
||||||
|
"unix",
|
||||||
|
"windows",
|
||||||
|
]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "11f53e03133963fb11ae0588e08b5e0b85be8be5"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "0832269100c492c595c4fe5f02e10d70889b9fa4d6a869c3ad59584cda0c5d31"
|
input-imports = [
|
||||||
|
"github.com/anvie/port-scanner",
|
||||||
|
"github.com/bwmarrin/discordgo",
|
||||||
|
"github.com/kidoman/go-steam",
|
||||||
|
]
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|||||||
@@ -36,3 +36,7 @@
|
|||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
unused-packages = true
|
unused-packages = true
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/kidoman/go-steam"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"RoomIDList":["room id list goes here"],
|
"RoomIDList":["room id list goes here"],
|
||||||
"RolesToNotify": ["<@&roleid>", "<@userid>"],
|
"RolesToNotify": ["<@&roleid>", "<@userid>"],
|
||||||
"GameStatus": "current playing game",
|
"GameStatus": "current playing game",
|
||||||
|
"PollingInterval": 10,
|
||||||
"Servers": [
|
"Servers": [
|
||||||
{
|
{
|
||||||
"Name": "Your awesome server",
|
"Name": "Your awesome server",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Variables used for command line parameters
|
// Variables used for command line parameters
|
||||||
@@ -17,6 +18,7 @@ type configStruct struct {
|
|||||||
RolesToNotify []string `json:"RolesToNotify"`
|
RolesToNotify []string `json:"RolesToNotify"`
|
||||||
Servers []server `json:"Servers"`
|
Servers []server `json:"Servers"`
|
||||||
GameStatus string `json:"GameStatus"`
|
GameStatus string `json:"GameStatus"`
|
||||||
|
PollingInterval time.Duration `json:"PollingInterval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type server struct {
|
type server struct {
|
||||||
@@ -43,4 +45,8 @@ func Configure() {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Config.PollingInterval == 0 {
|
||||||
|
log.Fatal("Please set your PollingInterval > 0 in your config file.")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
docker-build.sh
Executable file
5
docker-build.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
version=$(git describe --tags)
|
||||||
|
|
||||||
|
docker build -t mgerb/server-status:latest .
|
||||||
|
docker tag mgerb/server-status:latest mgerb/server-status:$version
|
||||||
|
|
||||||
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
server-status:
|
||||||
|
image: mgerb/server-status:latest
|
||||||
|
volumes:
|
||||||
|
- ./config.json:/server-status/config.json
|
||||||
5
docker-push.sh
Executable file
5
docker-push.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
version=$(git describe --tags)
|
||||||
|
|
||||||
|
docker push mgerb/server-status:latest;
|
||||||
|
docker push mgerb/server-status:$version;
|
||||||
|
|
||||||
5
main.go
5
main.go
@@ -8,11 +8,6 @@ import (
|
|||||||
"github.com/mgerb/ServerStatus/serverstatus"
|
"github.com/mgerb/ServerStatus/serverstatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Variables used for command line parameters
|
|
||||||
var (
|
|
||||||
BotID string
|
|
||||||
)
|
|
||||||
|
|
||||||
var version = "undefined"
|
var version = "undefined"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
36
readme.md
36
readme.md
@@ -1,11 +1,9 @@
|
|||||||
# Server Status
|
# Server Status
|
||||||
Scans a list of TCP servers checking checking which are currently online.
|
Scans a list of servers checking checking which are currently online.
|
||||||
This bot will send a chat notification when the status of a server changes (goes on or offline).
|
This bot will send a chat notification when the status of a server changes (goes on or offline).
|
||||||
|
|
||||||
I originally made this bot to check if private World of Warcraft servers were up or not.
|
- **TCP** - should work with all servers
|
||||||
It's actually much more useful than that and can be used for most servers.
|
- **UDP** - [Source RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol) is supported
|
||||||
|
|
||||||
NOTE: This bot currently does not work for UDP servers.
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
- Download the latest release [here](https://github.com/mgerb/ServerStatus/releases)
|
- Download the latest release [here](https://github.com/mgerb/ServerStatus/releases)
|
||||||
@@ -13,10 +11,36 @@ NOTE: This bot currently does not work for UDP servers.
|
|||||||
- Execute the OS specific binary!
|
- Execute the OS specific binary!
|
||||||
|
|
||||||
### Mentioning Roles/Users
|
### Mentioning Roles/Users
|
||||||
- you must first get your role/user id
|
- you must first get your role/user id (see below of obtaining ID's)
|
||||||
- for user `<@userid>`
|
- for user `<@userid>`
|
||||||
- for role `<@&roleid>`
|
- for role `<@&roleid>`
|
||||||
|
|
||||||
|
### Polling Interval
|
||||||
|
The polling interval is how often the bot will try to ping the servers.
|
||||||
|
A good interval is 10 seconds, but this may need some adjustment if
|
||||||
|
it happens to be spamming notifications.
|
||||||
|
|
||||||
|
- time in seconds
|
||||||
|
- configurable in `config.json`
|
||||||
|
|
||||||
|
## With Docker
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -it -v /path/to/your/config.json:/server-status/config.json:ro mgerb/server-status
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker Compose
|
||||||
|
|
||||||
|
```
|
||||||
|
version: "2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
server-status:
|
||||||
|
image: mgerb/server-status:latest
|
||||||
|
volumes:
|
||||||
|
- /path/to/your/config.json:/server-status/config.json
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
To get the current status of your servers simply type `!ServerStatus` in chat.
|
To get the current status of your servers simply type `!ServerStatus` in chat.
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ package serverstatus
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anvie/port-scanner"
|
"github.com/anvie/port-scanner"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
steam "github.com/kidoman/go-steam"
|
||||||
"github.com/mgerb/ServerStatus/bot"
|
"github.com/mgerb/ServerStatus/bot"
|
||||||
"github.com/mgerb/ServerStatus/config"
|
"github.com/mgerb/ServerStatus/config"
|
||||||
)
|
)
|
||||||
@@ -52,6 +54,19 @@ func scanServers() {
|
|||||||
serverScanner := portscanner.NewPortScanner(server.Address, time.Second*2, 1)
|
serverScanner := portscanner.NewPortScanner(server.Address, time.Second*2, 1)
|
||||||
serverUp := serverScanner.IsOpen(server.Port) //check if the port is open
|
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 && serverUp != prevServerUp {
|
if serverUp && serverUp != prevServerUp {
|
||||||
sendMessageToRooms(green, server.Name, "Is now online :smiley:", true)
|
sendMessageToRooms(green, server.Name, "Is now online :smiley:", true)
|
||||||
} else if !serverUp && serverUp != prevServerUp {
|
} else if !serverUp && serverUp != prevServerUp {
|
||||||
@@ -61,7 +76,7 @@ func scanServers() {
|
|||||||
config.Config.Servers[index].Online = serverUp
|
config.Config.Servers[index].Online = serverUp
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * config.Config.PollingInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user