Commit 404d574c authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

zabbix-agent: add memcached monitoring

parent 9a4bed23
......@@ -32,6 +32,7 @@ zabbix_agent_templates:
- Template App SSH Service
- Template App Zabbix Server
- Template App PostgreSQL
- Template App Memcached
- Linux servers
......@@ -57,3 +57,6 @@
- uptime - time memcached is alive
- listen_disabled_num - the number of times: the max number of connections is reachedand:ii
- conn_yields - Number of times a client connection was throttled.
- hits - get_hits / cmd_get. It indicates how efficient your Memcached server is.
- fill - used bytes / limit_maxbytes - Fill percentage
- evictions - an eviction is when an item that still has time to live is removed from the cache because a brand new item needs to be allocated
- command flush - the flush_all command invalidates all items in the database
- connections_total - total number of connections
import argparse
import json
import os
from memcache import Client
SOCKET_DIR = '/run/memcached'
def stats(socket):
client = Client([f'unix://{SOCKET_DIR}/{socket}'])
stats = client.get_stats()
if not stats:
def discover():
sockets = []
for loc in os.listdir(SOCKET_DIR):
if not loc.endswith('.sock'):
sockets.append({"{#SOCKET}": loc})
print(json.dumps({"data": sockets}))
def main():
parser = argparse.ArgumentParser(description='memcached statistics dumptool (in json)')
parser.add_argument('--discover', action='store_true', help='discover memcached sockets')
parser.add_argument('--socket', type=str, help='the memcached socket location')
args = parser.parse_args()
if args.socket:
if __name__ == "__main__":
......@@ -25,6 +25,17 @@
pacman: name=perl-dbi,perl-dbd-pg,perl-json
when: "'postgresql-servers' in group_names"
- name: install memcached monitoring packages
pacman: name=python-memcached
when: "'memcached' in group_names"
- name: adding existing zabbix-agent to memcached group
name: zabbix-agent
groups: memcached
append: yes
when: "'memcached' in group_names"
- file: path=/etc/zabbix state=directory owner=root group=root mode=755
- name: create host PSK
......@@ -83,6 +94,7 @@
- name: Install helper scripts
copy: dest=/usr/local/bin/ mode=0755 owner=root group=root
zabbix-agent ALL=(root) NOPASSWD: /usr/local/bin/borg list --json --format {start}{end} --sort-by timestamp --last 1, /usr/local/bin/
zabbix-agent ALL=(root) NOPASSWD: /usr/local/bin/borg list --json --format {start}{end} --sort-by timestamp --last 1, /usr/local/bin/, /usr/local/bin/
zabbix-agent ALL=(postgres) NOPASSWD: /usr/local/bin/, /usr/local/bin/
......@@ -63,3 +63,7 @@ UserParameter=linux.pressure,perl -MJSON -E 'my %h; for my $filename (@ARGV) {op,arch-audit -u | grep -v "from testing repos"
UserParameter=arch_archive.db_count,echo 'select count(*) from files;' | sqlite3 /home/archive/archive-uploader.sqlite
UserParameter=memcached.stats[*],sudo /usr/local/bin/ --socket '$1'
UserParameter=memcached.stats_discover,/usr/local/bin/ --discover
#UserParameter=postgresql.dbsize_discover,sudo -u postgres /usr/local/bin/ discover
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment