zabbix/templates/etc/zabbix/zabbix_agent.d/userparameter_container.con...

90 lines
2.9 KiB
Django/Jinja

#!/bin/bash
#This is custom user parameters for LXC containers.
{% for item in zabbix_agent_params %}
{% if item.name == 'container' %}
# Container default parameters
UserParameter=ct.ramtotal,free -b |grep Mem | awk '{print $2}'
UserParameter=ct.ramused,free -b |grep Mem | awk '{print $3}'
UserParameter=ct.ramfree,free -b |grep Mem |awk '{print $7}'
UserParameter=ct.ramfree_proc,free | grep Mem | awk '{print $7/$2 * 100.0}' | awk '{printf "%.0f\n", $1}'
UserParameter=ct.ramcache,free -b | grep Mem | awk '{print $7}'
UserParameter=ct.swaptotal,free -b |grep Swap |awk '{print $2}'
UserParameter=ct.swapused,free -b |grep Swap |awk '{print $3}'
UserParameter=ct.swapfree,free -b |grep Swap |awk '{print $4}'
UserParameter=ct.swapfree_proc,free -b |grep Swap | awk '{print ($2 - $3)/$2 * 100.0}' | awk '{printf "%.0f\n", $1}'
UserParameter=ct.uptime,cat /proc/uptime | awk '{print $1}'
UserParameter=ct.processes,ps -AL --no-headers | wc -l
UserParameter=ct.localtime,date +%s
UserParameter=ct.issue,cat /etc/issue
{% endif %}
{% if item.name == 'postfix' %}
# Postfix parameters
UserParameter=postfix.pfmailq,mailq | grep -v "Mail queue is empty" | grep -c '^[0-9A-Z]'
UserParameter=postfix[*],/usr/local/bin/zabbix_scripts/postfix-zabbix-stats.bash $1
{% endif %}
{% if item.name == 'ldap' %}
# LDAP parameters
UserParameter=ldap.user_count,cat /tmp/disroot_user_list
{% endif %}
{% if item.name == 'postgres' %}
{% include "files/userparameter_postgres.conf" ignore missing %}
{% endif %}
{% if item.name == 'nginx' %}
#NGINX userparameters
UserParameter=nginx[*],/usr/local/bin/zabbix_scripts/nginx-check.sh "$1" "$2"
{% endif %}
{% if item.name == 'nextcloud' %}
# Nextcloud
UserParameter=nextcloud[*],cat /tmp/cloudstats | grep "$1" | cut -d "<" -f 2 | cut -d ">" -f 2 | head -n 1
{% endif %}
{% if item.name == 'dovecot' %}
# Dovecot
UserParameter=dovecot.usercount,cat /tmp/dovecot_user_count
UserParameter=dovecot.devicecount,cat /tmp/dovecot_device_count
UserParameter=dovecot.processes,ps -A |grep imap |wc -l
{% endif %}
{% if item.name == 'lufi' %}
# Lufi
UserParameter=lufi[*],cat /tmp/lufi_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% if item.name == 'privatebin' %}
# PrivateBin
UserParameter=privatebin[*],cat /tmp/bin_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% if item.name == 'etherpad' %}
# Etherpad
UserParameter=etherpad[*],cat /tmp/pad_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% if item.name == 'forgejo' %}
# Forgejo
UserParameter=forgejo[*],cat /tmp/git_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% if item.name == 'prosody' %}
# Prosody
UserParameter=prosody[*],cat /tmp/prosody_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% if item.name == 'jitsi' %}
# Jitsi
UserParameter=jitsi[*],cat /tmp/jitsi_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% if item.name == 'mumble' %}
# Mumble
UserParameter=prmumbleosody[*],cat /tmp/mumble_stats | grep $1 | cut -d' ' -f2-
{% endif %}
{% endfor %}