Skip to content

Instantly share code, notes, and snippets.

@fengjijiao
Last active May 3, 2022 23:21
Show Gist options
  • Select an option

  • Save fengjijiao/27c366e3741ed31556ad91fd2f301af0 to your computer and use it in GitHub Desktop.

Select an option

Save fengjijiao/27c366e3741ed31556ad91fd2f301af0 to your computer and use it in GitHub Desktop.
simply to install netstat
#!/bin/bash
wget -O netstat https://github.com/fengjijiao/netstat-http-api/releases/download/0.0.1/netstat-linux-amd64
chmod +x netstat
mv netstat /usr/local/bin
mkdir -p /usr/local/etc/netstat
wget -O /usr/local/etc/netstat/config.yaml https://raw.githubusercontent.com/fengjijiao/netstat-http-api/main/config.yaml
cat << EOT > /etc/systemd/system/netstat.service
[unit]
Description=netstat
Wants=network.target
After=syslog.target network-online.target
[Service]
Type=simple
Environment=GOGC=20
ExecStart=/usr/local/bin/netstat -c /usr/local/etc/netstat/config.yaml
Restart=on-failure
RestartSec=10
KillMode=process
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOT
systemctl enable --now netstat
cat << EOF
configuration file: /usr/local/etc/netstat/config.yaml
EOF
#rc-service netstat start
#rc-update add netstat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment