zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

WordPress Munin Plugin

June 13, 2011 by Igor Drobot 2 Comments

The original Plugin was written by Chris Bair, after some tunings it worked fine for me.

I made some useful modifications to this Plugin:
– Visualization of the number of Drafts
– Set table prefix (I hate hardcodet things)



And now how to use it, first you need to create a configuration file for the plugin(replace the needed credentials)

1
vim /etc/munin/plugin-conf.d/wordpress_stats

vim /etc/munin/plugin-conf.d/wordpress_stats

1
2
3
4
5
6
[wordpress*]
env.DB_HOST localhost
env.DB_NAME database01
env.DB_USER user01
env.DB_PASSWORD XYZ!123
env.DB_PREFIX wp_

[wordpress*] env.DB_HOST localhost env.DB_NAME database01 env.DB_USER user01 env.DB_PASSWORD XYZ!123 env.DB_PREFIX wp_

And the plugin:

1
vim /etc/munin/plugins/wordpress_stats

vim /etc/munin/plugins/wordpress_stats

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
 
if [ "$1" = "config" ]; then
    echo 'graph_title Wordpress average'
    echo 'graph_category Wordpress'
    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 'drafts.label Drafts'
    echo 'comments.label Comments'
    echo 'pingbacks.label Pingbacks'
    echo 'users.label Users'
    exit 0
fi
 
POSTS=0
DRAFTS=0
COMMENTS=0
PINGBACKS=0
USERS=0
 
POSTS=`mysql -h$DB_HOST  -p$DB_PASSWORD -u$DB_USER -D $DB_NAME  --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"`
 
DRAFTS=`mysql -h$DB_HOST  -p$DB_PASSWORD -u$DB_USER -D $DB_NAME  --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}posts WHERE post_status = 'draft' 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 ${DB_PREFIX}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 ${DB_PREFIX}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 ${DB_PREFIX}users ;"`
 
# Output
echo "posts.value $POSTS"
echo "drafts.value $DRAFTS"
echo "comments.value $COMMENTS"
echo "pingbacks.value $PINGBACKS"
echo "users.value $USERS"

#!/bin/sh if [ "$1" = "config" ]; then echo 'graph_title Wordpress average' echo 'graph_category Wordpress' 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 'drafts.label Drafts' echo 'comments.label Comments' echo 'pingbacks.label Pingbacks' echo 'users.label Users' exit 0 fi POSTS=0 DRAFTS=0 COMMENTS=0 PINGBACKS=0 USERS=0 POSTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"` DRAFTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}posts WHERE post_status = 'draft' 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 ${DB_PREFIX}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 ${DB_PREFIX}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 ${DB_PREFIX}users ;"` # Output echo "posts.value $POSTS" echo "drafts.value $DRAFTS" echo "comments.value $COMMENTS" echo "pingbacks.value $PINGBACKS" echo "users.value $USERS"

Click to resize example

Filed Under: Bash, Linux, Monitoring, Networking Tagged With: Monitoring, Munin, munin-node, Wordpress

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Trackbacks

  1. Serverauslastung mit Munin aufzeichnen – Blog says:
    March 20, 2016 at 23:52

    […] WordPress Plugin http://zeldor.biz/2011/06/wordpress-munin-plugin/ […]

  2. GB Bilder » Wordpress Munin Plugin « ID's blog says:
    June 13, 2011 at 16:52

    […] hier den Beitrag weiterlesen: WordPress Munin Plugin « ID's blog […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok