1
+ # django-munin
2
+
1
3
This is a Django application to make it a bit simpler to use
2
- Munin (http://munin-monitoring.org/ ) to monitor various metrics
4
+ [ Munin] ( http://munin-monitoring.org/ ) to monitor various metrics
3
5
for your Django app.
4
6
5
7
First, it includes a munin plugin that you can symlink into
6
- /etc/munin/plugins/ and point at your django application and it will
8
+ ` /etc/munin/plugins/ ` and point at your django application and it will
7
9
gather data for munin to graph. Second, it contains a couple views
8
10
that return some very basic information about the state of your app:
9
11
database performance, number of users, number of sessions, etc. Third,
10
12
it provides a decorator to make it simple to expose your own custom
11
13
metrics to Munin.
12
14
13
- Install django-munin into your python path with the usual pip install
14
- or whatever you are doing. Then add 'munin' to your INSTALLED_APPS and
15
- run 'manage.py syncdb' (it just needs to set up one database table
15
+ ## Installing
16
+
17
+ Install ` django-munin ` into your python path with the usual ` pip install `
18
+ or whatever you are doing. Then add ` munin ` to your ` INSTALLED_APPS ` and
19
+ run ` manage.py syncdb ` (it just needs to set up one database table
16
20
that it will use for performance testing).
17
21
18
22
To access the included basic views, add the following pattern to your
19
- urls.py:
23
+ ` urls.py ` :
20
24
21
- ('^munin/',include('munin.urls')),
25
+ ('^munin/',include('munin.urls')),
22
26
23
27
The views available there are then going to be at:
24
28
25
- * munin/db_performance/ (milliseconds to perform insert/select/delete operations)
26
- * munin/total_users/ (total number of Users)
27
- * munin/active_users/ (number of users logged in in the last hour)
28
- * munin/total_sessions/ (total number of sessions)
29
- * munin/active_sessions/ (number of sessions that are not expired)
29
+ * ` munin/db_performance/ ` (milliseconds to perform insert/select/delete operations)
30
+ * ` munin/total_users/ ` (total number of Users)
31
+ * ` munin/active_users/ ` (number of users logged in in the last hour)
32
+ * ` munin/total_sessions/ ` (total number of sessions)
33
+ * ` munin/active_sessions/ ` (number of sessions that are not expired)
30
34
31
35
Those were the only metrics I could think of that would be potentially
32
36
useful on just about any Django app and were likely to always be
@@ -35,11 +39,11 @@ available.
35
39
(I'm going to assume that you are already a pro at configuring
36
40
Munin. If not, go get on that. Munin is very cool)
37
41
38
- Next, copy scripts/django.py into your /usr/share/munin/plugins/
42
+ Next, copy ` scripts/django.py ` into your ` /usr/share/munin/plugins/ `
39
43
directory.
40
44
41
45
For each metric that you want Munin to monitor, make a symlink in
42
- /etc/munin/plugins/ to /usr/share/munin/plugins/django.py with an
46
+ ` /etc/munin/plugins/ ` to ` /usr/share/munin/plugins/django.py ` with an
43
47
appropriate name. Eg, to monitor all five of the included ones (as
44
48
root, probably):
45
49
@@ -50,9 +54,9 @@ root, probably):
50
54
$ ln -s /usr/share/munin/plugins/django.py /etc/munin/plugins/myapp_active_sessions
51
55
52
56
You then need to configure each of them in
53
- /etc/munin/plugin-conf.d/munin-node
57
+ ` /etc/munin/plugin-conf.d/munin-node `
54
58
55
- For each, give it a stanza with env.url and graph_category set. To
59
+ For each, give it a stanza with ` env.url ` and ` graph_category ` set. To
56
60
continue the above, you'd add something like:
57
61
58
62
[myapp_db_performance]
@@ -78,21 +82,23 @@ continue the above, you'd add something like:
78
82
Restart your Munin node, and it should start collecting and graphing
79
83
that data.
80
84
85
+ ## Custom munin views
86
+
81
87
Those are pretty generic metrics though and the real power of this
82
88
application is that you can easily expose your own custom
83
89
metrics. Basically, anything that you can calculate in the context of
84
90
a Django view in your application, you can easily expose to Munin.
85
91
86
- django-munin includes a ' muninview' decorator that lets you write a
87
- regular django view that returns a list of (key,value) tuples and it
88
- will expose those to that django.py munin plugin for easy graphing.
92
+ ` django-munin ` includes a ` @ muninview` decorator that lets you write a
93
+ regular django view that returns a list of ` (key,value) ` tuples and it
94
+ will expose those to that ` django.py ` munin plugin for easy graphing.
89
95
90
- The @muninview decorator takes a config parameter, which is just a
96
+ The ` @muninview ` decorator takes a ` config ` parameter, which is just a
91
97
string of munin config directives. You'll want to put stuff like
92
- graph_title, graph_vlabel, and graph_info there. Possibly
93
- graph_category too (if you include it there, remove it from the munin
98
+ ` graph_title ` , ` graph_vlabel ` , and ` graph_info ` there. Possibly
99
+ ` graph_category ` too (if you include it there, remove it from the munin
94
100
plugin conf stanza). The view function that it wraps then just needs
95
101
to return a list of tuples.
96
102
97
103
The simplest way to get a feel for how this works is to look at how
98
- the included views were written. So check out munin/views.py.
104
+ the included views were written. So check out [ munin/views.py] ( https://github.com/ccnmtl/django-munin/blob/master/munin/views.py ) .
0 commit comments