Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
infrastructure
Commits
404d574c
Commit
404d574c
authored
Sep 24, 2019
by
Jelle van der Waa
🚧
Browse files
zabbix-agent: add memcached monitoring
parent
9a4bed23
Changes
6
Hide whitespace changes
Inline
Side-by-side
host_vars/apollo.archlinux.org
View file @
404d574c
...
...
@@ -32,6 +32,7 @@ zabbix_agent_templates:
- Template App SSH Service
- Template App Zabbix Server
- Template App PostgreSQL
- Template App Memcached
zabbix_agent_host_groups:
- Linux servers
...
...
hosts
View file @
404d574c
...
...
@@ -57,3 +57,6 @@ runner2.archlinux.org
[reproduciblebuilds]
repro1.pkgbuild.com
repro2.pkgbuild.com
[memcached]
apollo.archlinux.org
roles/zabbix-agent/files/memcached-stats.py
0 → 100644
View file @
404d574c
#!/usr/bin/python
'''
Metrics:
- 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
:
print
(
json
.
dumps
({}))
else
:
print
(
json
.
dumps
(
stats
[
0
][
1
]))
def
discover
():
sockets
=
[]
for
loc
in
os
.
listdir
(
SOCKET_DIR
):
if
not
loc
.
endswith
(
'.sock'
):
continue
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
.
discover
:
discover
()
if
args
.
socket
:
stats
(
args
.
socket
)
if
__name__
==
"__main__"
:
main
()
roles/zabbix-agent/tasks/main.yml
View file @
404d574c
...
...
@@ -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
user
:
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 @@
-
mysql-dbsize-stats.pl
-
postgresql-dbsize-stats.pl
-
postgresql-user-stats.pl
-
memcached-stats.py
-
name
:
Install helper scripts
copy
:
src=nginx-zabbix.pl dest=/usr/local/bin/nginx-zabbix.pl mode=0755 owner=root group=root
...
...
roles/zabbix-agent/templates/zabbix-agent-sudoers.conf.j2
View file @
404d574c
zabbix-agent ALL=(root) NOPASSWD: /usr/local/bin/borg list --json --format {start}{end} --sort-by timestamp --last 1, /usr/local/bin/mysql-dbsize-stats.pl
zabbix-agent ALL=(root) NOPASSWD: /usr/local/bin/borg list --json --format {start}{end} --sort-by timestamp --last 1, /usr/local/bin/mysql-dbsize-stats.pl
, /usr/local/bin/memcached-stats.py
zabbix-agent ALL=(postgres) NOPASSWD: /usr/local/bin/postgresql-dbsize-stats.pl, /usr/local/bin/postgresql-user-stats.pl
roles/zabbix-agent/templates/zabbix_agentd.conf
View file @
404d574c
...
...
@@ -63,3 +63,7 @@ UserParameter=linux.pressure,perl -MJSON -E 'my %h; for my $filename (@ARGV) {op
UserParameter
=
arch_audit
.
data
,
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
/
memcached
-
stats
.
py
--
socket
'$1'
UserParameter
=
memcached
.
stats_discover
,/
usr
/
local
/
bin
/
memcached
-
stats
.
py
--
discover
#UserParameter=postgresql.dbsize_discover,sudo -u postgres /usr/local/bin/postgresql-dbsize-stats.pl discover
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment