Revision 865f4ff4
Added by Marc Dequènes over 12 years ago
scripts/stat_apache | ||
---|---|---|
#!/bin/sh
|
||
|
||
PARAM=${1:-noexistent}
|
||
|
||
BASE_URL=https://$(hostname --fqdn)
|
||
|
||
CACHE_FILE=/tmp/zbx-apache
|
||
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
|
||
wget --bind-address 127.0.0.1 \
|
||
--user-agent=\"ApacheStats\/0.4 wget\/1.8\" -q \
|
||
-t3 -T5 --no-check-certificate \
|
||
-O ${CACHE_FILE} \
|
||
${BASE_URL}/server-status?auto
|
||
|
||
cat ${CACHE_FILE} | perl -ne "print \$1 if m/^${PARAM}: (\d*\.?\d+)/"
|
||
|
scripts/stat_bind9 | ||
---|---|---|
#!/bin/sh
|
||
|
||
PARAM=${1:-noexistent}
|
||
|
||
case "${PARAM}" in
|
||
ipv4)
|
||
PATTERN="IPv4 requests received"
|
||
;;
|
||
ipv6)
|
||
PATTERN="IPv6 requests received"
|
||
;;
|
||
success)
|
||
PATTERN="queries resulted in successful answer"
|
||
;;
|
||
failure)
|
||
PATTERN=""
|
||
;;
|
||
nxdomain)
|
||
PATTERN="queries resulted in NXDOMAIN"
|
||
;;
|
||
nxrrset)
|
||
PATTERN="queries resulted in nxrrset"
|
||
;;
|
||
recursion)
|
||
PATTERN="queries caused recursion"
|
||
;;
|
||
referral)
|
||
PATTERN="queries resulted in non authoritative answer"
|
||
;;
|
||
*)
|
||
exit
|
||
esac
|
||
|
||
grep "${PATTERN}" /var/cache/bind/named.stats | head -n 1 | awk '{ print $1 }'
|
||
|
scripts/stat_mysql_slave_status | ||
---|---|---|
#!/bin/sh
|
||
|
||
PARAM=${1:-noexistent}
|
||
|
||
CACHE_FILE=/tmp/zbx-mysql_slave_status
|
||
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
|
||
echo "SHOW SLAVE STATUS\\G" | mysql --defaults-file=/etc/mysql/debian.cnf \
|
||
--batch --skip-pager --skip-column-names >${CACHE_FILE}
|
||
cat ${CACHE_FILE} | perl -ne "print \$1 if m/\b${PARAM}: (.+)$/"
|
||
|
scripts/stat_mysql_status | ||
---|---|---|
#!/bin/sh
|
||
|
||
PARAM=${1:-noexistent}
|
||
|
||
CACHE_FILE=/tmp/zbx-mysql_status
|
||
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
|
||
echo "SHOW GLOBAL STATUS" | mysql --defaults-file=/etc/mysql/debian.cnf \
|
||
--batch --skip-pager --skip-column-names >${CACHE_FILE}
|
||
cat ${CACHE_FILE} | perl -ne "print \$1 if m/^${PARAM}\t([\d.]+)/"
|
||
|
scripts/stat_mysql_variables | ||
---|---|---|
#!/bin/sh
|
||
|
||
PARAM=${1:-noexistent}
|
||
|
||
CACHE_FILE=/tmp/zbx-mysql_variables
|
||
test -z `/usr/bin/find ${CACHE_FILE} -mmin -5 2>/dev/null` && \
|
||
echo "SHOW VARIABLES" | mysql --defaults-file=/etc/mysql/debian.cnf \
|
||
--batch --skip-pager --skip-column-names >${CACHE_FILE}
|
||
cat ${CACHE_FILE} | perl -ne "print \$1 if m/^${PARAM}\t([\d.]+)/"
|
||
|
scripts/stat_ntpd | ||
---|---|---|
#!/bin/sh
|
||
|
||
# http://www.ntp.org/ntpfaq/NTP-s-sw-clocks-quality.htm
|
||
|
||
PARAM=${1:-noexistent}
|
||
|
||
ntpq -c rv | perl -ne "print \$1 if m/\b${PARAM}=([-]?\d+\.\d+)/"
|
||
|
scripts/stat_openldap | ||
---|---|---|
#!/usr/bin/perl
|
||
|
||
# example parameter: /operations/add/monitorOpCompleted
|
||
|
||
use warnings;
|
||
use strict;
|
||
use File::Basename;
|
||
use IO::File;
|
||
use Data::Dumper;
|
||
|
||
my $param = $ARGV[0];
|
||
unless ($param =~ m#^(/[a-zA-Z0-9 ]+)+$#)
|
||
{
|
||
exit 1;
|
||
}
|
||
|
||
my $location = 'cn=' . join(',cn=', reverse(split(qr(/), dirname($param)))) . "monitor";
|
||
my $attr = basename($param);
|
||
|
||
my $fh = IO::File->new;
|
||
# shell escapes are not possible, $param was check earlier using regex
|
||
$fh->open('ldapsearch -Q -Y EXTERNAL -H ldapi:/// -b "' . $location . '" -s base -LLL "' . $attr . '" 2>/dev/null |');
|
||
while (my $line = $fh->getline)
|
||
{
|
||
if ($line =~ m/^$attr: (.*)$/)
|
||
{
|
||
print "$1\n";
|
||
exit 0;
|
||
}
|
||
}
|
||
|
||
exit 2;
|
scripts/stat_postfix_queue_size | ||
---|---|---|
#!/bin/sh
|
||
|
||
QUEUE=$1
|
||
|
||
qshape "${QUEUE}" | grep TOTAL | awk '{print $2}'
|
||
|
Also available in: Unified diff
[evol] add corresponding scripts