aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@alpinelinux.org>2021-08-18 10:09:34 +0000
committerLeonardo Arena <rnalrd@alpinelinux.org>2021-08-18 10:10:18 +0000
commitbbfde1f9e951809d855ec100be468b2bd0f73817 (patch)
treec6231376f6d559700d355af1ff39261f447b74a7
parentef28ed1ec2574162333663a9b991e666b7ff30a7 (diff)
downloadaports-bbfde1f9e951809d855ec100be468b2bd0f73817.tar.gz
aports-bbfde1f9e951809d855ec100be468b2bd0f73817.tar.bz2
aports-bbfde1f9e951809d855ec100be468b2bd0f73817.tar.xz
community/zabbix: fix proc.num support in Agent 2
Broken since 5.0.13+, see https://support.zabbix.com/browse/ZBX-19614
-rw-r--r--community/zabbix/0001-Revert-.G.-ZBXNEXT-6596-added-native-linux-proc.num-.patch269
-rw-r--r--community/zabbix/APKBUILD6
2 files changed, 273 insertions, 2 deletions
diff --git a/community/zabbix/0001-Revert-.G.-ZBXNEXT-6596-added-native-linux-proc.num-.patch b/community/zabbix/0001-Revert-.G.-ZBXNEXT-6596-added-native-linux-proc.num-.patch
new file mode 100644
index 0000000000..bd7e25ba9c
--- /dev/null
+++ b/community/zabbix/0001-Revert-.G.-ZBXNEXT-6596-added-native-linux-proc.num-.patch
@@ -0,0 +1,269 @@
+From 581ae83ceaa4274fb4389d09fcf28d62d81f13d8 Mon Sep 17 00:00:00 2001
+From: Leonardo Arena <rnalrd@alpinelinux.org>
+Date: Wed, 18 Aug 2021 11:06:57 +0200
+Subject: [PATCH] Revert "...G...... [ZBXNEXT-6596] added native linux proc.num
+ support plugin to Zabbix agent 2"
+
+This reverts commit 9427f39e32c5ff5201265ab8c5f73caff9962478.
+
+See https://support.zabbix.com/browse/ZBX-19614
+---
+ src/go/pkg/zbxlib/checks_linux.go | 2 +
+ src/go/plugins/proc/proc_linux.go | 110 +------------------------
+ src/go/plugins/proc/procfs_linux.go | 24 ------
+ src/go/plugins/zabbix/sync/sync_nix.go | 1 +
+ 4 files changed, 6 insertions(+), 131 deletions(-)
+
+diff --git a/src/go/pkg/zbxlib/checks_linux.go b/src/go/pkg/zbxlib/checks_linux.go
+index 206ad9542d..99cefa30cc 100644
+--- a/src/go/pkg/zbxlib/checks_linux.go
++++ b/src/go/pkg/zbxlib/checks_linux.go
+@@ -74,6 +74,8 @@ func resolveMetric(key string) (cfunc unsafe.Pointer) {
+ cfunc = unsafe.Pointer(C.NET_DNS)
+ case "net.dns.record":
+ cfunc = unsafe.Pointer(C.NET_DNS_RECORD)
++ case "proc.num":
++ cfunc = unsafe.Pointer(C.PROC_NUM)
+ case "system.boottime":
+ cfunc = unsafe.Pointer(C.SYSTEM_BOOTTIME)
+ case "net.tcp.listen":
+diff --git a/src/go/plugins/proc/proc_linux.go b/src/go/plugins/proc/proc_linux.go
+index 20af05f34f..5b58d12071 100644
+--- a/src/go/plugins/proc/proc_linux.go
++++ b/src/go/plugins/proc/proc_linux.go
+@@ -121,7 +121,6 @@ type procQuery struct {
+ name string
+ user string
+ cmdline string
+- state string
+ }
+
+ const (
+@@ -129,7 +128,6 @@ const (
+ procInfoName
+ procInfoUser
+ procInfoCmdline
+- procInfoState
+ )
+
+ type procInfo struct {
+@@ -138,7 +136,6 @@ type procInfo struct {
+ userid int64
+ cmdline string
+ arg0 string
+- state string
+ }
+
+ type cpuUtil struct {
+@@ -172,7 +169,6 @@ func newCpuUtilQuery(q *procQuery, pattern *regexp.Regexp) (query *cpuUtilQuery,
+ return
+ }
+ }
+-
+ query.cmdlinePattern = pattern
+ return
+ }
+@@ -185,13 +181,13 @@ func (p *Plugin) prepareQueries() (queries []*cpuUtilQuery, flags int) {
+ p.mutex.Lock()
+ for q, stats := range p.queries {
+ if now.Sub(stats.accessed) > maxInactivityPeriod {
+- p.Debugf("removed unused CPU utilization query %+v", q)
++ p.Debugf("removed unused CPU utilisation query %+v", q)
+ delete(p.queries, q)
+ continue
+ }
+ var query *cpuUtilQuery
+ if query, stats.err = newCpuUtilQuery(&q, stats.cmdlinePattern); stats.err != nil {
+- p.Debugf("cannot create CPU utilization query %+v: %s", q, stats.err)
++ p.Debugf("cannot create CPU utilisation query %+v: %s", q, stats.err)
+ continue
+ }
+ queries = append(queries, query)
+@@ -415,45 +411,9 @@ func (p *Plugin) Export(key string, params []string, ctx plugin.ContextProvider)
+ }
+ return
+ }
+-func (p *PluginExport) prepareQuery(q *procQuery) (query *cpuUtilQuery, flags int, err error) {
+- regxp, err := regexp.Compile(q.cmdline)
+- if err != nil {
+- return nil, 0, fmt.Errorf("cannot compile regex for %s: %s", q.cmdline, err.Error())
+- }
+-
+- if query, err = newCpuUtilQuery(q, regxp); err != nil {
+- return nil, 0, fmt.Errorf("cannot create CPU utilization query %+v: %s", q, err.Error())
+- }
+-
+- if q.name != "" {
+- flags |= procInfoName | procInfoCmdline
+- }
+- if q.user != "" {
+- flags |= procInfoUser
+- }
+- if q.cmdline != "" {
+- flags |= procInfoCmdline
+- }
+- if q.state != "" {
+- flags |= procInfoState
+- }
+-
+- return
+-}
+
+ // Export -
+ func (p *PluginExport) Export(key string, params []string, ctx plugin.ContextProvider) (result interface{}, err error) {
+- switch key {
+- case "proc.mem":
+- return p.exportProcMem(params)
+- case "proc.num":
+- return p.exportProcNum(params)
+- }
+-
+- return nil, plugin.UnsupportedMetricError
+-}
+-
+-func (p *PluginExport) exportProcMem(params []string) (result interface{}, err error) {
+ var name, mode, cmdline, memtype string
+ var usr *user.User
+
+@@ -632,67 +592,6 @@ func (p *PluginExport) exportProcMem(params []string) (result interface{}, err e
+ return memSize, nil
+ }
+
+-func (p *PluginExport) exportProcNum(params []string) (interface{}, error) {
+- var name, userName, state, cmdline string
+- switch len(params) {
+- case 4:
+- cmdline = params[3]
+- fallthrough
+- case 3:
+- switch params[2] {
+- case "all", "":
+- case "disk":
+- state = "D"
+- case "run":
+- state = "R"
+- case "sleep":
+- state = "S"
+- case "trace":
+- state = "T"
+- case "zomb":
+- state = "Z"
+- default:
+- return nil, errors.New("Invalid third parameter.")
+- }
+- fallthrough
+- case 2:
+- userName = params[1]
+- fallthrough
+- case 1:
+- name = params[0]
+- case 0:
+- default:
+- return nil, errors.New("Too many parameters.")
+- }
+-
+- var count int
+-
+- query, flags, err := p.prepareQuery(&procQuery{name, userName, cmdline, state})
+- if err != nil {
+- p.Debugf("Failed to prepare query: %s", err.Error())
+- return count, nil
+- }
+-
+- procs, err := getProcesses(flags)
+- if err != nil {
+- return nil, fmt.Errorf("Failed to get local processes: %s", err.Error())
+- }
+-
+- for _, proc := range procs {
+- if !query.match(proc) {
+- continue
+- }
+-
+- if state != proc.state && state != "" {
+- continue
+- }
+-
+- count++
+- }
+-
+- return count, nil
+-}
+-
+ func getMax(a, b float64) float64 {
+ if a > b {
+ return a
+@@ -776,8 +675,5 @@ func (p *PluginExport) validFile(proc *procInfo, name string, uid int64, cmdRgx
+
+ func init() {
+ plugin.RegisterMetrics(&impl, "Proc", "proc.cpu.util", "Process CPU utilization percentage.")
+- plugin.RegisterMetrics(&implExport, "ProcExporter",
+- "proc.mem", "Process memory utilization values.",
+- "proc.num", "The number of processes.",
+- )
++ plugin.RegisterMetrics(&implExport, "ProcExporter", "proc.mem", "Process memory utilization values.")
+ }
+diff --git a/src/go/plugins/proc/procfs_linux.go b/src/go/plugins/proc/procfs_linux.go
+index e6e1637933..cd9427647a 100644
+--- a/src/go/plugins/proc/procfs_linux.go
++++ b/src/go/plugins/proc/procfs_linux.go
+@@ -27,7 +27,6 @@ import (
+ "io"
+ "os"
+ "strconv"
+- "strings"
+ "syscall"
+
+ "zabbix.com/pkg/procfs"
+@@ -62,22 +61,6 @@ func getProcessName(pid string) (name string, err error) {
+ return string(data[left+1 : right]), nil
+ }
+
+-func getProcessState(pid string) (name string, err error) {
+- var data []byte
+- if data, err = read2k("/proc/" + pid + "/status"); err != nil {
+- return
+- }
+-
+- s := strings.Split(string(data), "\n")
+- for _, tmp := range s {
+- if strings.HasPrefix(tmp, "State:") && len(tmp) > 7 {
+- return string(tmp[7:8]), nil
+- }
+- }
+-
+- return "", fmt.Errorf("cannot find process state /proc/%s/status", pid)
+-}
+-
+ func getProcessUserID(pid string) (userid int64, err error) {
+ var fi os.FileInfo
+ if fi, err = os.Stat("/proc/" + pid); err != nil {
+@@ -184,13 +167,6 @@ func getProcesses(flags int) (processes []*procInfo, err error) {
+ continue
+ }
+ }
+- if flags&procInfoState != 0 {
+- if info.state, tmperr = getProcessState(entries[0].Name()); tmperr != nil {
+- impl.Debugf("cannot get process %s state: %s", entries[0].Name(), tmperr)
+- continue
+- }
+- }
+-
+ processes = append(processes, info)
+ }
+
+diff --git a/src/go/plugins/zabbix/sync/sync_nix.go b/src/go/plugins/zabbix/sync/sync_nix.go
+index f22ef75fa7..b743d2e050 100644
+--- a/src/go/plugins/zabbix/sync/sync_nix.go
++++ b/src/go/plugins/zabbix/sync/sync_nix.go
+@@ -25,6 +25,7 @@ func getMetrics() []string {
+ return []string{
+ "net.dns", "Checks if DNS service is up.",
+ "net.dns.record", "Performs DNS query.",
++ "proc.num", "The number of processes.",
+ "system.hw.chassis", "Chassis information.",
+ "system.hw.devices", "Listing of PCI or USB devices.",
+ "vfs.dir.count", "Directory entry count.",
+--
+2.32.0
+
diff --git a/community/zabbix/APKBUILD b/community/zabbix/APKBUILD
index 1ae8d332d7..e48b949a57 100644
--- a/community/zabbix/APKBUILD
+++ b/community/zabbix/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=zabbix
pkgver=5.0.14
-pkgrel=0
+pkgrel=1
pkgdesc="Enterprise-class open source distributed monitoring"
url="http://www.zabbix.com"
arch="all"
@@ -39,6 +39,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/zabbix/zabbix/archive/${pkgv
musl-fix-includes.patch
zabbix_server.conf.patch
zabbix_agent2.conf.patch
+ 0001-Revert-.G.-ZBXNEXT-6596-added-native-linux-proc.num-.patch
"
builddir="$srcdir/$pkgname-${pkgver/_/}"
@@ -265,4 +266,5 @@ a26e7ac422ff60a4b8eed3603022c3a1bde640870bb9286ab061c3cb5c2fd7e91ddb317cb3d1cf61
7f70dfd602aa164ec8cc65ebb7e8274c685975f6aea9051933928051b8d9b6e368e5a673a07e7084a2105468c5085d72fa7b9f934460f10648d594f28f031a91 automake.patch
72709df7624d99b2eaab8d91d95167580e80da10b3ac65b7f27f12d858f0d051d4f9143bcabceae2bfd51aeb7c4ca93e2b74670637ec0925b026e3c52475d52b musl-fix-includes.patch
183e2d99800d8eebb932cb31c5a3e8742ce6a15e87aec50dc49d9c20b35840eb7ede9920aa62d2c7a5e3f584f5c3df398aa08e93f98fa537a3ba6db63b472a1f zabbix_server.conf.patch
-84cc513fb5593d571e06e13afd0f6cfef78cbca71824f4d79dbaac71dcb7f8c4708a78b354fa4b9b814abc7edc170f513cebd7c247182c200e5fde4f928aa085 zabbix_agent2.conf.patch"
+84cc513fb5593d571e06e13afd0f6cfef78cbca71824f4d79dbaac71dcb7f8c4708a78b354fa4b9b814abc7edc170f513cebd7c247182c200e5fde4f928aa085 zabbix_agent2.conf.patch
+f054a34c519266e86f8c556bec3e7513d71ca0917ee54112df95d3dceb480488641dfdd225360a705348c633b962d1c8f677dbaa1d965ed1cae6827f5e902e29 0001-Revert-.G.-ZBXNEXT-6596-added-native-linux-proc.num-.patch"