Commit da43e0f7 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Initial commit

parents
opiplus2e: opi
opipcplus: opi
agent: zabbix-agent-service zabbix-agent-config
groupadd -g 26 zabbix
useradd -c "Zabbix Monitoring System" -d /var/lib/zabbix -g zabbix -s /bin/false -u 26 zabbix
tar xf zabbix-3.4.14.tar.gz
cd zabbix-3.4.14 && ./configure --prefix=/usr --sysconfdir=/etc --enable-agent --with-openssl
$(MAKE) -C zabbix-3.4.14
$(MAKE) -C zabbix-3.4.14 install
install -v -Dm755 zabbix_agentd-configure /usr/sbin/zabbix_agentd-configure
sed -e 's|.*PidFile=.*|PidFile=/run/zabbix/zabbix_agentd.pid|' -i /etc/zabbix_agentd.conf
sed -e 's|.*LogType=.*|LogType=system|' -i /etc/zabbix_agentd.conf
sed -e 's|^LogFile=.*|# LogFile=|' -i /etc/zabbix_agentd.conf
sed -e 's|^Server=.*|# Server=|' -i /etc/zabbix_agentd.conf
sed -e 's|^ServerActive=.*|# ServerActive=|' -i /etc/zabbix_agentd.conf
sed -e 's|^Hostname=.*|# Hostname=|' -i /etc/zabbix_agentd.conf
sed -e 's|.*HostMetadataItem=.*|HostMetadataItem=system.sw.os[name]|' -i /etc/zabbix_agentd.conf
sed -e 's|^# Include=/usr/local/etc/zabbix_agentd\.conf\.d/\*\.conf|Include=/etc/zabbix_agentd.conf.d/*.conf|' -i /etc/zabbix_agentd.conf
sed -e 's|^# UserParameter=.*|UserParameter=device.id,/usr/sbin/deviceid|' -i /etc/zabbix_agentd.conf
sed -e '/^UserParameter=device\.id.*/a UserParameter=device.product,/usr/sbin/deviceproduct' -i /etc/zabbix_agentd.conf
@echo "d /run/zabbix 755 zabbix zabbix -" > /usr/lib/tmpfiles.d/zabbix.conf
@echo "$$ZABBIX_AGENT_SERVICE" > /lib/systemd/system/zabbix-agent.service
systemctl enable zabbix-agent.service
@echo "$$ZABBIX_AGENT_CONFIG" >> /etc/config/zabbix
install -v -Dm755 zabbix /usr/share/easycwmp/functions
rm -rf zabbix-3.4.14
zabbix-agent-service:
define ZABBIX_AGENT_SERVICE
[Unit]
Description=Zabbix Agent
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/usr/sbin/zabbix_agentd-configure
ExecStart=/usr/sbin/zabbix_agentd
ExecStartPost=sleep 3
PIDFile=/run/zabbix/zabbix_agentd.pid
Restart=always
RestartSec=100
[Install]
WantedBy=multi-user.target
endef
export ZABBIX_AGENT_SERVICE
zabbix-agent-config:
define ZABBIX_AGENT_CONFIG
config zabbix 'agent'
option server ''
endef
export ZABBIX_AGENT_CONFIG
opi:
sed -e '/^UserParameter=device\.product.*/a UserParameter=system.hw.temp,bc <<< "scale=3; `cat /sys/devices/virtual/thermal/thermal_zone0/temp`/1000"' -i /etc/zabbix_agentd.conf
sed -e '/^UserParameter=system\.hw\.temp.*/a UserParameter=system.cpu.freq.max,echo "`cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq`000"' -i /etc/zabbix_agentd.conf
sed -e '/^UserParameter=system\.hw\.temp.*/a UserParameter=system.cpu.freq.cur,echo "`cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq`000"' -i /etc/zabbix_agentd.conf
sed -e '/^UserParameter=system\.hw\.temp.*/a UserParameter=system.cpu.freq.min,echo "`cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq`000"' -i /etc/zabbix_agentd.conf
server: zabbix-server-service zabbix-server-config httpd-conf
tar xf zabbix-3.4.14.tar.gz
cd zabbix-3.4.14 && ./configure --prefix=/usr --sysconfdir=/etc --enable-server --with-openssl --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
$(MAKE) -C zabbix-3.4.14
$(MAKE) -C zabbix-3.4.14 install
install -v -Dm755 zabbix_server-configure /usr/sbin/zabbix_server-configure
sed -e 's|.*LogType=.*|LogType=system|' -i /etc/zabbix_server.conf
sed -e 's|^LogFile=.*|# LogFile=|' -i /etc/zabbix_server.conf
sed -e 's|.*PidFile=.*|PidFile=/run/zabbix/zabbix_server.pid|' -i /etc/zabbix_server.conf
sed -e 's|^DBName=.*|# DBName=|' -i /etc/zabbix_server.conf
sed -e 's|^DBUser=.*|# DBUser=|' -i /etc/zabbix_server.conf
sed -e 's|^# Include=/usr/local/etc/zabbix_server\.conf\.d/\*\.conf|Include=/etc/zabbix_server.conf.d/*.conf|' -i /etc/zabbix_server.conf
cp -rv zabbix-3.4.14/frontends/php/* /srv/www
cp zabbix.conf.php /srv/www/conf
rm /srv/www/conf/zabbix.conf.php.example
chown -v -R apache:apache /srv/www
@echo "$$HTTPD_CONF" > /etc/httpd/conf/DirectoryIndex.conf
rm /srv/www/index.html
rm /srv/www/setup.php
sed -e 's/^.*post_max_size.*=.*/post_max_size = 16M/' -i /etc/php.ini
sed -e 's/^.*max_execution_time.*=.*/max_execution_time = 300/' -i /etc/php.ini
sed -e 's/^.*max_input_time.*=.*/max_input_time = 300/' -i /etc/php.ini
sed -e 's/^.*date\.timezone.*=.*/date.timezone = UTC/' -i /etc/php.ini
@echo "d /run/zabbix 755 zabbix zabbix -" > /usr/lib/tmpfiles.d/zabbix.conf
chmod u+s /bin/ping
@echo "$$ZABBIX_SERVER_SERVICE" > /lib/systemd/system/zabbix-server.service
systemctl enable zabbix-server.service
@echo "$$ZABBIX_SERVER_CONFIG" >> /etc/config/zabbix
install -v -Dm755 zabbix /usr/share/easycwmp/functions
echo "Defaults !requiretty" >> /etc/sudoers
echo "ALL ALL=(ALL) NOPASSWD: /usr/bin/nmap" >> /etc/sudoers
rm -rf zabbix-3.4.14
zabbix-server-service:
define ZABBIX_SERVER_SERVICE
[Unit]
Description=Zabbix Server
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/usr/sbin/zabbix_server-configure
ExecStart=/usr/sbin/zabbix_server
ExecReload=/usr/sbin/zabbix_server -R config_cache_reload
ExecStartPost=sleep 3
PIDFile=/run/zabbix/zabbix_server.pid
Restart=always
RestartSec=100
[Install]
WantedBy=multi-user.target
endef
export ZABBIX_SERVER_SERVICE
zabbix-server-config:
define ZABBIX_SERVER_CONFIG
config zabbix 'server'
option hostname ''
option name ''
option startpollers '5'
endef
export ZABBIX_SERVER_CONFIG
httpd-conf:
define HTTPD_CONF
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
#
endef
export HTTPD_CONF
#!/bin/sh
#common_execute_method_param "$parameter" "$permission" "$get_cmd" "$set_cmd" "xsd:$type" "$forcedinform"
# $forcedinform should be set to 1 if the parameter is included in the inform message otherwise empty
# Default of $type = string
#############################
# Entry point functuons #
#############################
prefix_list="$prefix_list $DMROOT.Zabbix."
entry_execute_method_list="$entry_execute_method_list entry_execute_method_root_Zabbix"
entry_execute_method_list_forcedinform="$entry_execute_method_list_forcedinform entry_execute_method_root_Zabbix"
entry_execute_method_root_Zabbix() {
case "$1" in ""|"$DMROOT."|"$DMROOT.Zabbix."*)
common_execute_method_obj "$DMROOT.Zabbix." "0"
common_execute_method_obj "$DMROOT.Zabbix.Agent." "0"
common_execute_method_param "$DMROOT.Zabbix.Agent.Server" "1" "zabbix_get_agent_server" "zabbix_set_agent_server"
return 0;
;;
esac
return $E_INVALID_PARAMETER_NAME;
}
#######################################
# Data model parameters functions #
#######################################
zabbix_get_agent_server() {
echo `$UCI_GET zabbix.agent.server`
}
zabbix_set_agent_server() {
local server=`$UCI_GET zabbix.agent.server`
if [ "$server" != "$1" ]; then
$UCI_SET zabbix.agent.server="$1"
$UCI_COMMIT
chmod a+r /etc/config/zabbix
fi
}
bin
/usr/sbin/.*
/usr/lib/tmpfiles.d/.*
/usr/bin/.*
/usr/share/easycwmp/functions/.*
/lib/systemd/system/.*
man
/usr/share/man/.*
var
/var/log/.*
mail
/var/mail/.*
etc
/etc/.*
#!/bin/sh
SERVER=`/sbin/uci -q get zabbix.agent.server`
if [ ! -z "$SERVER" ]; then
echo "Server=$SERVER" > /etc/zabbix_agentd.conf.d/zabbix_agent.conf
echo "ServerActive=$SERVER" >> /etc/zabbix_agentd.conf.d/zabbix_agent.conf
else
exit 1
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment