Subversion Repositories ezmunin

[/] [trunk/] [ezpublish_content] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 qwix
#!/bin/sh
2
#
3
# Plugin to monitor useful contents informations for an eZ Publish instance
4
#
5
# Usage: Link or copy into /etc/munin/<plugin-directory>/
6
# After that you can configure the plugin by editing
7
# your munin configuration file located here (on Debian)
8
#
9
# /etc/munin/plugin-conf.d/munin-node
10
#
11
# and add the following lines :
12 6 qwix
#
13
# [ezpublish_*]
14 3 qwix
# env.dbusername <dbusername>
15
# env.dbpassword <dbpassword>
16 6 qwix
# env.dbname <ezpublishdbname>#
17 3 qwix
#
18
# and restart munin-node after that :
19
#
20
# sudo /etc/init.d/munin-node restart
21
#
22
#
23
 
24
MYSQL_BIN="$(which mysql)"
25
MYSQL_USER=$dbusername
26
MYSQL_PASSWORD=$dbpassword
27
EZPUBLISH_DATABASENAME=$dbname
28 8 qwix
EZPUBLISH_INSTANCE="$(basename "$0")"
29 3 qwix
 
30
MYSQL="${MYSQL_BIN} -u "${MYSQL_USER}" -p"${MYSQL_PASSWORD}" "${EZPUBLISH_DATABASENAME}""
31
 
32
# {{{ variable declaration
33
 
34
monitor_list[0]='ezco'   # eZContentObjects
35
monitor_list[1]='ezcoa'  # eZContentObjectAttributes
36
monitor_list[2]='ezcotn' # eZContentObjectTreeNode
37
monitor_list[3]='ezcor'  # eZContentObjectRelations
38 9 qwix
monitor_list[4]='ezcod'  # eZContentObjectDrafts
39 3 qwix
 
40
label_list[0]='Content objects'
41
label_list[1]='Content object attributes'
42
label_list[2]='Content nodes'
43
label_list[3]='Content object relations'
44 9 qwix
label_list[4]='Content object drafts'
45 3 qwix
 
46
info_list[0]='eZ Publish content objects'
47
info_list[1]='eZ Publish contentobject attributes'
48
info_list[2]='eZ Publish contentobject tree node'
49
info_list[3]='eZ Publish content object relations'
50 9 qwix
info_list[4]='eZ Publish content object drafts'
51 3 qwix
 
52
query_list[0]='SELECT COUNT(id)      FROM ezcontentobject'
53
query_list[1]='SELECT COUNT(id)      FROM ezcontentobject_attribute'
54
query_list[2]='SELECT COUNT(node_id) FROM ezcontentobject_tree'
55
query_list[3]='SELECT COUNT(id)      FROM ezcontentobject_link'
56 9 qwix
query_list[4]='SELECT COUNT(id)      FROM ezcontentobject WHERE STATUS=0'
57 3 qwix
 
58
# }}}
59
 
60 6 qwix
# {{{ autoconf
61 3 qwix
# testing if everything is OK
62
# in the configuration of this plugin
63
if [ "$1" = "autoconf" ]; then
64 6 qwix
    echo "yes"
65
    exit 0
66 3 qwix
fi
67 6 qwix
# }}}
68 3 qwix
 
69 6 qwix
# {{{ config
70 3 qwix
# If run with the "config"-parameter, give out information on how the
71
# graphs should look.
72
if [ "$1" = "config" ]; then
73
 
74 8 qwix
    echo "graph_title ${EZPUBLISH_INSTANCE} : content statistics"
75 3 qwix
 
76 6 qwix
    echo 'graph_args --base 1000'
77
    echo 'graph_vlabel Values'
78
    echo 'graph_scale no'
79 3 qwix
 
80 6 qwix
    echo 'graph_category eZ Publish'
81 3 qwix
 
82 6 qwix
    for ((i=0; i < ${#monitor_list[*]}; i++))
83
    do
84
        echo "${monitor_list[$i]}.label ${label_list[$i]}"
85
        echo "${monitor_list[$i]}.info ${info_list[$i]}"
86
    done
87 3 qwix
 
88 6 qwix
    echo 'graph_info Content statistics for an eZ Publish instance'
89 3 qwix
 
90 6 qwix
    exit 0
91 3 qwix
fi
92 6 qwix
# }}}
93 3 qwix
 
94 6 qwix
# {{{ real work
95 3 qwix
for ((i=0; i< ${#query_list[*]}; i++))
96
do
97 6 qwix
    sql_result="$(${MYSQL} -e "${query_list[$i]}")"
98
    echo -n "${monitor_list[$i]}.value "
99
    echo ${sql_result} | cut -d' ' -f 2
100 3 qwix
done
101 6 qwix
# }}}
102 3 qwix
 
103 6 qwix
# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: