Project

General

Profile

« Previous | Next » 

Revision 865f4ff4

Added by Marc Dequènes about 10 years ago

[evol] add corresponding scripts

View differences:

scripts/stat_apache
1
#!/bin/sh
2

  
3
PARAM=${1:-noexistent}
4

  
5
BASE_URL=https://$(hostname --fqdn)
6

  
7
CACHE_FILE=/tmp/zbx-apache
8
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
9
	wget --bind-address 127.0.0.1 \
10
		--user-agent=\"ApacheStats\/0.4 wget\/1.8\" -q \
11
		-t3 -T5 --no-check-certificate \
12
		-O ${CACHE_FILE} \
13
		 ${BASE_URL}/server-status?auto
14

  
15
cat ${CACHE_FILE} | perl -ne "print \$1 if m/^${PARAM}: (\d*\.?\d+)/"
16

  
scripts/stat_bind9
1
#!/bin/sh
2

  
3
PARAM=${1:-noexistent}
4

  
5
case "${PARAM}" in
6
  ipv4)
7
	PATTERN="IPv4 requests received"
8
	;;
9
  ipv6)
10
	PATTERN="IPv6 requests received"
11
	;;
12
  success)
13
	PATTERN="queries resulted in successful answer"
14
	;;
15
  failure)
16
	PATTERN=""
17
	;;
18
  nxdomain)
19
	PATTERN="queries resulted in NXDOMAIN"
20
	;;
21
  nxrrset)
22
	PATTERN="queries resulted in nxrrset"
23
	;;
24
  recursion)
25
	PATTERN="queries caused recursion"
26
	;;
27
  referral)
28
	PATTERN="queries resulted in non authoritative answer"
29
	;;
30
  *)
31
    exit
32
esac
33

  
34
grep "${PATTERN}" /var/cache/bind/named.stats | head -n 1 | awk '{ print $1 }'
35

  
scripts/stat_mysql_slave_status
1
#!/bin/sh
2

  
3
PARAM=${1:-noexistent}
4

  
5
CACHE_FILE=/tmp/zbx-mysql_slave_status
6
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
7
	echo "SHOW SLAVE STATUS\\G" | mysql --defaults-file=/etc/mysql/debian.cnf \
8
	--batch --skip-pager --skip-column-names >${CACHE_FILE}
9
cat ${CACHE_FILE} | perl -ne "print \$1 if m/\b${PARAM}: (.+)$/"
10

  
scripts/stat_mysql_status
1
#!/bin/sh
2

  
3
PARAM=${1:-noexistent}
4

  
5
CACHE_FILE=/tmp/zbx-mysql_status
6
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
7
	echo "SHOW GLOBAL STATUS" | mysql --defaults-file=/etc/mysql/debian.cnf \
8
	--batch --skip-pager --skip-column-names >${CACHE_FILE}
9
cat ${CACHE_FILE} | perl -ne "print \$1 if m/^${PARAM}\t([\d.]+)/"
10

  
scripts/stat_mysql_variables
1
#!/bin/sh
2

  
3
PARAM=${1:-noexistent}
4

  
5
CACHE_FILE=/tmp/zbx-mysql_variables
6
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
7
	echo "SHOW VARIABLES" | mysql --defaults-file=/etc/mysql/debian.cnf \
8
	--batch --skip-pager --skip-column-names >${CACHE_FILE}
9
cat ${CACHE_FILE} | perl -ne "print \$1 if m/^${PARAM}\t([\d.]+)/"
10

  
scripts/stat_ntpd
1
#!/bin/sh
2

  
3
# http://www.ntp.org/ntpfaq/NTP-s-sw-clocks-quality.htm
4

  
5
PARAM=${1:-noexistent}
6

  
7
ntpq -c rv | perl -ne "print \$1 if m/\b${PARAM}=([-]?\d+\.\d+)/"
8

  
scripts/stat_openldap
1
#!/usr/bin/perl
2

  
3
# example parameter: /operations/add/monitorOpCompleted
4

  
5
use warnings;
6
use strict;
7
use File::Basename;
8
use IO::File;
9
use Data::Dumper;
10

  
11
my $param = $ARGV[0];
12
unless ($param =~ m#^(/[a-zA-Z0-9 ]+)+$#)
13
{
14
	exit 1;
15
}
16

  
17
my $location = 'cn=' . join(',cn=', reverse(split(qr(/), dirname($param)))) . "monitor";
18
my $attr = basename($param);
19

  
20
my $fh = IO::File->new;
21
# shell escapes are not possible, $param was check earlier using regex
22
$fh->open('ldapsearch -Q -Y EXTERNAL -H ldapi:/// -b "' . $location . '" -s base -LLL "' . $attr . '" 2>/dev/null |');
23
while (my $line = $fh->getline)
24
{
25
	if ($line =~ m/^$attr: (.*)$/)
26
	{
27
		print "$1\n";
28
		exit 0;
29
	}
30
}
31

  
32
exit 2;
scripts/stat_postfix_queue_size
1
#!/bin/sh
2

  
3
QUEUE=$1
4

  
5
qshape "${QUEUE}" | grep TOTAL | awk '{print $2}'
6

  

Also available in: Unified diff