4.0
2019-03-07T14:08:51Z
Templates/Applications
Template Yunohost
Template Yunohost
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
0
yunohost.backups.ageoflastbackup
1d;h10m45
90d
365d
0
3
days
0
0
0
0
0
Yunohost : Backups
3s
200
1
0
0
0
0
0
0
0
-
Number of Yunohost backups
0
yunohost.backups.number
1d;h11
90d
365d
0
3
0
0
0
0
0
Yunohost : Backups
3s
200
1
0
0
0
0
0
0
0
-
Id of the last migration available
0
yunohost.migrations.lastavailable
1d;h10m50
90d
365d
0
3
0
0
0
0
0
Yunohost : Migrations
3s
200
1
0
0
0
0
0
0
0
-
Id of the last migration installed
0
yunohost.migrations.lastinstalled
1d;h10m55
90d
365d
0
3
0
0
0
0
0
Yunohost : Migrations
3s
200
1
0
0
0
0
0
0
0
Yunohost domains
0
yunohost.domains.discover
1d;h10
0
0
0
0
0
0
30d
Certificate {#DOMAIN} expiration
18
yunohost.domain.cert.expiration[{#DOMAIN}]
0
180d
365d
0
3
d
0
0
0
0
0
Yunohost : Certificates
Yunohost : Certificates : Expiration
5
(.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*);
\2
3s
200
1
0
0
0
0
0
0
0
yunohost.domain.cert[{#DOMAIN}]
Certificate {#DOMAIN} state
18
yunohost.domain.cert.state[{#DOMAIN}]
0
180d
0
0
1
0
0
0
0
0
Yunohost : Certificates
Yunohost : Certificates : State
Yunohost : certificates
5
(.*);(.*);(.*);(.*);(.*);(.*);(.*);(.*);
\3:unknown=0:critical=1:warning=2:attention=3:good=4;great=5
5
^(unknown|critical|warning|attention|good|great):(?=.*\1=(\d))
\2
3s
200
1
0
0
0
0
0
0
0
yunohost.domain.cert[{#DOMAIN}]
Informations {#DOMAIN} full
0
yunohost.domain.cert[{#DOMAIN}]
1d
180d
0
0
1
0
0
0
0
0
Yunohost : Certificates
3s
200
1
0
0
0
0
0
0
0
3s
200
1
0
0
0
0
0
0
TCP Ports opened
0
yunohost.ports.tcp.discover
1d;h9m30
0
0
0
0
0
0
7d
Check TCP port {#PORT} responding
0
net.tcp.service[tcp,127.0.0.1,{#PORT}]
900s
90d
365d
0
3
0
0
0
0
0
Yunohost : Ports
Service state
3s
200
1
0
0
0
0
0
0
0
{Template Yunohost:net.tcp.service[tcp,127.0.0.1,{#PORT}].last()}=0
0
TCP port {#PORT} not responding
0
0
4
0
1
3s
200
1
0
0
0
0
0
0
UDP Ports opened
0
yunohost.ports.udp.discover
1d;h9m45
0
0
0
0
0
0
0d
Check UDP port {#PORT} listening
0
net.udp.listen[{#PORT}]
900s
90d
365d
0
3
0
0
0
0
0
Yunohost : Ports
Service state
3s
200
1
0
0
0
0
0
0
0
{Template Yunohost:net.udp.listen[{#PORT}].last()}=0
0
UDP port {#PORT} not listening
0
0
4
0
1
3s
200
1
0
0
0
0
0
0
Yunohost services
0
yunohost.services.discover
1d;h10m15
0
0
0
0
0
0
7d
Yunohost service {#SERVICE} status
18
yunohost.service.statusrunp[{#SERVICE}]
0
7d
365d
0
3
0
0
0
0
0
Yunohost : Services
Yunohost : Services : Status
Yunohost : services
12
$.active
5
(.*)
\1:inactive=0:active=1:unknown=2;disabled=3
5
^(inactive|active|unknown|disabled):(?=.*\1=(\d))
\2
3s
200
1
0
0
0
0
0
0
0
yunohost.service.status[{#SERVICE}]
Yunohost service {#SERVICE} status (full)
0
yunohost.service.status[{#SERVICE}]
15m
7d
0
0
1
0
0
0
0
0
Yunohost : Services
3s
200
1
0
0
0
0
0
0
0
{Template Yunohost:yunohost.service.statusrunp[{#SERVICE}].last()}=3
0
Service {#SERVICE} disabled
0
0
4
0
1
{Template Yunohost:yunohost.service.statusrunp[{#SERVICE}].last()}=0
0
Service {#SERVICE} state is inactive
0
0
4
0
1
{Template Yunohost:yunohost.service.statusrunp[{#SERVICE}].last()}=2
0
Service {#SERVICE} state is unknown
0
0
4
0
1
3s
200
1
0
0
0
0
0
0
Yunohost users
0
yunohost.users.discover
1d;h10m30
0
0
0
0
0
0
30d
Quota percent for user {#USERNAME}
0
yunohost.user.quota[{#USERNAME}]
1h
30d
365d
0
3
%
0
0
0
0
0
Yunohost : Users
3s
200
1
0
0
0
0
0
0
0
{Template Yunohost:yunohost.user.quota[{#USERNAME}].last()}>=80
0
User {#USERNAME} quota exceed 80%
0
0
3
0
1
{Template Yunohost:yunohost.user.quota[{#USERNAME}].last()}>=90
0
User {#USERNAME} quota exceed 90%
0
0
4
0
1
3s
200
1
0
0
0
0
0
0
{Template Yunohost:yunohost.migrations.lastavailable.last()}<>{Template Yunohost:yunohost.migrations.lastinstalled.last()}
0
Yunhost has migration in pending state
0
0
1
0
1
{Template Yunohost:yunohost.backups.ageoflastbackup.last()}>=7
0
Yunhost hasn't backup since 7 days
0
0
4
0
1
{Template Yunohost:yunohost.backups.number.last()}=0
0
Yunhost hasn't backup yet
0
0
4
0
1
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