Added zabbix playbook
This commit is contained in:
parent
499b6397b2
commit
38b43ac575
20 changed files with 315 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
|
||||
uname -a|grep -q xen >/dev/null
|
||||
if [ "$?" -eq "0" ] ;then
|
||||
eth_dev=p$(ip route|grep default|awk '{print $5}')
|
||||
else
|
||||
eth_dev=$(ip route|grep default|awk '{print $5}')
|
||||
fi
|
||||
|
||||
lsmod |grep -q -E 'virtio_net|xen_net'
|
||||
if [ "$?" -eq "1" ] ;then
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k eth_dev.speed -o $(ethtool $eth_dev|grep Speed|awk '{print $2}'|tr -d [:alpha:]|tr -d '/') >/dev/null
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k eth_dev.duplex -o $(ethtool $eth_dev|grep Duplex|awk '{print $2}') >/dev/null
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
# called by Zabbix to see if iptables is running
|
||||
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
|
||||
|
||||
if [ $( iptables -n -L INPUT|wc -l ) -gt 6 ] ; then
|
||||
iptablesstatus="0"
|
||||
else
|
||||
iptablesstatus="1"
|
||||
fi
|
||||
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k net.iptables.status -o $iptablesstatus >/dev/null
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
logfile="/var/log/centos-ro-devices"
|
||||
|
||||
ro_mounted_devices=$(awk '$4 ~ "^ro[,$]" && $3 !~ "(squashfs|iso9660|tmpfs|nfs)" {print $0}' /proc/mounts | wc -l)
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k devices.ro -o $ro_mounted_devices >/dev/null
|
||||
echo "=== $(date) === Read-Only devices on this system $(hostname)" >> $logfile
|
||||
awk '$4 ~ "^ro[,$]" && $3 !~ "(squashfs|iso9660|tmpfs|nfs)" {print $0} ' /proc/mounts >> $logfile
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
PATH=$PATH:/usr/local/bin:/sbin:/usr/sbin/
|
||||
|
||||
function init_log() {
|
||||
logfile=/var/log/centos-hw-raid.log
|
||||
echo "=========================================================" > $logfile
|
||||
echo " CentOS Hardware Raid check - $(date +%Y%m%d-%H%M)" >> $logfile
|
||||
echo "=========================================================" >> $logfile
|
||||
}
|
||||
|
||||
function 3w_xxxx_check() {
|
||||
echo "3ware controller found .. launching raid check" >> $logfile
|
||||
for controller in $(tw_cli show |grep ^c|awk '{print $1}') ;
|
||||
do
|
||||
for disk in $(tw_cli /${controller} show |grep ^p|awk '{print $1}') ;
|
||||
do
|
||||
tw_cli /${controller} show |grep ^${disk}|egrep -q 'OK|NOT-PRESENT'
|
||||
if [ "$?" -ne "0" ] ;then
|
||||
tw_cli /${controller} show >> $logfile
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k hwraid.3ware -o 1 >/dev/null
|
||||
exit 1
|
||||
else
|
||||
echo "3ware controller ${controller} / array ${array} status : OK" >> $logfile
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k hwraid.3ware -o 0 >/dev/null
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function 3w_9xxx_check() {
|
||||
3w_xxxx_check
|
||||
}
|
||||
|
||||
function arcmsr_check() {
|
||||
echo "ARECA controller found .. launching raid check" >> $logfile
|
||||
for array in $(areca-cli rsf info|egrep -v 'Name|=|GuiErr'|awk '{print $1}') ;
|
||||
do
|
||||
areca-cli rsf info raid=${array}|grep -q Normal
|
||||
if [ "$?" -ne "0" ] ;then
|
||||
areca-cli rsf info raid=${array} >> $logfile
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k hwraid.arcmsr -o 1 >/dev/null
|
||||
exit 1
|
||||
else
|
||||
echo "Areca array ${array} status : OK" >> $logfile
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k hwraid.arcmsr -o 0 >/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function megaraid_sas_check() {
|
||||
echo "Megaraid_sas controller found .. launching raid check" >> $logfile
|
||||
for LDid in $(/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL|grep "Virtual Drive:"|awk '{print $3}') ;
|
||||
do
|
||||
/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -L${LDid} -aALL|grep -q Optimal
|
||||
if [ "$?" -ne "0" ] ;then
|
||||
/opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL >>$logfile
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k hwraid.megaraid -o 1 >/dev/null
|
||||
exit 1
|
||||
else
|
||||
echo "Megaraid_sas array ${array} status : OK" >> $logfile
|
||||
/opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL >>$logfile
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k hwraid.megaraid -o 0 >/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
init_log
|
||||
|
||||
# Ensuring sg kmod is loaded, as needed by those tools ...
|
||||
lsmod|grep -q sg || modprobe sg
|
||||
|
||||
for kmod in 3w_9xxx 3w_xxxx arcmsr megaraid_sas; do
|
||||
/sbin/lsmod |grep -q ${kmod}
|
||||
if [ "$?" = "0" ];then
|
||||
${kmod}_check
|
||||
fi
|
||||
done
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
grep md /proc/mdstat >/dev/null 2>&1
|
||||
if [ $? = "0" ] ;then
|
||||
for mddev in $( grep md /proc/mdstat |awk '{print $1}') ;
|
||||
do
|
||||
md_count=$(/sbin/mdadm --detail /dev/${mddev}|grep Failed|cut -f 2 -d ":"|tr -d [:blank:])
|
||||
if [ $md_count > "0" ] ;then
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k mdstat.failed -o $md_count >/dev/null
|
||||
exit
|
||||
else
|
||||
zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k mdstat.failed -o 0 >/dev/null
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
BIN
roles/zabbix/zabbix-agent/files/selinux/8/centos-zabbix-agent.pp
Normal file
BIN
roles/zabbix/zabbix-agent/files/selinux/8/centos-zabbix-agent.pp
Normal file
Binary file not shown.
|
@ -0,0 +1,20 @@
|
|||
policy_module(centos-zabbix-agent, 1.1)
|
||||
|
||||
require{
|
||||
type zabbix_agent_t;
|
||||
type zabbix_t;
|
||||
type ping_t;
|
||||
type zabbix_tmp_t;
|
||||
class process setrlimit;
|
||||
}
|
||||
|
||||
allow ping_t zabbix_tmp_t:file read_file_perms;
|
||||
allow ping_t zabbix_t:tcp_socket { read write };
|
||||
allow zabbix_agent_t self:process setrlimit;
|
||||
|
||||
kernel_read_network_state(zabbix_agent_t)
|
||||
domain_read_all_domains_state(zabbix_agent_t)
|
||||
dev_read_sysfs(zabbix_agent_t)
|
||||
corenet_tcp_connect_all_ports(zabbix_agent_t)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue