mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Category Tree: reduce number of categories
This commit is contained in:
parent
a3c2338b1f
commit
84c28707eb
20 changed files with 22 additions and 26 deletions
94
plugins/wordpress/wordpress
Executable file
94
plugins/wordpress/wordpress
Executable file
|
@ -0,0 +1,94 @@
|
|||
#!/bin/sh
|
||||
# wordpress-munin plugin
|
||||
#
|
||||
# Author Andre Darafarin
|
||||
# Improvements by Chris Bair
|
||||
# Version 0.2 15 Feb 2011
|
||||
#
|
||||
#
|
||||
: <<=cut
|
||||
=head1 NAME
|
||||
|
||||
Wordpress-Munin plugin
|
||||
|
||||
A simple Munin plugin to monitor some data from a running wordpress instance
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The plugin need access to the database of the wordpress instance.
|
||||
|
||||
|
||||
=head2 Config file
|
||||
|
||||
Add file plugin-conf.d/wordpress and fill like this
|
||||
|
||||
|
||||
=over 4
|
||||
|
||||
=item * [wordpress]
|
||||
# Name of section. Must be wordpress.
|
||||
|
||||
=item * env.DB_NAME your_db_name
|
||||
# Replace your_db_name
|
||||
|
||||
=item * env.DB_USER your_db_username
|
||||
# Replace you_db_username
|
||||
|
||||
=item * env.DB_PASSWORD your_db_pass
|
||||
# Replace your_db_pass
|
||||
|
||||
=item * env.DB_HOST host_of_your_db
|
||||
# Replace with host of database server. Will be localhost for many users.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
0.2 15 Feb 2011
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Andre Darafarin, happypork.com
|
||||
=cut
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Wordpress average'
|
||||
echo 'graph_category cms'
|
||||
echo 'graph_order posts comments pingbacks users'
|
||||
echo 'graph_vlabel Wordpress'
|
||||
echo 'graph_info Some Statistics of Wordpress'
|
||||
echo 'posts.label Posts'
|
||||
echo 'posts.draw LINE3'
|
||||
echo 'comments.label Comments'
|
||||
echo 'pingbacks.label Pingbacks'
|
||||
echo 'users.label Users'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
POSTS=0
|
||||
COMMENTS=0
|
||||
PINGBACKS=0
|
||||
USERS=0
|
||||
|
||||
# DBNAME=${logfile:-/var/log/syslog}
|
||||
|
||||
POSTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"`
|
||||
|
||||
COMMENTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_comments WHERE comment_approved = '1' AND comment_type = '';"`
|
||||
|
||||
PINGBACKS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_comments WHERE comment_approved = '1' AND comment_type = 'pingback';"`
|
||||
|
||||
USERS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_users ;"`
|
||||
|
||||
|
||||
#AUSGABE BEREICH
|
||||
echo "posts.value $POSTS"
|
||||
echo "comments.value $COMMENTS"
|
||||
echo "pingbacks.value $PINGBACKS"
|
||||
echo "users.value $USERS"
|
||||
|
||||
|
||||
|
107
plugins/wordpress/wordpress-mu-or-network
Executable file
107
plugins/wordpress/wordpress-mu-or-network
Executable file
|
@ -0,0 +1,107 @@
|
|||
#!/bin/bash
|
||||
# wordpress-mu-munin plugin
|
||||
#
|
||||
# Author Andre Darafarin
|
||||
# Improvements by Chris Bair
|
||||
# Modified for Wordpress MU (or Network) by raT rat@espiv.net @ 22-04-2011
|
||||
# Version 0.2 15 Feb 2011
|
||||
#
|
||||
#
|
||||
#
|
||||
: <<=cut
|
||||
=head1 NAME
|
||||
|
||||
Wordpress-Munin plugin
|
||||
|
||||
A simple Munin plugin to monitor some data from a running wordpress instance
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The plugin need access to the database of the wordpress instance.
|
||||
|
||||
|
||||
=head2 Config file
|
||||
|
||||
Add file plugin-conf.d/wordpress and fill like this
|
||||
|
||||
|
||||
=over 4
|
||||
|
||||
=item * [wordpress]
|
||||
# Name of section. Must be wordpress.
|
||||
|
||||
=item * env.DB_NAME your_db_name
|
||||
# Replace your_db_name
|
||||
|
||||
=item * env.DB_USER your_db_username
|
||||
# Replace you_db_username
|
||||
|
||||
=item * env.DB_PASSWORD your_db_pass
|
||||
# Replace your_db_pass
|
||||
|
||||
=item * env.DB_HOST host_of_your_db
|
||||
# Replace with host of database server. Will be localhost for many users.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
0.2 15 Feb 2011
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Andre Darafarin, happypork.com
|
||||
=cut
|
||||
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Wordpress average'
|
||||
echo 'graph_order posts comments pingbacks users'
|
||||
echo 'graph_category cms'
|
||||
echo 'graph_vlabel Wordpress'
|
||||
echo 'graph_info Some Statistics of Wordpress'
|
||||
echo 'posts.label Posts'
|
||||
echo 'posts.draw LINE3'
|
||||
echo 'comments.label Comments'
|
||||
echo 'pingbacks.label Pingbacks'
|
||||
echo 'users.label Users'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
USERS=0
|
||||
POSTS=0
|
||||
COMMENTS=0
|
||||
PINGBACKS=0
|
||||
POSTS_=0
|
||||
COMMENTS_=0
|
||||
PINGBACKS_=0
|
||||
|
||||
|
||||
# DBNAME=${logfile:-/var/log/syslog}
|
||||
|
||||
BLOGS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="select blog_id from wp_blogs
|
||||
"`
|
||||
for i in $BLOGS
|
||||
do
|
||||
|
||||
|
||||
POSTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_${i}_posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"`
|
||||
let POSTS_=POSTS_+POSTS
|
||||
|
||||
COMMENTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_${i}_comments WHERE comment_approved = '1' AND comment_type = '';"`
|
||||
let COMMENTS_=COMMENTS_+COMMENTS
|
||||
|
||||
PINGBACKS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_${i}_comments WHERE comment_approved = '1' AND comment_type = 'pingback';"`
|
||||
let PINGBACKS_=PINGBACKS_+PINGBACKS
|
||||
|
||||
done
|
||||
USERS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_users ;"`
|
||||
|
||||
|
||||
#AUSGABE BEREICH
|
||||
echo "posts.value $POSTS_"
|
||||
echo "comments.value $COMMENTS_"
|
||||
echo "pingbacks.value $PINGBACKS_"
|
||||
echo "users.value $USERS"
|
122
plugins/wordpress/wordpress-multisite
Executable file
122
plugins/wordpress/wordpress-multisite
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/bin/sh
|
||||
# wordpress-multisite plugin
|
||||
: <<=cut
|
||||
=head1 NAME
|
||||
|
||||
Wordpress-Multisite Munin Plugin
|
||||
|
||||
A Munin plugin to monitor posts, comments and pingbacks from every multisite instance.
|
||||
It uses multigraphs and also shows the combined number of posts, comments, pingbacks, instances and users.
|
||||
|
||||
Most database queries came from the wordpress-mu-plugin which was written by Andre Darafarin and Chris Bair
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
The plugin need access to the wordpress database
|
||||
|
||||
=head2 Config file
|
||||
|
||||
Create the config file plugin-conf.d/wordpress with the following values:
|
||||
|
||||
[wordpress*]
|
||||
env.mysqlopts # I.e. -uroot -prootpass
|
||||
env.mysqlconnection # Defaults to -hlocalhost
|
||||
env.database # I.e. wordpress
|
||||
env.dbprefix # Defaults to wp_
|
||||
env.networksize # Blogs are ordered by id in multigraph view. This value should contain the numbers
|
||||
# of digits that are needed to fit all the blog id's in. This value influences the
|
||||
# designation of data to munin and it will start collecting fresh data if you change
|
||||
# this number. Defaults to 2, (so networks with <= 99 blogs will be sorted correctly)
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 0.4 (2017-01-13)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Jonas Palm <jonaspalm . posteo . de>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv3 or higher
|
||||
=cut
|
||||
|
||||
# fill vars
|
||||
DB_OPTIONS=${mysqlopts}
|
||||
DB_CONNECTION=${mysqlconnection:--hlocalhost}
|
||||
DB_NAME=${database}
|
||||
DB_PREFIX=${dbprefix:-wp_}
|
||||
NETWORK_SIZE=${networksize:-2}
|
||||
|
||||
MYSQL_CMD=$(which mysql)
|
||||
|
||||
# wp_get dataname [blogid]
|
||||
wp_get() {
|
||||
local DB_QUERY=
|
||||
local BLOGID=
|
||||
if [ -n "$2" ] && [ "$2" -gt "1" ]; then
|
||||
# DB prefix for every wordpress instance in the network
|
||||
# Nr 1 is the main network blog and doesn't has a prefix
|
||||
BLOGID=${2}_
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
comments) DB_QUERY="SELECT COUNT(*) FROM ${DB_PREFIX}${BLOGID}comments WHERE comment_approved = '1' AND comment_type = '';" ;;
|
||||
ids) DB_QUERY="SELECT blog_id FROM ${DB_PREFIX}blogs;" ;;
|
||||
pingbacks) DB_QUERY="SELECT COUNT(*) FROM ${DB_PREFIX}${BLOGID}comments WHERE comment_approved = '1' AND comment_type = 'pingback';" ;;
|
||||
posts) DB_QUERY="SELECT COUNT(*) FROM ${DB_PREFIX}${BLOGID}posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';" ;;
|
||||
title) DB_QUERY="SELECT option_value FROM ${DB_PREFIX}${BLOGID}options WHERE option_name = 'siteurl';" ;;
|
||||
users) DB_QUERY="SELECT COUNT(*) FROM ${DB_PREFIX}users;"
|
||||
esac
|
||||
|
||||
"$MYSQL_CMD" $DB_CONNECTION $DB_OPTIONS "$DB_NAME" --column-names=0 -s --execute="$DB_QUERY"
|
||||
}
|
||||
|
||||
# whole network
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "multigraph wordpress"
|
||||
echo "graph_title Wordpress Mulitsite"
|
||||
echo "graph_order instances users posts comments pingbacks"
|
||||
echo "graph_vlabel Wordpress"
|
||||
echo "graph_category cms"
|
||||
echo "graph_info Some Statistics of Wordpress"
|
||||
echo "instances.label Instances"
|
||||
echo "users.label Users"
|
||||
echo "posts.label Posts"
|
||||
echo "comments.label Comments"
|
||||
echo "pingbacks.label Pingbacks"
|
||||
else
|
||||
for n in $(wp_get ids); do
|
||||
POSTS=$((POSTS + $(wp_get posts "$n")))
|
||||
COMMENTS=$((COMMENTS + $(wp_get comments "$n")))
|
||||
PINGBACKS=$((PINGBACKS + $(wp_get pingbacks "$n")))
|
||||
CNT=$((CNT + 1))
|
||||
done
|
||||
|
||||
echo "multigraph wordpress"
|
||||
echo "posts.value $POSTS"
|
||||
echo "comments.value $COMMENTS"
|
||||
echo "pingbacks.value $PINGBACKS"
|
||||
echo "instances.value $CNT"
|
||||
echo "users.value $(wp_get users)"
|
||||
fi
|
||||
|
||||
# single blogs
|
||||
for n in $(wp_get ids); do
|
||||
blogid_sortable="$(printf "%0${NETWORK_SIZE}d" "$n")"
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "multigraph wordpress.site_${blogid_sortable}"
|
||||
echo "graph_title $(wp_get title "$n")"
|
||||
echo "graph_order posts comments pingbacks"
|
||||
echo "graph_vlabel Wordpress ID ${blogid_sortable}"
|
||||
echo "posts.label Posts"
|
||||
echo "comments.label Comments"
|
||||
echo "pingbacks.label Pingbacks"
|
||||
else
|
||||
echo "multigraph wordpress.site_${blogid_sortable}"
|
||||
echo "posts.value $(wp_get posts "$n")"
|
||||
echo "comments.value $(wp_get comments "$n")"
|
||||
echo "pingbacks.value $(wp_get pingbacks "$n")"
|
||||
fi
|
||||
done
|
126
plugins/wordpress/wordpress2
Normal file
126
plugins/wordpress/wordpress2
Normal file
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
||||
/*
|
||||
** REQUIRES PHP5-CLI **
|
||||
---- DESCRIPTION ----
|
||||
wordpress plugin for munin
|
||||
it's a simple plugin to monitor users, comments, pingbacks
|
||||
and your posts from your wordpress homepage.
|
||||
|
||||
Simply put your path of wp-config.php in your munin-node
|
||||
configuration and this plugin does the rest for you.
|
||||
Happy monitoring! :)
|
||||
|
||||
This plugin was inspired by the existing wordpress plugin in bash/sh:
|
||||
https://github.com/munin-monitoring/contrib/blob/master/plugins/other/wordpress
|
||||
|
||||
|
||||
---- CONFIGURATION ----
|
||||
You just need to provide the path to your
|
||||
wp-config.php of your wordpress installation.
|
||||
|
||||
The configuration for munin-node is by default
|
||||
at: /etc/munin/plugin-conf.d/munin-node
|
||||
|
||||
Example configuration:
|
||||
[wordpress]
|
||||
env.NAME Blog of Chuck Norris
|
||||
env.CONF /var/www/wordpress/wp-config.php
|
||||
|
||||
or you can use:
|
||||
|
||||
[wordpress]
|
||||
env.NAME Blog of Chuck Norris
|
||||
env.HOST 127.0.0.1
|
||||
env.USER blog
|
||||
env.PASS password
|
||||
env.DBNM wordpress
|
||||
env.TBPF wp_
|
||||
|
||||
|
||||
---- More details ----
|
||||
@Author...: Patrik Kernstock
|
||||
@Version..: v1.1
|
||||
@Date.....: 26 November 2012
|
||||
@Web......: http://pkern.at
|
||||
@Support..: support@pkern.at
|
||||
@GitHub...: https://github.com/patschi/munin-plugins
|
||||
@License..: http://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||
|
||||
*/
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
// Get configuration variables
|
||||
$d["name"] = getenv("NAME");
|
||||
$d["conf"] = getenv("CONF");
|
||||
$d["host"] = getenv("HOST");
|
||||
$d["user"] = getenv("USER");
|
||||
$d["pass"] = getenv("PASS");
|
||||
$d["tbpf"] = getenv("TBPF");
|
||||
$d["dbnm"] = getenv("DBNM");
|
||||
|
||||
if(!empty($d["conf"]) && !empty($d["name"])) {
|
||||
// INCLUDE wp-config.php
|
||||
define("ABSPATH", str_replace("wp-config.php", "", $d["conf"]));
|
||||
require_once($d["conf"]);
|
||||
$d["host"] = DB_HOST;
|
||||
$d["user"] = DB_USER;
|
||||
$d["pass"] = DB_PASSWORD;
|
||||
$d["dbnm"] = DB_NAME;
|
||||
$d["tbpf"] = $table_prefix;
|
||||
}
|
||||
|
||||
if($argv[1] == "config") {
|
||||
echo 'graph_title wordpress statistic of '.$d["name"]."\n";
|
||||
echo 'graph_order users posts comments pingbacks'."\n";
|
||||
echo 'graph_vlabel Wordpress'."\n";
|
||||
echo 'graph_info some wordpress statistics of '.$d["name"]."\n";
|
||||
echo 'graph_category cms'."\n";
|
||||
echo 'users.label Users'."\n";
|
||||
echo 'posts.label Posts'."\n";
|
||||
echo 'posts.draw LINE3'."\n";
|
||||
echo 'comments.label Comments'."\n";
|
||||
echo 'pingbacks.label Pingbacks'."\n";
|
||||
exit(0);
|
||||
|
||||
}else if($argv[1] == "autoconf") {
|
||||
if(file_exists($d["conf"])) {
|
||||
echo "yes";
|
||||
exit(0);
|
||||
}else{
|
||||
echo "no (config does not exist)";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($d["conf"])) {
|
||||
if(!file_exists($d["conf"])) {
|
||||
echo "Error: config does not exist!";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// INIT VARIABLES
|
||||
$users = 0;
|
||||
$posts = 0;
|
||||
$comments = 0;
|
||||
$pingbacks = 0;
|
||||
|
||||
// GET DATA
|
||||
mysql_connect($d["host"], $d["user"], $d["pass"]) or die("Error: Failed to connect to the MySQL database!");
|
||||
mysql_select_db($d["dbnm"]) or die("Error: Failed to select database!");
|
||||
|
||||
$users = mysql_result(mysql_query("SELECT COUNT(*) FROM ".$d["tbpf"]."users;"), 0);
|
||||
$posts = mysql_result(mysql_query("SELECT COUNT(*) FROM ".$d["tbpf"]."posts WHERE post_status='publish' AND post_password='' AND post_type='post';"), 0);
|
||||
$comments = mysql_result(mysql_query("SELECT COUNT(*) FROM ".$d["tbpf"]."comments WHERE comment_approved='1' AND comment_type='';"), 0);
|
||||
$pingbacks = mysql_result(mysql_query("SELECT COUNT(*) FROM ".$d["tbpf"]."comments WHERE comment_approved='1' AND comment_type='pingback';"), 0);
|
||||
|
||||
// OUTPUT DATA
|
||||
echo "users.value ".$users ."\n";
|
||||
echo "posts.value ".$posts ."\n";
|
||||
echo "comments.value ".$comments ."\n";
|
||||
echo "pingbacks.value ".$pingbacks."\n";
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue