{"id":18388188,"url":"https://github.com/ccnmtl/django-munin","last_synced_at":"2025-08-10T20:10:24.817Z","repository":{"id":1287547,"uuid":"1227352","full_name":"ccnmtl/django-munin","owner":"ccnmtl","description":"django application for simple munin integration","archived":false,"fork":false,"pushed_at":"2023-10-12T16:45:30.000Z","size":15,"stargazers_count":57,"open_issues_count":2,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-22T10:35:24.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccnmtl.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-01-06T19:32:12.000Z","updated_at":"2024-01-05T12:05:12.000Z","dependencies_parsed_at":"2024-11-06T01:54:14.119Z","dependency_job_id":"4e6a77e6-a224-4bed-a63b-ebdc7625d443","html_url":"https://github.com/ccnmtl/django-munin","commit_stats":{"total_commits":19,"total_committers":8,"mean_commits":2.375,"dds":"0.42105263157894735","last_synced_commit":"0b244c159201cfd511738c815a8777d0842d1f91"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fdjango-munin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fdjango-munin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fdjango-munin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fdjango-munin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccnmtl","download_url":"https://codeload.github.com/ccnmtl/django-munin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247583100,"owners_count":20961968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:32:12.872Z","updated_at":"2025-04-07T02:33:10.408Z","avatar_url":"https://github.com/ccnmtl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-munin\n\nThis is a Django application to make it a bit simpler to use \n[Munin](http://munin-monitoring.org/) to monitor various metrics\nfor your Django app. \n\nFirst, it includes a munin plugin that you can symlink into\n`/etc/munin/plugins/` and point at your django application and it will\ngather data for munin to graph. Second, it contains a couple views\nthat return some very basic information about the state of your app:\ndatabase performance, number of users, number of sessions, etc. Third,\nit provides a decorator to make it simple to expose your own custom\nmetrics to Munin. \n\n## Installing\n\nInstall `django-munin` into your python path with the usual `pip install`\nor whatever you are doing. Then add `munin` to your `INSTALLED_APPS` and\nrun `manage.py syncdb` (it just needs to set up one database table\nthat it will use for performance testing). \n\nTo access the included basic views, add the following pattern to your\n`urls.py`: \n\n    ('^munin/',include('munin.urls')),\n\nThe views available there are then going to be at:\n\n* `munin/db_performance/`   (milliseconds to perform insert/select/delete operations)\n* `munin/total_users/`      (total number of Users)\n* `munin/active_users/`     (number of users logged in in the last hour)\n* `munin/total_sessions/`   (total number of sessions)\n* `munin/active_sessions/`  (number of sessions that are not expired)\n\nThose were the only metrics I could think of that would be potentially\nuseful on just about any Django app and were likely to always be\navailable. \n\n(I'm going to assume that you are already a pro at configuring\nMunin. If not, go get on that. Munin is very cool)  \n\nNext, copy `plugins/django.py` into your `/usr/share/munin/plugins/`\ndirectory. \n\nFor each metric that you want Munin to monitor, make a symlink in\n`/etc/munin/plugins/` to `/usr/share/munin/plugins/django.py` with an\nappropriate name. Eg, to monitor all five of the included ones (as\nroot, probably):\n\n    $ ln -s /usr/share/munin/plugins/django.py /etc/munin/plugins/myapp_db_performance\n    $ ln -s /usr/share/munin/plugins/django.py /etc/munin/plugins/myapp_total_users\n    $ ln -s /usr/share/munin/plugins/django.py /etc/munin/plugins/myapp_active_users\n    $ ln -s /usr/share/munin/plugins/django.py /etc/munin/plugins/myapp_total_sessions\n    $ ln -s /usr/share/munin/plugins/django.py /etc/munin/plugins/myapp_active_sessions\n\nYou then need to configure each of them in\n`/etc/munin/plugin-conf.d/munin-node`\n\nFor each, give it a stanza with `env.url` and `graph_category` set. To\ncontinue the above, you'd add something like: \n\n    [myapp_db_performance]\n    env.url http://example.com/munin/db_performance/\n    env.graph_category myapp\n\n    [myapp_total_users]\n    env.url http://example.com/munin/total_users/\n    env.graph_category myapp\n\n    [myapp_active_users]\n    env.url http://example.com/munin/active_users/\n    env.graph_category myapp\n\n    [myapp_total_sessions]\n    env.url http://example.com/munin/total_sessions/\n    env.graph_category myapp\n\n    [myapp_active_sessions]\n    env.url http://example.com/munin/active_sessions/\n    env.graph_category myapp\n\t\nIf your HTTP server require Basic Authentication, you can add login and password\nas parameters:\n\n    [myapp_active_sessions]\n    env.url http://example.com/munin/active_sessions/\n    env.graph_category myapp\n\tenv.login mylogin\n\tenv.password mypassword\n\nRestart your Munin node, and it should start collecting and graphing\nthat data. \n\n## Custom munin views\n\nThose are pretty generic metrics though and the real power of this\napplication is that you can easily expose your own custom\nmetrics. Basically, anything that you can calculate in the context of\na Django view in your application, you can easily expose to Munin. \n\n`django-munin` includes a `@muninview` decorator that lets you write a\nregular django view that returns a list of `(key,value)` tuples and it\nwill expose those to that `django.py` munin plugin for easy graphing. \n\nThe `@muninview` decorator takes a `config` parameter, which is just a\nstring of munin config directives. You'll want to put stuff like\n`graph_title`, `graph_vlabel`, and `graph_info` there. Possibly\n`graph_category` too (if you include it there, remove it from the munin\nplugin conf stanza). The view function that it wraps then just needs\nto return a list of tuples.\n\nThe simplest way to get a feel for how this works is to look at how\nthe included views were written. So check out [munin/views.py](https://github.com/ccnmtl/django-munin/blob/master/munin/views.py).  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnmtl%2Fdjango-munin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccnmtl%2Fdjango-munin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnmtl%2Fdjango-munin/lists"}