当前位置:网站首页>Customize ZABBIX agent RPM package
Customize ZABBIX agent RPM package
2022-07-24 06:33:00 【Step on the path of the pit】
1. Install package
yum install rpm-build rpmrebuild
2. Unpack
2.1 Create a packaging catalog
https://repo.huaweicloud.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.5-1.el7.x86_64.rpm
cd /root [[email protected] ~]# rpmrebuild -p zabbix-agent-4.0.5-1.el7.x86_64.rpm Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY result: /root/rpmbuild/RPMS/x86_64/zabbix-agent-4.0.5-1.el7.x86_64.rpm
# Directory description : [[email protected] ~]# tree /root/rpmbuild/ /root/rpmbuild/ ├── BUILD ├── BUILDROOT ├── RPMS │ └── x86_64 │ └── zabbix-agent-4.0.5-1.el7.x86_64.rpm ├── SOURCES ├── SPECS └── SRPMS BUILDROOT # The temporary installation directory of the compiled software SPECS # Deposit SPEC File directory BUILD # compile rpm The temporary directory of the package RPM # The final generated installable rpm The directory of the package SRPM # The ultimate goal of software rpm Source format storage path
2.2 extract SPEC file
[[email protected] ~]# rpmrebuild -s /root/rpmbuild/SPECS/zabbix-agent.spec -p zabbix-agent-4.0.5-1.el7.x86_64.rpm Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY Warning :zabbix-agent-4.0.5-1.el7.x86_64.rpm: head V4 RSA/SHA512 Signature, secret key ID a14fe591: NOKEY
2.3 extract rpm file
# Create a compile folder : mkdir -p /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64 # extract rpm cd /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64 rpm2cpio /root/zabbix-agent-4.0.5-1.el7.x86_64.rpm |cpio -div cd /root/rpmbuild [[email protected] rpmbuild]# tree -F . ├── BUILD/ ├── BUILDROOT/ │ └── zabbix-agent-4.0.5-1.el7.x86_64.rpm/ │ ├── etc/ │ │ ├── logrotate.d/ │ │ │ └── zabbix-agent │ │ └── zabbix/ │ │ ├── zabbix_agentd.conf │ │ └── zabbix_agentd.d/ │ │ └── userparameter_mysql.conf │ ├── usr/ │ │ ├── lib/ │ │ │ ├── systemd/ │ │ │ │ └── system/ │ │ │ │ └── zabbix-agent.service │ │ │ └── tmpfiles.d/ │ │ │ └── zabbix-agent.conf │ │ ├── sbin/ │ │ │ └── zabbix_agentd* │ │ └── share/ │ │ ├── doc/ │ │ │ └── zabbix-agent-4.0.5/ │ │ │ ├── AUTHORS │ │ │ ├── ChangeLog │ │ │ ├── COPYING │ │ │ ├── NEWS │ │ │ └── README │ │ └── man/ │ │ └── man8/ │ │ └── zabbix_agentd.8.gz │ └── var/ │ ├── log/ │ │ └── zabbix/ │ └── run/ │ └── zabbix/ ├── RPMS/ │ └── x86_64/ │ └── zabbix-agent-4.0.5-1.el7.x86_64.rpm ├── SOURCES/ ├── SPECS/ │ └── zabbix-agent.spec └── SRPMS/
2.4 Customize zabbix_agentd.conf
[[email protected] rpmbuild]# grep -v ^# /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64/etc/zabbix/zabbix_agentd.conf |sed '/^$/d' PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=200 DebugLevel=3 EnableRemoteCommands=1 Server=Zabbix Server ListenIP=0.0.0.0 ServerActive=Zabbix Server Hostname=Zabbix Server RefreshActiveChecks=60 Include=/etc/zabbix/zabbix_agentd.d/*.conf UnsafeUserParameters=1
2.5 modify spec file
# Create directory , Upload files
cd /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64/etc/zabbix
mkdir {scripts,templates}
# Upload conf File to /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64/etc/zabbix/zabbix_agentd.d Under the table of contents
# Upload script file to /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64/etc/zabbix/scripts Under the table of contents
# Upload template file to /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64/etc/zabbix/templates Under the table of contents
[[email protected] rpmbuild]# cd /root/rpmbuild/SPECS/
[[email protected] SPECS]# vim zabbix-agent.spec
# Add the path and file permissions of the custom script , Part of it
%files
%config(noreplace) %attr(0644, root, root) "/etc/logrotate.d/zabbix-agent"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/zabbix_agentd.conf"
%dir %attr(0755, root, root) "/etc/zabbix/zabbix_agentd.d"
# ----- start The new content ------
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/zabbix_agentd.d/clickhouse.conf"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/zabbix_agentd.d/mysql.conf"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/zabbix_agentd.d/osBase.conf"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/zabbix_agentd.d/zookeeper.conf"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/zabbix_agentd.d/serviceStatus.conf"
#
%dir %attr(0755, root, root) "/etc/zabbix/scripts"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/scripts/clickhouse.sh"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/scripts/mysql.sh"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/scripts/procCheck.sh"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/scripts/tcpStatus.sh"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/scripts/zookeeper.sh"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/scripts/serviceStatus.sh"
%dir %attr(0755, root, root) "/etc/zabbix/templates"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/templates/zbx_templates_mysql_master3306.xml"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/templates/zbx_templates_clickhouse18100.xml"
%config(noreplace) %attr(0644, root, root) "/etc/zabbix/templates/zbx_templates_zookeeper18127.xml"
# ----- start The new content ------
* Tue Sep 29 2015 Kodai Terashima <[email protected]> - 3.0.0alpha2-3
- add IfModule for mod_php5 in apache configuration file
%doc %attr(0644, root, root) "/usr/share/doc/zabbix-agent-4.0.5/NEWS"
%doc %attr(0644, root, root) "/usr/share/doc/zabbix-agent-4.0.5/README"
%doc %attr(0644, root, root) "/usr/share/man/man8/zabbix_agentd.8.gz"
%dir %attr(0755, zabbix, zabbix) "/var/log/zabbix"
%dir %attr(0755, zabbix, zabbix) "/var/run/zabbix"
%pre -p /bin/sh
getent group zabbix > /dev/null || groupadd -r zabbix
getent passwd zabbix > /dev/null || \
useradd -r -g zabbix -d /var/lib/zabbix -s /sbin/nologin \
-c "Zabbix Monitoring System" zabbix
:
%post -p /bin/sh
if [ $1 -eq 1 ] ; then
# Initial installation
/usr/bin/systemctl preset zabbix-agent.service >/dev/null 2>&1 || :
# The new content
sed -i "/^Hostname=/cHostname=`hostname`" /etc/zabbix/zabbix_agentd.conf >/dev/null
fi
3. pack
rpmbuild Common parameters : -bb Just compile binary rpm package -bs Just compile the source code rpm package -ba Compile both binary and source code rpm package cd /root/rpmbuild/SPECS/ [[email protected] SPECS]# rpmbuild -ba /root/rpmbuild/SPECS/zabbix-agent.spec Processing documents :zabbix-agent-4.0.5-1.el7.x86_64 Provides: config(zabbix-agent) = 4.0.5-1.el7 zabbix-agent = 4.0.5-1.el7 zabbix-agent(x86-64) = 4.0.5-1.el7 Requires(interp): /bin/sh /bin/sh /bin/sh /bin/sh Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1 Requires(pre): /bin/sh Requires(post): /bin/sh Requires(preun): /bin/sh Requires(postun): /bin/sh Obsoletes: zabbix writes :/root/rpmbuild/SRPMS/zabbix-agent-4.0.5-1.el7.src.rpm writes :/root/rpmbuild/RPMS/x86_64/zabbix-agent-4.0.5-1.el7.x86_64.rpm perform (%clean): /bin/sh -e /var/tmp/rpm-tmp.OSE0ta + umask 022 + cd /root/rpmbuild/BUILD + /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/zabbix-agent-4.0.5-1.el7.x86_64 + exit 0 # A new generation of rpm package :/root/rpmbuild/RPMS/x86_64/zabbix-agent-4.0.5-1.el7.x86_64.rpm
边栏推荐
- history命令历史记录中加时间
- [test tool]
- Leetcode refers to the duplicate number in the offer jz3 array
- 进行挂载永久挂载后无法开机
- IP notes (7)
- Batch operation of generating MySQL statements from Excel
- Install Apache manually
- Transition effect
- Mysql database - SQL summary (remember to pay attention to me! Come on in China!)
- NFS共享服务及实验
猜你喜欢

