Home

Awesome

Main-Docker Go Report Card Maintainability Docker Image Size (latest semver)

<h1><a href="https://github.com/aceberg/watchyourports"> <img src="https://raw.githubusercontent.com/aceberg/watchyourports/main/assets/logo.png" width="35" /> </a>WatchYourPorts</h1>

Open ports inventory for local servers. Exports data to InfluxDB2/Grafana

Screenshot

<details> <summary>More screenshots</summary> <img src="https://raw.githubusercontent.com/aceberg/WatchYourPorts/main/assets/Screenshot2.png"> <img src="https://raw.githubusercontent.com/aceberg/WatchYourPorts/main/assets/Screenshot3.png"> </details>

Quick start

docker run --name wyp \
-e "TZ=Asia/Novosibirsk" \
-v ~/.dockerdata/WatchYourPorts:/data/WatchYourPorts \
-p 8853:8853 \
aceberg/watchyourports

Or use docker-compose.yml

Login

You can limit access to WYP with ForAuth. Here is an example: docker-compose-auth.yml
Also, SSO tools like Authelia should work.

Import ports from Docker

  1. Run docker-export.sh on a server, where Docker is installed. $ADDR is IP or domain name of the server, without http(s):// prefix. It will be used to ping ports.
./docker-export.sh $ADDR
  1. Paste the output to hosts.yaml file in WatchYourPorts config dir
  2. You can add as many servers to hosts.yaml, as you want

Config

Configuration can be done through config.yaml file or GUI, or environment variables

VariableDescriptionDefault
HOSTListen address0.0.0.0
PORTPort for web GUI8853
THEMEAny theme name from https://bootswatch.com in lowcase or additionalgrass
COLORBackground color: light or darkdark
TIMEOUTHow often watched ports are scanned (minutes)10
HIST_TRIMHow many port states are saved in memory and displayed90
TZSet your timezone for correct time""

InfluxDB2 config

This config matches Grafana's config for InfluxDB data source

VariableDescriptionDefaultExample
INFLUX_ENABLEEnable export to InfluxDB2falsetrue
INFLUX_SKIP_TLSSkip TLS Verifyfalsetrue
INFLUX_ADDRAddress:port of InfluxDB2 serverhttps://192.168.2.3:8086/
INFLUX_BUCKETInfluxDB2 buckettest
INFLUX_ORGInfluxDB2 orghome
INFLUX_TOKENSecret token, generated by InfluxDB2

Options

KeyDescriptionDefault
-dPath to config dir/data/WatchYourPorts
-nPath to local JS and Themes (node-bootstrap)""

Local network only

By default, this app pulls themes, icons and fonts from the internet. But, in some cases, it may be useful to have an independent from global network setup. I created a separate image with all necessary modules and fonts.

docker run --name node-bootstrap       \
    -v ~/.dockerdata/icons:/app/icons  \ # For local images
    -p 8850:8850                       \
    aceberg/node-bootstrap
docker run --name wyp \
    -v ~/.dockerdata/WatchYourPorts:/data/WatchYourPorts \
    -p 8853:8853 \
    aceberg/watchyourports -n "http://$YOUR_IP:8850"

Or use docker-compose

API

GET /api/all

Returns all data about saved addresses in json.

<details> <summary>Response example</summary>
{
    "192.168.2.2": {
        "Name": "SomeAddrName",
        "Addr": "192.168.2.2",
        "PortMap": {},  // All saved ports will be here
        "Total": 0,
        "Watching": 0,
        "Online": 0,
        "Offline": 0
    },
}
</details><br>
GET /api/history

All history data from memory.

<details> <summary>Response example</summary>
{
"192.168.2.3:8849": {
        "Name": "OS",
        "Addr": "192.168.2.3",
        "Port": 8849,
        "PortName": "MiniBoard",
        "State": [
            {
                "Date": "2024-06-28 22:42:45",
                "State": true
            },
            {
                "Date": "2024-06-28 22:52:45",
                "State": true
            }
        ],
        "NowState": true
    },
}
</details><br>
GET /api/port/:addr

Returns current PortMap for addr.

<details> <summary>Request example</summary>
curl http://0.0.0.0:8853/api/port/192.168.2.2
</details> <details> <summary>Response example</summary>
{
    "8850": {
        "Name": "node-bootstrap",
        "Port": 8850,
        "State": true,
        "Watch": true
    },
    "8851": {
        "Name": "Exercise Diary",
        "Port": 8851,
        "State": true,
        "Watch": true
    },

}
</details><br>
GET /api/port/:addr/:port

Gets state of one port

<details> <summary>Request example</summary>
curl http://0.0.0.0:8853/api/port/192.168.2.2/8844
</details> <details> <summary>Response example</summary>
{
    "Name": "git-syr",
    "Port": 8844,
    "State": true,
    "Watch": true
}
</details><br>

Thanks