Code Monkey home page Code Monkey logo

serverstatus's Introduction

ServerStatus

ServerStatus is a full rewrite of mojeda's ServerStatus script, which in turn is a modified version of BlueVM's script.

Live demo:

There are many things which I dislike about the original script, for example:

  • requires webserver and PHP for every client
  • querys clients for every user that visits the site
  • hangs when said clients don't respond
  • loading slow with many servers
  • messy codebase
  • progress bar animation skips
  • setup process complicated

Therefore I made my own ServerStatus which is quite different than the others under the hood, but still looks as nice!

The way my ServerStatus works is as following:

  • Master server listens on port 35061 TCP
  • Clients connect to the master server
  • Clients generate statistics and send it to the master server periodically (eg. every second)
  • Master server writes summarized stats to web-dir/json/stats.json
  • Users load HTML page with JavaScript, which fetches the stats.json every two seconds and updates the table

Installation & Usage

Master Server

Name "sergate" given by Dasiel :)

Switch to a non-privileged user or create one. Port 35601 needs to be free and forwarded/open for running the server.

git clone https://github.com/BotoX/ServerStatus.git
cd ServerStatus/server
make
./sergate

If everything goes well you can move on to the next step!

Configuration

Simply edit the config.json file, it's self explanatory.

{"servers":
	[
		{
			"username": "s01",
			"name": "Mainserver 1",
			"type": "Dedicated Server",
			"host": "GenericServerHost123",
			"location": "Austria",
			"password": "some-hard-to-guess-copy-paste-password"
		},
	]
}

If you want to temporarily disable a server you can add

"disabled": true

There are also some command line switches which you should be aware of. Simply add the -h switch when running the binary to find out!

    -h, --help            Show this help message and exit
    -v, --verbose         Verbose output
    -c, --config=<str>    Config file to use
    -d, --web-dir=<str>   Location of the web directory
    -b, --bind=<str>      Bind to address
    -p, --port=<int>      Listen on port

Also, don't forget to copy/move the web directory (ServerStatus/status) to a place where your webserver can find it.

Running

You could manually run the master server, but using a startup script is preferred.

Debian and other init.d based systems

Copy the init.d script to /etc/init.d

cp ServerStatus/other/sergate.initd /etc/init.d/sergate

Edit it with your favourite text editor and change the following lines according to your setup:

# Change this according to your setup!
DAEMON_PATH="/usr/local/share/ServerStatus/server"
WEB_PATH="/var/www/botox.bz/status"
DAEMON="sergate"
OPTS="-d $WEB_PATH"
RUNAS="www-data"

Start the service by running as root

service sergate start

Add it to the autostart by running as root

update-rc.d sergate defaults

Arch Linux and other systemd based systems

Copy the systemd service to /etc/systemd/system

cp ServerStatus/other/sergate.service /etc/systemd/system/sergate.service

Edit it with your favourite text editor and change the following lines according to your setup:

WorkingDirectory=/usr/local/share/ServerStatus/server
User=botox.bz
Group=http
ExecStart=/usr/local/share/ServerStatus/server/sergate -d /home/botox.bz/status

Start the service by running as root

systemctl start sergate

Add it to the autostart by running as root

systemctl enable sergate
Note:

Make sure that the user which runs the master server has access to the web path and can write to $WEB_PATH/json.

Client

There are two client implementations at the moment:

  • Python2 [preferred]
  • Python2-psutil
  • Bash

All three scripts are fully supported and as easy to set up. More implementations will follow, feel free to create one and make a pull request.

While the Python2 and Bash clients only support GNU/Linux, Python2-psutil supports a wide range of operating systems, such as BSD or Windows, see Python2-psutil

Automatic installation

The bash script client-setup.sh in other/ is an easy way to set up a new client. You need to have wget and ca-certificates (or use wget --no-check-certificate) installed for it to work. You could run it like this:

wget https://raw.github.com/BotoX/ServerStatus/master/other/client-setup.sh
bash client-setup.sh

The script will also detect wether you're using systemd or SysVinit and ask you wether it should create a service/autostart for the client. You can also use this script to easily update the already installed one.

Manual installation

With your favourite text editor change the following lines according to your setup:

Python Client

SERVER = "status.botox.bz"
PORT = 35601
USER = "s01"
PASSWORD = "some-hard-to-guess-copy-paste-password"
INTERVAL = 1 # Update interval

Python2-psutil Client

SERVER = "status.botox.bz"
PORT = 35601
USER = "s01"
PASSWORD = "some-hard-to-guess-copy-paste-password"
INTERVAL = 1 # Update interval

This client can be run on all operating systems supported by the psutil project.

Windows

It will also work on Windows, either use the precompiled and self-contained version or install Python2 and psutil. The precompiled version has been built using py2exe. The setup script is included if you want to build it yourself. After installing all the dependencies run "python setup.py py2exe" and hope.

The windows configuration works different to make the precompiled and self-contained version possible. Edit the client.cfg file according to your setup:

[client]
SERVER = status.botox.bz
PORT = 35601
USER = s01
PASSWORD = some-hard-to-guess-copy-paste-password
INTERVAL = 1