Summary of ten common vulnerabilities (principle, harm, defense)

Jenkins automated unattended operation (up / down)

Heap overflow of kernel PWN basic tutorial

Server hardware and RAID configuration practice

UE4 reload system 1. basic principle of reload system
![[226] instructions for Wireshark parameters](/img/47/0d3fd221695920e02b1f690a2a21c1.png)
[226] instructions for Wireshark parameters

Ia class summary (1)

【222】内存溢出及定位

Do not rent a server, build your own personal business website (how to buy a domain name)

leetcode剑指offer JZ73 翻转单词序列
随机推荐
测试经理/测试组长/测试主管面试题
Windows下Mysql5.7忘记root密码解决方法
手动安装Apache
Remote connection to Qunhui NAS at home [no public IP, free intranet penetration]
【214】什么是自动化框架
IP notes (10)
Leetcode sword finger offer jz23: the entry node of the link in the linked list
MySQL forgot to exit and close the window directly. How to delete the entire folder now
sed命令
Transition effect
Life warning Maxim
Sword finger offer jz10 Fibonacci sequence
IP notes (6)
PXE technology network installation
Animation effect
Use and principle of spark broadcast variable and accumulator
微信TBS在线安装内核失败的解决方法
Flink state use
Modeling of XML
UE4 reload system 1. basic principle of reload system