├── README.md
├── aerospike
├── aerospike.conf
├── aerospike.sh
└── aerospike.xml
├── check_backups
├── buckets.zabbix
├── check_backups.conf
├── check_backups.sh
└── check_backups.xml
├── iostat
├── iostat-collect.sh
├── iostat-parse.sh
├── iostat.conf
└── iostat.xml
├── linux-sockets
├── linux-sockets.xml
├── sockets.conf
├── sockets.sh
└── sockets.xml
├── mongodb
├── mongodb.conf
├── mongodb.py
└── mongodb.sh
├── mysql
└── userparameter_mysql.conf
├── netstat
├── netstat.sh
├── netstat.xml
├── sockets.conf
└── sockets.sh
├── nginx-background
├── nginx-background.conf
├── nginx-background.sh
└── nginx-background.xml
├── nginx
├── nginx.conf
├── nginx.sh
└── nginx.xml
├── php-fpm-multiple-pools
├── fpm-multiple-pools.xml
├── fpm-pool.conf
└── fpm-pool.sh
├── php-fpm
├── fpm.conf
├── fpm.sh
└── fpm.xml
├── redis
├── redis.conf
├── redis.sh
└── redis.xml
└── ssl-checks
├── ssl-checks.xml
├── ssl.conf
├── ssl.pl
└── zabbix-external-check-scripts
└── ssl
/README.md:
--------------------------------------------------------------------------------
1 | zabbix-templates
2 | ================
3 |
4 | Zabbix templates for various services and applications.
5 |
6 |
--------------------------------------------------------------------------------
/aerospike/aerospike.conf:
--------------------------------------------------------------------------------
1 | UserParameter=aerospike[*],/etc/zabbix/scripts/aerospike.sh $1 $2 $3 $4
2 |
--------------------------------------------------------------------------------
/aerospike/aerospike.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | DEFAULT_HOST=127.0.0.1
5 | DEFAULT_PORT=3000
6 | DEFAULT_KEY=objects
7 |
8 |
9 | if [ "$1" != "" ] ; then
10 | DEFAULT_KEY=$1
11 | fi
12 |
13 | if [ "$2" != "" ] ; then
14 | DEFAULT_HOST=$2
15 | fi
16 |
17 | if [ "$3" != "" ] ; then
18 | OPT1=$3
19 | fi
20 |
21 | if [ "$4" != "" ] ; then
22 | OPT2=$4
23 | fi
24 |
25 | down=`asinfo -h $DEFAULT_HOST -p $DEFAULT_PORT -v version | grep error | wc -l`
26 |
27 | if [ "$down" = "1" ] ; then
28 | echo "-1"
29 | exit
30 | fi
31 |
32 |
33 | case "$DEFAULT_KEY" in
34 | sets)
35 | if [ "$OPT1" != "" ] ; then
36 | if [ "$OPT2" = "" ] ;then
37 | OPT2="n_objects"
38 | fi
39 | asinfo -h $DEFAULT_HOST -p $DEFAULT_PORT -v sets -l | grep "set_name=$OPT1:" | grep -oe "$OPT2=[^:]\+" | awk -F= '{print $2}'
40 | else
41 | sets=`asinfo -h $DEFAULT_HOST -p $DEFAULT_PORT -v sets -l | grep -oe 'set_name=[^:]\+' | awk -F= '{print $2}'`
42 | for x in $sets ; do
43 | if [ "$res" != "" ] ; then
44 | res=$res','
45 | fi
46 | res=$res'{"{#SET}":"'$x'"}'
47 | done
48 | echo '{"data":['$res']}'
49 | fi
50 | ;;
51 | keys)
52 | /usr/bin/asinfo -h $DEFAULT_HOST -p $DEFAULT_PORT | head -n 4 | tail -n 1 | tr ';' '\n' | awk -F '=' '{print $1;}' | xargs
53 | ;;
54 | latency)
55 | case $OPT1 in
56 | 8) OPT1='$5' ;;
57 | 64) OPT1='$6' ;;
58 | *) OPT1='$4' ;;
59 | esac
60 | /usr/bin/asmonitor -d /var/lib/zabbix/.asmonitor -e "latency -v reads -h $DEFAULT_HOST -p $DEFAULT_PORT " | grep ":$DEFAULT_PORT" | awk "{print $OPT1}"
61 | ;;
62 | stat_read_latency_gt100 | stat_read_latency_gt250 | stat_read_latency_gt50 | stat_write_latency_gt100 | stat_write_latency_gt250 | stat_write_latency_gt50 )
63 | /usr/bin/asmonitor -h $DEFAULT_HOST -p $DEFAULT_PORT -d /var/lib/zabbix/.asmonitor -e 'stat' | grep "$DEFAULT_KEY" | awk '{print $2}'
64 | ;;
65 | *)
66 | res=`/usr/bin/asinfo -h $DEFAULT_HOST -p $DEFAULT_PORT | head -n 4 | tail -n 1 | tr ';' '\n' | tr -d ' ' | grep "^$DEFAULT_KEY=" | awk -F '=' '{print $2;}'`
67 | if [[ "$res" == "" ]] ; then
68 | res='0'
69 | fi
70 | echo $res
71 | ;;
72 | esac
73 |
--------------------------------------------------------------------------------
/check_backups/buckets.zabbix:
--------------------------------------------------------------------------------
1 | /backups/server1
2 | /backups/server2
3 |
--------------------------------------------------------------------------------
/check_backups/check_backups.conf:
--------------------------------------------------------------------------------
1 | UserParameter=backups[*],/etc/zabbix/scripts/check_backups.sh $1
2 | UserParameter=backups.discovery,/etc/zabbix/scripts/check_backups.sh discovery
3 |
--------------------------------------------------------------------------------
/check_backups/check_backups.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | backup_config=/backups/buckets.zabbix
5 | DIR=.
6 |
7 | if [[ "$1" != "" ]] ; then
8 | DIR=$1
9 | if [[ "$DIR" == "discovery" ]] ; then
10 | for bucket in `cat ` ; do
11 | if [[ "$buckets" != "$backup_config" ]] ; then
12 | buckets=$buckets','
13 | fi
14 | buckets=$buckets'{"{#BUCKET}":"'$bucket'"}'
15 | done
16 | echo '{"data":['$buckets']}'
17 |
18 | exit
19 | fi
20 | fi
21 |
22 | #checks if there are fresh files and each of them is not empty
23 |
24 | last_files=`find $DIR -mtime -2 -exec echo {} \; | grep -ve "^$DIR$"`
25 |
26 | if [[ "$last_files" == "" ]] ; then
27 | echo 1
28 | exit
29 | fi
30 |
31 | for file in $last_files ; do
32 | size=`stat -c%s $file`
33 | if [[ "$size" == "0" ]] ; then
34 | echo 2
35 | exit
36 | fi
37 | done
38 |
39 | echo 0
40 |
--------------------------------------------------------------------------------
/check_backups/check_backups.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 | 2014-06-30T14:17:44Z
5 |
6 |
7 | Linux servers
8 |
9 |
10 |
11 |
12 | Template Backup server
13 | Template Backup server
14 |
15 |
16 | Linux servers
17 |
18 |
19 |
20 |
21 | Backups
22 |
23 |
24 |
25 |
26 |
27 | Backup buckets
28 | 0
29 |
30 |
31 | backups[discovery]
32 | 86400
33 | 0
34 |
35 |
36 | 0
37 |
38 |
39 |
40 |
41 |
42 | 0
43 |
44 |
45 |
46 |
47 |
48 | {#BUCKET}:
49 | 30
50 |
51 |
52 |
53 | Backup bucket {#BUCKET} state
54 | 0
55 |
56 | 0
57 |
58 | backups[{#BUCKET}]
59 | 3600
60 | 90
61 | 365
62 | 0
63 | 3
64 |
65 |
66 | 0
67 |
68 | 0
69 |
70 |
71 | 1
72 |
73 |
74 |
75 | 0
76 | 0
77 |
78 |
79 |
80 |
81 |
82 |
83 | 0
84 |
85 |
86 | Backups
87 |
88 |
89 |
90 | Backup bucket status
91 |
92 |
93 |
94 |
95 |
96 | {Template Backup server:backups[{#BUCKET}].last(0)}>0
97 | Backup bucket {#BUCKET} has some errors
98 |
99 | 0
100 | 2
101 |
102 | 0
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/iostat/iostat-collect.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | SECONDS=$2
4 | TOFILE=$1
5 | IOSTAT="/usr/bin/iostat"
6 |
7 | [[ $# -lt 2 ]] && { echo "FATAL: some parameters not specified"; exit 1; }
8 |
9 | DISK=$($IOSTAT -x 1 $SECONDS | awk 'BEGIN {check=0;} {if(check==1 && $1=="avg-cpu:"){check=0}if(check==1 && $1!=""){print $0}if($1=="Device:"){check=1}}' | tr '\n' '|')
10 | echo $DISK | sed 's/|/\n/g' > $TOFILE
11 | echo 0
12 |
--------------------------------------------------------------------------------
/iostat/iostat-parse.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | NUMBER=0
4 | FROMFILE=$1
5 | DISK=$2
6 | METRIC=$3
7 |
8 | [[ $# -lt 3 ]] && { echo "FATAL: some parameters not specified"; exit 1; }
9 | [[ -f "$FROMFILE" ]] || { echo "FATAL: datafile not found"; exit 1; }
10 |
11 | case "$3" in
12 | "rrqm/s")
13 | NUMBER=2
14 | ;;
15 | "wrqm/s")
16 | NUMBER=3
17 | ;;
18 | "r/s")
19 | NUMBER=4
20 | ;;
21 | "w/s")
22 | NUMBER=5
23 | ;;
24 | "rkb/s")
25 | NUMBER=6
26 | ;;
27 | "wkb/s")
28 | NUMBER=7
29 | ;;
30 | "avgrq-sz")
31 | NUMBER=8
32 | ;;
33 | "avgqu-sz")
34 | NUMBER=9
35 | ;;
36 | "await")
37 | NUMBER=10
38 | ;;
39 | "r_await")
40 | NUMBER=11
41 | ;;
42 | "w_await")
43 | NUMBER=12
44 | ;;
45 | "svctm")
46 | NUMBER=13
47 | ;;
48 | "util")
49 | NUMBER=14
50 | ;;
51 | *) echo ZBX_NOTSUPPORTED; exit 1 ;;
52 | esac
53 |
54 | grep -w $DISK $FROMFILE | tail -n +2 | tr -s ' ' |awk -v N=$NUMBER 'BEGIN {sum=0.0;count=0;} {sum=sum+$N;count=count+1;} END {printf("%.2f\n", sum/count);}'
55 |
--------------------------------------------------------------------------------
/iostat/iostat.conf:
--------------------------------------------------------------------------------
1 | # Disk statistics via iostat (sysstat)
2 | # Attention: Second parameter in iostat.collect must be less than Timeout option in zabbix_agentd.conf
3 | UserParameter=iostat.discovery, iostat -d | awk 'BEGIN {check=0;count=0;array[0]=0;} {if(check==1 && $1 != ""){array[count]=$1;count=count+1;}if($1=="Device:"){check=1;}} END {printf("{\n\t\"data\":[\n");for(i=0;i
2 |
3 | 2.0
4 | 2015-10-12T08:43:54Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template Iostat-Disk-Utilization
13 | Template Iostat-Disk-Utilization
14 |
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | Iostat
23 |
24 |
25 |
26 | -
27 | Iostat: Collect statistics
28 | 0
29 |
30 | 0
31 |
32 | iostat.collect
33 | 60
34 | 7
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 |
60 | 0
61 |
62 |
63 | Iostat
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | Disks discovery
73 | 0
74 |
75 |
76 | iostat.discovery
77 | 3600
78 | 0
79 |
80 |
81 |
82 | 0
83 | 0
84 |
85 | 0
86 |
87 |
88 |
89 |
90 | 0
91 |
92 |
93 |
94 |
95 |
96 |
97 | 0
98 |
99 |
100 |
101 | {#HARDDISK}
102 | ^(xvd|sd|hd|vd)[a-z]
103 | 8
104 | A
105 |
106 |
107 |
108 | 1
109 |
110 |
111 |
112 | Disk {#HARDDISK} average queue size
113 | 0
114 |
115 | 0
116 |
117 | iostat.metric[{#HARDDISK},avgqu-sz]
118 | 60
119 | 7
120 | 365
121 | 0
122 | 0
123 |
124 | req
125 | 0
126 |
127 |
128 | 0
129 | 0
130 |
131 | 0
132 |
133 | 1
134 |
135 |
136 |
137 | 0
138 | 0
139 |
140 |
141 |
142 |
143 |
144 | The average queue length of the requests that were issued to the device.
145 | 0
146 |
147 |
148 | Iostat
149 |
150 |
151 |
152 |
153 |
154 |
155 | Disk {#HARDDISK} average requests size
156 | 0
157 |
158 | 0
159 |
160 | iostat.metric[{#HARDDISK},avgrq-sz]
161 | 60
162 | 7
163 | 365
164 | 0
165 | 0
166 |
167 | sector/request
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 | The average size (in sectors) of the requests that were issued to the device.
188 | 0
189 |
190 |
191 | Iostat
192 |
193 |
194 |
195 |
196 |
197 |
198 | Disk {#HARDDISK} await
199 | 0
200 |
201 | 0
202 |
203 | iostat.metric[{#HARDDISK},await]
204 | 60
205 | 7
206 | 365
207 | 0
208 | 0
209 |
210 | ms
211 | 0
212 |
213 |
214 | 0
215 | 0
216 |
217 | 0
218 |
219 | 1
220 |
221 |
222 |
223 | 0
224 | 0
225 |
226 |
227 |
228 |
229 |
230 | The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
231 | 0
232 |
233 |
234 | Iostat
235 |
236 |
237 |
238 |
239 |
240 |
241 | Disk {#HARDDISK} read await
242 | 0
243 |
244 | 0
245 |
246 | iostat.metric[{#HARDDISK},r_await]
247 | 60
248 | 7
249 | 365
250 | 0
251 | 0
252 |
253 | ms
254 | 0
255 |
256 |
257 | 0
258 | 0
259 |
260 | 0
261 |
262 | 1
263 |
264 |
265 |
266 | 0
267 | 0
268 |
269 |
270 |
271 |
272 |
273 | The average time (in milliseconds) for read requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
274 | 0
275 |
276 |
277 | Iostat
278 |
279 |
280 |
281 |
282 |
283 |
284 | Disk {#HARDDISK} read from device per second
285 | 0
286 |
287 | 0
288 |
289 | iostat.metric[{#HARDDISK},rkb/s]
290 | 60
291 | 7
292 | 365
293 | 0
294 | 0
295 |
296 | kb/s
297 | 0
298 |
299 |
300 | 0
301 | 0
302 |
303 | 0
304 |
305 | 1
306 |
307 |
308 |
309 | 0
310 | 0
311 |
312 |
313 |
314 |
315 |
316 | The number of kbytes read from the device per second
317 | 0
318 |
319 |
320 | Iostat
321 |
322 |
323 |
324 |
325 |
326 |
327 | Disk {#HARDDISK} read operations per second
328 | 0
329 |
330 | 0
331 |
332 | iostat.metric[{#HARDDISK},r/s]
333 | 60
334 | 7
335 | 365
336 | 0
337 | 0
338 |
339 | ops
340 | 0
341 |
342 |
343 | 0
344 | 0
345 |
346 | 0
347 |
348 | 1
349 |
350 |
351 |
352 | 0
353 | 0
354 |
355 |
356 |
357 |
358 |
359 | The number of read requests per second
360 | 0
361 |
362 |
363 | Iostat
364 |
365 |
366 |
367 |
368 |
369 |
370 | Disk {#HARDDISK} read requests merge per second
371 | 0
372 |
373 | 0
374 |
375 | iostat.metric[{#HARDDISK},rrqm/s]
376 | 60
377 | 7
378 | 365
379 | 0
380 | 0
381 |
382 | rps
383 | 0
384 |
385 |
386 | 0
387 | 0
388 |
389 | 0
390 |
391 | 1
392 |
393 |
394 |
395 | 0
396 | 0
397 |
398 |
399 |
400 |
401 |
402 | The number of read requests merged per second that were queued to the hard disk
403 | 0
404 |
405 |
406 | Iostat
407 |
408 |
409 |
410 |
411 |
412 |
413 | Disk {#HARDDISK} utilization
414 | 0
415 |
416 | 0
417 |
418 | iostat.metric[{#HARDDISK},util]
419 | 60
420 | 7
421 | 365
422 | 0
423 | 0
424 |
425 | %
426 | 0
427 |
428 |
429 | 0
430 | 0
431 |
432 | 0
433 |
434 | 1
435 |
436 |
437 |
438 | 0
439 | 0
440 |
441 |
442 |
443 |
444 |
445 | Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.
446 | 0
447 |
448 |
449 | Iostat
450 |
451 |
452 |
453 |
454 |
455 |
456 | Disk {#HARDDISK} write await
457 | 0
458 |
459 | 0
460 |
461 | iostat.metric[{#HARDDISK},w_await]
462 | 60
463 | 7
464 | 365
465 | 0
466 | 0
467 |
468 | ms
469 | 0
470 |
471 |
472 | 0
473 | 0
474 |
475 | 0
476 |
477 | 1
478 |
479 |
480 |
481 | 0
482 | 0
483 |
484 |
485 |
486 |
487 |
488 | The average time (in milliseconds) for write requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
489 | 0
490 |
491 |
492 | Iostat
493 |
494 |
495 |
496 |
497 |
498 |
499 | Disk {#HARDDISK} write operations per second
500 | 0
501 |
502 | 0
503 |
504 | iostat.metric[{#HARDDISK},w/s]
505 | 60
506 | 7
507 | 365
508 | 0
509 | 0
510 |
511 | ops
512 | 0
513 |
514 |
515 | 0
516 | 0
517 |
518 | 0
519 |
520 | 1
521 |
522 |
523 |
524 | 0
525 | 0
526 |
527 |
528 |
529 |
530 |
531 | The number (after merges) of write requests completed per second for the device.
532 | 0
533 |
534 |
535 | Iostat
536 |
537 |
538 |
539 |
540 |
541 |
542 | Disk {#HARDDISK} write requests merge per second
543 | 0
544 |
545 | 0
546 |
547 | iostat.metric[{#HARDDISK},wrqm/s]
548 | 60
549 | 7
550 | 365
551 | 0
552 | 0
553 |
554 | rps
555 | 0
556 |
557 |
558 | 0
559 | 0
560 |
561 | 0
562 |
563 | 1
564 |
565 |
566 |
567 | 0
568 | 0
569 |
570 |
571 |
572 |
573 |
574 | The number of write requests merged per second that were queued to the device.
575 | 0
576 |
577 |
578 | Iostat
579 |
580 |
581 |
582 |
583 |
584 |
585 | Disk {#HARDDISK} written to the device per second
586 | 0
587 |
588 | 0
589 |
590 | iostat.metric[{#HARDDISK},wkb/s]
591 | 60
592 | 7
593 | 365
594 | 0
595 | 0
596 |
597 | kb/s
598 | 0
599 |
600 |
601 | 0
602 | 0
603 |
604 | 0
605 |
606 | 1
607 |
608 |
609 |
610 | 0
611 | 0
612 |
613 |
614 |
615 |
616 |
617 | The number of kilobytes written to the device per second.
618 | 0
619 |
620 |
621 | Iostat
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 | Disk {#HARDDISK} await
632 | 900
633 | 200
634 | 0.0000
635 | 100.0000
636 | 1
637 | 1
638 | 0
639 | 1
640 | 0
641 | 0.0000
642 | 0.0000
643 | 1
644 | 0
645 | 0
646 | 0
647 |
648 |
649 | 0
650 | 0
651 | C80000
652 | 0
653 | 2
654 | 0
655 | -
656 | Template Iostat-Disk-Utilization
657 | iostat.metric[{#HARDDISK},await]
658 |
659 |
660 |
661 | 1
662 | 0
663 | 00C800
664 | 0
665 | 2
666 | 0
667 | -
668 | Template Iostat-Disk-Utilization
669 | iostat.metric[{#HARDDISK},r_await]
670 |
671 |
672 |
673 | 2
674 | 0
675 | 0000C8
676 | 0
677 | 2
678 | 0
679 | -
680 | Template Iostat-Disk-Utilization
681 | iostat.metric[{#HARDDISK},w_await]
682 |
683 |
684 |
685 |
686 |
687 | Disk {#HARDDISK} merges
688 | 900
689 | 200
690 | 0.0000
691 | 100.0000
692 | 1
693 | 1
694 | 0
695 | 1
696 | 0
697 | 0.0000
698 | 0.0000
699 | 1
700 | 0
701 | 0
702 | 0
703 |
704 |
705 | 0
706 | 0
707 | 0000CC
708 | 0
709 | 2
710 | 0
711 | -
712 | Template Iostat-Disk-Utilization
713 | iostat.metric[{#HARDDISK},rrqm/s]
714 |
715 |
716 |
717 | 1
718 | 0
719 | 00CC00
720 | 0
721 | 2
722 | 0
723 | -
724 | Template Iostat-Disk-Utilization
725 | iostat.metric[{#HARDDISK},wrqm/s]
726 |
727 |
728 |
729 |
730 |
731 | Disk {#HARDDISK} queue
732 | 900
733 | 200
734 | 0.0000
735 | 100.0000
736 | 1
737 | 1
738 | 0
739 | 1
740 | 0
741 | 0.0000
742 | 0.0000
743 | 1
744 | 0
745 | 0
746 | 0
747 |
748 |
749 | 0
750 | 0
751 | BB0000
752 | 1
753 | 2
754 | 0
755 | -
756 | Template Iostat-Disk-Utilization
757 | iostat.metric[{#HARDDISK},avgqu-sz]
758 |
759 |
760 |
761 | 1
762 | 0
763 | 0000BB
764 | 0
765 | 2
766 | 0
767 | -
768 | Template Iostat-Disk-Utilization
769 | iostat.metric[{#HARDDISK},avgrq-sz]
770 |
771 |
772 |
773 |
774 |
775 | Disk {#HARDDISK} read and write
776 | 900
777 | 200
778 | 0.0000
779 | 100.0000
780 | 1
781 | 1
782 | 0
783 | 1
784 | 0
785 | 0.0000
786 | 0.0000
787 | 1
788 | 0
789 | 0
790 | 0
791 |
792 |
793 | 1
794 | 0
795 | CC0000
796 | 0
797 | 2
798 | 0
799 | -
800 | Template Iostat-Disk-Utilization
801 | iostat.metric[{#HARDDISK},wkb/s]
802 |
803 |
804 |
805 | 0
806 | 0
807 | 0000CC
808 | 0
809 | 2
810 | 0
811 | -
812 | Template Iostat-Disk-Utilization
813 | iostat.metric[{#HARDDISK},rkb/s]
814 |
815 |
816 |
817 |
818 |
819 | Disk {#HARDDISK} utilization
820 | 900
821 | 200
822 | 0.0000
823 | 100.0000
824 | 1
825 | 1
826 | 0
827 | 1
828 | 0
829 | 0.0000
830 | 90.0000
831 | 0
832 | 0
833 | 0
834 | 0
835 |
836 |
837 | 2
838 | 0
839 | 0000C8
840 | 0
841 | 2
842 | 0
843 | -
844 | Template Iostat-Disk-Utilization
845 | iostat.metric[{#HARDDISK},w/s]
846 |
847 |
848 |
849 | 0
850 | 1
851 | C80000
852 | 1
853 | 2
854 | 0
855 | -
856 | Template Iostat-Disk-Utilization
857 | iostat.metric[{#HARDDISK},util]
858 |
859 |
860 |
861 | 1
862 | 0
863 | 00C800
864 | 0
865 | 2
866 | 0
867 | -
868 | Template Iostat-Disk-Utilization
869 | iostat.metric[{#HARDDISK},r/s]
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 | {Template Iostat-Disk-Utilization:iostat.collect.last(0)}=1
886 | Iostat statistics not collected on {HOSTNAME}
887 |
888 | 0
889 | 2
890 |
891 | 0
892 |
893 |
894 |
895 |
896 |
--------------------------------------------------------------------------------
/linux-sockets/linux-sockets.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 | 2014-12-03T15:48:12Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template Unix sockets status
13 | Template Unix sockets status
14 |
15 |
16 | Templates
17 |
18 |
19 |
20 |
21 | Unix sockets
22 |
23 |
24 |
25 | -
26 | Sockets CLOSE-WAIT
27 | 0
28 |
29 | 0
30 |
31 | sockets[CLOSE-WAIT,{$SOCKET_ADDRESS}]
32 | 60
33 | 90
34 | 365
35 | 0
36 | 3
37 |
38 |
39 | 0
40 |
41 | 0
42 |
43 |
44 | 1
45 |
46 |
47 |
48 | 0
49 | 0
50 |
51 |
52 |
53 |
54 |
55 | Другая сторона (узел-2) переходит в это состояние, отправив, в свою очередь сегмент ACK и продолжает одностороннюю передачу
56 | 0
57 |
58 |
59 | Unix sockets
60 |
61 |
62 |
63 |
64 | -
65 | Sockets CLOSING
66 | 0
67 |
68 | 0
69 |
70 | sockets[CLOSING,{$SOCKET_ADDRESS}]
71 | 60
72 | 90
73 | 365
74 | 0
75 | 3
76 |
77 |
78 | 0
79 |
80 | 0
81 |
82 |
83 | 1
84 |
85 |
86 |
87 | 0
88 | 0
89 |
90 |
91 |
92 |
93 |
94 |
95 | 0
96 |
97 |
98 | Unix sockets
99 |
100 |
101 |
102 |
103 | -
104 | Sockets ESTABLISHED
105 | 0
106 |
107 | 0
108 |
109 | sockets[ESTAB,{$SOCKET_ADDRESS}]
110 | 60
111 | 90
112 | 365
113 | 0
114 | 3
115 |
116 |
117 | 0
118 |
119 | 0
120 |
121 |
122 | 1
123 |
124 |
125 |
126 | 0
127 | 0
128 |
129 |
130 |
131 |
132 |
133 |
134 | 0
135 |
136 |
137 | Unix sockets
138 |
139 |
140 |
141 |
142 | -
143 | Sockets FIN-WAIT-1
144 | 0
145 |
146 | 0
147 |
148 | sockets[FIN-WAIT-1,{$SOCKET_ADDRESS}]
149 | 60
150 | 90
151 | 365
152 | 0
153 | 3
154 |
155 |
156 | 0
157 |
158 | 0
159 |
160 |
161 | 1
162 |
163 |
164 |
165 | 0
166 | 0
167 |
168 |
169 |
170 |
171 |
172 |
173 | 0
174 |
175 |
176 | Unix sockets
177 |
178 |
179 |
180 |
181 | -
182 | Sockets FIN-WAIT-2
183 | 0
184 |
185 | 0
186 |
187 | sockets[FIN-WAIT-2,{$SOCKET_ADDRESS}]
188 | 60
189 | 90
190 | 365
191 | 0
192 | 3
193 |
194 |
195 | 0
196 |
197 | 0
198 |
199 |
200 | 1
201 |
202 |
203 |
204 | 0
205 | 0
206 |
207 |
208 |
209 |
210 |
211 |
212 | 0
213 |
214 |
215 | Unix sockets
216 |
217 |
218 |
219 |
220 | -
221 | Sockets LAST-ACK
222 | 0
223 |
224 | 0
225 |
226 | sockets[LAST-ACK,{$SOCKET_ADDRESS}]
227 | 60
228 | 90
229 | 365
230 | 0
231 | 3
232 |
233 |
234 | 0
235 |
236 | 0
237 |
238 |
239 | 1
240 |
241 |
242 |
243 | 0
244 | 0
245 |
246 |
247 |
248 |
249 |
250 |
251 | 0
252 |
253 |
254 | Unix sockets
255 |
256 |
257 |
258 |
259 | -
260 | Sockets LISTEN
261 | 0
262 |
263 | 0
264 |
265 | sockets[LISTEN,{$SOCKET_ADDRESS}]
266 | 60
267 | 90
268 | 365
269 | 0
270 | 3
271 |
272 |
273 | 0
274 |
275 | 0
276 |
277 |
278 | 1
279 |
280 |
281 |
282 | 0
283 | 0
284 |
285 |
286 |
287 |
288 |
289 |
290 | 0
291 |
292 |
293 | Unix sockets
294 |
295 |
296 |
297 |
298 | -
299 | Sockets SYN-RECV
300 | 0
301 |
302 | 0
303 |
304 | sockets[SYN-RECV,{$SOCKET_ADDRESS}]
305 | 60
306 | 90
307 | 365
308 | 0
309 | 3
310 |
311 |
312 | 0
313 |
314 | 0
315 |
316 |
317 | 1
318 |
319 |
320 |
321 | 0
322 | 0
323 |
324 |
325 |
326 |
327 |
328 |
329 | 0
330 |
331 |
332 | Unix sockets
333 |
334 |
335 |
336 |
337 | -
338 | Sockets SYN-SENT
339 | 0
340 |
341 | 0
342 |
343 | sockets[SYN-SENT,{$SOCKET_ADDRESS}]
344 | 60
345 | 90
346 | 365
347 | 0
348 | 3
349 |
350 |
351 | 0
352 |
353 | 0
354 |
355 |
356 | 1
357 |
358 |
359 |
360 | 0
361 | 0
362 |
363 |
364 |
365 |
366 |
367 |
368 | 0
369 |
370 |
371 | Unix sockets
372 |
373 |
374 |
375 |
376 | -
377 | Sockets TIME-WAIT
378 | 0
379 |
380 | 0
381 |
382 | sockets[TIME-WAIT,{$SOCKET_ADDRESS}]
383 | 60
384 | 90
385 | 365
386 | 0
387 | 3
388 |
389 |
390 | 0
391 |
392 | 0
393 |
394 |
395 | 1
396 |
397 |
398 |
399 | 0
400 | 0
401 |
402 |
403 |
404 |
405 |
406 |
407 | 0
408 |
409 |
410 | Unix sockets
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 | {$SOCKET_ADDRESS}
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 | Unix sockets states
430 | 900
431 | 200
432 | 0.0000
433 | 100.0000
434 | 1
435 | 1
436 | 0
437 | 1
438 | 0
439 | 0.0000
440 | 0.0000
441 | 0
442 | 0
443 | 0
444 | 0
445 |
446 |
447 | 0
448 | 0
449 | 009600
450 | 0
451 | 2
452 | 0
453 | -
454 | Template Unix sockets status
455 | sockets[CLOSE-WAIT,{$SOCKET_ADDRESS}]
456 |
457 |
458 |
459 | 1
460 | 0
461 | 000096
462 | 0
463 | 2
464 | 0
465 | -
466 | Template Unix sockets status
467 | sockets[CLOSING,{$SOCKET_ADDRESS}]
468 |
469 |
470 |
471 | 2
472 | 0
473 | 960096
474 | 0
475 | 2
476 | 0
477 | -
478 | Template Unix sockets status
479 | sockets[FIN-WAIT-1,{$SOCKET_ADDRESS}]
480 |
481 |
482 |
483 | 3
484 | 0
485 | 009696
486 | 0
487 | 2
488 | 0
489 | -
490 | Template Unix sockets status
491 | sockets[FIN-WAIT-2,{$SOCKET_ADDRESS}]
492 |
493 |
494 |
495 | 4
496 | 0
497 | 969600
498 | 0
499 | 2
500 | 0
501 | -
502 | Template Unix sockets status
503 | sockets[LAST-ACK,{$SOCKET_ADDRESS}]
504 |
505 |
506 |
507 | 5
508 | 0
509 | 969696
510 | 0
511 | 2
512 | 0
513 | -
514 | Template Unix sockets status
515 | sockets[LISTEN,{$SOCKET_ADDRESS}]
516 |
517 |
518 |
519 | 6
520 | 0
521 | FF0000
522 | 0
523 | 2
524 | 0
525 | -
526 | Template Unix sockets status
527 | sockets[SYN-RECV,{$SOCKET_ADDRESS}]
528 |
529 |
530 |
531 | 7
532 | 0
533 | 00FF00
534 | 0
535 | 2
536 | 0
537 | -
538 | Template Unix sockets status
539 | sockets[SYN-SENT,{$SOCKET_ADDRESS}]
540 |
541 |
542 |
543 | 8
544 | 0
545 | 0000FF
546 | 0
547 | 2
548 | 0
549 | -
550 | Template Unix sockets status
551 | sockets[TIME-WAIT,{$SOCKET_ADDRESS}]
552 |
553 |
554 |
555 | 9
556 | 0
557 | FF00FF
558 | 0
559 | 2
560 | 0
561 | -
562 | Template Unix sockets status
563 | sockets[ESTAB,{$SOCKET_ADDRESS}]
564 |
565 |
566 |
567 |
568 |
569 |
570 |
--------------------------------------------------------------------------------
/linux-sockets/sockets.conf:
--------------------------------------------------------------------------------
1 | UserParameter=sockets[*],/etc/zabbix/scripts/sockets.sh "$1" "$2"
2 |
--------------------------------------------------------------------------------
/linux-sockets/sockets.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PORT="$2"
4 |
5 | CACHETTL="55" # Время действия кеша в секундах (чуть меньше чем период опроса элементов)
6 | CACHE="/tmp/zabbix-sockets-status.$PORT.cache"
7 |
8 | if [ -s "$CACHE" ]; then
9 | TIMECACHE=`stat -c"%Z" "$CACHE"`
10 | else
11 | TIMECACHE=0
12 | fi
13 |
14 | TIMENOW=`date '+%s'`
15 |
16 | if [ "$(($TIMENOW - $TIMECACHE))" -gt "$CACHETTL" ]; then
17 | if [[ $PORT == "" ]] ; then
18 | ss -na | grep -v State | awk '{print $1;}' | sort | uniq -c > $CACHE
19 | else
20 | ss -na src $PORT | grep -v State | awk '{print $1;}' | sort | uniq -c > $CACHE
21 | fi
22 | fi
23 |
24 | res=`grep "$1" $CACHE | awk '{print $1;}'`
25 | if [[ "$res" == "" ]] ; then
26 | echo 0
27 | else
28 | echo $res
29 | fi
30 |
--------------------------------------------------------------------------------
/mongodb/mongodb.conf:
--------------------------------------------------------------------------------
1 | # mongodb stats
2 | UserParameter=mongodb.zabbix.sender,/etc/zabbix/scripts/mongodb.sh
3 |
--------------------------------------------------------------------------------
/mongodb/mongodb.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """
3 | Date: 03/01/2017
4 | Author: Long Chen
5 | Description: A script to get MongoDB metrics
6 | Requires: MongoClient in python
7 | """
8 |
9 | from calendar import timegm
10 | from time import gmtime
11 |
12 | from pymongo import MongoClient, errors
13 | from sys import exit
14 |
15 | import json
16 |
17 | class MongoDB(object):
18 | """main script class"""
19 | # pylint: disable=too-many-instance-attributes
20 | def __init__(self):
21 | self.mongo_host = "mongo"
22 | self.mongo_port = 27017
23 | self.mongo_db = ["admin", ]
24 | self.mongo_user = None
25 | self.mongo_password = None
26 | self.__conn = None
27 | self.__dbnames = None
28 | self.__metrics = []
29 |
30 | def connect(self):
31 | """Connect to MongoDB"""
32 | if self.__conn is None:
33 | if self.mongo_user is None:
34 | try:
35 | self.__conn = MongoClient('mongodb://%s:%s' %
36 | (self.mongo_host,
37 | self.mongo_port))
38 | except errors.PyMongoError as py_mongo_error:
39 | print('Error in MongoDB connection: %s' %
40 | str(py_mongo_error))
41 | else:
42 | try:
43 | self.__conn = MongoClient('mongodb://%s:%s@%s:%s' %
44 | (self.mongo_user,
45 | self.mongo_password,
46 | self.mongo_host,
47 | self.mongo_port))
48 | except errors.PyMongoError as py_mongo_error:
49 | print('Error in MongoDB connection: %s' %
50 | str(py_mongo_error))
51 |
52 | def add_metrics(self, k, v):
53 | """add each metric to the metrics list"""
54 | dict_metrics = {}
55 | dict_metrics['key'] = k
56 | dict_metrics['value'] = v
57 | self.__metrics.append(dict_metrics)
58 |
59 | def print_metrics(self):
60 | """print out all metrics"""
61 | metrics = self.__metrics
62 | for metric in metrics:
63 | zabbix_item_key = str(metric['key'])
64 | zabbix_item_value = str(metric['value'])
65 | print('- ' + zabbix_item_key + ' ' + zabbix_item_value)
66 |
67 | def get_db_names(self):
68 | """get a list of DB names"""
69 | if self.__conn is None:
70 | self.connect()
71 | db_handler = self.__conn[self.mongo_db[0]]
72 |
73 | master = db_handler.command('isMaster')['ismaster']
74 | dict_metrics = {}
75 | dict_metrics['key'] = 'mongodb.ismaster'
76 | if master:
77 | dict_metrics['value'] = 1
78 | db_names = self.__conn.database_names()
79 | self.__dbnames = db_names
80 | else:
81 | dict_metrics['value'] = 0
82 | self.__metrics.append(dict_metrics)
83 |
84 | def get_mongo_db_lld(self):
85 | """print DB list in json format, to be used for
86 | mongo db discovery in zabbix"""
87 | if self.__dbnames is None:
88 | db_names = self.get_db_names()
89 | else:
90 | db_names = self.__dbnames
91 | dict_metrics = {}
92 | db_list = []
93 | dict_metrics['key'] = 'mongodb.discovery'
94 | dict_metrics['value'] = {"data": db_list}
95 | if db_names is not None:
96 | for db_name in db_names:
97 | dict_lld_metric = {}
98 | dict_lld_metric['{#MONGODBNAME}'] = db_name
99 | db_list.append(dict_lld_metric)
100 | dict_metrics['value'] = '{"data": ' + json.dumps(db_list) + '}'
101 | self.__metrics.insert(0, dict_metrics)
102 |
103 | def get_oplog(self):
104 | """get replica set oplog information"""
105 | if self.__conn is None:
106 | self.connect()
107 | db_handler = self.__conn['local']
108 |
109 | coll = db_handler.oplog.rs
110 |
111 | op_first = (coll.find().sort('$natural', 1).limit(1))
112 | op_last = (coll.find().sort('$natural', -1).limit(1))
113 |
114 | # if host is not a member of replica set, without this check we will
115 | # raise StopIteration as guided in
116 | # http://api.mongodb.com/python/current/api/pymongo/cursor.html
117 |
118 | if op_first.count() > 0 and op_last.count() > 0:
119 | op_fst = (op_first.next())['ts'].time
120 | op_last_st = op_last[0]['ts']
121 | op_lst = (op_last.next())['ts'].time
122 |
123 | status = round(float(op_lst - op_fst), 1)
124 | self.add_metrics('mongodb.oplog', status)
125 |
126 | current_time = timegm(gmtime())
127 | oplog = int(((str(op_last_st).split('('))[1].split(','))[0])
128 | self.add_metrics('mongodb.oplog-sync', (current_time - oplog))
129 |
130 |
131 | def get_maintenance(self):
132 | """get replica set maintenance info"""
133 | if self.__conn is None:
134 | self.connect()
135 | db_handler = self.__conn
136 |
137 | fsync_locked = int(db_handler.is_locked)
138 | self.add_metrics('mongodb.fsync-locked', fsync_locked)
139 |
140 | try:
141 | config = db_handler.admin.command("replSetGetConfig", 1)
142 | connstring = (self.mongo_host + ':' + str(self.mongo_port))
143 | connstrings = list()
144 |
145 | for i in range(0, len(config['config']['members'])):
146 | host = config['config']['members'][i]['host']
147 | connstrings.append(host)
148 |
149 | if connstring in host:
150 | priority = config['config']['members'][i]['priority']
151 | hidden = int(config['config']['members'][i]['hidden'])
152 |
153 | self.add_metrics('mongodb.priority', priority)
154 | self.add_metrics('mongodb.hidden', hidden)
155 | except errors.PyMongoError:
156 | print ('Error while fetching replica set configuration.'
157 | 'Not a member of replica set?')
158 | except UnboundLocalError:
159 | print ('Cannot use this mongo host: must be one of ' + ','.join(connstrings))
160 | exit(1)
161 |
162 | def get_server_status_metrics(self):
163 | """get server status"""
164 | if self.__conn is None:
165 | self.connect()
166 | db_handler = self.__conn[self.mongo_db[0]]
167 | ss = db_handler.command('serverStatus')
168 |
169 | # db info
170 | self.add_metrics('mongodb.version', ss['version'])
171 | self.add_metrics('mongodb.storageEngine', ss['storageEngine']['name'])
172 | self.add_metrics('mongodb.uptime', int(ss['uptime']))
173 | self.add_metrics('mongodb.okstatus', int(ss['ok']))
174 |
175 | # asserts
176 | for k, v in ss['asserts'].items():
177 | self.add_metrics('mongodb.asserts.' + k, v)
178 |
179 | # operations
180 | for k, v in ss['opcounters'].items():
181 | self.add_metrics('mongodb.operation.' + k, v)
182 |
183 | # memory
184 | for k in ['resident', 'virtual', 'mapped', 'mappedWithJournal']:
185 | self.add_metrics('mongodb.memory.' + k, ss['mem'][k])
186 |
187 | # connections
188 | for k, v in ss['connections'].items():
189 | self.add_metrics('mongodb.connection.' + k, v)
190 |
191 | # network
192 | for k, v in ss['network'].items():
193 | self.add_metrics('mongodb.network.' + k, v)
194 |
195 | # extra info
196 | self.add_metrics('mongodb.page.faults',
197 | ss['extra_info']['page_faults'])
198 |
199 | #wired tiger
200 | if ss['storageEngine']['name'] == 'wiredTiger':
201 | self.add_metrics('mongodb.used-cache',
202 | ss['wiredTiger']['cache']
203 | ["bytes currently in the cache"])
204 | self.add_metrics('mongodb.total-cache',
205 | ss['wiredTiger']['cache']
206 | ["maximum bytes configured"])
207 | self.add_metrics('mongodb.dirty-cache',
208 | ss['wiredTiger']['cache']
209 | ["tracked dirty bytes in the cache"])
210 |
211 | # global lock
212 | lock_total_time = ss['globalLock']['totalTime']
213 | self.add_metrics('mongodb.globalLock.totalTime', lock_total_time)
214 | for k, v in ss['globalLock']['currentQueue'].items():
215 | self.add_metrics('mongodb.globalLock.currentQueue.' + k, v)
216 | for k, v in ss['globalLock']['activeClients'].items():
217 | self.add_metrics('mongodb.globalLock.activeClients.' + k, v)
218 |
219 | def get_db_stats_metrics(self):
220 | """get DB stats for each DB"""
221 | if self.__conn is None:
222 | self.connect()
223 | if self.__dbnames is None:
224 | self.get_db_names()
225 | if self.__dbnames is not None:
226 | for mongo_db in self.__dbnames:
227 | db_handler = self.__conn[mongo_db]
228 | dbs = db_handler.command('dbstats')
229 | for k, v in dbs.items():
230 | if k in ['storageSize', 'ok', 'avgObjSize', 'indexes',
231 | 'objects', 'collections', 'fileSize',
232 | 'numExtents', 'dataSize', 'indexSize',
233 | 'nsSizeMB']:
234 | self.add_metrics('mongodb.stats.' + k +
235 | '[' + mongo_db + ']', int(v))
236 | def close(self):
237 | """close connection to mongo"""
238 | if self.__conn is not None:
239 | self.__conn.close()
240 |
241 | if __name__ == '__main__':
242 | mongodb = MongoDB()
243 | mongodb.get_db_names()
244 | mongodb.get_mongo_db_lld()
245 | mongodb.get_oplog()
246 | mongodb.get_maintenance()
247 | mongodb.get_server_status_metrics()
248 | mongodb.get_db_stats_metrics()
249 | mongodb.print_metrics()
250 | mongodb.close()
251 |
--------------------------------------------------------------------------------
/mongodb/mongodb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Date: 22/01/2017
4 | # Author: Long Chen
5 | # Description: A script to send MongoDB stats to zabbix server by using zabbix sender
6 | # Requires: Zabbix Sender, zabbix-mongodb.py
7 |
8 | get_MongoDB_metrics(){
9 | python /etc/zabbix/scripts/mongodb.py
10 | }
11 |
12 | # Send the results to zabbix server by using zabbix sender
13 | result=$(get_MongoDB_metrics | /usr/bin/zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -i - 2>&1)
14 | response=$(echo "$result" | awk -F ';' '$1 ~ /^info/ && match($1,/[0-9].*$/) {sum+=substr($1,RSTART,RLENGTH)} END {print sum}')
15 | if [ -n "$response" ]; then
16 | echo "$response"
17 | else
18 | echo "$result"
19 | fi
20 |
--------------------------------------------------------------------------------
/mysql/userparameter_mysql.conf:
--------------------------------------------------------------------------------
1 | # For all the following commands HOME should be set to the directory that has .my.cnf file with password information.
2 |
3 | # Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
4 | # Key syntax is mysql.status[variable].
5 | UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uzabbix-agent -p7yNPKc9nLCXsv8R8 -N | awk '{print $$2}'
6 |
7 | # Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].
8 | # Key syntax is mysql.size[,,].
9 | # Database may be a database name or "all". Default is "all".
10 | # Table may be a table name or "all". Default is "all".
11 | # Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".
12 | # Database is mandatory if a table is specified. Type may be specified always.
13 | # Returns value in bytes.
14 | # 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
15 | UserParameter=mysql.size[*],echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema='$1'")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name='$2'");" | HOME=/var/lib/zabbix mysql -N
16 |
17 | UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin -uzabbix-agent -pPASSWORD_HERE ping | grep -c alive
18 | UserParameter=mysql.version,mysql -V
19 |
--------------------------------------------------------------------------------
/netstat/netstat.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | CACHETTL="55" # Время действия кеша в секундах (чуть меньше чем период опроса элементов)
5 | CACHE="/tmp/zabbix-netstat-status.cache"
6 |
7 | if [ -s "$CACHE" ]; then
8 | TIMECACHE=`stat -c"%Z" "$CACHE"`
9 | else
10 | TIMECACHE=0
11 | fi
12 |
13 | TIMENOW=`date '+%s'`
14 |
15 | if [ "$(($TIMENOW - $TIMECACHE))" -gt "$CACHETTL" ]; then
16 | netstat -s > $CACHE
17 | fi
18 |
19 | if [[ "$1" == "" ]] ; then
20 | grep -e '[0-9]' $CACHE | sed 's/[0-9][0-9]*//g' | sed 's/\s\+/ /g' | sed 's/^ //' | grep -v :
21 | exit
22 | fi
23 |
24 | res=`grep "$1" $CACHE | sed 's/[^0-9]*[^0-9-]\(-\?[0-9]\+\).*/\1/g' | head -n 1`
25 | if [[ "$res" == "" ]] ; then
26 | echo 0
27 | else
28 | echo $res
29 | fi
30 |
31 |
--------------------------------------------------------------------------------
/netstat/sockets.conf:
--------------------------------------------------------------------------------
1 | UserParameter=sockets[*],/etc/zabbix/scripts/sockets.sh "$1" "$2"
2 | UserParameter=netstat[*],/etc/zabbix/scripts/netstat.sh "$1"
3 |
--------------------------------------------------------------------------------
/netstat/sockets.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PORT="$2"
4 |
5 | CACHETTL="55" # Время действия кеша в секундах (чуть меньше чем период опроса элементов)
6 | CACHE="/tmp/zabbix-sockets-status.$PORT.cache"
7 |
8 | if [ -s "$CACHE" ]; then
9 | TIMECACHE=`stat -c"%Z" "$CACHE"`
10 | else
11 | TIMECACHE=0
12 | fi
13 |
14 | TIMENOW=`date '+%s'`
15 |
16 | if [ "$(($TIMENOW - $TIMECACHE))" -gt "$CACHETTL" ]; then
17 | if [[ $PORT == "" ]] ; then
18 | ss -na | grep -v State | grep -v LISTEN | awk '{print $1;}' | sort | uniq -c > $CACHE
19 | else
20 | ss -na src $PORT | grep -v State | awk '{print $1;}' | sort | uniq -c > $CACHE
21 | fi
22 | fi
23 |
24 | res=`grep "$1" $CACHE | awk '{print $1;}'`
25 | if [[ "$res" == "" ]] ; then
26 | echo 0
27 | else
28 | echo $res
29 | fi
30 |
--------------------------------------------------------------------------------
/nginx-background/nginx-background.conf:
--------------------------------------------------------------------------------
1 | UserParameter=nginx-background[*],/etc/zabbix/scripts/nginx-background.sh "$1" "$2"
2 |
--------------------------------------------------------------------------------
/nginx-background/nginx-background.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##################################
3 | # Zabbix monitoring script
4 | #
5 | # nginx:
6 | # - anything available via nginx stub-status module
7 | #
8 | ##################################
9 | # Contact:
10 | # vincent.viallet@gmail.com
11 | ##################################
12 | # ChangeLog:
13 | # 20100922 VV initial creation
14 | ##################################
15 |
16 | # Zabbix requested parameter
17 | ZBX_REQ_DATA="$1"
18 | ZBX_REQ_DATA_URL="$2"
19 |
20 | # Nginx defaults
21 | NGINX_STATUS_DEFAULT_URL="http://localhost:80/fpm/inner_nginx1"
22 | WGET_BIN="/usr/bin/wget"
23 |
24 | #
25 | # Error handling:
26 | # - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
27 | # - items need to be of type "float" (allow negative + float)
28 | #
29 | ERROR_NO_ACCESS_FILE="-0.9900"
30 | ERROR_NO_ACCESS="-0.9901"
31 | ERROR_WRONG_PARAM="-0.9902"
32 | ERROR_DATA="-0.9903" # either can not connect / bad host / bad port
33 |
34 | # Handle host and port if non-default
35 | if [ ! -z "$ZBX_REQ_DATA_URL" ]; then
36 | URL="$ZBX_REQ_DATA_URL"
37 | else
38 | URL="$NGINX_STATUS_DEFAULT_URL"
39 | fi
40 |
41 | # save the nginx stats in a variable for future parsing
42 | NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null)
43 |
44 | # error during retrieve
45 | if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then
46 | echo $ERROR_DATA
47 | exit 1
48 | fi
49 |
50 | #
51 | # Extract data from nginx stats
52 | #
53 | case $ZBX_REQ_DATA in
54 | active_connections) echo "$NGINX_STATS" | head -1 | cut -f3 -d' ';;
55 | accepted_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f2 -d' ';;
56 | handled_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f3 -d' ';;
57 | handled_requests) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f4 -d' ';;
58 | reading) echo "$NGINX_STATS" | tail -1 | cut -f2 -d' ';;
59 | writing) echo "$NGINX_STATS" | tail -1 | cut -f4 -d' ';;
60 | waiting) echo "$NGINX_STATS" | tail -1 | cut -f6 -d' ';;
61 | failed_connections)
62 | one=`echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f2 -d' '`
63 | two=`echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f3 -d' '`
64 | let a=$one-$two
65 | echo $a
66 | ;;
67 | *) echo $ERROR_WRONG_PARAM; exit 1;;
68 | esac
69 |
70 | exit 0
71 |
--------------------------------------------------------------------------------
/nginx-background/nginx-background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 | 2015-10-12T08:45:56Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template Nginx-Background
13 | Template Nginx-Background
14 |
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | Nginx-Background
23 |
24 |
25 |
26 | -
27 | Nginx $1
28 | 0
29 |
30 | 0
31 |
32 | nginx-background[waiting,{$NGINX_BACKGROUND_STATUS_URL}]
33 | 60
34 | 30
35 | 365
36 | 0
37 | 0
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 |
60 | 0
61 |
62 |
63 | Nginx-Background
64 |
65 |
66 |
67 |
68 |
69 | -
70 | Nginx $1
71 | 0
72 |
73 | 0
74 |
75 | nginx-background[writing,{$NGINX_BACKGROUND_STATUS_URL}]
76 | 60
77 | 30
78 | 365
79 | 0
80 | 0
81 |
82 |
83 | 0
84 |
85 |
86 | 0
87 | 0
88 |
89 | 0
90 |
91 | 1
92 |
93 |
94 |
95 | 0
96 | 0
97 |
98 |
99 |
100 |
101 |
102 |
103 | 0
104 |
105 |
106 | Nginx-Background
107 |
108 |
109 |
110 |
111 |
112 | -
113 | Nginx $1
114 | 0
115 |
116 | 0
117 |
118 | nginx-background[active_connections,{$NGINX_BACKGROUND_STATUS_URL}]
119 | 60
120 | 30
121 | 365
122 | 0
123 | 0
124 |
125 |
126 | 0
127 |
128 |
129 | 0
130 | 0
131 |
132 | 0
133 |
134 | 1
135 |
136 |
137 |
138 | 0
139 | 0
140 |
141 |
142 |
143 |
144 |
145 |
146 | 0
147 |
148 |
149 | Nginx-Background
150 |
151 |
152 |
153 |
154 |
155 | -
156 | Nginx $1
157 | 0
158 |
159 | 0
160 |
161 | nginx-background[reading,{$NGINX_BACKGROUND_STATUS_URL}]
162 | 60
163 | 30
164 | 365
165 | 0
166 | 0
167 |
168 |
169 | 0
170 |
171 |
172 | 0
173 | 0
174 |
175 | 0
176 |
177 | 1
178 |
179 |
180 |
181 | 0
182 | 0
183 |
184 |
185 |
186 |
187 |
188 |
189 | 0
190 |
191 |
192 | Nginx-Background
193 |
194 |
195 |
196 |
197 |
198 | -
199 | Nginx $1/sec
200 | 0
201 |
202 | 0
203 |
204 | nginx-background[handled_connections,{$NGINX_BACKGROUND_STATUS_URL}]
205 | 60
206 | 30
207 | 365
208 | 0
209 | 0
210 |
211 |
212 | 1
213 |
214 |
215 | 0
216 | 0
217 |
218 | 0
219 |
220 | 1
221 |
222 |
223 |
224 | 0
225 | 0
226 |
227 |
228 |
229 |
230 |
231 |
232 | 0
233 |
234 |
235 | Nginx-Background
236 |
237 |
238 |
239 |
240 |
241 | -
242 | Nginx $1/sec
243 | 0
244 |
245 | 0
246 |
247 | nginx-background[handled_requests,{$NGINX_BACKGROUND_STATUS_URL}]
248 | 60
249 | 30
250 | 365
251 | 0
252 | 0
253 |
254 |
255 | 1
256 |
257 |
258 | 0
259 | 0
260 |
261 | 0
262 |
263 | 1
264 |
265 |
266 |
267 | 0
268 | 0
269 |
270 |
271 |
272 |
273 |
274 |
275 | 0
276 |
277 |
278 | Nginx-Background
279 |
280 |
281 |
282 |
283 |
284 | -
285 | Nginx $1/sec
286 | 0
287 |
288 | 0
289 |
290 | nginx-background[accepted_connections,{$NGINX_BACKGROUND_STATUS_URL}]
291 | 60
292 | 30
293 | 365
294 | 0
295 | 0
296 |
297 |
298 | 1
299 |
300 |
301 | 0
302 | 0
303 |
304 | 0
305 |
306 | 1
307 |
308 |
309 |
310 | 0
311 | 0
312 |
313 |
314 |
315 |
316 |
317 |
318 | 0
319 |
320 |
321 | Nginx-Background
322 |
323 |
324 |
325 |
326 |
327 | -
328 | Nginx failed connections
329 | 0
330 |
331 | 0
332 |
333 | nginx-background[failed_connections,{$NGINX_BACKGROUND_STATUS_URL}]
334 | 60
335 | 90
336 | 365
337 | 0
338 | 3
339 |
340 |
341 | 1
342 |
343 |
344 | 0
345 | 0
346 |
347 | 0
348 |
349 | 1
350 |
351 |
352 |
353 | 0
354 | 0
355 |
356 |
357 |
358 |
359 |
360 |
361 | 0
362 |
363 |
364 | Nginx-Background
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 | {$NGINX_BACKGROUND_STATUS_URL}
375 | http://127.0.0.1/nginx_status
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 | {Template Nginx-Background:nginx-background[failed_connections,{$NGINX_BACKGROUND_STATUS_URL}].last(0)}>0
385 | Not enough NGINX {HOSTNAME} workers
386 |
387 | 0
388 | 3
389 |
390 | 0
391 |
392 |
393 |
394 |
395 |
396 | Nginx-Background - Connections and Requests status
397 | 900
398 | 200
399 | 0.0000
400 | 100.0000
401 | 0
402 | 0
403 | 0
404 | 1
405 | 0
406 | 0.0000
407 | 0.0000
408 | 1
409 | 0
410 | 0
411 | 0
412 |
413 |
414 | 0
415 | 1
416 | FF9999
417 | 0
418 | 4
419 | 0
420 | -
421 | Template Nginx-Background
422 | nginx-background[accepted_connections,{$NGINX_BACKGROUND_STATUS_URL}]
423 |
424 |
425 |
426 | 1
427 | 2
428 | 990000
429 | 0
430 | 4
431 | 0
432 | -
433 | Template Nginx-Background
434 | nginx-background[handled_connections,{$NGINX_BACKGROUND_STATUS_URL}]
435 |
436 |
437 |
438 | 2
439 | 0
440 | 009900
441 | 0
442 | 4
443 | 0
444 | -
445 | Template Nginx-Background
446 | nginx-background[handled_requests,{$NGINX_BACKGROUND_STATUS_URL}]
447 |
448 |
449 |
450 |
451 |
452 | Nginx-Background - Threads status
453 | 900
454 | 200
455 | 0.0000
456 | 100.0000
457 | 0
458 | 0
459 | 1
460 | 1
461 | 0
462 | 0.0000
463 | 0.0000
464 | 1
465 | 0
466 | 0
467 | 0
468 |
469 |
470 | 0
471 | 5
472 | 990000
473 | 0
474 | 4
475 | 0
476 | -
477 | Template Nginx-Background
478 | nginx-background[writing,{$NGINX_BACKGROUND_STATUS_URL}]
479 |
480 |
481 |
482 | 1
483 | 5
484 | 999900
485 | 0
486 | 4
487 | 0
488 | -
489 | Template Nginx-Background
490 | nginx-background[reading,{$NGINX_BACKGROUND_STATUS_URL}]
491 |
492 |
493 |
494 | 2
495 | 5
496 | 009900
497 | 0
498 | 4
499 | 0
500 | -
501 | Template Nginx-Background
502 | nginx-background[waiting,{$NGINX_BACKGROUND_STATUS_URL}]
503 |
504 |
505 |
506 |
507 |
508 |
509 |
--------------------------------------------------------------------------------
/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | UserParameter=nginx[*],/etc/zabbix/scripts/nginx.sh "$1" "$2"
2 |
--------------------------------------------------------------------------------
/nginx/nginx.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##################################
3 | # Zabbix monitoring script
4 | #
5 | # nginx:
6 | # - anything available via nginx stub-status module
7 | #
8 | ##################################
9 | # Contact:
10 | # vincent.viallet@gmail.com
11 | ##################################
12 | # ChangeLog:
13 | # 20100922 VV initial creation
14 | ##################################
15 |
16 | # Zabbix requested parameter
17 | ZBX_REQ_DATA="$1"
18 | ZBX_REQ_DATA_URL="$2"
19 |
20 | # Nginx defaults
21 | NGINX_STATUS_DEFAULT_URL="http://127.0.0.1/status"
22 | WGET_BIN="/usr/bin/wget"
23 |
24 | #
25 | # Error handling:
26 | # - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
27 | # - items need to be of type "float" (allow negative + float)
28 | #
29 | ERROR_NO_ACCESS_FILE="-0.9"
30 | ERROR_NO_ACCESS="-0.91"
31 | ERROR_WRONG_PARAM="-0.92"
32 | ERROR_DATA="-0.93" # either can not connect / bad host / bad port
33 |
34 | # Handle host and port if non-default
35 | if [ ! -z "$ZBX_REQ_DATA_URL" ]; then
36 | URL="$ZBX_REQ_DATA_URL"
37 | else
38 | URL="$NGINX_STATUS_DEFAULT_URL"
39 | fi
40 |
41 | # save the nginx stats in a variable for future parsing
42 | NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null)
43 |
44 | # error during retrieve
45 | if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then
46 | echo $ERROR_DATA
47 | exit 1
48 | fi
49 |
50 | #
51 | # Extract data from nginx stats
52 | #
53 | case $ZBX_REQ_DATA in
54 | active_connections) echo "$NGINX_STATS" | head -1 | cut -f3 -d' ';;
55 | accepted_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f2 -d' ';;
56 | handled_connections) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f3 -d' ';;
57 | handled_requests) echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f4 -d' ';;
58 | reading) echo "$NGINX_STATS" | tail -1 | cut -f2 -d' ';;
59 | writing) echo "$NGINX_STATS" | tail -1 | cut -f4 -d' ';;
60 | waiting) echo "$NGINX_STATS" | tail -1 | cut -f6 -d' ';;
61 | failed_connections)
62 | one=`echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f2 -d' '`
63 | two=`echo "$NGINX_STATS" | grep -Ev '[a-zA-Z]' | cut -f3 -d' '`
64 | let a=$one-$two
65 | echo $a
66 | ;;
67 | *) echo $ERROR_WRONG_PARAM; exit 1;;
68 | esac
69 |
70 | exit 0
71 |
--------------------------------------------------------------------------------
/nginx/nginx.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 | 2014-04-07T13:19:36Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template Nginx
13 | Template Nginx
14 |
15 |
16 | Templates
17 |
18 |
19 |
20 |
21 | Nginx
22 |
23 |
24 |
25 | -
26 | Nginx $1
27 | 0
28 |
29 | 0
30 |
31 | nginx[waiting,{$NGINX_STATUS_URL}]
32 | 60
33 | 30
34 | 365
35 | 0
36 | 0
37 |
38 |
39 | 0
40 |
41 | 0
42 |
43 |
44 | 1
45 |
46 |
47 |
48 | 0
49 | 0
50 |
51 |
52 |
53 |
54 |
55 |
56 | 0
57 |
58 |
59 | Nginx
60 |
61 |
62 |
63 |
64 | -
65 | Nginx $1
66 | 0
67 |
68 | 0
69 |
70 | nginx[writing,{$NGINX_STATUS_URL}]
71 | 60
72 | 30
73 | 365
74 | 0
75 | 0
76 |
77 |
78 | 0
79 |
80 | 0
81 |
82 |
83 | 1
84 |
85 |
86 |
87 | 0
88 | 0
89 |
90 |
91 |
92 |
93 |
94 |
95 | 0
96 |
97 |
98 | Nginx
99 |
100 |
101 |
102 |
103 | -
104 | Nginx $1
105 | 0
106 |
107 | 0
108 |
109 | nginx[active_connections,{$NGINX_STATUS_URL}]
110 | 60
111 | 30
112 | 365
113 | 0
114 | 0
115 |
116 |
117 | 0
118 |
119 | 0
120 |
121 |
122 | 1
123 |
124 |
125 |
126 | 0
127 | 0
128 |
129 |
130 |
131 |
132 |
133 |
134 | 0
135 |
136 |
137 | Nginx
138 |
139 |
140 |
141 |
142 | -
143 | Nginx $1
144 | 0
145 |
146 | 0
147 |
148 | nginx[reading,{$NGINX_STATUS_URL}]
149 | 60
150 | 30
151 | 365
152 | 0
153 | 0
154 |
155 |
156 | 0
157 |
158 | 0
159 |
160 |
161 | 1
162 |
163 |
164 |
165 | 0
166 | 0
167 |
168 |
169 |
170 |
171 |
172 |
173 | 0
174 |
175 |
176 | Nginx
177 |
178 |
179 |
180 |
181 | -
182 | Nginx $1/sec
183 | 0
184 |
185 | 0
186 |
187 | nginx[handled_requests,{$NGINX_STATUS_URL}]
188 | 60
189 | 30
190 | 365
191 | 0
192 | 0
193 |
194 |
195 | 1
196 |
197 | 0
198 |
199 |
200 | 1
201 |
202 |
203 |
204 | 0
205 | 0
206 |
207 |
208 |
209 |
210 |
211 |
212 | 0
213 |
214 |
215 | Nginx
216 |
217 |
218 |
219 |
220 | -
221 | Nginx $1/sec
222 | 0
223 |
224 | 0
225 |
226 | nginx[accepted_connections,{$NGINX_STATUS_URL}]
227 | 60
228 | 30
229 | 365
230 | 0
231 | 0
232 |
233 |
234 | 1
235 |
236 | 0
237 |
238 |
239 | 1
240 |
241 |
242 |
243 | 0
244 | 0
245 |
246 |
247 |
248 |
249 |
250 |
251 | 0
252 |
253 |
254 | Nginx
255 |
256 |
257 |
258 |
259 | -
260 | Nginx $1/sec
261 | 0
262 |
263 | 0
264 |
265 | nginx[handled_connections,{$NGINX_STATUS_URL}]
266 | 60
267 | 30
268 | 365
269 | 0
270 | 0
271 |
272 |
273 | 1
274 |
275 | 0
276 |
277 |
278 | 1
279 |
280 |
281 |
282 | 0
283 | 0
284 |
285 |
286 |
287 |
288 |
289 |
290 | 0
291 |
292 |
293 | Nginx
294 |
295 |
296 |
297 |
298 | -
299 | Nginx failed connections
300 | 0
301 |
302 | 0
303 |
304 | nginx[failed_connections,{$NGINX_STATUS_URL}]
305 | 60
306 | 90
307 | 365
308 | 0
309 | 3
310 |
311 |
312 | 1
313 |
314 | 0
315 |
316 |
317 | 1
318 |
319 |
320 |
321 | 0
322 | 0
323 |
324 |
325 |
326 |
327 |
328 |
329 | 0
330 |
331 |
332 | Nginx
333 |
334 |
335 |
336 |
337 | -
338 | Number of $1 process
339 | 0
340 |
341 | 0
342 |
343 | proc.num[nginx]
344 | 300
345 | 30
346 | 365
347 | 0
348 | 3
349 |
350 |
351 | 0
352 |
353 | 0
354 |
355 |
356 | 1
357 |
358 |
359 |
360 | 0
361 | 0
362 |
363 |
364 |
365 |
366 |
367 |
368 | 0
369 |
370 |
371 | Nginx
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 | {$NGINX_STATUS_URL}
381 | http://127.0.0.1:10061/nginx_status
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 | {Template Nginx:proc.num[nginx].last(0)}=0
391 | Nginx is not running on {HOSTNAME}
392 |
393 | 0
394 | 5
395 | Nginx is not running.
396 |
397 | It has been stopped / shutdown or has crashed.
398 | Check on the server for more details:
399 | - w / last
400 | - dmesg logs
401 | - /var/log/messages
402 | - nginx error logs
403 | 0
404 |
405 |
406 |
407 | {Template Nginx:nginx[failed_connections,{$NGINX_STATUS_URL}].last(0)}>0
408 | Not enough NGINX {HOSTNAME} workers
409 |
410 | 0
411 | 3
412 |
413 | 0
414 |
415 |
416 |
417 |
418 |
419 | Nginx - Connections and Requests status
420 | 900
421 | 200
422 | 0.0000
423 | 100.0000
424 | 0
425 | 0
426 | 0
427 | 1
428 | 0
429 | 0.0000
430 | 0.0000
431 | 1
432 | 0
433 | 0
434 | 0
435 |
436 |
437 | 0
438 | 1
439 | FF9999
440 | 0
441 | 4
442 | 0
443 | -
444 | Template Nginx
445 | nginx[accepted_connections,{$NGINX_STATUS_URL}]
446 |
447 |
448 |
449 | 1
450 | 2
451 | 990000
452 | 0
453 | 4
454 | 0
455 | -
456 | Template Nginx
457 | nginx[handled_connections,{$NGINX_STATUS_URL}]
458 |
459 |
460 |
461 | 2
462 | 0
463 | 009900
464 | 0
465 | 4
466 | 0
467 | -
468 | Template Nginx
469 | nginx[handled_requests,{$NGINX_STATUS_URL}]
470 |
471 |
472 |
473 |
474 |
475 | Nginx - Threads status
476 | 900
477 | 200
478 | 0.0000
479 | 100.0000
480 | 0
481 | 0
482 | 1
483 | 1
484 | 0
485 | 0.0000
486 | 0.0000
487 | 1
488 | 0
489 | 0
490 | 0
491 |
492 |
493 | 0
494 | 1
495 | 990000
496 | 0
497 | 4
498 | 0
499 | -
500 | Template Nginx
501 | nginx[writing,{$NGINX_STATUS_URL}]
502 |
503 |
504 |
505 | 1
506 | 1
507 | 999900
508 | 0
509 | 4
510 | 0
511 | -
512 | Template Nginx
513 | nginx[reading,{$NGINX_STATUS_URL}]
514 |
515 |
516 |
517 | 2
518 | 1
519 | 009900
520 | 0
521 | 4
522 | 0
523 | -
524 | Template Nginx
525 | nginx[waiting,{$NGINX_STATUS_URL}]
526 |
527 |
528 |
529 |
530 |
531 |
532 |
--------------------------------------------------------------------------------
/php-fpm-multiple-pools/fpm-multiple-pools.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3.4
4 | 2018-12-20T12:56:52Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template php-fpm pools
13 | Template php-fpm pools
14 |
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | php-fpm
23 |
24 |
25 |
26 | -
27 | Total fpm memory usage
28 | 0
29 |
30 |
31 | proc.mem[php5-fpm,,sum]
32 | 30s
33 | 1w
34 | 365d
35 | 0
36 | 3
37 |
38 | b
39 |
40 |
41 | 0
42 | 0
43 |
44 | 0
45 |
46 |
47 |
48 | 0
49 |
50 |
51 |
52 |
53 |
54 |
55 | 0
56 |
57 |
58 | php-fpm
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | -
68 | Total fpm processes
69 | 0
70 |
71 |
72 | proc.num[php5-fpm]
73 | 1m
74 | 1w
75 | 365d
76 | 0
77 | 3
78 |
79 |
80 |
81 |
82 | 0
83 | 0
84 |
85 | 0
86 |
87 |
88 |
89 | 0
90 |
91 |
92 |
93 |
94 |
95 |
96 | 0
97 |
98 |
99 | php-fpm
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | PHP FPM pools
112 | 0
113 |
114 |
115 | php-fpm-pool[discovery]
116 | 1h
117 | 0
118 |
119 |
120 |
121 | 0
122 | 0
123 |
124 | 0
125 |
126 |
127 |
128 | 0
129 |
130 |
131 |
132 |
133 |
134 |
135 | 0
136 |
137 |
138 |
139 | 30d
140 |
141 |
142 |
143 | {#POOL} $1/sec
144 | 0
145 |
146 |
147 | php-fpm-pool["accepted conn","{#STATUS}"]
148 | 1m
149 | 90d
150 | 365d
151 | 0
152 | 0
153 |
154 |
155 |
156 |
157 | 0
158 | 0
159 |
160 | 0
161 |
162 |
163 |
164 | 0
165 |
166 |
167 |
168 |
169 |
170 |
171 | 0
172 |
173 |
174 | php-fpm
175 |
176 |
177 |
178 |
179 |
180 |
181 | 10
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | {#POOL} $1
191 | 0
192 |
193 |
194 | php-fpm-pool["active processes","{#STATUS}"]
195 | 1m
196 | 90d
197 | 365d
198 | 0
199 | 0
200 |
201 |
202 |
203 |
204 | 0
205 | 0
206 |
207 | 0
208 |
209 |
210 |
211 | 0
212 |
213 |
214 |
215 |
216 |
217 |
218 | 0
219 |
220 |
221 | php-fpm
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 | {#POOL} $1
233 | 0
234 |
235 |
236 | php-fpm-pool["idle processes","{#STATUS}"]
237 | 1m
238 | 90d
239 | 365d
240 | 0
241 | 0
242 |
243 |
244 |
245 |
246 | 0
247 | 0
248 |
249 | 0
250 |
251 |
252 |
253 | 0
254 |
255 |
256 |
257 |
258 |
259 |
260 | 0
261 |
262 |
263 | php-fpm
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 | {#POOL} $1
275 | 0
276 |
277 |
278 | php-fpm-pool["listen queue","{#STATUS}"]
279 | 1m
280 | 90d
281 | 365d
282 | 0
283 | 0
284 |
285 |
286 |
287 |
288 | 0
289 | 0
290 |
291 | 0
292 |
293 |
294 |
295 | 0
296 |
297 |
298 |
299 |
300 |
301 |
302 | 0
303 |
304 |
305 | php-fpm
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 | {#POOL} $1
317 | 0
318 |
319 |
320 | php-fpm-pool["listen queue len","{#STATUS}"]
321 | 1m
322 | 90d
323 | 365d
324 | 0
325 | 0
326 |
327 |
328 |
329 |
330 | 0
331 | 0
332 |
333 | 0
334 |
335 |
336 |
337 | 0
338 |
339 |
340 |
341 |
342 |
343 |
344 | 0
345 |
346 |
347 | php-fpm
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 | {#POOL} $1
359 | 0
360 |
361 |
362 | php-fpm-pool["max children reached","{#STATUS}"]
363 | 1m
364 | 90d
365 | 365d
366 | 0
367 | 0
368 |
369 |
370 |
371 |
372 | 0
373 | 0
374 |
375 | 0
376 |
377 |
378 |
379 | 0
380 |
381 |
382 |
383 |
384 |
385 |
386 | 0
387 |
388 |
389 | php-fpm
390 |
391 |
392 |
393 |
394 |
395 |
396 | 9
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 | {#POOL} $1
406 | 0
407 |
408 |
409 | php-fpm-pool["slow requests","{#STATUS}"]
410 | 1m
411 | 90d
412 | 365d
413 | 0
414 | 0
415 |
416 |
417 |
418 |
419 | 0
420 | 0
421 |
422 | 0
423 |
424 |
425 |
426 | 0
427 |
428 |
429 |
430 |
431 |
432 |
433 | 0
434 |
435 |
436 | php-fpm
437 |
438 |
439 |
440 |
441 |
442 |
443 | 10
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 | {#POOL} $1
453 | 0
454 |
455 |
456 | php-fpm-pool["total processes","{#STATUS}"]
457 | 1m
458 | 90d
459 | 365d
460 | 0
461 | 0
462 |
463 |
464 |
465 |
466 | 0
467 | 0
468 |
469 | 0
470 |
471 |
472 |
473 | 0
474 |
475 |
476 |
477 |
478 |
479 |
480 | 0
481 |
482 |
483 | php-fpm
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 | {#POOL} Processor usage
495 | 0
496 |
497 |
498 | proc.cpu.util[,"{#POOL}"]
499 | 1m
500 | 14d
501 | 365d
502 | 0
503 | 0
504 |
505 |
506 |
507 |
508 | 0
509 | 0
510 |
511 | 0
512 |
513 |
514 |
515 | 0
516 |
517 |
518 |
519 |
520 |
521 |
522 | 0
523 |
524 |
525 | php-fpm
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 | {Template php-fpm pools:php-fpm-pool["max children reached","{#STATUS}"].last()}<>0
539 | 0
540 |
541 | Not enough workers for php-fpm pool {#POOL} at
542 | 0
543 |
544 |
545 | 0
546 | 2
547 |
548 | 0
549 | 0
550 |
551 |
552 |
553 |
554 | {Template php-fpm pools:php-fpm-pool["active processes","{#STATUS}"].last(0)}<0
555 | 0
556 |
557 | PHP-fpm pool {#POOL} of {HOSTNAME} is down
558 | 0
559 |
560 |
561 | 0
562 | 5
563 |
564 | 0
565 | 0
566 |
567 |
568 |
569 |
570 |
571 |
572 | php-fpm pool {#POOL} Accepted Connections / sec
573 | 900
574 | 200
575 | 0.0000
576 | 100.0000
577 | 1
578 | 1
579 | 0
580 | 1
581 | 0
582 | 0.0000
583 | 0.0000
584 | 0
585 | 0
586 | 0
587 | 0
588 |
589 |
590 | 0
591 | 0
592 | 00C800
593 | 0
594 | 2
595 | 0
596 | -
597 | Template php-fpm pools
598 | php-fpm-pool["accepted conn","{#STATUS}"]
599 |
600 |
601 |
602 |
603 |
604 | php-fpm pool {#POOL} Processes
605 | 900
606 | 200
607 | 0.0000
608 | 100.0000
609 | 1
610 | 1
611 | 1
612 | 1
613 | 0
614 | 0.0000
615 | 0.0000
616 | 0
617 | 0
618 | 0
619 | 0
620 |
621 |
622 | 0
623 | 0
624 | C80000
625 | 0
626 | 2
627 | 0
628 | -
629 | Template php-fpm pools
630 | php-fpm-pool["active processes","{#STATUS}"]
631 |
632 |
633 |
634 | 1
635 | 0
636 | 00C800
637 | 0
638 | 2
639 | 0
640 | -
641 | Template php-fpm pools
642 | php-fpm-pool["idle processes","{#STATUS}"]
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 | {$PHP_FPM_STATUS_URL}
656 | http://127.0.0.1:10061/php-fpm_status
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
--------------------------------------------------------------------------------
/php-fpm-multiple-pools/fpm-pool.conf:
--------------------------------------------------------------------------------
1 | UserParameter=php-fpm-pool[*],/etc/zabbix/scripts/fpm-pool.sh "$1" "$2"
2 |
--------------------------------------------------------------------------------
/php-fpm-multiple-pools/fpm-pool.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##################################
3 | # Zabbix monitoring script
4 | #
5 | # php-fpm:
6 | # - anything available via FPM status page
7 | #
8 | ##################################
9 |
10 |
11 | if [[ "$1" == "discovery" ]] ; then
12 | echo '{"data":['
13 | for file in `find /etc/php5/fpm/pool.d/ /etc/php/*/fpm/pool.d/ -name '*.conf' 2>/dev/null` ; do
14 | poolname=`grep -e '^\s*\[[a-zA-Z-]*\]\s*$' $file | sed -e 's/.*\[\(.*\)\].*/\1/'`
15 | status_path=`grep -e '^\s*pm\.status_path\s*=\s*' $file | awk -F '=' '{print $2;}' | sed -e 's/^\s*\([^ ;]*\)\s*;\?.*/\1/'`
16 | if [[ "$comma" == 1 ]] ; then
17 | echo ','
18 | fi
19 | echo ' {'
20 | echo ' "{#POOL}":"'$poolname'",'
21 | echo ' "{#STATUS}":"'$status_path'"'
22 | echo -n ' }'
23 | comma=1
24 | done
25 | echo ']}'
26 | exit
27 | fi
28 |
29 |
30 | # Zabbix requested parameter
31 | ZBX_REQ_DATA="$1"
32 | ZBX_REQ_DATA_URL="$2"
33 |
34 | # Nginx defaults
35 | STATUS_HOST="http://127.0.0.1"
36 | NGINX_STATUS_DEFAULT_URL="/status"
37 |
38 | WGET_BIN="/usr/bin/wget"
39 |
40 | #
41 | # Error handling:
42 | # - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
43 | # - items need to be of type "float" (allow negative + float)
44 | #
45 | ERROR_NO_ACCESS_FILE="-0.9900"
46 | ERROR_NO_ACCESS="-0.9901"
47 | ERROR_WRONG_PARAM="-0.9902"
48 | ERROR_DATA="-0.9903" # either can not connect / bad host / bad port
49 |
50 | # Handle host and port if non-default
51 | if [ ! -z "$ZBX_REQ_DATA_URL" ]; then
52 | URL="$ZBX_REQ_DATA_URL"
53 | else
54 | URL="$NGINX_STATUS_DEFAULT_URL"
55 | fi
56 |
57 | URL=${STATUS_HOST}${URL}
58 |
59 | # save the nginx stats in a variable for future parsing
60 | NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null)
61 |
62 | # error during retrieve
63 | if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then
64 | echo $ERROR_DATA
65 | exit 1
66 | fi
67 |
68 | #
69 | # Extract data from nginx stats
70 | #
71 | #RESULT=$(echo "$NGINX_STATS" | awk 'print $0;match($0, "^'"$ZBX_REQ_DATA"':[[:space:]]+(.*)", a) { print a[1] }')
72 | #RESULT=$(echo "$NGINX_STATS" | grep "$ZBX_REQ_DATA" | awk -F : '{print $2}')
73 | RESULT=$(echo "$NGINX_STATS" | awk -F : "{if(\$1==\"$ZBX_REQ_DATA\") print \$2}")
74 | if [ $? -ne 0 -o -z "$RESULT" ]; then
75 | echo $ERROR_WRONG_PARAM
76 | exit 1
77 | fi
78 |
79 | echo $RESULT
80 |
81 | exit 0
82 |
--------------------------------------------------------------------------------
/php-fpm/fpm.conf:
--------------------------------------------------------------------------------
1 | UserParameter=php-fpm[*],/etc/zabbix/scripts/fpm.sh "$1" "$2"
2 |
--------------------------------------------------------------------------------
/php-fpm/fpm.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##################################
3 | # Zabbix monitoring script
4 | #
5 | # php-fpm:
6 | # - anything available via FPM status page
7 | #
8 | ##################################
9 | # Contact:
10 | # vincent.viallet@gmail.com
11 | ##################################
12 | # ChangeLog:
13 | # 20100922 VV initial creation
14 | ##################################
15 |
16 | # Zabbix requested parameter
17 | ZBX_REQ_DATA="$1"
18 | ZBX_REQ_DATA_URL="$2"
19 |
20 | # Nginx defaults
21 | NGINX_STATUS_DEFAULT_URL="http://localhost/fpm/status"
22 | WGET_BIN="/usr/bin/wget"
23 |
24 | #
25 | # Error handling:
26 | # - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
27 | # - items need to be of type "float" (allow negative + float)
28 | #
29 | ERROR_NO_ACCESS_FILE="-0.91"
30 | ERROR_NO_ACCESS="-0.92"
31 | ERROR_WRONG_PARAM="-0.93"
32 | ERROR_DATA="-0.94" # either can not connect / bad host / bad port
33 |
34 | # Handle host and port if non-default
35 | if [ ! -z "$ZBX_REQ_DATA_URL" ]; then
36 | URL="$ZBX_REQ_DATA_URL"
37 | else
38 | URL="$NGINX_STATUS_DEFAULT_URL"
39 | fi
40 |
41 | # save the nginx stats in a variable for future parsing
42 | NGINX_STATS=$($WGET_BIN -q $URL -O - 2>/dev/null)
43 |
44 | # error during retrieve
45 | if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then
46 | echo $ERROR_DATA
47 | exit 1
48 | fi
49 |
50 | #
51 | # Extract data from nginx stats
52 | #
53 | #RESULT=$(echo "$NGINX_STATS" | awk 'print $0;match($0, "^'"$ZBX_REQ_DATA"':[[:space:]]+(.*)", a) { print a[1] }')
54 | #RESULT=$(echo "$NGINX_STATS" | grep "$ZBX_REQ_DATA" | awk -F : '{print $2}')
55 | RESULT=$(echo "$NGINX_STATS" | awk -F : "{if(\$1==\"$ZBX_REQ_DATA\") print \$2}")
56 | if [ $? -ne 0 -o -z "$RESULT" ]; then
57 | echo $ERROR_WRONG_PARAM
58 | exit 1
59 | fi
60 |
61 | echo $RESULT
62 |
63 | exit 0
64 |
--------------------------------------------------------------------------------
/php-fpm/fpm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 | 2015-10-12T08:46:18Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template php-fpm
13 | Template php-fpm
14 |
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | php-fpm
23 |
24 |
25 |
26 | -
27 | $1
28 | 0
29 |
30 | 0
31 |
32 | php-fpm["total processes",{$PHP_FPM_STATUS_URL}]
33 | 60
34 | 90
35 | 365
36 | 0
37 | 0
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 |
60 | 0
61 |
62 |
63 | php-fpm
64 |
65 |
66 |
67 |
68 |
69 | -
70 | $1
71 | 0
72 |
73 | 0
74 |
75 | php-fpm["listen queue",{$PHP_FPM_STATUS_URL}]
76 | 60
77 | 90
78 | 365
79 | 0
80 | 0
81 |
82 |
83 | 0
84 |
85 |
86 | 0
87 | 0
88 |
89 | 0
90 |
91 | 1
92 |
93 |
94 |
95 | 0
96 | 0
97 |
98 |
99 |
100 |
101 |
102 |
103 | 0
104 |
105 |
106 | php-fpm
107 |
108 |
109 |
110 |
111 |
112 | -
113 | $1
114 | 0
115 |
116 | 0
117 |
118 | php-fpm["listen queue len",{$PHP_FPM_STATUS_URL}]
119 | 60
120 | 90
121 | 365
122 | 0
123 | 0
124 |
125 |
126 | 0
127 |
128 |
129 | 0
130 | 0
131 |
132 | 0
133 |
134 | 1
135 |
136 |
137 |
138 | 0
139 | 0
140 |
141 |
142 |
143 |
144 |
145 |
146 | 0
147 |
148 |
149 | php-fpm
150 |
151 |
152 |
153 |
154 |
155 | -
156 | $1
157 | 0
158 |
159 | 0
160 |
161 | php-fpm["active processes",{$PHP_FPM_STATUS_URL}]
162 | 60
163 | 90
164 | 365
165 | 0
166 | 0
167 |
168 |
169 | 0
170 |
171 |
172 | 0
173 | 0
174 |
175 | 0
176 |
177 | 1
178 |
179 |
180 |
181 | 0
182 | 0
183 |
184 |
185 |
186 |
187 |
188 |
189 | 0
190 |
191 |
192 | php-fpm
193 |
194 |
195 |
196 |
197 |
198 | -
199 | $1
200 | 0
201 |
202 | 0
203 |
204 | php-fpm["idle processes",{$PHP_FPM_STATUS_URL}]
205 | 60
206 | 90
207 | 365
208 | 0
209 | 0
210 |
211 |
212 | 0
213 |
214 |
215 | 0
216 | 0
217 |
218 | 0
219 |
220 | 1
221 |
222 |
223 |
224 | 0
225 | 0
226 |
227 |
228 |
229 |
230 |
231 |
232 | 0
233 |
234 |
235 | php-fpm
236 |
237 |
238 |
239 |
240 |
241 | -
242 | $1/sec
243 | 0
244 |
245 | 0
246 |
247 | php-fpm["accepted conn",{$PHP_FPM_STATUS_URL}]
248 | 60
249 | 90
250 | 365
251 | 0
252 | 0
253 |
254 |
255 | 1
256 |
257 |
258 | 0
259 | 0
260 |
261 | 0
262 |
263 | 1
264 |
265 |
266 |
267 | 0
268 | 0
269 |
270 |
271 |
272 |
273 |
274 |
275 | 0
276 |
277 |
278 | php-fpm
279 |
280 |
281 |
282 |
283 |
284 | -
285 | $1/sec
286 | 0
287 |
288 | 0
289 |
290 | php-fpm["slow requests",{$PHP_FPM_STATUS_URL}]
291 | 60
292 | 90
293 | 365
294 | 0
295 | 0
296 |
297 |
298 | 1
299 |
300 |
301 | 0
302 | 0
303 |
304 | 0
305 |
306 | 1
307 |
308 |
309 |
310 | 0
311 | 0
312 |
313 |
314 |
315 |
316 |
317 |
318 | 0
319 |
320 |
321 | php-fpm
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 | {$PHP_FPM_STATUS_URL}
332 | http://127.0.0.1:10061/php-fpm_status
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 | {Template php-fpm:php-fpm["active processes",{$PHP_FPM_STATUS_URL}].nodata(220)}=1 or {Template php-fpm:php-fpm["active processes",{$PHP_FPM_STATUS_URL}].last(0)}<0
342 | PHP-fpm of {HOSTNAME} is down
343 |
344 | 0
345 | 5
346 |
347 | 0
348 |
349 |
350 | Zabbix agent on {HOST.NAME} is unreachable for 5 minutes
351 | {Template OS Linux:agent.ping.nodata(5m)}=1
352 |
353 |
354 |
355 |
356 |
357 |
358 | php-fpm Accepted Connections / sec
359 | 900
360 | 200
361 | 0.0000
362 | 100.0000
363 | 1
364 | 1
365 | 0
366 | 1
367 | 0
368 | 0.0000
369 | 0.0000
370 | 0
371 | 0
372 | 0
373 | 0
374 |
375 |
376 | 0
377 | 0
378 | C80000
379 | 0
380 | 2
381 | 0
382 | -
383 | Template php-fpm
384 | php-fpm["accepted conn",{$PHP_FPM_STATUS_URL}]
385 |
386 |
387 |
388 |
389 |
390 | php-fpm Listen Queue
391 | 900
392 | 200
393 | 0.0000
394 | 100.0000
395 | 1
396 | 1
397 | 0
398 | 1
399 | 0
400 | 0.0000
401 | 0.0000
402 | 0
403 | 0
404 | 0
405 | 0
406 |
407 |
408 | 0
409 | 0
410 | EE0000
411 | 0
412 | 2
413 | 0
414 | -
415 | Template php-fpm
416 | php-fpm["listen queue len",{$PHP_FPM_STATUS_URL}]
417 |
418 |
419 |
420 | 1
421 | 0
422 | 00EE00
423 | 0
424 | 2
425 | 0
426 | -
427 | Template php-fpm
428 | php-fpm["listen queue",{$PHP_FPM_STATUS_URL}]
429 |
430 |
431 |
432 |
433 |
434 | php-fpm Processes
435 | 900
436 | 200
437 | 0.0000
438 | 100.0000
439 | 1
440 | 1
441 | 1
442 | 1
443 | 0
444 | 0.0000
445 | 0.0000
446 | 0
447 | 0
448 | 0
449 | 0
450 |
451 |
452 | 0
453 | 0
454 | EE0000
455 | 0
456 | 4
457 | 0
458 | -
459 | Template php-fpm
460 | php-fpm["active processes",{$PHP_FPM_STATUS_URL}]
461 |
462 |
463 |
464 | 1
465 | 0
466 | 00EE00
467 | 0
468 | 1
469 | 0
470 | -
471 | Template php-fpm
472 | php-fpm["idle processes",{$PHP_FPM_STATUS_URL}]
473 |
474 |
475 |
476 |
477 |
478 | php-fpm Slow Requests / sec
479 | 900
480 | 200
481 | 0.0000
482 | 100.0000
483 | 1
484 | 1
485 | 0
486 | 1
487 | 0
488 | 0.0000
489 | 0.0000
490 | 0
491 | 0
492 | 0
493 | 0
494 |
495 |
496 | 0
497 | 0
498 | C80000
499 | 0
500 | 2
501 | 0
502 | -
503 | Template php-fpm
504 | php-fpm["slow requests",{$PHP_FPM_STATUS_URL}]
505 |
506 |
507 |
508 |
509 |
510 |
511 |
--------------------------------------------------------------------------------
/redis/redis.conf:
--------------------------------------------------------------------------------
1 | UserParameter=redis.discovery,/etc/zabbix/scripts/redis.sh localhost list_key_space_db
2 | UserParameter=redis[*],/etc/zabbix/scripts/redis.sh $1 $2 $3
3 |
--------------------------------------------------------------------------------
/redis/redis.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #Redis status
4 |
5 | METRIC="$2"
6 | SERV="$1"
7 | DB="$3"
8 |
9 | PORT="6379"
10 |
11 | if [[ -z "$1" ]]; then
12 | #echo "Please set server"
13 | #exit 1
14 | SERV=127.0.0.1
15 | fi
16 |
17 | CACHETTL="55" # Время действия кеша в секундах (чуть меньше чем период опроса элементов)
18 | CACHE="/tmp/redis-status-`echo $SERV | md5sum | cut -d" " -f1`.cache"
19 |
20 | if [ -s "$CACHE" ]; then
21 | TIMECACHE=`stat -c"%Z" "$CACHE"`
22 | else
23 | TIMECACHE=0
24 | fi
25 |
26 | TIMENOW=`date '+%s'`
27 |
28 | if [ "$(($TIMENOW - $TIMECACHE))" -gt "$CACHETTL" ]; then
29 | redis-cli -h $SERV -p $PORT info > $CACHE
30 | #(echo -en "INFO\r\n"; sleep 1;) | nc $SERV $PORT > $CACHE || exit 1
31 | fi
32 |
33 | FIRST_ELEMENT=1
34 | function json_head {
35 | printf "{";
36 | printf "\"data\":[";
37 | }
38 |
39 | function json_end {
40 | printf "]";
41 | printf "}";
42 | }
43 |
44 | function check_first_element {
45 | if [[ $FIRST_ELEMENT -ne 1 ]]; then
46 | printf ","
47 | fi
48 | FIRST_ELEMENT=0
49 | }
50 |
51 | function databse_detect {
52 | json_head
53 | for dbname in $LIST_DATABSE
54 | do
55 | local dbname_t=$(echo $dbname| sed 's!\n!!g')
56 | check_first_element
57 | printf "{"
58 | printf "\"{#DBNAME}\":\"$dbname_t\""
59 | printf "}"
60 | done
61 | json_end
62 | }
63 |
64 | case $METRIC in
65 | 'redis_version')
66 | cat $CACHE | grep "redis_version:" | cut -d':' -f2
67 | ;;
68 | 'redis_git_sha1')
69 | cat $CACHE | grep "redis_git_sha1:" | cut -d':' -f2
70 | ;;
71 | 'redis_git_dirty')
72 | cat $CACHE | grep "redis_git_dirty:" | cut -d':' -f2
73 | ;;
74 | 'redis_mode')
75 | cat $CACHE | grep "redis_mode:" | cut -d':' -f2
76 | ;;
77 | 'arch_bits')
78 | cat $CACHE | grep "arch_bits:" | cut -d':' -f2
79 | ;;
80 | 'multiplexing_api')
81 | cat $CACHE | grep "multiplexing_api:" | cut -d':' -f2
82 | ;;
83 | 'gcc_version')
84 | cat $CACHE | grep "gcc_version:" | cut -d':' -f2
85 | ;;
86 | 'uptime_in_seconds')
87 | cat $CACHE | grep "uptime_in_seconds:" | cut -d':' -f2
88 | ;;
89 | 'lru_clock')
90 | cat $CACHE | grep "lru_clock:" | cut -d':' -f2
91 | ;;
92 | 'connected_clients')
93 | cat $CACHE | grep "connected_clients:" | cut -d':' -f2
94 | ;;
95 | 'client_longest_output_list')
96 | cat $CACHE | grep "client_longest_output_list:" | cut -d':' -f2
97 | ;;
98 | 'client_biggest_input_buf')
99 | cat $CACHE | grep "client_biggest_input_buf:" | cut -d':' -f2
100 | ;;
101 | 'used_memory')
102 | cat $CACHE | grep "used_memory:" | cut -d':' -f2
103 | ;;
104 | 'used_memory_peak')
105 | cat $CACHE | grep "used_memory_peak:" | cut -d':' -f2
106 | ;;
107 | 'mem_fragmentation_ratio')
108 | cat $CACHE | grep "mem_fragmentation_ratio:" | cut -d':' -f2
109 | ;;
110 | 'loading')
111 | cat $CACHE | grep "loading:" | cut -d':' -f2
112 | ;;
113 | 'rdb_changes_since_last_save')
114 | cat $CACHE | grep "rdb_changes_since_last_save:" | cut -d':' -f2
115 | ;;
116 | 'rdb_bgsave_in_progress')
117 | cat $CACHE | grep "rdb_bgsave_in_progress:" | cut -d':' -f2
118 | ;;
119 | 'aof_rewrite_in_progress')
120 | cat $CACHE | grep "aof_rewrite_in_progress:" | cut -d':' -f2
121 | ;;
122 | 'aof_enabled')
123 | cat $CACHE | grep "aof_enabled:" | cut -d':' -f2
124 | ;;
125 | 'aof_rewrite_scheduled')
126 | cat $CACHE | grep "aof_rewrite_scheduled:" | cut -d':' -f2
127 | ;;
128 | 'total_connections_received')
129 | cat $CACHE | grep "total_connections_received:" | cut -d':' -f2
130 | ;;
131 | 'total_commands_processed')
132 | cat $CACHE | grep "total_commands_processed:" | cut -d':' -f2
133 | ;;
134 | 'instantaneous_ops_per_sec')
135 | cat $CACHE | grep "instantaneous_ops_per_sec:" | cut -d':' -f2
136 | ;;
137 | 'rejected_connections')
138 | cat $CACHE | grep "rejected_connections:" | cut -d':' -f2
139 | ;;
140 | 'expired_keys')
141 | cat $CACHE | grep "expired_keys:" | cut -d':' -f2
142 | ;;
143 | 'evicted_keys')
144 | cat $CACHE | grep "evicted_keys:" | cut -d':' -f2
145 | ;;
146 | 'keyspace_hits')
147 | cat $CACHE | grep "keyspace_hits:" | cut -d':' -f2
148 | ;;
149 | 'keyspace_misses')
150 | cat $CACHE | grep "keyspace_misses:" | cut -d':' -f2
151 | ;;
152 | 'pubsub_channels')
153 | cat $CACHE | grep "pubsub_channels:" | cut -d':' -f2
154 | ;;
155 | 'pubsub_patterns')
156 | cat $CACHE | grep "pubsub_patterns:" | cut -d':' -f2
157 | ;;
158 | 'latest_fork_usec')
159 | cat $CACHE | grep "latest_fork_usec:" | cut -d':' -f2
160 | ;;
161 | 'role')
162 | cat $CACHE | grep "role:" | cut -d':' -f2
163 | ;;
164 | 'connected_slaves')
165 | cat $CACHE | grep "connected_slaves:" | cut -d':' -f2
166 | ;;
167 | 'used_cpu_sys')
168 | cat $CACHE | grep "used_cpu_sys:" | cut -d':' -f2
169 | ;;
170 | 'used_cpu_user')
171 | cat $CACHE | grep "used_cpu_user:" | cut -d':' -f2
172 | ;;
173 | 'used_cpu_sys_children')
174 | cat $CACHE | grep "used_cpu_sys_children:" | cut -d':' -f2
175 | ;;
176 | 'used_cpu_user_children')
177 | cat $CACHE | grep "used_cpu_user_children:" | cut -d':' -f2
178 | ;;
179 | 'key_space_db_keys')
180 | cat $CACHE | grep $DB:|cut -d':' -f2|awk -F, '{print $1}'|cut -d'=' -f2
181 | ;;
182 | 'key_space_db_expires')
183 | cat $CACHE | grep $DB:|cut -d':' -f2|awk -F, '{print $2}'|cut -d'=' -f2
184 | ;;
185 | 'list_key_space_db')
186 | LIST_DATABSE=`cat $CACHE | grep '^db[0-9]\+:'|cut -d: -f1`
187 | databse_detect
188 | ;;
189 | *)
190 | echo "Not selected metric"
191 | exit 0
192 | ;;
193 | esac
194 |
--------------------------------------------------------------------------------
/ssl-checks/ssl-checks.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3.4
4 | 2018-12-14T12:07:07Z
5 |
6 |
7 | Templates
8 |
9 |
10 |
11 |
12 | Template SSL checks
13 | Template SSL checks
14 |
15 |
16 |
17 | Templates
18 |
19 |
20 |
21 |
22 | SSL
23 |
24 |
25 |
26 |
27 |
28 | SSL certificates check
29 | 0
30 |
31 |
32 | ssl.discovery["{$IGNORED_SSL_DOMAINS}"]
33 | 1h
34 | 0
35 |
36 |
37 |
38 | 0
39 | 0
40 |
41 | 0
42 |
43 |
44 |
45 | 0
46 |
47 |
48 |
49 |
50 |
51 |
52 | 0
53 |
54 |
55 |
56 | 1h
57 |
58 |
59 |
60 | Days before {#DOMAIN} ssl certificate expiration
61 | 10
62 |
63 |
64 | ssl[daysBeforeExpiration, {#DOMAIN}]
65 | 3h
66 | 14d
67 | 365d
68 | 0
69 | 3
70 |
71 | days
72 |
73 |
74 | 0
75 | 0
76 |
77 | 0
78 |
79 |
80 |
81 | 0
82 |
83 |
84 |
85 |
86 |
87 |
88 | 0
89 |
90 |
91 | SSL
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | Domain {#DOMAIN} is valid to SSL certificate
103 | 10
104 |
105 |
106 | ssl[isDomainValid, {#DOMAIN}]
107 | 3h
108 | 14d
109 | 365d
110 | 0
111 | 3
112 |
113 |
114 |
115 |
116 | 0
117 | 0
118 |
119 | 0
120 |
121 |
122 |
123 | 0
124 |
125 |
126 |
127 |
128 |
129 |
130 | 0
131 |
132 |
133 | SSL
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | {$CHECK_SSL_DOMAIN_NAMES}<>0 and {Template SSL checks:ssl[isDomainValid, {#DOMAIN}].last()}<>1
147 | 0
148 |
149 | Invalid SSL certificate for {#DOMAIN}
150 | 0
151 |
152 |
153 | 0
154 | 2
155 | The domain name {#DOMAIN} is not present in allowed domain names list. Try https://{#DOMAIN}
156 | 0
157 | 1
158 |
159 |
160 |
161 |
162 | {Template SSL checks:ssl[daysBeforeExpiration, {#DOMAIN}].last()}<{$SSL_EXPIRATION_WARNING_DAYS}
163 | 0
164 |
165 | SSL certificate for {#DOMAIN} will expire soon
166 | 0
167 |
168 |
169 | 0
170 | 2
171 |
172 | 0
173 | 1
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 | {$CHECK_SSL_DOMAIN_NAMES}
187 | 1
188 |
189 |
190 | {$IGNORED_SSL_DOMAINS}
191 |
192 |
193 |
194 | {$SSL_EXPIRATION_WARNING_DAYS}
195 | 7
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
--------------------------------------------------------------------------------
/ssl-checks/ssl.conf:
--------------------------------------------------------------------------------
1 | UserParameter=ssl.discovery[*],/etc/zabbix/scripts/ssl.pl "$1" "$2"
2 |
--------------------------------------------------------------------------------
/ssl-checks/ssl.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $nginxConfigPath = "/etc/nginx/";
4 | $mainConfigName = "nginx.conf";
5 |
6 |
7 | $ignoredDomainsRaw = $ARGV[0];
8 | @ignoredDomains = split /[\s,;|]+/g, $ignoredDomainsRaw;
9 | %ignoredDomainsHash = ();
10 | foreach $domain (@ignoredDomains) {
11 | $ignoredDomainsHash{$domain} = 1;
12 | }
13 |
14 | sub readFile {
15 | my ($filename) = @_;
16 |
17 | if(!($filename =~ /^\//)) {
18 | $filename = $nginxConfigPath . $filename;
19 | }
20 |
21 | open(my $handle, '<', $filename)
22 | or die('Error openning file '.$filename);
23 | $contents = '';
24 | while (<$handle>) {
25 | $contents .= $_;
26 | }
27 | close($handle);
28 | $contents =~ s/\#[^\n]*//g;
29 | return $contents;
30 | }
31 |
32 |
33 | #Join separate config files to one config
34 | $mainConfig = readFile($mainConfigName);
35 | while ($mainConfig =~ /(include\s+([^\n;]+);\s*)\n/) {
36 | $includeFilenameTemplate = $2;
37 | $includeCommand = quotemeta $1;
38 |
39 | if (!($includeFilenameTemplate=~/^\//)) {
40 | $includeFilenameTemplate = $nginxConfigPath . $includeFilenameTemplate;
41 | }
42 |
43 | if ($includeFilenameTemplate=~/\*/) {
44 | $filelist = `ls -1 $includeFilenameTemplate 2>/dev/null`;
45 | @filelist = split /\n/,$filelist;
46 | $concatenatedFiles = '';
47 | foreach $filename (@filelist) {
48 | $concatenatedFiles .= readFile($filename);
49 | }
50 | $mainConfig =~ s/$includeCommand/$concatenatedFiles/g;
51 | } else {
52 | $mainConfig =~ s/$includeCommand/$files{$includeFilename}/g;
53 | }
54 | }
55 |
56 | @servers = split /\s*server\s*\{/i, $mainConfig;
57 | %allServerNames = ();
58 | shift @servers;
59 |
60 | foreach $config (@servers) {
61 | if($config =~ /listen [^;]*(ssl|http2)/ || $config =~ /\sssl\s+on\s*;/) {
62 | $config =~ /server_name\s+([^;]+);/;
63 | $serverNamesRaw = $1;
64 | @configServerNames = split /\s+/, $serverNamesRaw;
65 | foreach $serverName (@configServerNames) {
66 | if(!($serverName =~ /^(_|localhost)?$/) && !exists($ignoredDomainsHash{$serverName})) {
67 | $allServerNames{$serverName} = 1;
68 | }
69 | }
70 | }
71 | }
72 |
73 | print '{"data":['."\n";
74 | $firstRow=1;
75 | foreach $serverName (keys %allServerNames) {
76 | if(!$firstRow) {
77 | print ",\n";
78 | }
79 | $firstRow=0;
80 | print '{"{#DOMAIN}":"'.$serverName.'"}';
81 | }
82 | print "\n]}";
83 |
--------------------------------------------------------------------------------
/ssl-checks/zabbix-external-check-scripts/ssl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | use POSIX;
4 |
5 | $action=$ARGV[0];
6 | $domain=$ARGV[1];
7 |
8 | if($action eq 'daysBeforeExpiration') {
9 | $notAfterDate=`echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -dates | grep notAfter | awk -F'=' '{print \$2;}' 2>/dev/null`;
10 | $expirationTimestamp=`date --date="$notAfterDate" +%s`;
11 | $currentTimestamp=`date +%s`;
12 | print floor(($expirationTimestamp-$currentTimestamp)/3600/24);
13 | } elsif($action eq 'isDomainValid') {
14 | $mainDomain=`echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -subject | awk -F'=' '{print \$3;}'`;
15 | $additionalDomains=`echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -text | grep DNS:`;
16 |
17 | @additionalDomains = split /,?[\n\s]*DNS:[\s\n]*/g, $additionalDomains;
18 |
19 | @domains = ($mainDomain, @additionalDomains);
20 | %validDomains = ();
21 |
22 | foreach $domain (@domains) {
23 | $domain =~ s/[\s\n]*//g;
24 | if(! ($domain eq '')) {
25 | $validDomains{$domain} = 1;
26 | }
27 | }
28 |
29 | print exists($validDomains{$domain}) ? 1 : 0;
30 | } else {
31 | print "Invalid action\n";
32 | exit 1;
33 | }
34 |
35 | print "\n";
36 |
--------------------------------------------------------------------------------