├── 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 |
12 | Template App DRBD
13 | Template App DRBD
14 |
15 |
16 | Templates
17 |
18 |
19 |
20 |
21 | DRBD
22 |
23 |
24 |
25 |
26 |
27 | DRBD Resources
28 | 0
29 |
30 |
31 | drbd.resource.discovery
32 | 43200
33 | 0
34 |
35 |
36 |
37 | 0
38 | 0
39 |
40 | 0
41 |
42 |
43 |
44 |
45 | 0
46 |
47 |
48 |
49 |
50 |
51 | :
52 | 30
53 | Find DRBD Resources on the host via "/etc/init.d/drbd status" output
54 |
55 |
56 | {#RESOURCE_NAME} cstate
57 | 7
58 |
59 | 0
60 |
61 | drbd.resource.cstate[{#RESOURCE_NAME}]
62 | 120
63 | 7
64 | 365
65 | 0
66 | 4
67 |
68 |
69 | 0
70 |
71 |
72 | 0
73 | 0
74 |
75 | 0
76 |
77 | 1
78 |
79 |
80 |
81 | 0
82 | 0
83 |
84 |
85 |
86 |
87 |
88 | Connection State for {#RESOURCE_NAME} DRBD Volume
89 | 0
90 |
91 |
92 | DRBD
93 |
94 |
95 |
96 |
97 |
98 |
99 | {#RESOURCE_NAME} dstate
100 | 7
101 |
102 | 0
103 |
104 | drbd.resource.dstate[{#RESOURCE_NAME}]
105 | 120
106 | 7
107 | 365
108 | 0
109 | 4
110 |
111 |
112 | 0
113 |
114 |
115 | 0
116 | 0
117 |
118 | 0
119 |
120 | 1
121 |
122 |
123 |
124 | 0
125 | 0
126 |
127 |
128 |
129 |
130 |
131 | Device State for {#RESOURCE_NAME} DRBD Volume
132 | 0
133 |
134 |
135 | DRBD
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 | {Template App DRBD:drbd.resource.dstate[{#RESOURCE_NAME}].regexp(UpToDate)}=0
145 | DRBD Volume {#RESOURCE_NAME} Device State Not UpToDate
146 |
147 | 0
148 | 4
149 |
150 | 0
151 |
152 |
153 | {Template App DRBD:drbd.resource.cstate[{#RESOURCE_NAME}].regexp(Connected)}=0
154 | DRBD Volume {#RESOURCE_NAME} Not Connected
155 |
156 | 0
157 | 4
158 |
159 | 0
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
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 |
12 | Template EMC-Iomega ix2 ix4 NAS SNMP
13 | Template EMC-Iomega ix2 ix4 NAS SNMP
14 |
15 |
16 | Templates
17 |
18 |
19 |
20 |
21 | NAS
22 |
23 |
24 |
25 | -
26 | Available memory
27 | 6
28 |
29 | 0
30 | .1.3.6.1.4.1.2021.4.5.0
31 | hrStorageMemorySize[available]
32 | 600
33 | 7
34 | 365
35 | 0
36 | 3
37 |
38 | B
39 | 0
40 |
41 | {$SNMP_SECNAME}
42 | 0
43 | 0
44 |
45 | 0
46 |
47 | 1
48 |
49 |
50 |
51 | 0
52 | 0
53 |
54 |
55 |
56 |
57 |
58 | Available memory
59 | 0
60 |
61 |
62 | NAS
63 |
64 |
65 |
66 |
67 |
68 | -
69 | Free memory in %
70 | 15
71 |
72 | 0
73 |
74 | hrStorageMemorySize[,pfree]
75 | 60
76 | 7
77 | 365
78 | 0
79 | 0
80 |
81 | %
82 | 0
83 |
84 |
85 | 0
86 | 0
87 |
88 | 0
89 |
90 | 1
91 |
92 | 100*last("hrStorageMemorySize[available]")/last("hrStorageMemorySize[total]")
93 |
94 | 0
95 | 0
96 |
97 |
98 |
99 |
100 |
101 |
102 | 0
103 |
104 |
105 | NAS
106 |
107 |
108 |
109 |
110 |
111 | -
112 | NAS Name
113 | 6
114 |
115 | 0
116 | .1.3.6.1.2.1.1.5.0
117 | hrStorageName
118 | 36000
119 | 7
120 | 365
121 | 0
122 | 1
123 |
124 |
125 | 0
126 |
127 | {$SNMP_SECNAME}
128 | 0
129 | 0
130 |
131 | 0
132 |
133 | 1
134 |
135 |
136 |
137 | 0
138 | 0
139 |
140 |
141 |
142 |
143 |
144 |
145 | 0
146 |
147 |
148 | NAS
149 |
150 |
151 |
152 |
153 |
154 | -
155 | Ping
156 | 3
157 |
158 | 0
159 |
160 | icmpping
161 | 60
162 | 7
163 | 30
164 | 0
165 | 3
166 |
167 |
168 | 0
169 |
170 |
171 | 0
172 | 0
173 |
174 | 0
175 |
176 | 1
177 |
178 |
179 |
180 | 0
181 | 0
182 |
183 |
184 |
185 |
186 |
187 |
188 | 0
189 |
190 |
191 | NAS
192 |
193 |
194 |
195 | Zabbix agent ping status
196 |
197 |
198 |
199 | -
200 | Processor load (1 min average per core)
201 | 6
202 |
203 | 0
204 | iso.3.6.1.4.1.2021.10.1.3.1
205 | hrStorageLoad[percpu,avg1]
206 | 60
207 | 7
208 | 365
209 | 0
210 | 0
211 |
212 |
213 | 0
214 |
215 | {$SNMP_SECNAME}
216 | 0
217 | 0
218 |
219 | 0
220 |
221 | 1
222 |
223 |
224 |
225 | 0
226 | 0
227 |
228 |
229 |
230 |
231 |
232 | The processor load is calculated as system CPU load divided by number of CPU cores.
233 | 0
234 |
235 |
236 | NAS
237 |
238 |
239 |
240 |
241 |
242 | -
243 | Processor load (5 min average per core)
244 | 6
245 |
246 | 0
247 | iso.3.6.1.4.1.2021.10.1.3.2
248 | hrStorageLoad[percpu,avg5]
249 | 60
250 | 7
251 | 365
252 | 0
253 | 0
254 |
255 |
256 | 0
257 |
258 | {$SNMP_SECNAME}
259 | 0
260 | 0
261 |
262 | 0
263 |
264 | 1
265 |
266 |
267 |
268 | 0
269 | 0
270 |
271 |
272 |
273 |
274 |
275 | The processor load is calculated as system CPU load divided by number of CPU cores.
276 | 0
277 |
278 |
279 | NAS
280 |
281 |
282 |
283 |
284 |
285 | -
286 | Processor load (15 min average per core)
287 | 6
288 |
289 | 0
290 | iso.3.6.1.4.1.2021.10.1.3.3
291 | hrStorageLoad[percpu,avg15]
292 | 60
293 | 7
294 | 365
295 | 0
296 | 0
297 |
298 |
299 | 0
300 |
301 | {$SNMP_SECNAME}
302 | 0
303 | 0
304 |
305 | 0
306 |
307 | 1
308 |
309 |
310 |
311 | 0
312 | 0
313 |
314 |
315 |
316 |
317 |
318 | The processor load is calculated as system CPU load divided by number of CPU cores.
319 | 0
320 |
321 |
322 | NAS
323 |
324 |
325 |
326 |
327 |
328 | -
329 | RAID status
330 | 6
331 |
332 | 0
333 | .1.3.6.1.4.1.1139.10.4.1.0
334 | hrStorageRAIDStatus
335 | 60
336 | 7
337 | 365
338 | 0
339 | 1
340 |
341 |
342 | 0
343 |
344 | {$SNMP_SECNAME}
345 | 0
346 | 0
347 |
348 | 0
349 |
350 | 1
351 |
352 |
353 |
354 | 0
355 | 0
356 |
357 |
358 |
359 |
360 |
361 | Values can be
362 | * REBUILDING
363 | * DEGRADED
364 | * REBUILDFS
365 | * FAULTED
366 | * NORMAL
367 | 0
368 |
369 |
370 | NAS
371 |
372 |
373 |
374 |
375 |
376 | -
377 | RAID type
378 | 6
379 |
380 | 0
381 | .1.3.6.1.4.1.1139.10.4.2.0
382 | hrStorageRAIDType
383 | 7200
384 | 7
385 | 365
386 | 0
387 | 3
388 |
389 |
390 | 0
391 |
392 | {$SNMP_SECNAME}
393 | 0
394 | 0
395 |
396 | 0
397 |
398 | 1
399 |
400 |
401 |
402 | 0
403 | 0
404 |
405 |
406 |
407 |
408 |
409 | RAID mode
410 | 0
411 |
412 |
413 | NAS
414 |
415 |
416 |
417 |
418 |
419 | -
420 | Total memory
421 | 6
422 |
423 | 0
424 | .1.3.6.1.4.1.2021.4.11.0
425 | hrStorageMemorySize[total]
426 | 3600
427 | 7
428 | 365
429 | 0
430 | 3
431 |
432 | B
433 | 0
434 |
435 | {$SNMP_SECNAME}
436 | 0
437 | 0
438 |
439 | 0
440 |
441 | 1
442 |
443 |
444 |
445 | 0
446 | 0
447 |
448 |
449 |
450 |
451 |
452 | Total memory
453 | 0
454 |
455 |
456 | NAS
457 |
458 |
459 |
460 |
461 |
462 | -
463 | Uptime
464 | 6
465 |
466 | 1
467 | .1.3.6.1.2.1.25.1.1.0
468 | hrStorageUptime
469 | 600
470 | 7
471 | 365
472 | 0
473 | 3
474 |
475 | uptime
476 | 0
477 |
478 | {$SNMP_SECNAME}
479 | 0
480 | 0
481 |
482 | 0
483 |
484 | 0.01
485 |
486 |
487 |
488 | 0
489 | 0
490 |
491 |
492 |
493 |
494 |
495 |
496 | 0
497 |
498 |
499 | NAS
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 | Disk IDs
509 | 6
510 |
511 | .1.3.6.1.4.1.1139.10.4.3.1.1
512 | hrStorageDiskId
513 | 3600
514 | 0
515 |
516 |
517 | {$SNMP_SECNAME}
518 | 0
519 | 0
520 |
521 | 0
522 |
523 |
524 |
525 |
526 | 0
527 |
528 |
529 |
530 |
531 |
532 | :
533 | 30
534 |
535 |
536 |
537 | Description of storage $1
538 | 6
539 |
540 | 0
541 | .1.3.6.1.4.1.1139.10.4.3.1.2.{#SNMPVALUE}
542 | hrStorageDescr[{#SNMPVALUE}]
543 | 3600
544 | 7
545 | 365
546 | 0
547 | 1
548 |
549 |
550 | 0
551 |
552 | {$SNMP_SECNAME}
553 | 0
554 | 0
555 |
556 | 0
557 |
558 | 1
559 |
560 |
561 |
562 | 0
563 | 0
564 |
565 |
566 |
567 |
568 |
569 | A description of the type and instance of the storage described by this entry.
570 | 0
571 |
572 |
573 | NAS
574 |
575 |
576 |
577 |
578 |
579 |
580 | Status of disk $1
581 | 6
582 |
583 | 0
584 | .1.3.6.1.4.1.1139.10.4.3.1.4.{#SNMPVALUE}
585 | hrStorageStatus[{#SNMPVALUE}]
586 | 60
587 | 7
588 | 365
589 | 0
590 | 1
591 |
592 |
593 | 0
594 |
595 | {$SNMP_SECNAME}
596 | 0
597 | 0
598 |
599 | 0
600 |
601 | 1
602 |
603 |
604 |
605 | 0
606 | 0
607 |
608 |
609 |
610 |
611 |
612 | Disk status
613 | 0
614 |
615 |
616 | NAS
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageStatus[{#SNMPVALUE}].str(FAULTED)}=1
626 | Disk faluire on {HOST.NAME}
627 |
628 | 0
629 | 3
630 |
631 | 0
632 |
633 |
634 | {Template EMC-Iomega ix2 ix4 NAS SNMP:hrStorageStatus[{#SNMPVALUE}].diff(0)}>0
635 | Disk status change on {HOST.NAME}
636 |
637 | 0
638 | 2
639 |
640 | 0
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
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 |
12 | Template App rsnapshot
13 | Template App rsnapshot
14 |
15 |
16 | Templates
17 |
18 |
19 |
20 |
21 | rsnapshot
22 |
23 |
24 |
25 |
26 |
27 | Rsnapshot enabled backups
28 | 0
29 |
30 |
31 | rsnapshot.discovery
32 | 1440
33 | 0
34 |
35 |
36 |
37 | 0
38 | 0
39 |
40 | 0
41 |
42 |
43 |
44 |
45 | 0
46 |
47 |
48 |
49 |
50 |
51 | :
52 | 30
53 |
54 |
55 |
56 | rsnapshot $1 backup
57 | 0
58 |
59 | 0
60 |
61 | rsnapshot.check[{#TYPE}]
62 | 3600
63 | 7
64 | 365
65 | 0
66 | 3
67 |
68 | unixtime
69 | 0
70 |
71 |
72 | 0
73 | 0
74 |
75 | 0
76 |
77 | 1
78 |
79 |
80 |
81 | 0
82 | 0
83 |
84 |
85 |
86 |
87 |
88 |
89 | 0
90 |
91 |
92 | rsnapshot
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | {Template App rsnapshot:rsnapshot.check[{#TYPE}].now()}-{Template App rsnapshot:rsnapshot.check[{#TYPE}].last()}>{#MAXAGE}
102 | rsnapshot {#TYPE} backup too old on {HOST.NAME}
103 |
104 | 0
105 | 3
106 |
107 | 0
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
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 |
12 | Template Zimbra NE
13 | Template Zimbra NE
14 | Zimbra Network Edition checks by YetOpen
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | Zimbra
23 |
24 |
25 |
26 | -
27 | Number of backups in the last 24h
28 | 0
29 |
30 | 0
31 |
32 | zimbrane.backup[24]
33 | 3600
34 | 90
35 | 365
36 | 0
37 | 3
38 |
39 |
40 | 0
41 |
42 |
43 | 0
44 | 0
45 |
46 | 0
47 |
48 | 1
49 |
50 |
51 |
52 | 0
53 | 0
54 |
55 |
56 |
57 |
58 |
59 | Number of Zimbra backups in the last "n" hours
60 | 0
61 |
62 |
63 | Zimbra
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
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 |
12 | Template Zimbra Services
13 | Template Zimbra Services
14 |
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | Zimbra
23 |
24 |
25 | Zimbra service
26 |
27 |
28 |
29 | -
30 | Zimbra Queue
31 | 0
32 |
33 | 0
34 |
35 | zimbra.queue
36 | 60
37 | 90
38 | 365
39 | 0
40 | 3
41 |
42 |
43 | 0
44 |
45 |
46 | 0
47 | 0
48 |
49 | 0
50 |
51 | 1
52 |
53 |
54 |
55 | 0
56 | 0
57 |
58 |
59 |
60 |
61 |
62 |
63 | 0
64 |
65 |
66 | Zimbra
67 |
68 |
69 |
70 |
71 |
72 | -
73 | Zimbra version
74 | 0
75 |
76 | 0
77 |
78 | zimbra.version
79 | 43200
80 | 7
81 | 0
82 | 0
83 | 1
84 |
85 |
86 | 0
87 |
88 |
89 | 0
90 | 0
91 |
92 | 0
93 |
94 | 1
95 |
96 |
97 |
98 | 0
99 | 0
100 |
101 |
102 |
103 |
104 |
105 |
106 | 0
107 |
108 |
109 | Zimbra
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | Zimbra services discovery
119 | 0
120 |
121 |
122 | zimbra.discovery
123 | 86400
124 | 0
125 |
126 |
127 |
128 | 0
129 | 0
130 |
131 | 0
132 |
133 |
134 |
135 |
136 | 0
137 |
138 |
139 |
140 |
141 |
142 |
143 | 0
144 |
145 |
146 |
147 | 30
148 |
149 |
150 |
151 | Zimbra service "$1"
152 | 0
153 |
154 | 0
155 |
156 | zimbra.status[{#ZIMBRASERVICE}]
157 | 120
158 | 7
159 | 365
160 | 0
161 | 3
162 |
163 |
164 | 0
165 |
166 |
167 | 0
168 | 0
169 |
170 | 0
171 |
172 | 1
173 |
174 |
175 |
176 | 0
177 | 0
178 |
179 |
180 |
181 |
182 |
183 |
184 | 0
185 |
186 |
187 | Zimbra service
188 |
189 |
190 |
191 | Service state
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 | {Template Zimbra Services:zimbra.status[{#ZIMBRASERVICE}].last()}<>1
200 | Zimbra service "{#ZIMBRASERVICE}" not running on {HOST.NAME}
201 |
202 | 0
203 | 2
204 |
205 | 0
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
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 |
--------------------------------------------------------------------------------