1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
cd ~ mkdir zabbix/ cd zabbix/ wget http://www.zabbix.com/downloads/2.0.6/zabbix_agents_2.0.6.linux2_6_23.amd64.tar.gz tar fvxz zabbix_agents_2.0.6.linux2_6_23.amd64.tar.gz cp ~/src/zabbix/bin/* /usr/bin/ cp ~/src/zabbix/sbin/* /usr/sbin/ groupadd zabbix useradd -g zabbix zabbix mkdir /var/log/zabbix-agent chown zabbix:zabbix /var/log/zabbix-agent/ cp ~/src/zabbix/conf/zabbix_agent.conf /usr/local/etc/ cp ~/src/zabbix/conf/zabbix_agentd.conf /usr/local/etc/ nano /usr/local/etc/zabbix_agent.conf |
Ändere
1 |
Server=127.0.0.1 in Server=123.456.789.123 |
Logfile konfigurieren
1 2 3 |
nano /usr/local/etc/zabbix_agent.conf LogFile=/var/log/zabbix-agent/zabbix_agentd.log nano /etc/init.d/zabbix-agent |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
#! /bin/sh counter=0 zabbix_counter=$(ps -ef | grep zabbix_agentd | grep -v grep | wc -l) start(){ echo "-------------------------------------------------------------------" echo " LAUNCHING ZABBIX AGENT" if [ $zabbix_counter -gt 0 ]; then echo " * Zabbix agent was previously running" echo " * Number of Zabbix agentd instances= $zabbix_counter" echo "-----------------------------------------------------------------" fi # Checking if the user is able to start the agent.... if the user is not able to, script performs su to # the user zabbix and starts the agent if [ $(whoami) != "zabbix" ];then sudo -u zabbix zabbix_agentd else # Script is acting as the zabbix user, so it can start the agent. zabbix_agentd fi sleep 10 zabbix_counter=$(ps -ef | grep zabbix_agentd | grep -v grep | wc -l) if [ $zabbix_counter -gt 0 ]; then echo " * Zabbix agent succesfully started" echo " * Number of zabbix agentd instances= $zabbix_counter" echo "-------------------------------------------------------------------" else echo " * Zabbix agent couldn't be started, check Zabbix logs" echo "-------------------------------------------------------------------" fi } stop(){ # Checking if the user is able to stop the agent.... if the user is not able to, script performs su to # the user zabbix and kills the agent. Also script tries to kill zabbix-agent processes 5 times using a counter, if at # the fith try the agent is still there, script outputs a message to the console. echo "-------------------------------------------------------------------" echo " STOPPING ZABBIX AGENT" if [ $zabbix_counter -eq 0 ]; then echo " * Zabbix agent was not running on this machine" echo "-------------------------------------------------------------------" fi while [ $zabbix_counter -gt 0 ] && [ $counter -lt 5 ] ; do let counter=counter+1 echo " * Number of Attempts (Max 5)=$counter" echo " * Stopping zabbix.." echo " * Number of zabbix agentd instances= $zabbix_counter" if [ $(whoami) != "zabbix" ];then sudo -u zabbix killall zabbix_agentd > /dev/null & else killall zabbix_agentd > /dev/null & fi sleep 10 # Script has a 10 second delay to avoid attempting to kill a process that is still shutting down. If the script # can't kill the processes, an error will appear. # After 10 seconds script checks again the number of zabbix_agentd processes running, # if it's 0, script will exit the loop and continue on zabbix_counter=$(ps -ef | grep zabbix_agentd | grep -v grep | wc -l) done if [ $zabbix_counter -gt 0 ]; then echo " * Zabbix agent couldn't be stopped, check Zabbix logs" echo "-------------------------------------------------------------------" fi if [ $zabbix_counter -eq 0 ]; then echo " * Zabbix agent successfully stopped" echo "-------------------------------------------------------------------" fi } restart(){ stop # Gives system some time to stop processes before script restarts service sleep 10 # Now script can start the agent again start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo "Usage: zabbix {start|stop|restart}" exit 1 esac exit 0 |
1 2 3 4 |
chmod 744 /etc/init.d/zabbix-agent ln -s /etc/init.d/zabbix-agent /sbin/zabbix-agent update-rc.d zabbix-agent defaults |
Ausgabe
1 2 |
update-rc.d: using dependency based boot sequencing insserv: warning: script 'zabbix-agent' missing LSB tags and overrides |
aus /etc/init.d/sekeleton die ersten paar Zeilen herauskopieren und in /etc/init.d/zabbix-agent herein kopieren
1 2 3 4 5 6 7 8 9 10 11 |
#! /bin/sh ### BEGIN INIT INFO # Provides: zabbix-agent # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Example initscript # Description: This file should be used to construct scripts to be # placed in /etc/init.d. ### END INIT INFO |
Zeile Provides: entsprechend anpassen.
Diese Lösung schien in manchen Fälle Probleme zu bereiten.
Folgender Weg funktioniert definitiv:
Entsprechenden Agent unter diesem Link herunter laden: http://repo.zabbix.com/zabbix/2.0/debian/pool/main/z/zabbix/
1 2 3 4 5 6 |
cd ~ mkdir zabbix cd zabbix wget http://repo.zabbix.com/zabbix/2.0/debian/pool/main/z/zabbix/zabbix-agent_2.0.6-2+wheezy_amd64.deb dpkg -i zabbix-agent_2.0.6-2+wheezy_amd64.deb nano /etc/zabbix/zabbix_agentd.conf |
Die üblichen Änderung an der Agent konfiguration kann nun vorgenommen werden (Server IP / Log Verzeichnis / UserParameter usw.)
Der Agent wird mit
[code lang=”bash”]/etc/init.d/zabbix-agent restart[/code]
neu gestartet
Für die UserParameter fehlen noch z.B. die SmartMonTools.
Diese werden mit
1 |
apt-get install smartmontools |
nachinstalliert.
UserParameter Einstellungen befinden sich auf der Zabbix Konfigurationsseite.