Skip to content

Instantly share code, notes, and snippets.



Last active May 21, 2016
What would you like to do?
A munin plugin for to monitor online presence in Slack
#!/usr/bin/env python
slack_user_munin - A munin plugin for to monitor online presence in Slack
Copyright (C) 2015 Christian Stade-Schuldt
Author: Christian Stade-Schuldt
Like Munin, this plugin is licensed under the GNU GPL v2 license
Add the following section to your munin-node's plugin configuration:
env.slack_token [slack_token]
This plugin supports the following munin configuration parameters:
#%# family=auto contrib
#%# capabilities=autoconf
import os
import sys
import urllib3
from slacker import Slacker
def get_online_presence():
slack = Slacker(os.environ['slack_token'])
response = slack.users.list(presence=True)
all_members = response.body['members']
status = {}
for member in all_members:
if not member.get('deleted') and not member.get('is_bot'):
presence = member.get('presence')
if presence not in status:
status[presence] = 0
status[presence] += 1
print 'online.value %s' % (status['active'])
def print_config():
print "graph_title Online Slack Users"
print "graph_vlabel number of users"
print "graph_category slack"
print "graph_info This graph shows the online Slack users."
print "graph_scale no"
print "online.label online"
print "online.type GAUGE"
print "online.draw AREA"
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'config':
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
print 'yes'
elif len(sys.argv) == 1 or len(sys.argv) == 2 and sys.argv[1] == 'fetch':
# Some docs say it'll be called with fetch, some say no arg at all
sys.exit("Couldn't retrieve slack online presence")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment