-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathescenic_utilization_
executable file
·155 lines (116 loc) · 3.9 KB
/
escenic_utilization_
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
: <<=cut
=head1 NAME
escenic_utilization - Munin plugin to show the utilization factor of an
Escenic Content Engine instance
=head1 APPLICABLE SYSTEMS
escenic_utilization works with all installations of Escenic Content Engine
5.1 and onwards. It uses the pidfiles located in /var/run/escenic/ to
locate different instances of Content Engine and graphs their utilization
individually.
=head1 CONFIGURATION
escenic_utilization needs to know which instance it will run on. Since 5.1,
ECE out of the box allows easy configuration of several instances. These
end up putting their pidfiles in /var/run/escenic/ece-xxx.pid. If you
do not specify pidfiles, the instance name 'default' is used.
The plugin needs to access the escenic-admin webapp in order to retrieve
the utilization, and in order to get that it uses HTTP. Please specify the
port number on which the escenic-admin webapp is mounted, for each instance
on the machine. If, for example, your instance name is 'default' then add
the following configration:
[escenic_utilization_default]
env.port=8080
=head1 INTERPRETATION
The graph shows the number of concurrent accesses to the HTTP stack at
any one time, as made available by the "top" resource in Escenic Content
Engine.
A value of 0 means that the instance is idle.
A value of 4 means that the instance was processing four concurrent HTTP
requests at the same time.
=head1 MAGIC MARKERS
#%# family=manual contrib
#%# capabilities=autoconf suggest
=head1 CONFIGURATION
There are a few options that can be specified to control how a particular
instance of this works, particularly you need to indicate the port number
where the escenic-admin web app is located.
port - port number where escenic-admin is available,
no default. Try 8080 :-).
ece_instance - name of instance. Defaults to output of 'suggest'
The instance names is used to name the graphs.
graphtitle - if unspecified, the graph title is prepended with the
name of the instance.
=cut
common()
{
graph_update=yes
tmp_ece_instance=$(echo $(basename $0) | sed s,escenic_utilization_,,)
ece_instance=${ece_instance:-${tmp_ece_instance}}
if [ -z "${port}" ]; then
. /etc/escenic/ece.conf
. /etc/escenic/ece-$ece_instance.conf
if [ -z "$appserver_port" ] ; then
graph_info="${graph_info} In order to use this plug-in you need to configure 'env.port' in the [escenic_utilization_${ece_instance}] somewhere in /etc/munin/plugin-conf.d/"
graph_update=no
else
port=$appserver_port
fi
fi
if [ -z "${graphtitle}" ]; then
graphtitle="${ece_instance}"
fi
}
config()
{
echo "graph_title $graphtitle utilization "
echo "graph_args --base 1000 -l 0"
echo "graph_vlabel threads"
echo "graph_info The number of active HTTP threads on the $graphtitle instance, which equates to \"how busy\" the instance is. ${graph_info}"
echo "graph_category Escenic"
echo "update ${graph_update}"
cat <<EOM
utilization.draw LINE1
utilization.label Active threads
utilization.info The number of threads actively rendering a web page as counted by top. 1.0 means one thread was active.
utilization.warning 30
utilization.critical 35
EOM
}
#
# autoconf
#
if [ "$1" = "autoconf" ]; then
if [ ! -r "/etc/default/ece" ] ; then
echo "no (No /etc/default/ece)"
exit 0
fi
. /etc/default/ece
if [ -z "$engine_instance_list" ] ; then
echo "no (No engine instances configured in /etc/default/ece)"
exit 0
fi
echo "yes"
exit 0
fi
#
# suggest
#
if [ "$1" = "suggest" ]; then
if [ -r /etc/default/ece ] ; then
. /etc/default/ece
echo $engine_instance_list
fi
exit 0
fi
common
#
# config
#
if [ "$1" = "config" ]; then
config
exit 0
fi
#
# fetch
#
wget --timeout=1 -O - -o /dev/null http://localhost:${port}/escenic-admin/top | awk 'BEGIN{a=0} /[1-9]/ { a=a+$1} END { print "utilization.value " a/100 }'