From 0665788479994608624bb7c43b05cb5797c1fb2a Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 12:45:16 -0700 Subject: [PATCH 01/14] Initial commit --- plugins/minecraft/jsonapi/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/minecraft/jsonapi/README.md diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md new file mode 100644 index 00000000..7288f567 --- /dev/null +++ b/plugins/minecraft/jsonapi/README.md @@ -0,0 +1,4 @@ +munin-bukkit-plugins +==================== + +Some useful Munin plugins if you run a Bukkit (Minecraft) server with JSONAPI. \ No newline at end of file From a02e98adda5a80fd80f0aa4c0b63aa1fc6efad5d Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 20:58:21 +0100 Subject: [PATCH 02/14] initial README --- plugins/minecraft/jsonapi/README.md | 31 ++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index 7288f567..46edf68c 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -1,4 +1,29 @@ -munin-bukkit-plugins -==================== +# munin-bukkit-plugins -Some useful Munin plugins if you run a Bukkit (Minecraft) server with JSONAPI. \ No newline at end of file +This repository contains some useful [Munin](http://munin-monitoring.org/) plugins to monitor and observe a [Bukkit](http://bukkit.org) server. + +Read more in my [blog post](http://). + +## Requirements + +* Bukkit server with [JSONAPI](https://github.com/alecgorge/jsonapi) plugin +* Web server with Munin (2) and `PHP` support + +## Configuration + +1. Adjust the JSONAPI variables in each plugin +1. Make sure the `PHP` binary in the Shebang line is executable + +## Installation + +1. Clone this repository: `git clone git@github.com:frdmn/munin-bukkit-plugins.git` +1. Perform your configuration (see above) +1. Move the plugins into the Munin plugin directory: `mv mcjson* /usr/share/munin/plugins/` +1. Change the ownership: `chown munin:munin /usr/share/munin/plugins/mcjson*` +1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mcjson*` +1. Enable the plugins: `ln -s /usr/share/munin/plugins/mcjson* /etc/munin/plugins/` +1. Restart your munin-node: `service munin-node restart` +1. Run your cron: + + su - munin --shell=/bin/sh + /usr/bin/munin-cron \ No newline at end of file From b6bf87120c75652c711832d0c1ba084061568f17 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 20:58:31 +0100 Subject: [PATCH 03/14] first version of the plugins --- plugins/minecraft/jsonapi/mcjsonplayers | 46 ++++++++++++++++++++ plugins/minecraft/jsonapi/mcjsonramusage | 55 ++++++++++++++++++++++++ plugins/minecraft/jsonapi/mcjsontps | 46 ++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 plugins/minecraft/jsonapi/mcjsonplayers create mode 100644 plugins/minecraft/jsonapi/mcjsonramusage create mode 100644 plugins/minecraft/jsonapi/mcjsontps diff --git a/plugins/minecraft/jsonapi/mcjsonplayers b/plugins/minecraft/jsonapi/mcjsonplayers new file mode 100644 index 00000000..cb7fe1b8 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcjsonplayers @@ -0,0 +1,46 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / JSONAPI - players online +graph_category bukkit_jsonapi +graph_vlabel players +graph_args --base 1000 -l 0 +players.type GAUGE +players.label players +"); +exit(); +} + +## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +require('/var/cache/munin/JSONAPI.php'); + +## Prepare API call +$api = new JSONAPI($hostname, $port, $username, $password, $salt); +$result = $api->call("getPlayerCount"); + +## Check for success +if ($result['result'] == 'success'){ + ## Print values + print('players.value ' . $result['success'] . "\n"); +} +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcjsonramusage b/plugins/minecraft/jsonapi/mcjsonramusage new file mode 100644 index 00000000..cdab345a --- /dev/null +++ b/plugins/minecraft/jsonapi/mcjsonramusage @@ -0,0 +1,55 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / JSONAPI - RAM usage +graph_category bukkit_jsonapi +graph_vlabel RAM usage in GB +graph_args --base 1024 -l 0 +total.label total +total.type GAUGE +used.label used +used.type GAUGE +"); +exit(); +} + +## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +require('/var/cache/munin/JSONAPI.php'); + +## Prepare API call +$api = new JSONAPI($hostname, $port, $username, $password, $salt); +$result = $api->callMultiple(array( + "system.getJavaMemoryUsage", + "system.getJavaMemoryTotal" + ), array( + array(), + array(), +)); + +## Check for success +if ($result['result'] == 'success'){ + ## Print values + print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n"); + print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n"); +} +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcjsontps b/plugins/minecraft/jsonapi/mcjsontps new file mode 100644 index 00000000..bf483e88 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcjsontps @@ -0,0 +1,46 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / JSONAPI - ticks per second (TPS) +graph_category bukkit_jsonapi +graph_vlabel ticks per second +graph_args --base 1000 -l 0 +tps.type GAUGE +tps.label TPS +"); +exit(); +} + +## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +require('/var/cache/munin/JSONAPI.php'); + +## Prepare API call +$api = new JSONAPI($hostname, $port, $username, $password, $salt); +$result = $api->call("system.getServerClockDebug"); + +## Check for success +if ($result['result'] == 'success'){ + ## Print values + print('tps.value ' . round($result['success']['clockRate'], 2) . "\n"); +} +?> \ No newline at end of file From 3dde76f89a6876b8191e53218ae95490563ceb6c Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 20:59:14 +0100 Subject: [PATCH 04/14] fixed missing code --- plugins/minecraft/jsonapi/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index 46edf68c..b209e75e 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -25,5 +25,6 @@ Read more in my [blog post](http://). 1. Restart your munin-node: `service munin-node restart` 1. Run your cron: + su - munin --shell=/bin/sh /usr/bin/munin-cron \ No newline at end of file From 9066b8ff7adfa69c8c2ec522f3d80696f3d505ff Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 21:01:34 +0100 Subject: [PATCH 05/14] more pretty code highlighting --- plugins/minecraft/jsonapi/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index b209e75e..f877b656 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -23,8 +23,4 @@ Read more in my [blog post](http://). 1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mcjson*` 1. Enable the plugins: `ln -s /usr/share/munin/plugins/mcjson* /etc/munin/plugins/` 1. Restart your munin-node: `service munin-node restart` -1. Run your cron: - - - su - munin --shell=/bin/sh - /usr/bin/munin-cron \ No newline at end of file +1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron` \ No newline at end of file From 70b328acd7a0c61cf34cc62405d3837ca5ada3de Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 21:02:11 +0100 Subject: [PATCH 06/14] fixed a typo --- plugins/minecraft/jsonapi/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index f877b656..4753e27e 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -7,7 +7,7 @@ Read more in my [blog post](http://). ## Requirements * Bukkit server with [JSONAPI](https://github.com/alecgorge/jsonapi) plugin -* Web server with Munin (2) and `PHP` support +* Web server with `PHP` support and Munin (2) ## Configuration @@ -23,4 +23,4 @@ Read more in my [blog post](http://). 1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mcjson*` 1. Enable the plugins: `ln -s /usr/share/munin/plugins/mcjson* /etc/munin/plugins/` 1. Restart your munin-node: `service munin-node restart` -1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron` \ No newline at end of file +1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron \ No newline at end of file From 815075fe862a2624088dc2931e5885a8b02e2be6 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 21:03:19 +0100 Subject: [PATCH 07/14] missing '`' --- plugins/minecraft/jsonapi/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index 4753e27e..d231e870 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -23,4 +23,4 @@ Read more in my [blog post](http://). 1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mcjson*` 1. Enable the plugins: `ln -s /usr/share/munin/plugins/mcjson* /etc/munin/plugins/` 1. Restart your munin-node: `service munin-node restart` -1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron \ No newline at end of file +1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron` \ No newline at end of file From c94bfaf97286c741fd668c6dff54325a4ac60f6b Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Tue, 26 Mar 2013 22:18:39 +0100 Subject: [PATCH 08/14] reorded the tasks --- plugins/minecraft/jsonapi/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index d231e870..2afff01d 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -11,12 +11,12 @@ Read more in my [blog post](http://). ## Configuration +1. Clone this repository: `git clone git@github.com:frdmn/munin-bukkit-plugins.git` 1. Adjust the JSONAPI variables in each plugin 1. Make sure the `PHP` binary in the Shebang line is executable ## Installation -1. Clone this repository: `git clone git@github.com:frdmn/munin-bukkit-plugins.git` 1. Perform your configuration (see above) 1. Move the plugins into the Munin plugin directory: `mv mcjson* /usr/share/munin/plugins/` 1. Change the ownership: `chown munin:munin /usr/share/munin/plugins/mcjson*` From ed43e06b400bc3ab9ced87f855764c5c1af4dcd1 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 27 Mar 2013 07:11:10 +0100 Subject: [PATCH 09/14] new README for new plugins --- plugins/minecraft/jsonapi/README.md | 33 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index 2afff01d..c1d0d1e0 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -1,26 +1,43 @@ # munin-bukkit-plugins -This repository contains some useful [Munin](http://munin-monitoring.org/) plugins to monitor and observe a [Bukkit](http://bukkit.org) server. +This repository contains some useful [Munin](http://munin-monitoring.org/) plugins to monitor and observe a [Bukkit](http://bukkit.org) server: -Read more in my [blog post](http://). +* **mcjsonplayers** - players currently online +* **mcjsonramusage** - RAM usage +* **mcjsontps** - TPS (ticks per second) +* **mcsqls2killshostile** - hostile mob kills +* **mcsqls2killsneutral** - neutral mob kills +* **mcsqls2killspassive** - passive mob kills +* **mcsqls2players** - new players per day +* **mcsqlubshame** - kicks/bans/mutes/etc. per day + +mcjson* requires [JSONAPI](https://github.com/alecgorge/jsonapi/). +mcsqls2* requires [Statistician](http://dev.bukkit.org/server-mods/statisticianv2/). +mcsqlub* requires [Ultrabans](http://dev.bukkit.org/server-mods/ultrabans/). + +Read more in my [blog post](http://blog.frd.mn/posts/munin-bukkit-plugins/). ## Requirements -* Bukkit server with [JSONAPI](https://github.com/alecgorge/jsonapi) plugin * Web server with `PHP` support and Munin (2) +* Bukkit server with JSONAPI for the JSONAPI plugins (`mcjson*`) +* Bukkit server with Ultrabans for the Ultrabans plugins (`mcsqlub*`) +* Bukkit server with Statistician for the MySQL plugins (`mcsqls2*`) +* MySQL server for the SQL plugins ## Configuration 1. Clone this repository: `git clone git@github.com:frdmn/munin-bukkit-plugins.git` -1. Adjust the JSONAPI variables in each plugin +1. Adjust the JSONAPI variables in the mcjson* files +1. Adjust the MySQL variables in the mcsql* files 1. Make sure the `PHP` binary in the Shebang line is executable ## Installation 1. Perform your configuration (see above) -1. Move the plugins into the Munin plugin directory: `mv mcjson* /usr/share/munin/plugins/` -1. Change the ownership: `chown munin:munin /usr/share/munin/plugins/mcjson*` -1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mcjson*` -1. Enable the plugins: `ln -s /usr/share/munin/plugins/mcjson* /etc/munin/plugins/` +1. Move the plugins into the Munin plugin directory: `mv mc* /usr/share/munin/plugins/` +1. Change the ownership: `chown munin:munin /usr/share/munin/plugins/mc*` +1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mc*` +1. Enable the plugins: `ln -s /usr/share/munin/plugins/mc* /etc/munin/plugins/` 1. Restart your munin-node: `service munin-node restart` 1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron` \ No newline at end of file From 2b174682449c5d76731120da23223babc34c8a0f Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 27 Mar 2013 07:11:27 +0100 Subject: [PATCH 10/14] new Statistician and Ultrabans (SQL) plugins --- plugins/minecraft/jsonapi/mcsqls2killshostile | 151 ++++++++++++++++++ plugins/minecraft/jsonapi/mcsqls2killsneutral | 79 +++++++++ plugins/minecraft/jsonapi/mcsqls2killspassive | 119 ++++++++++++++ plugins/minecraft/jsonapi/mcsqls2players | 55 +++++++ plugins/minecraft/jsonapi/mcsqlubshame | 129 +++++++++++++++ 5 files changed, 533 insertions(+) create mode 100644 plugins/minecraft/jsonapi/mcsqls2killshostile create mode 100644 plugins/minecraft/jsonapi/mcsqls2killsneutral create mode 100644 plugins/minecraft/jsonapi/mcsqls2killspassive create mode 100644 plugins/minecraft/jsonapi/mcsqls2players create mode 100644 plugins/minecraft/jsonapi/mcsqlubshame diff --git a/plugins/minecraft/jsonapi/mcsqls2killshostile b/plugins/minecraft/jsonapi/mcsqls2killshostile new file mode 100644 index 00000000..c81e36f0 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2killshostile @@ -0,0 +1,151 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - hostile mob kills per day +graph_category bukkit_sql_kills +graph_vlabel hostile mob kills per day +graph_args --base 1000 -l 0 +blaze.type GAUGE +blaze.label killed blazes +spider.type GAUGE +spider.label killed spiders +creeper.type GAUGE +creeper.label killed creepers +ghast.type GAUGE +ghast.label killed ghasts +magmacube.type GAUGE +magmacube.label killed magma cubes +silverfish.type GAUGE +silverfish.label killed silverfish +skeleton.type GAUGE +skeleton.label killed skeletons +slime.type GAUGE +slime.label killed slimes +witch.type GAUGE +witch.label killed witches +zombie.type GAUGE +zombie.label killed zombies +irongolem.type GAUGE +irongolem.label killed iron golems +enderdragon.type GAUGE +enderdragon.label killed ender dragons +wither.type GAUGE +wither.label killed withers +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for blaze kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Blaze'")) { + ## Print values + print('blaze.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for spider kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%Spider'")) { + ## Print values + print('spider.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for creeper kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%reeper%'")) { + ## Print values + print('creeper.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ghast kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ghast'")) { + ## Print values + print('ghast.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for magma cube kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MagmaCube'")) { + ## Print values + print('magmacube.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for silverfish and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Silverfish'")) { + ## Print values + print('silverfish.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for skeleton kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Skeleton'")) { + ## Print values + print('skeleton.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for slime kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Slime'")) { + ## Print values + print('slime.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for witch kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Witch'")) { + ## Print values + print('witch.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for zombie kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie'")) { + ## Print values + print('zombie.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for iron golem kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%ron%'")) { + ## Print values + print('irongolem.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ender dragon kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'EnderDragon'")) { + ## Print values + print('enderdragon.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for wither kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wither'")) { + ## Print values + print('wither.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2killsneutral b/plugins/minecraft/jsonapi/mcsqls2killsneutral new file mode 100644 index 00000000..d5282d0c --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2killsneutral @@ -0,0 +1,79 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - neutral mob kills per day +graph_category bukkit_sql_kills +graph_vlabel neutral mob kills per day +graph_args --base 1000 -l 0 +enderman.type GAUGE +enderman.label killed endermen +wolf.type GAUGE +wolf.label killed wolf +zombiepigman.type GAUGE +zombiepigman.label killed zombie pigmen +snowman.type GAUGE +snowman.label killed snowmen +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for enderman and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Enderman'")) { + ## Print values + print('enderman.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for wolf kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wolf'")) { + ## Print values + print('wolf.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for zombie pigman kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie Pigman'")) { + ## Print values + print('zombiepigman.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for zombie snowman kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Snowman'")) { + ## Print values + print('snowman.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2killspassive b/plugins/minecraft/jsonapi/mcsqls2killspassive new file mode 100644 index 00000000..8dacf9e4 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2killspassive @@ -0,0 +1,119 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - passive mob kills per day +graph_category bukkit_sql_kills +graph_vlabel passive mob kills per day +graph_args --base 1000 -l 0 +bat.type GAUGE +bat.label killed bats +chicken.type GAUGE +chicken.label killed chickens +cow.type GAUGE +cow.label killed cows +mooshroom.type GAUGE +mooshroom.label killed mooshrooms +ocelot.type GAUGE +ocelot.label killed magma ocelots +pig.type GAUGE +pig.label killed pigs +sheep.type GAUGE +sheep.label killed sheeps +squid.type GAUGE +squid.label killed squids +villager.type GAUGE +villager.label killed villager +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for bat kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Bat'")) { + ## Print values + print('bat.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for chicken kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Chicken'")) { + ## Print values + print('chicken.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for mooshroom kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MushroomCow'")) { + ## Print values + print('mooshroom.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for cow kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Cow'")) { + ## Print values + print('cow.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ocelot kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ocelot'")) { + ## Print values + print('ocelot.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for pig kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Pig'")) { + ## Print values + print('pig.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for sheep and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Sheep'")) { + ## Print values + print('sheep.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for squid kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Squid'")) { + ## Print values + print('squid.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for villager and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Villager'")) { + ## Print values + print('villager.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2players b/plugins/minecraft/jsonapi/mcsqls2players new file mode 100644 index 00000000..21682268 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2players @@ -0,0 +1,55 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - new players per day +graph_category bukkit_sql +graph_vlabel new players per day +graph_args --base 1000 -l 0 +players.type GAUGE +players.label new players +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries return the amount of rows +if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE firstever_login > $today")) { + ## Print values + print('players.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqlubshame b/plugins/minecraft/jsonapi/mcsqlubshame new file mode 100644 index 00000000..784f9864 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqlubshame @@ -0,0 +1,129 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Ultrabans - shame per day +graph_category bukkit_sql +graph_vlabel amount of shame per day +graph_args --base 1000 -l 0 +unban.type GAUGE +unban.label unbans +kick.type GAUGE +kick.label kicks +warning.type GAUGE +warning.label warnings +ban.type GAUGE +ban.label bans +ipban.type GAUGE +ipban.label ipbans +fine.type GAUGE +fine.label fines +jail.type GAUGE +jail.label jails +permban.type GAUGE +permban.label permbans +mute.type GAUGE +mute.label mutes +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for unbans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) { + ## Print values + print('unban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for kicks return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) { + ## Print values + print('kick.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for warnings return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) { + ## Print values + print('warning.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for bans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) { + ## Print values + print('ban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ipbans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) { + ## Print values + print('ipban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for fines return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) { + ## Print values + print('fine.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for jails return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) { + ## Print values + print('jail.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for permbans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) { + ## Print values + print('permban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for mutes - part 1 return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) { + ## Store result + $tmp1 = mysqli_num_rows($result); +} + +## Select queries for mutes - part 2 return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) { + ## Store result + $tmp2 = mysqli_num_rows($result); +} + +$mutes = $tmp1 + $tmp2; + +print('mute.value ' . $mutes . "\n"); + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file From 22436814ea4f0359bd031e7fda4821eaf28c4d38 Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 27 Mar 2013 07:12:30 +0100 Subject: [PATCH 11/14] added some whitespaces --- plugins/minecraft/jsonapi/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index c1d0d1e0..2df23925 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -11,9 +11,9 @@ This repository contains some useful [Munin](http://munin-monitoring.org/) plugi * **mcsqls2players** - new players per day * **mcsqlubshame** - kicks/bans/mutes/etc. per day -mcjson* requires [JSONAPI](https://github.com/alecgorge/jsonapi/). -mcsqls2* requires [Statistician](http://dev.bukkit.org/server-mods/statisticianv2/). -mcsqlub* requires [Ultrabans](http://dev.bukkit.org/server-mods/ultrabans/). +mcjson* requires [JSONAPI](https://github.com/alecgorge/jsonapi/) +mcsqls2* requires [Statistician](http://dev.bukkit.org/server-mods/statisticianv2/) +mcsqlub* requires [Ultrabans](http://dev.bukkit.org/server-mods/ultrabans/) Read more in my [blog post](http://blog.frd.mn/posts/munin-bukkit-plugins/). From 4192c14f767fab871f038ccf12cb456d47c76c8d Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Thu, 28 Mar 2013 16:06:49 +0100 Subject: [PATCH 12/14] comment format renewal --- plugins/minecraft/jsonapi/mcjsonplayers | 41 +++++---- plugins/minecraft/jsonapi/mcjsonramusage | 41 +++++---- plugins/minecraft/jsonapi/mcjsontps | 41 +++++---- plugins/minecraft/jsonapi/mcsqls2killshostile | 34 +++++--- plugins/minecraft/jsonapi/mcsqls2killsneutral | 58 +++++++------ plugins/minecraft/jsonapi/mcsqls2killspassive | 78 +++++++++-------- plugins/minecraft/jsonapi/mcsqls2players | 46 ++++++---- plugins/minecraft/jsonapi/mcsqlubshame | 83 +++++++++++-------- 8 files changed, 250 insertions(+), 172 deletions(-) diff --git a/plugins/minecraft/jsonapi/mcjsonplayers b/plugins/minecraft/jsonapi/mcjsonplayers index cb7fe1b8..49781c1b 100644 --- a/plugins/minecraft/jsonapi/mcjsonplayers +++ b/plugins/minecraft/jsonapi/mcjsonplayers @@ -1,14 +1,22 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / JSONAPI - players online @@ -31,16 +40,16 @@ players.label players exit(); } -## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +// Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) require('/var/cache/munin/JSONAPI.php'); -## Prepare API call +// Prepare API call $api = new JSONAPI($hostname, $port, $username, $password, $salt); $result = $api->call("getPlayerCount"); -## Check for success +// Check for success if ($result['result'] == 'success'){ - ## Print values + // Print values print('players.value ' . $result['success'] . "\n"); } ?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcjsonramusage b/plugins/minecraft/jsonapi/mcjsonramusage index cdab345a..5255320a 100644 --- a/plugins/minecraft/jsonapi/mcjsonramusage +++ b/plugins/minecraft/jsonapi/mcjsonramusage @@ -1,14 +1,22 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / JSONAPI - RAM usage @@ -33,10 +42,10 @@ used.type GAUGE exit(); } -## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +// Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) require('/var/cache/munin/JSONAPI.php'); -## Prepare API call +// Prepare API call $api = new JSONAPI($hostname, $port, $username, $password, $salt); $result = $api->callMultiple(array( "system.getJavaMemoryUsage", @@ -46,9 +55,9 @@ $result = $api->callMultiple(array( array(), )); -## Check for success +// Check for success if ($result['result'] == 'success'){ - ## Print values + // Print values print('used.value ' . round($result['success'][0]['success']/1000,2) . "\n"); print('total.value ' . round($result['success'][1]['success']/1000,2) . "\n"); } diff --git a/plugins/minecraft/jsonapi/mcjsontps b/plugins/minecraft/jsonapi/mcjsontps index bf483e88..226d3400 100644 --- a/plugins/minecraft/jsonapi/mcjsontps +++ b/plugins/minecraft/jsonapi/mcjsontps @@ -1,14 +1,22 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / JSONAPI - ticks per second (TPS) @@ -31,16 +40,16 @@ tps.label TPS exit(); } -## Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) +// Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php) require('/var/cache/munin/JSONAPI.php'); -## Prepare API call +// Prepare API call $api = new JSONAPI($hostname, $port, $username, $password, $salt); $result = $api->call("system.getServerClockDebug"); -## Check for success +// Check for success if ($result['result'] == 'success'){ - ## Print values + // Print values print('tps.value ' . round($result['success']['clockRate'], 2) . "\n"); } ?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2killshostile b/plugins/minecraft/jsonapi/mcsqls2killshostile index c81e36f0..46ec0617 100644 --- a/plugins/minecraft/jsonapi/mcsqls2killshostile +++ b/plugins/minecraft/jsonapi/mcsqls2killshostile @@ -1,14 +1,23 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / Statistician - hostile mob kills per day diff --git a/plugins/minecraft/jsonapi/mcsqls2killsneutral b/plugins/minecraft/jsonapi/mcsqls2killsneutral index d5282d0c..2f222f92 100644 --- a/plugins/minecraft/jsonapi/mcsqls2killsneutral +++ b/plugins/minecraft/jsonapi/mcsqls2killsneutral @@ -1,14 +1,23 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / Statistician - neutral mob kills per day @@ -37,43 +47,43 @@ snowman.label killed snowmen exit(); } -## Construct 'minumum' timstamp +// Construct 'minumum' timstamp $current = mktime(); $today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); -## Initiate connection +// Initiate connection $connection = mysqli_connect($hostname, $username, $password, $database, $port); -## Check connection +// Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } -## Select queries for enderman and return the amount of rows +// Select queries for enderman and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Enderman'")) { - ## Print values + // Print values print('enderman.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for wolf kills and return the amount of rows +// Select queries for wolf kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wolf'")) { - ## Print values + // Print values print('wolf.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for zombie pigman kills and return the amount of rows +// Select queries for zombie pigman kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie Pigman'")) { - ## Print values + // Print values print('zombiepigman.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for zombie snowman kills and return the amount of rows +// Select queries for zombie snowman kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Snowman'")) { - ## Print values + // Print values print('snowman.value ' . mysqli_num_rows($result) . "\n"); } -## Close connection +// Close connection mysqli_close($connection); ?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2killspassive b/plugins/minecraft/jsonapi/mcsqls2killspassive index 8dacf9e4..b0e5b430 100644 --- a/plugins/minecraft/jsonapi/mcsqls2killspassive +++ b/plugins/minecraft/jsonapi/mcsqls2killspassive @@ -1,14 +1,23 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / Statistician - passive mob kills per day @@ -47,73 +57,73 @@ villager.label killed villager exit(); } -## Construct 'minumum' timstamp +// Construct 'minumum' timstamp $current = mktime(); $today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); -## Initiate connection +// Initiate connection $connection = mysqli_connect($hostname, $username, $password, $database, $port); -## Check connection +// Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } -## Select queries for bat kills and return the amount of rows +// Select queries for bat kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Bat'")) { - ## Print values + // Print values print('bat.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for chicken kills and return the amount of rows +// Select queries for chicken kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Chicken'")) { - ## Print values + // Print values print('chicken.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for mooshroom kills and return the amount of rows +// Select queries for mooshroom kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MushroomCow'")) { - ## Print values + // Print values print('mooshroom.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for cow kills and return the amount of rows +// Select queries for cow kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Cow'")) { - ## Print values + // Print values print('cow.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for ocelot kills and return the amount of rows +// Select queries for ocelot kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ocelot'")) { - ## Print values + // Print values print('ocelot.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for pig kills and return the amount of rows +// Select queries for pig kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Pig'")) { - ## Print values + // Print values print('pig.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for sheep and return the amount of rows +// Select queries for sheep and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Sheep'")) { - ## Print values + // Print values print('sheep.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for squid kills and return the amount of rows +// Select queries for squid kills and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Squid'")) { - ## Print values + // Print values print('squid.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for villager and return the amount of rows +// Select queries for villager and return the amount of rows if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Villager'")) { - ## Print values + // Print values print('villager.value ' . mysqli_num_rows($result) . "\n"); } -## Close connection +// Close connection mysqli_close($connection); ?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2players b/plugins/minecraft/jsonapi/mcsqls2players index 21682268..4b44d470 100644 --- a/plugins/minecraft/jsonapi/mcsqls2players +++ b/plugins/minecraft/jsonapi/mcsqls2players @@ -1,14 +1,23 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / Statistician - new players per day @@ -31,25 +41,25 @@ players.label new players exit(); } -## Construct 'minumum' timstamp +// Construct 'minumum' timstamp $current = mktime(); $today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); -## Initiate connection +// Initiate connection $connection = mysqli_connect($hostname, $username, $password, $database, $port); -## Check connection +// Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } -## Select queries return the amount of rows +// Select queries return the amount of rows if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE firstever_login > $today")) { - ## Print values + // Print values print('players.value ' . mysqli_num_rows($result) . "\n"); } -## Close connection +// Close connection mysqli_close($connection); ?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqlubshame b/plugins/minecraft/jsonapi/mcsqlubshame index 784f9864..302203c8 100644 --- a/plugins/minecraft/jsonapi/mcsqlubshame +++ b/plugins/minecraft/jsonapi/mcsqlubshame @@ -1,14 +1,24 @@ #!/usr/bin/php 1) && ($argv[1] == 'config')) { print("graph_title Bukkit / Ultrabans - shame per day @@ -47,76 +58,76 @@ mute.label mutes exit(); } -## Construct 'minumum' timstamp +// Construct 'minumum' timstamp $current = mktime(); $today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); -## Initiate connection +// Initiate connection $connection = mysqli_connect($hostname, $username, $password, $database, $port); -## Check connection +// Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } -## Select queries for unbans return the amount of rows +// Select queries for unbans return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) { - ## Print values + // Print values print('unban.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for kicks return the amount of rows +// Select queries for kicks return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) { - ## Print values + // Print values print('kick.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for warnings return the amount of rows +// Select queries for warnings return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) { - ## Print values + // Print values print('warning.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for bans return the amount of rows +// Select queries for bans return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) { - ## Print values + // Print values print('ban.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for ipbans return the amount of rows +// Select queries for ipbans return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) { - ## Print values + // Print values print('ipban.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for fines return the amount of rows +// Select queries for fines return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) { - ## Print values + // Print values print('fine.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for jails return the amount of rows +// Select queries for jails return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) { - ## Print values + // Print values print('jail.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for permbans return the amount of rows +// Select queries for permbans return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) { - ## Print values + // Print values print('permban.value ' . mysqli_num_rows($result) . "\n"); } -## Select queries for mutes - part 1 return the amount of rows +// Select queries for mutes - part 1 return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) { - ## Store result + // Store result $tmp1 = mysqli_num_rows($result); } -## Select queries for mutes - part 2 return the amount of rows +// Select queries for mutes - part 2 return the amount of rows if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) { - ## Store result + // Store result $tmp2 = mysqli_num_rows($result); } @@ -124,6 +135,6 @@ $mutes = $tmp1 + $tmp2; print('mute.value ' . $mutes . "\n"); -## Close connection +// Close connection mysqli_close($connection); ?> \ No newline at end of file From f1cef24112e6978a3dd3fe6092914c387870a72b Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Thu, 13 Mar 2014 11:52:21 +0100 Subject: [PATCH 13/14] Example for alerts / limits --- plugins/minecraft/jsonapi/README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index 2df23925..ed4997b5 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -15,7 +15,7 @@ mcjson* requires [JSONAPI](https://github.com/alecgorge/jsonapi/) mcsqls2* requires [Statistician](http://dev.bukkit.org/server-mods/statisticianv2/) mcsqlub* requires [Ultrabans](http://dev.bukkit.org/server-mods/ultrabans/) -Read more in my [blog post](http://blog.frd.mn/posts/munin-bukkit-plugins/). +Read more in my [blog post](http://blog.frd.mn/munin-bukkit-plugins/). ## Requirements @@ -40,4 +40,16 @@ Read more in my [blog post](http://blog.frd.mn/posts/munin-bukkit-plugins/). 1. Make sure they are exectuable: `chmod 755 /usr/share/munin/plugins/mc*` 1. Enable the plugins: `ln -s /usr/share/munin/plugins/mc* /etc/munin/plugins/` 1. Restart your munin-node: `service munin-node restart` -1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron` \ No newline at end of file +1. Run your cron: `su - munin --shell=/bin/sh -c /usr/bin/munin-cron` + +## Alerts and limits? + +To setup alerts and limits add the following lines in your specific node in the `munin.conf` file: + + [kotor.yeahwh.at] + address 5.9.115.5 + [...] + mctps_main.warning 19.9: # Warning alert on < 19.9 + mctps_main.critical 19: # Critical alert on < 19.0 + mcplayer_main.warning 20 # Warning alert when there are 20 players online + mcplayer_main.critical 30 # Critical alert when there are more than 30 players online \ No newline at end of file From fb433dc4e1be01f65b9300f77776e881e4f7ee7d Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Thu, 13 Mar 2014 11:54:35 +0100 Subject: [PATCH 14/14] Indention --- plugins/minecraft/jsonapi/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/minecraft/jsonapi/README.md b/plugins/minecraft/jsonapi/README.md index ed4997b5..3385293b 100644 --- a/plugins/minecraft/jsonapi/README.md +++ b/plugins/minecraft/jsonapi/README.md @@ -46,10 +46,10 @@ Read more in my [blog post](http://blog.frd.mn/munin-bukkit-plugins/). To setup alerts and limits add the following lines in your specific node in the `munin.conf` file: - [kotor.yeahwh.at] - address 5.9.115.5 - [...] - mctps_main.warning 19.9: # Warning alert on < 19.9 - mctps_main.critical 19: # Critical alert on < 19.0 - mcplayer_main.warning 20 # Warning alert when there are 20 players online - mcplayer_main.critical 30 # Critical alert when there are more than 30 players online \ No newline at end of file + [kotor.yeahwh.at] + address 5.9.115.5 + [...] + mctps_main.warning 19.9: # Warning alert on < 19.9 + mctps_main.critical 19: # Critical alert on < 19.0 + mcplayer_main.warning 20 # Warning alert when there are 20 players online + mcplayer_main.critical 30 # Critical alert when there are more than 30 players online \ No newline at end of file