├── README.md ├── zabbix-drbd ├── README.md ├── app_drbd_template.xml ├── scripts │ └── drbd_stats ├── sudoers.d │ └── drbd_conf └── yo-drbd.conf ├── zabbix-iomega_ix2-ix4 └── yo_iomega_ix2-ix4.xml ├── zabbix-rsnapshot ├── README.md ├── check_rsnapshot.pl ├── yo-rsnapshot.conf └── yo_check_rsnapshot.xml └── zabbix-zimbra ├── CHANGELOG.md ├── README.md ├── sudo_zbx-zimbra.conf ├── yo-zimbra-ne-backup.conf ├── yo-zimbra.conf ├── yo_zimbra_ne_backup_template.xml ├── yo_zimbra_template.xml └── zbx_zimbra.sh /README.md: -------------------------------------------------------------------------------- 1 | Zabbix templates 2 | ================ 3 | 4 | This is my collection of Zabbix templates and scripts 5 | 6 | 7 | Contact 8 | ------- 9 | [YetOpen S.r.l](http://www.yetopen.it) 10 | -------------------------------------------------------------------------------- /zabbix-drbd/README.md: -------------------------------------------------------------------------------- 1 | DRBD autodiscovery and monitoring 2 | ================================= 3 | 4 | Monitoring tools for DRBD, originally found on [Zabbix forum](https://www.zabbix.com/forum/showthread.php?t=43750) with some modifications 5 | (like the ability to run using the output of `drbd-overview` instead of `/etc/init.d/drbd`). 6 | 7 | 8 | -------------------------------------------------------------------------------- /zabbix-drbd/app_drbd_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 2015-10-12T20:07:36Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /zabbix-drbd/scripts/drbd_stats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import commands 3 | import sys 4 | 5 | def usage(): 6 | print "Usage: drbd_stats [discovery|dstate|cstate] RESOURCE" 7 | sys.exit(1) 8 | 9 | if len(sys.argv) < 2 or len(sys.argv) > 3: 10 | usage() 11 | 12 | command = sys.argv[1] 13 | 14 | if command in ['dstate','cstate']: 15 | resource = sys.argv[2] 16 | print commands.getoutput('drbdadm {0} {1}'.format(command,resource)) 17 | sys.exit(0) 18 | 19 | if command == 'discovery': 20 | data = '' 21 | resources = commands.getoutput("/usr/sbin/drbd-overview | /usr/bin/sed -n 's/.*[0-9]:\([a-z0-9\/]*\)\ .*/\\1/p'").split('\n') 22 | for res in resources: 23 | data += '{ "{#RESOURCE_NAME}": "%s" },' % res 24 | print '{ "data": [ %s ] }' % data[0:-1] 25 | sys.exit(0) 26 | 27 | usage() 28 | -------------------------------------------------------------------------------- /zabbix-drbd/sudoers.d/drbd_conf: -------------------------------------------------------------------------------- 1 | zabbix ALL=(ALL) NOPASSWD:/etc/zabbix/scripts/drbd_stats 2 | -------------------------------------------------------------------------------- /zabbix-drbd/yo-drbd.conf: -------------------------------------------------------------------------------- 1 | UserParameter=drbd.resource.cstate[*],sudo /etc/zabbix/scripts/drbd_stats cstate $1 2 | UserParameter=drbd.resource.dstate[*],sudo /etc/zabbix/scripts/drbd_stats dstate $1 3 | UserParameter=drbd.resource.discovery,sudo /etc/zabbix/scripts/drbd_stats discovery 4 | -------------------------------------------------------------------------------- /zabbix-iomega_ix2-ix4/yo_iomega_ix2-ix4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 2016-11-27T19:48:33Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 651 | 652 | 653 | 654 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageMemorySize[available].last(0)}<20 655 | Lack of available memory on server {HOST.NAME} 656 | 657 | 0 658 | 3 659 | 660 | 0 661 | 662 | 663 | 664 | {Template EMC-Iomega ix2 ix4 NAS SNMP:icmpping.last(0)}#1 665 | Ping to NAS {HOST.NAME} lost 666 | 667 | 0 668 | 4 669 | 670 | 0 671 | 672 | 673 | 674 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageRAIDStatus.str(FAULTED)}=1 675 | RAID faulted 676 | 677 | 0 678 | 4 679 | 680 | 0 681 | 682 | 683 | 684 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageRAIDStatus.str(REBUILDING)}=1 685 | RAID rebuilding 686 | 687 | 0 688 | 2 689 | 690 | 0 691 | 692 | 693 | 694 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageRAIDStatus.str(DEGRADED)}=1 695 | RAID warning 696 | 697 | 0 698 | 3 699 | 700 | 0 701 | 702 | 703 | 704 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageUptime.change(0)}<0 705 | {HOST.NAME} has just been restarted 706 | 707 | 0 708 | 1 709 | 710 | 0 711 | 712 | 713 | 714 | 715 | 716 | CPU load 717 | 900 718 | 200 719 | 0.0000 720 | 100.0000 721 | 1 722 | 1 723 | 0 724 | 1 725 | 0 726 | 0.0000 727 | 0.0000 728 | 1 729 | 0 730 | 0 731 | 0 732 | 733 | 734 | 0 735 | 0 736 | 009900 737 | 0 738 | 2 739 | 0 740 | 741 | Template EMC-Iomega ix2 ix4 NAS SNMP 742 | hrStorageLoad[percpu,avg1] 743 | 744 | 745 | 746 | 1 747 | 0 748 | 000099 749 | 0 750 | 2 751 | 0 752 | 753 | Template EMC-Iomega ix2 ix4 NAS SNMP 754 | hrStorageLoad[percpu,avg5] 755 | 756 | 757 | 758 | 2 759 | 0 760 | 990000 761 | 0 762 | 2 763 | 0 764 | 765 | Template EMC-Iomega ix2 ix4 NAS SNMP 766 | hrStorageLoad[percpu,avg15] 767 | 768 | 769 | 770 | 771 | 772 | Memory usage 773 | 900 774 | 200 775 | 0.0000 776 | 100.0000 777 | 1 778 | 1 779 | 0 780 | 1 781 | 0 782 | 0.0000 783 | 0.0000 784 | 0 785 | 0 786 | 0 787 | 0 788 | 789 | 790 | 0 791 | 0 792 | DD0000 793 | 0 794 | 2 795 | 0 796 | 797 | Template EMC-Iomega ix2 ix4 NAS SNMP 798 | hrStorageMemorySize[total] 799 | 800 | 801 | 802 | 1 803 | 5 804 | 00C800 805 | 0 806 | 2 807 | 0 808 | 809 | Template EMC-Iomega ix2 ix4 NAS SNMP 810 | hrStorageMemorySize[available] 811 | 812 | 813 | 814 | 815 | 816 | 817 | -------------------------------------------------------------------------------- /zabbix-rsnapshot/README.md: -------------------------------------------------------------------------------- 1 | rsnapshot backup monitoring 2 | =========================== 3 | 4 | Check rsnapshot enabled backup (discovery) and related results. 5 | 6 | Some checks were just taken from the original script without check. The template does LLD and checks every hour for the status. 7 | 8 | 9 | Requires packages libfile-readbackwards-perl and libtimedate-perl installed (this is how Ubuntu/Debian calls them) 10 | 11 | 12 | Copyright 13 | --------- 14 | GPL 15 | 16 | Author 17 | ------ 18 | [Lorenzo Milesi](http://www.yetopen.it). 19 | 20 | Original author: [Thorsten Kramm](https://github.com/lab4/check_rsnapshot). 21 | -------------------------------------------------------------------------------- /zabbix-rsnapshot/check_rsnapshot.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Script to perform several checks on rsnapshot backups 4 | # License GPL 5 | # Author: Thorsten Kramm 6 | # Author: Lorenzo Milesi 7 | 8 | use strict; 9 | use warnings; 10 | use File::ReadBackwards; # apt-get install libfile-readbackwards-perl 11 | use Date::Parse; # apt-get install libtimedate-perl 12 | use Date::Language; 13 | my $date_parse = Date::Language->new('English'); 14 | 15 | 16 | my $config_file; 17 | if($ARGV[2]) 18 | { 19 | $config_file = $ARGV[2]; 20 | } 21 | else 22 | { 23 | $config_file = '/etc/rsnapshot.conf'; 24 | } 25 | if( ! -e $config_file ) 26 | { 27 | print "ERROR Config $config_file not found\n"; 28 | exit; 29 | } 30 | 31 | # Read the config 32 | open(CONFIG,"<".$config_file); 33 | my $row; 34 | my $snapshot_root = 0; 35 | my $logfile = 0; 36 | my @types = (); 37 | # max age of the backup, for triggers 38 | my %ages = ( "hourly", "86400", 39 | "daily", "86400", 40 | "weekly", "604800", 41 | "monthly", "18748800", 42 | "yearly", "220752000"); 43 | while($row = ) 44 | { 45 | if( $row =~ /^snapshot_root\s+(\S+)/ ) 46 | { 47 | $snapshot_root = $1; 48 | } 49 | if( $row =~ /^logfile\s+(\S+)/ ) 50 | { 51 | $logfile = $1; 52 | } 53 | if( $row =~ /^retain\s+(\S+)/ ) 54 | { 55 | push(@types, $1); 56 | } 57 | } 58 | close(CONFIG); 59 | if(!$snapshot_root) 60 | { 61 | print "ERROR No rsnapshot_root"; 62 | exit; 63 | } 64 | if(!$logfile) 65 | { 66 | print "ERROR No rsnapshot logfile"; 67 | exit; 68 | } 69 | 70 | # Discovery (LLD) 71 | if($ARGV[0] eq "discovery") 72 | { 73 | print "{\"data\":[\n"; 74 | my $n = $#types; 75 | foreach (@types) 76 | { 77 | print "\t{ \"{#TYPE}\":\"$_\", \"{#MAXAGE}\":\"$ages{$_}\" }"; 78 | print "," if $n--; 79 | print "\n"; 80 | } 81 | print "]}\n"; 82 | } 83 | # Perform checks 84 | elsif($ARGV[0] eq "last_successfully_backup") 85 | { 86 | if(! $ARGV[1]) # Missing interval 87 | { 88 | print "ERROR Missing interval\n"; 89 | exit; 90 | } 91 | if(! -e $logfile ) 92 | { 93 | print "ERROR Cant open logfile $logfile\n"; 94 | exit; 95 | } 96 | my $log = File::ReadBackwards->new($logfile); 97 | my $log_line; 98 | my $interval = $ARGV[1]; 99 | while( defined( $log_line = $log->readline ) ) 100 | { 101 | 102 | #print $log_line ; 103 | if( $log_line =~ /\[(.*)\].*$interval: completed successfully/ && $log_line !~ /logger/ ) 104 | { 105 | print $date_parse->str2time($1); 106 | $log->close; 107 | exit; 108 | } 109 | } 110 | $log->close; 111 | } 112 | elsif($ARGV[0] eq "bytes_received") 113 | { 114 | if(! $ARGV[1]) # Missing interval 115 | { 116 | print "ERROR Missing interval\n"; 117 | exit; 118 | } 119 | if(! -e $logfile ) 120 | { 121 | print "ERROR Cant open logfile $logfile\n"; 122 | exit; 123 | } 124 | 125 | my $log = File::ReadBackwards->new($logfile); 126 | my $log_line; 127 | my $interval = $ARGV[1]; 128 | my $do_counting = 0; 129 | my $bytes_received = 0; 130 | while( defined( $log_line = $log->readline ) ) 131 | { 132 | #print $log_line ; 133 | if( $log_line =~ /$interval: completed successfully$/ && $log_line !~ /logger/ ) 134 | { 135 | $do_counting = 1; 136 | } 137 | elsif( $log_line =~ /$interval: started$/ && $log_line !~ /logger/ ) 138 | { 139 | $log->close; 140 | print $bytes_received; 141 | exit; 142 | } 143 | if( $do_counting == 1 && $log_line =~ /received ([0-9]+) bytes/ ) 144 | { 145 | $bytes_received = $bytes_received+$1; 146 | } 147 | } 148 | $log->close; 149 | } 150 | elsif($ARGV[0] eq "free_backup_space") 151 | { 152 | if(! -e $snapshot_root) 153 | { 154 | print "ERROR snapshot_root $snapshot_root not found"; 155 | exit; 156 | } 157 | my $free_backup_space; 158 | my $df = 'df -P '.$snapshot_root; 159 | open(PIPE, $df.'|'); 160 | while(my $row = ) 161 | { 162 | if($row =~ /[0-9]+\s+[0-9]+\s+[0-9]+\s+([0-9]+)/) 163 | { 164 | $free_backup_space = $1; 165 | } 166 | } 167 | close(PIPE); 168 | print $free_backup_space*1024; # df gives KBytes, but we want Bytes 169 | } 170 | -------------------------------------------------------------------------------- /zabbix-rsnapshot/yo-rsnapshot.conf: -------------------------------------------------------------------------------- 1 | UserParameter=rsnapshot.check[*],/etc/zabbix/scripts/check_rsnapshot.pl last_successfully_backup $1 2 | UserParameter=rsnapshot.freespace,/etc/zabbix/scripts/check_rsnapshot.pl free_backup_space 3 | UserParameter=rsnapshot.discovery,/etc/zabbix/scripts/check_rsnapshot.pl discovery 4 | -------------------------------------------------------------------------------- /zabbix-rsnapshot/yo_check_rsnapshot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 2015-01-09T14:25:24Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /zabbix-zimbra/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2016.07.15 2 | ---------- 3 | 4 | Updated the bash script to fork in background, thanks to @Ufo28. 5 | 6 | The script doesn't lock anymore Zabbix agent, and forks the update process in background. This ensures much faster reply and 7 | avoids timeout problems with the agent. 8 | -------------------------------------------------------------------------------- /zabbix-zimbra/README.md: -------------------------------------------------------------------------------- 1 | # Zimbra monitoring with Zabbix 2 | 3 | This template offers services autodiscover, version tracking and service status. 4 | It's compatibile with Zimbra 8.6+ (and its services with spaces). 5 | 6 | Please note the external script requires sudo privileges to run, so either copy the content of the sudo_zbx-zimbra.conf file to your sudoers 7 | or link it to /etc/sudoers.d/. 8 | Also copy yo-zimbra.conf to /etc/zabbix/zabbix_agentd.d/ and the script file to your zabbix agent's script directory (usually /etc/zabbix/scripts, if differeny adjust yo-zimbra.conf accordingly). 9 | 10 | Restart zabbix-agent and import the template to your server. 11 | The service discovery is set very long (1 day), so it may take that long for services to show up in Zabbix. 12 | The discovery command can take more than the 3s of the default command timeout, used by both agent and server/proxy. In case you see something like 13 | ``` 14 | Zabbix agent item "zimbra.discovery" on host "webmail.domain.it" failed: first network error, wait for 15 seconds 15 | ``` 16 | you should change the `Timeout` value in zabbix_agentd.d/yo-zimbra.conf. 17 | 18 | Please note you should **change the timeout on the server/proxy** accordingly. 19 | 20 | The bash script was inspired by [blog.linuxnet.ch](https://blog.linuxnet.ch/zimbra-monitoring-with-zabbix/). 21 | 22 | # Zimbra Network Edition backup check 23 | 24 | This is a basic check which runs `zmbackupquery` looking for the number of completed backup in the last *n*th hours. 25 | By default the template check the latest 24h, but you can change or add new check as you prefer. 26 | 27 | In the future it can be improved with different checks for full or incremental backups. 28 | 29 | # License & Copyright 30 | Code and documentation copyright 2018 YetOpen S.r.l.. Released under the GPLv3 license. 31 | -------------------------------------------------------------------------------- /zabbix-zimbra/sudo_zbx-zimbra.conf: -------------------------------------------------------------------------------- 1 | # Don't log every invocation of zmcontrol 2 | Cmnd_Alias ZIMBRA_BIN_ZABBIX = /opt/zimbra/bin/zmcontrol,/opt/zimbra/bin/zmbackupquery 3 | Defaults!ZIMBRA_BIN_ZABBIX !syslog 4 | zabbix ALL=(zimbra) NOPASSWD: ZIMBRA_BIN_ZABBIX 5 | -------------------------------------------------------------------------------- /zabbix-zimbra/yo-zimbra-ne-backup.conf: -------------------------------------------------------------------------------- 1 | UserParameter=zimbrane.backup[*],sudo -u zimbra /opt/zimbra/bin/zmbackupquery --from "$(date +%Y%m%d%H%M%S -d '$1 hour ago')" | grep "Status: completed" | wc -l 2 | -------------------------------------------------------------------------------- /zabbix-zimbra/yo-zimbra.conf: -------------------------------------------------------------------------------- 1 | UserParameter=zimbra.status[*],/etc/zabbix/scripts/zbx_zimbra.sh "$1" 2 | UserParameter=zimbra.version,/etc/zabbix/scripts/zbx_zimbra.sh version 3 | UserParameter=zimbra.discovery,/etc/zabbix/scripts/zbx_zimbra.sh discover 4 | UserParameter=zimbra.queue,/opt/zimbra/common/sbin/mailq |grep Request |awk '{print $5}' 5 | # zmcontrol takes some time... 6 | Timeout=15 7 | -------------------------------------------------------------------------------- /zabbix-zimbra/yo_zimbra_ne_backup_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.0 4 | 2018-12-12T13:04:45Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 75 | 76 | 77 | 78 | {Template Zimbra NE:zimbrane.backup[24].last()}=0 79 | No backups in the last 24h 80 | 81 | 0 82 | 3 83 | 84 | 0 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /zabbix-zimbra/yo_zimbra_template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.0 4 | 2018-02-21T20:15:51Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 217 | 218 | 219 | 220 | {Template Zimbra Services:zimbra.queue.last()}>200 and {Template Zimbra Services:zimbra.queue.last()}<500 221 | Zimbra queue greater than 200 messages 222 | 223 | 0 224 | 2 225 | 226 | 0 227 | 228 | 229 | 230 | {Template Zimbra Services:zimbra.queue.last()}>500 231 | Zimbra queue greater than 500 messages 232 | 233 | 0 234 | 4 235 | 236 | 0 237 | 238 | 239 | 240 | 241 | 242 | Service state 243 | 244 | 245 | 0 246 | Down 247 | 248 | 249 | 1 250 | Up 251 | 252 | 253 | 254 | 255 | 256 | -------------------------------------------------------------------------------- /zabbix-zimbra/zbx_zimbra.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Zabbix script to check Zimbra services and perform service discovery. 4 | # Supports Zimbra 8.6 and "two-worded" service names 5 | # Author: Lorenzo Milesi 6 | # Copytight: YetOpen S.r.l. 2016 7 | # License: GPLv3 8 | 9 | # uncomment for debug 10 | #set -x 11 | 12 | COMMAND="sudo -H -u zimbra /opt/zimbra/bin/zmcontrol" 13 | FILE='/var/run/zabbix/zimbra_status' 14 | DISCOVER_FILE='/var/run/zabbix/zimbra_discover' 15 | 16 | fork_get_status() { 17 | maxage=100 18 | 19 | # Very basic concurrency check 20 | x=0 21 | while [ -f "$FILE.tmp" ]; do 22 | sleep 5; 23 | x=$((x+1)) 24 | # don't wait too long anyway, remove an eventually stale lock. Anyway we have 15s zabbix agent timeout 25 | if [ $x -ge 3 ]; then 26 | rm "$FILE.tmp"; 27 | fi 28 | done 29 | #check if cached status file size > 0 30 | if [ -s ${FILE} ]; then 31 | OLD=`stat -c %Z $FILE` 32 | NOW=`date +%s` 33 | 34 | # if older then maxage, update file 35 | if [ `expr $NOW - $OLD` -gt $maxage ]; then 36 | $COMMAND status > $FILE.tmp 37 | mv $FILE.tmp $FILE 38 | fi 39 | else 40 | rm -f ${FILE} 41 | $COMMAND status > $FILE.tmp 42 | mv $FILE.tmp $FILE 43 | fi 44 | } 45 | 46 | fork_discover() { 47 | # Return a list of running services in JSON 48 | SRVCS=$($COMMAND status | grep -v ^Host | awk '{$(NF--)=""; print}' | sed 's/^/\t{ \"{#ZIMBRASERVICE}\":\"/' | sed 's/\ $/\" },/') 49 | echo "{" 50 | echo -e "\t\"data\":[\n" 51 | # Remove last comma from the sting, to make a good JSON 52 | echo $(echo $SRVCS | sed 's/,\+$//') 53 | echo -e "\n\t]\n" 54 | echo "}" 55 | } 56 | 57 | case "$1" in 58 | version) 59 | # Return zimbra version 60 | VERS=$($COMMAND -v) 61 | if [ $? -eq 0 ] ; then 62 | echo $VERS 63 | exit 0; 64 | fi 65 | # error 66 | exit 1; 67 | ;; 68 | discover) 69 | [ -f "$DISCOVER_FILE" ] && cat $DISCOVER_FILE 70 | fork_discover > $DISCOVER_FILE & 71 | exit 0; 72 | ;; 73 | *) 74 | # move on... 75 | check=$1 76 | 77 | if [ "$check" = "" ]; then 78 | echo "No Zimbra service specified..." 79 | exit 1 80 | fi 81 | 82 | fork_get_status & 83 | 84 | STATUS="$(cat $FILE | grep "`printf '\t'`$check " | awk '{print $NF}')" 85 | 86 | if [ "$STATUS" != "Running" ]; then 87 | echo 0 88 | else 89 | echo 1 90 | fi 91 | ;; 92 | esac 93 | 94 | exit 0; 95 | --------------------------------------------------------------------------------