rm -f /etc/zabbix/zabbix_agentd.conf
cat <<EOT >> /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
DebugLevel=3
EnableRemoteCommands=1
Server=zabbix.catonrug.net
ServerActive=zabbix.catonrug.net
EOT
Host=$(hostname)
echo "Hostname=$Host" >> /etc/zabbix/zabbix_agentd.conf
chconfig zabbix-agent on
Another example to deploy
zext_ssl_cert.sh:
#!/bin/sh
mkdir -p /etc/zabbix/externalscripts
cat <<EOT > /etc/zabbix/externalscripts/zext_ssl_cert.sh
#!/bin/sh
#------------------------------------------------------------
# zext_ssl_cert.sh
# Script checks for number of days until certificate expires or the issuing authority
# depending on switch passed on command line.
#
#Based on script from aperto.fr (http://aperto.fr/cms/en/blog/15-blog-en/15-ssl-certificate-expiration-monitoring-with-zabbix.html)
#with additions by racooper@tamu.edu.
#------------------------------------------------------------
DEBUG=0
if [ \$DEBUG -gt 0 ]
then
exec 2>>/tmp/my.log
set -x
fi
f=\$1
host=\$2
port=\$3
case \$f in
-d)
end_date=\`openssl s_client -host \$host -port \$port -showcerts -prexit </dev/null 2>/dev/null |
sed -n '/BEGIN CERTIFICATE/,/END CERT/p' |
openssl x509 -text 2>/dev/null |
sed -n 's/ *Not After : *//p'\`
if [ -n "\$end_date" ]
then
end_date_seconds=\`date '+%s' --date "\$end_date"\`
now_seconds=\`date '+%s'\`
echo "(\$end_date_seconds-\$now_seconds)/24/3600" | bc
fi
;;
-i)
issue_dn=\`openssl s_client -host \$host -port \$port -showcerts -prexit </dev/null 2>/dev/null |
sed -n '/BEGIN CERTIFICATE/,/END CERT/p' |
openssl x509 -text 2>/dev/null |
sed -n 's/ *Issuer: *//p'\`
if [ -n "\$issue_dn" ]
then
issuer=\`echo \$issue_dn | sed -n 's/.*CN=*//p'\`
echo \$issuer
fi
;;
*)
echo "usage: \$0 [-i|-d] hostname port"
echo " -i Show Issuer"
echo " -d Show valid days remaining"
;;
esac
EOT
chmod +x /etc/zabbix/externalscripts/zext_ssl_cert.sh
No comments:
Post a Comment