Bash Client

SERVER="status.botox.bz"
PORT=35601
USER="s01"
PASSWORD="some-hard-to-guess-copy-paste-password"
INTERVAL=1 # Update interval

Running

After you've verified that the client configuration is correct, by running it, you can either make it start automatically by a startup script or cronjob, or just start it manually:

nohup ./client.py &> /dev/null &

Debian and other init.d based systems

Simply add something like this to /etc/rc.local:

su -l $USERNAME -c "/path/to/client.py &> /dev/null &"

Arch Linux and other systemd based systems

Create a new systemd service by creating the file /etc/systemd/system/serverstatus.service with similar content:

[Unit]
Description=ServerStatus Client
After=network.target

[Service]
Type=simple
IgnoreSIGPIPE=no
User=$USERNAME
ExecStart=/path/to/client.py

[Install]
WantedBy=multi-user.target
Note:

IgnoreSIGPIPE=no is important for the bash client, when this line is missing it wont reconnect and flood the journal with broken pipe errors.

You don't have to worry about the clients in case the master server goes down, they will keep trying to reconnect until they can reach the master server again.

Additional information

For questions you can contact me via IRC. You can find me under the nick BotoX in the following networks: Freenode, QuakeNet, Rizon, synIRC and StormBit

License

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <[email protected]>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.

If you plan on modifying this project I'd be happy if you let me know!

Credits

Obviously the original script from BlueVM and mojeda's fork.

I'd also like to thank the Teeworlds project for some of the code which has been used in this project.

serverstatus's People

Contributors

botox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverstatus's Issues

Pre compiled exe?

Hello is it possible to get the exe on the github repo i saw this issue but the guy didn't provided it #18

status page "blue errors"

would been useful to not show this error and just wait for next update, show last update instead of erroring out the whole page

i really like your monitoring tool, its simple, fast and elegant

Init.d Centos

Init.d centos don't work.

/lib/lsb/init-functions no exist.

Centos 6

html

Hi!
When I opened index.html in Google Chrome, I found that the html was like this:
image
Why does the html look different from yours, and there is no data display on it?
I'm sure there's a json file from the client under the json folder.

error running sergate as init.d

when i execute "service sergate start" i get this error:

[root@chicago init.d]# service sergate start
/etc/init.d/sergate: line 12: /lib/lsb/init-functions: No such file or directory

that is fixed with

yum install redhat-lsb

and next error is

[root@chicago init.d]# service sergate start
/etc/init.d/sergate: line 29: log_daemon_msg: command not found
/etc/init.d/sergate: line 30: start-stop-daemon: command not found
/etc/init.d/sergate: line 32: log_end_msg: command not found

Python psutil client does not work on Windows

Hello,

Me again. I'm trying to get the client-psutil.py script working on Windows OS.

I'm running it on Python 2.7.10 and have the psutil x86 package installed. I've filled in the client details and attempt to execute the python script. I've noticed two errors:

  1. The psutil.BOOT_TIME called out on line 21 has been renamed psutil.boot_time. I was able to quickly fix this issue.
  2. When I attempt to execute the script, I get a recurring error:

('Caught Exception:', TypeError("unsupported operand type(s) for -: 'float' and
'function'",))
Connecting...
Authentication successful. Access granted.

You are connecting via: IPv4

('Caught Exception:', TypeError("unsupported operand type(s) for -: 'float' and
'function'",))
Connecting...
Authentication successful. Access granted.

You are connecting via: IPv4

Traceback (most recent call last):
File "client-psutil.py", line 131, in
CPU = get_cpu()
File "client-psutil.py", line 56, in get_cpu
return psutil.cpu_percent(interval=INTERVAL)
File "C:\Python27\lib\site-packages\psutil__init__.py", line 1455, in cpu_per
cent
time.sleep(interval)
KeyboardInterrupt

  • At the end you see me killing the recurring error, however it does seem like the client connects for a second before dropping off each time the error cycles.

SWAP, HDD and RAM not showing up correctly

Using debian 7 on all my servers.
sergate is running on a OpenVZ debian 7 instance.
Using the python (recommend) client, however the other clients have the same problem.

Screenshot:
error

[FYI] I created an open source new skin for this project

I build a new skin for this project with typescript, react and Ant Design.

Features

  • better responsive web design
  • multiple language support (built-in English, Simplified Chinese, Traditional Chinese]

It is also under WTFPL public license, you can do anything with it as you needed.

pc review
[pc screenshot]

mobile review
[mobile screenshot]

Stuck at install

When i try to install it show: root@web:~/ServerStatus/server# ./sergate [server]: Bound to :35601
Installation stuck here.

Cannot add more then 32 servers

I'm adding servers to the config.json file and when I hit server number 33 new servers stopped showing up on the monitoring page after I restarted the sergate process.

Is there a limitation to the number of servers that can be added with this monitoring tool?

Thanks

Feature Request: IPv6 as Disabled insead of Down

Can the client script check and report IPv6 Disabled with maybe an orange back colour instead of it reporting IPv6 Down in Red when it is only disabled?

I see RED and think something is wrong when IPv6 is merely disabled 😞

Thanks

/lib/lsb/init-functions: No such file or directory

hello, i am trying to install server status on my new VPS. it is a centos box, when i am trying to install the client it says

/etc/init.d/serverstatus: line 12: /lib/lsb/init-functions: No such file or directory

did i do wrong? i hope you could help me.

Thank you,
Dhavid

Client hangs when connection is very bad for some time

When the connection is very bad for a longer period (packet loss) the python client sometimes stops working entirely, even when the connection comes back. I have to restart it then. stdout shows nothing suspicious.

I have a problem SpeedRx=(3.21949e+10-3.21949e+10)/1

Hello,

I have a problem during client launch

(root@FC02) (/home) # ./serverstatus-client.sh

Connected.

./serverstatus-client.sh: ligne 121: let: SpeedRx=(3.21949e+10-3.21949e+10)/1 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".21949e+10-3.21949e+10)/1")
./serverstatus-client.sh: ligne 122: let: SpeedTx=(1.45228e+11-1.45228e+11)/1 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".45228e+11-1.45228e+11)/1")
./serverstatus-client.sh: ligne 121: let: SpeedRx=(3.2195e+10-3.21949e+10)/1 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".2195e+10-3.21949e+10)/1")
./serverstatus-client.sh: ligne 122: let: SpeedTx=(1.45229e+11-1.45228e+11)/1 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".45229e+11-1.45228e+11)/1")
./serverstatus-client.sh: ligne 121: let: SpeedRx=(3.21952e+10-3.2195e+10)/1 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".21952e+10-3.2195e+10)/1")
./serverstatus-client.sh: ligne 122: let: SpeedTx=(1.45229e+11-1.45229e+11)/1 : erreur de syntaxe : opérateur arithmétique non valable (le symbole erroné est ".45229e+11-1.45229e+11)/1")

( My debian is language french )

Thanks, !

Update Error

Hello,

the script completly dont work currently on Centos or Debian:

Server Script

Failed to start sergate.service: Unit sergate.service failed to load: No such file or directory.

than if start manually

serverstatus

and the clients can also not connect...

whats wrong with this script currently?

localhost's client can not display

hey

i install server status on my vps as a server and i want to make this vps as a client too. when i installed client and configured, i can not got information about it.

Firewall Rules

Hello,

I have been using your script for very long time, and now i have an issue. I am using a control panel called vestaCP and it add iptable/firewall on the installation package. But, it seems that it block the port that your script use for the connection to the main server. I already try to add rules, but it seems not working at all.

Any idea on how to solve the issue?

Many thanks,
Dhavid

Network Status no updated

Hi,

I've been using your script for a very long time, and like it so much. I never encountered any problem before, but today when I am installing the script on one of my server, all the data is showing except the network data. I never have any issue before, you maybe you could please give me a hand to solve this issue. The server is hosted on OVH and the dashboard is located in this page : https://goo.gl/v5W0t0

Thanks

Will the software be updated? 有无继续开发计划

It is a good project, but now seems not be updated.
And i try to modify cppla's version, I use golang to rewrite the client program, and i want to rewrite the server program too.
The server program is wirtten by C++,However, my C++/C code is so poor. So could you someone work with me?
Thanks!

image

PS i try to compile the server program in windows, but it can not work,
image

my version: https://github.com/CHN-STUDENT/ServerStatus/
cppla version: https://github.com/cppla/ServerStatus/

很好的项目,但是现在为什么不填坑了?
cppla 的版本很好用,我也照着他的版本重写了golang 版本的客户端,现在能跨平台检测了,我现在希望继续优化重写服务端,但是我的C++水平太次了,所以呢,不知道有没有人给我点指点意见?

windows .exe file

Not so much an issue as a request. Could you just link to the clients/windows/client.exe file instead of including it in the repo? That file alone accounts for more than half the size of your repository, and I would imagine only a small percent of ServerStatus users would be using it..of course I could be wrong :)

Thanks

Cant start the daemon through service command

Hey!

When trying to run the daemon from sudo service serrate start i get

Failed to start sergate.service: Unit sergate.service not found.

Any idea? I've followed every step correctly, I'm running Ubuntu 16.04

thanks!

I put on this hosting why

If this message doesn't disappear make sure that you have Javascript enabled.
Otherwise the status server is probably down.
I put on this hosting why?

Can't initiate sergate

When I set up the client and run the bash in client server, it shows:
/usr/local/share/serverstatus-client.sh: line 121: let: SpeedRx=(5.90376e+10-5.90376e+10)/1: syntax error: invalid arithmetic operator (error token is ".90376e+10-5.90376e+10)/1")
/usr/local/share/serverstatus-client.sh: line 122: let: SpeedTx=(5.73197e+10-5.73197e+10)/1: syntax error: invalid arithmetic operator (error token is ".73197e+10-5.73197e+10)/1")

Update interval

I set up and kept all the settings default. And the data refresh every 5 or more seconds,but the demo page seems to be realtime. How to configure?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.