2017 © Pedro Peláez
 

symfony-bundle mc-monitor

Service for monitoring minecraft servers

image

mmd/mc-monitor

Service for monitoring minecraft servers

  • Saturday, April 2, 2016
  • by moldcraft
  • Repository
  • 0 Watchers
  • 1 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Minecraft Servers Monitor

Create your own service that makes regular requests to minecraft servers and sends the information to a webhook (your site)., (*1)

This will prevent your site being blocked when making requests to servers., (*2)

Install

  • Install the bundle and its dependecies, (*3)

    composer require \
        'mmd/mc-monitor:dev-master' \
        'sensio/buzz-bundle:dev-master' \
        'neitanod/forceutf8:dev-master' \
        'xpaw/php-minecraft-query:dev-master'
    
  • Include bundle in app/AppKernel.php, (*4)

    $bundles = array(
        ...
        new Mmd\Bundle\McMonitorBundle\MmdMcMonitorBundle(),
    );
    
  • Include routing in app/config/routing.yml, (*5)

    mmd_mc_monitor:
        resource: "@MmdMcMonitorBundle/Resources/config/routing.yml"
        prefix:   /mc-monitor
    
  • Add parameters to app/config/parameters.yml, (*6)

    # The secret used in API requests
    mmd.mc_monitor.secret: "my-secret"
    
    # The url to your site (with server list) where monitoring will send servers status updates
    mmd.mc_monitor.webhook: "https://my-site.com/monitoring-updates"
    
  • Create database tables, (*7)

    php app/console doctrine:schema:update --force
    

Configure

  • Set crontab to execute command that checks servers status and send information to the webhook, (*8)

    cd /path/to/project/root/
    sudo -u www-data php app/console mmd:mc-monitor:check 3
    

You can specify how many servers to check at once., (*9)

The servers will be ordered ascending by last checked time., (*10)

Run command as apache user www-data to prevent Unable to write in the cache directory error. In this case the cron must be set as root user for the sudo command to work in background., (*11)

Usage

  • Add server ip to monitoring, (*12)

    # Request
    GET /mc-monitor/api/v1/<secret>/add/<ip>
    
    # Response
    {"status":true, "message": "Server added"}
    # or
    {"status":false, "message": "Invalid ip"}
    
  • In your application, you must handle monitoring server updates requests to the url set in the mmd.mc_monitor.webhook parameter, (*13)

The monitoring will do requests in the following format, (*14)

POST https://site.com/secret-url-for-mc-monitor/
{
    secret: "<secret-set-in-parameters>",
    servers: {
        "<server-ip>": {
            status: true, /* true=online, false=offline */
            data: {
                'hostname': '<span style="color:#00AAAA;">Awesome</span> <strong>minecraft</strong> server motd',
                'numplayers': 7,
                'maxplayers': 20,
                'version': '1.<span style="color:#AA00AA;">8</span>'
            }
        },
        "<server-ip>": {...},
        ...
    }
}
  • Remove a server from monitoring

There is no way to remove a server from monitoring directly. This is done for cases when someone knows your secret, he will not be able to remove all servers from monitoring., (*15)

A server can be removed from monitoring by sending a json response to the API, when it will make a request to specified webhook url, in the following format:, (*16)

{
    "remove": [
        "127.0.0.1:25565",
        "192.168.1.100",
        "<server-ip>"
    ]
}

The Versions

02/04 2016

dev-master

9999999-dev https://github.com/MmdBundles/McMonitorBundle

Service for monitoring minecraft servers

  Sources   Download

MIT

The Requires

 

by Avatar moldcraft

api server monitor minecraft