5.0
2020-11-26T12:48:35Z
Templates/Applications
Template Yunohost
Template Yunohost
Please check default value template macro.
cat /etc/sudoers.d/zabbix
zabbix ALL=(ALL) NOPASSWD: /etc/zabbix/zabbix_agentd.d/yunohost.sh
cat /etc/zabbix/zabbix_agentd.d/userP_yunohost.conf
UserParameter=yunohost.users.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.users.discover
UserParameter=yunohost.user.quota[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.user.quota "$1"
UserParameter=yunohost.domains.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.domains.discover
UserParameter=yunohost.domain.cert[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.domain.cert "$1"
UserParameter=yunohost.services.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.services.discover
UserParameter=yunohost.service.status[*],sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.service.status "$1"
UserParameter=yunohost.backups.number,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.backups.number
UserParameter=yunohost.backups.ageoflastbackup,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.backups.ageoflastbackup
UserParameter=yunohost.ports.tcp.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.tcp.discovery
UserParameter=yunohost.ports.udp.discover,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.ports.udp.discovery
UserParameter=yunohost.migrations.lastinstalled,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.migrations.lastinstalled
UserParameter=yunohost.migrations.lastavailable,sudo /etc/zabbix/zabbix_agentd.d/yunohost.sh yunohost.migrations.lastavailable
cat /etc/zabbix/zabbix_agentd.d/yunohost.sh
#!/bin/bash
yunobin=$(which yunohost)
if [ "$1" == "yunohost.users.discover" ];then
users=$($yunobin user list --fields 'uid' | awk -F ': ' '/username: / {print $2}');echo -n "{\"data\":[";for user in $users;do echo -n "{\"{#USERNAME}\":\"$user\"},";done | sed 's/,$//' ;echo "]}"
fi
if [ "$1" == "yunohost.user.quota" ] ;then
quota=$($yunobin user info "$2" | grep -Po "use:.*\(\K([0-9]{1,3})");if [ -z "$quota" ];then echo 0 ; else echo "$quota" ;fi
fi
if [ "$1" == "yunohost.domains.discover" ] ;then
domains=$($yunobin domain list --output-as plain);echo -n "{\"data\":[";for domain in $domains;do echo -n "{\"{#DOMAIN}\":\"$domain\"},";done | sed 's/,$//' ;echo "]}"
fi
if [ "$1" == "yunohost.domain.cert" ] ;then
$yunobin domain cert-status "$2" --output-as plain --full| awk '/#/{ next;} {printf "%s;",$0} END {print ""}'
fi
if [ "$1" == "yunohost.services.discover" ] ;then
services=$($yunobin service status 2>/dev/null| grep -Po '^([A-Za-z]+)(?=(:))');echo -n "{\"data\":[";for service in $services;do echo -n "{\"{#SERVICE}\":\"$service\"},";done | sed 's/,$//' ;echo "]}"
fi
if [ "$1" == "yunohost.service.status" ] ;then
service=$($yunobin service status "$2" --output-as json 2>/dev/null)
if [[ "$(echo $service | jq -r '.description')" == *"doesn't exists for systemd"* ]] ;then
echo "$service" | jq -c '.active = "disabled"'
else
echo "$service"
fi
fi
if [ "$1" == "yunohost.backups.number" ] ;then
$yunobin backup list --output-as plain | wc -l
fi
if [ "$1" == "yunohost.backups.ageoflastbackup" ] ;then
if [ $($yunobin backup list --output-as plain | wc -l) -ne 0 ] ;then
timestamp=$(date +"%d/%m/%Y %H:%M" -d"$($yunobin backup list -i | tail -n 4 | head -n 1 | grep -Po 'created_at: \K(.*)')")
echo $(( ($(date +%s) - $(date -d"$timestamp" +%s))/(60*60*24) ))
else
echo "No backup detected"
fi
fi
if [ "$1" == "yunohost.ports.tcp.discovery" ] ;then
ports=$($yunobin firewall list -r --output-as plain | awk '/#ipv4/{flag=1;next}/#uPnP/{flag=0}flag' | awk '/##TCP/{flag=1;next}/##TCP/{flag=0}flag');echo -n "{\"data\":[";for port in $ports;do echo -n "{\"{#PORT}\":\"$port\"},";done | sed 's/,$//' ;echo "]}"
fi
if [ "$1" == "yunohost.ports.udp.discovery" ] ;then
ports=$($yunobin firewall list -r --output-as plain | awk '/#ipv4/{flag=1;next}/#uPnP/{flag=0}flag' | awk '/##UDP/{flag=1;next}/##TCP/{flag=0}flag');echo -n "{\"data\":[";for port in $ports;do echo -n "{\"{#PORT}\":\"$port\"},";done | sed 's/,$//' ;echo "]}"
fi
if [ "$1" == "yunohost.migrations.lastinstalled" ] ;then
$yunobin tools migrations state | grep -Po " number: \K(.*)"
fi
if [ "$1" == "yunohost.migrations.lastavailable" ] ;then
$yunobin tools migrations list | tail -n 1 | grep -Po " number: \K(.*)"
fi
Templates/Applications
Yunohost : Backups
Yunohost : Certificates
Yunohost : Certificates : Expiration
Yunohost : Certificates : State
Yunohost : Migrations
Yunohost : Ports
Yunohost : Services
Yunohost : Services : Status
Yunohost : Users
-
Age of the last backup
yunohost.backups.ageoflastbackup
1d;h10m45
days
Yunohost : Backups
{last()}>={$YUNOHOST.BACKUP.MAXDAYS}
YunoHost hasn't backup since more than {$YUNOHOST.BACKUP.MAXDAYS} days
{ITEM.LASTVALUE}
HIGH
Please check https://yunohost.org/en/backup
YES
-
Number of Yunohost backups
yunohost.backups.number
1d;h11
Yunohost : Backups
{last()}=0
YunoHost hasn't backup yet
HIGH
Please check https://yunohost.org/en/backup
YES
-
Id of the last migration available
yunohost.migrations.lastavailable
1d;h10m50
Yunohost : Migrations
-
Id of the last migration installed
yunohost.migrations.lastinstalled
1d;h10m55
Yunohost : Migrations
Yunohost domains
yunohost.domains.discover
1d;h10
Certificate {#DOMAIN} expiration
DEPENDENT
yunohost.domain.cert.expiration[{#DOMAIN}]
0
180d
d
Yunohost : Certificates
Yunohost : Certificates : Expiration
REGEX
(.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*);
\2
yunohost.domain.cert[{#DOMAIN}]
{last()}<{$YUNOHOST.CERTIFICATE.REMAININGDAYS_AVG}
Remaining days for certificate {#DOMAIN} < {$YUNOHOST.CERTIFICATE.REMAININGDAYS_AVG}
{ITEM.LASTVALUE}
AVERAGE
Remaining days for certificate {#DOMAIN} < {$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
{Template Yunohost:yunohost.domain.cert.expiration[{#DOMAIN}].last()}< {$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
Remaining days for certificate {#DOMAIN} < {$YUNOHOST.CERTIFICATE.REMAININGDAYS_HIGH}
{Template Yunohost:yunohost.domain.cert.expiration[{#DOMAIN}].last()}<{$YUNOHOST.CERTIFICATE.REMAININGDAYS_HIGH}
{last()}< {$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
Remaining days for certificate {#DOMAIN} < {$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
{ITEM.LASTVALUE}
DISASTER
{last()}<{$YUNOHOST.CERTIFICATE.REMAININGDAYS_HIGH}
Remaining days for certificate {#DOMAIN} < {$YUNOHOST.CERTIFICATE.REMAININGDAYS_HIGH}
{ITEM.LASTVALUE}
HIGH
Remaining days for certificate {#DOMAIN} < {$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
{Template Yunohost:yunohost.domain.cert.expiration[{#DOMAIN}].last()}< {$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
Certificate {#DOMAIN} state
DEPENDENT
yunohost.domain.cert.state[{#DOMAIN}]
0
180d
0
CHAR
Yunohost : Certificates
Yunohost : Certificates : State
Yunohost : certificates
REGEX
(.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*);
\3:unknown=0:critical=1:warning=2:attention=3:good=4;great=5
REGEX
^(unknown|critical|warning|attention|good|great):(?=.*\1=(\d))
\2
yunohost.domain.cert[{#DOMAIN}]
Informations {#DOMAIN} full
yunohost.domain.cert[{#DOMAIN}]
1d
180d
0
CHAR
Yunohost : Certificates
TCP Ports opened
yunohost.ports.tcp.discover
1d;h9m30
7d
Check TCP port {#PORT} responding
net.tcp.service[tcp,127.0.0.1,{#PORT}]
900s
Yunohost : Ports
Yunohost : Service state
{last()}=0
TCP port {#PORT} not responding
HIGH
YES
UDP Ports opened
yunohost.ports.udp.discover
1d;h9m45
0d
Check UDP port {#PORT} listening
net.udp.listen[{#PORT}]
900s
Yunohost : Ports
Yunohost : Service state
{last()}=0
UDP port {#PORT} not listening
HIGH
YES
Yunohost services
yunohost.services.discover
1d;h10m15
7d
Yunohost service {#SERVICE} status
DEPENDENT
yunohost.service.statusrunp[{#SERVICE}]
0
7d
Yunohost : Services
Yunohost : Services : Status
Yunohost : services
JSONPATH
$.active
REGEX
(.*)
\1:inactive=0:active=1:unknown=2;disabled=3
REGEX
^(inactive|active|unknown|disabled):(?=.*\1=(\d))
\2
yunohost.service.status[{#SERVICE}]
{last()}=3
Service {#SERVICE} disabled
HIGH
YES
{last()}=0
Service {#SERVICE} state is inactive
HIGH
YES
{last()}=2
Service {#SERVICE} state is unknown
HIGH
YES
Yunohost service {#SERVICE} status (full)
yunohost.service.status[{#SERVICE}]
15m
7d
0
CHAR
Yunohost : Services
Yunohost users
yunohost.users.discover
1d;h10m30
Quota percent for user {#USERNAME}
yunohost.user.quota[{#USERNAME}]
1h
30d
%
Yunohost : Users
{last()}>=80
User {#USERNAME} quota exceed 80%
AVERAGE
YES
{last()}>=90
User {#USERNAME} quota exceed 90%
HIGH
YES
{$YUNOHOST.BACKUP.MAXDAYS}
7
The oldest backup age in day before trigger
{$YUNOHOST.CERTIFICATE.REMAININGDAYS_AVG}
14
Expiration date in X days AVG trigger
{$YUNOHOST.CERTIFICATE.REMAININGDAYS_DISASTER}
1
Expiration date in X days DISASTER trigger
{$YUNOHOST.CERTIFICATE.REMAININGDAYS_HIGH}
7
Expiration date in X days HIGH trigger
{Template Yunohost:yunohost.migrations.lastavailable.last()}<>{Template Yunohost:yunohost.migrations.lastinstalled.last()}
YunoHost has migration in pending state
INFO
Check Yunohost documentation and "yunohost/admin/#/tools/migrations/ " url or "sudo yunohost tools migrations migrate" command
YES
Yunohost : Service state
0
Down
1
Up
Yunohost : certificates
0
unknown
1
critical
2
warning
3
attention
4
good
5
great
Yunohost : services
0
inactive
1
active
2
unknow
3
disabled