137 lines
7.0 KiB
Django/Jinja
137 lines
7.0 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/ldap_stats | grep "active" | awk '{print $2}'
|
|
UserParameter=ldap.user_deleted,cat /tmp/ldap_stats | grep "deleted" | awk '{print $2}'
|
|
UserParameter=ldap.user_blocked,cat /tmp/ldap_stats | grep "blocked" | awk '{print $2}'
|
|
{% 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[*],cat /tmp/dovecot_stats | grep $1 | cut -d' ' -f2-
|
|
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[*],curl -s http://localhost:8888/stats | jq '$1'
|
|
{% endif %}
|
|
|
|
{% if item.name == 'mumble' %}
|
|
# Mumble
|
|
UserParameter=mumble[*],cat /tmp/mumble_stats | grep $1 | cut -d' ' -f2-
|
|
{% endif %}
|
|
|
|
{% if item.name == 'mariadb' %}
|
|
# Mariadb
|
|
UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
|
|
UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
|
|
UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
|
|
UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
|
|
UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
|
|
UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
|
|
UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
|
|
{% endif %}
|
|
|
|
{% if item.name == 'postgres' %}
|
|
# Postgres
|
|
UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
|
|
|
|
UserParameter=pgsql.connections.sum[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.connections.sum.sql"
|
|
UserParameter=pgsql.connections[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.connections.sql"
|
|
UserParameter=pgsql.connections.prepared[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.connections.prepared.sql"
|
|
|
|
UserParameter=pgsql.dbstat.sum[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.dbstat.sum.sql"
|
|
UserParameter=pgsql.dbstat[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.dbstat.sql"
|
|
|
|
UserParameter=pgsql.transactions[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.transactions.sql"
|
|
UserParameter=pgsql.config.hash[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.config.hash.sql"
|
|
UserParameter=pgsql.wal.stat[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.wal.stat.sql"
|
|
UserParameter=pgsql.locks[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.locks.sql"
|
|
UserParameter=pgsql.queries[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -v tmax=$6 -f "/var/lib/zabbix/postgresql/pgsql.query.time.sql"
|
|
UserParameter=pgsql.uptime[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.uptime.sql"
|
|
UserParameter=pgsql.cache.hit[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.cache.hit.sql"
|
|
UserParameter=pgsql.scans[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.scans.sql"
|
|
UserParameter=pgsql.frozenxid[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.frozenxid.sql"
|
|
|
|
UserParameter=pgsql.discovery.db[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.discovery.db.sql"
|
|
UserParameter=pgsql.db.size[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -c "SELECT pg_database_size('$6')"
|
|
UserParameter=pgsql.ping[*], pg_isready -h "$1" -p "$2"
|
|
UserParameter=pgsql.ping.time[*], LANG=C.UTF-8 psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.ping.time.sql"
|
|
UserParameter=pgsql.version[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -c "SELECT version();"
|
|
|
|
UserParameter=pgsql.replication.count[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -c "SELECT count(*) FROM pg_stat_replication"
|
|
UserParameter=pgsql.replication.recovery_role[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.replication.recovery_role.sql"
|
|
UserParameter=pgsql.replication.lag.sec[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.replication.lag.sql"
|
|
UserParameter=pgsql.replication.status[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5" -f "/var/lib/zabbix/postgresql/pgsql.replication.status.sql"
|
|
{% endif %}
|
|
{% if item.name == 'sitecheck' %}
|
|
UserParameter=site.score[*],python3 /usr/local/bin/zabbix-scripts/sitecheck.py $1 $2
|
|
{% endif %}
|
|
{% endfor %}
|