!22 [sync] PR-18: upgrade to ganglia web 3.7.6 add patch to improve with PHP 8

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2025-01-09 09:55:39 +00:00 committed by Gitee
commit 862491ee12
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
20 changed files with 4041 additions and 268 deletions

View File

@ -0,0 +1,60 @@
From 4ca52a1be8ef9b2ce1c62fdb4e5ba4db44132ad0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Terje=20R=C3=B8sten?= <terjeros@gmail.com>
Date: Tue, 15 Oct 2024 20:24:40 +0200
Subject: [PATCH] Fix return value from mod_python init
---
gmond/modules/python/mod_python.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/gmond/modules/python/mod_python.c b/gmond/modules/python/mod_python.c
index 484429e..cdfeb7e 100644
--- a/gmond/modules/python/mod_python.c
+++ b/gmond/modules/python/mod_python.c
@@ -601,11 +601,14 @@ static struct PyModuleDef moduledef = {
#define INITERROR return NULL
PyMODINIT_FUNC PyInit_metric_init(apr_pool_t *p)
+
#else
+
#define INITERROR return
static int pyth_metric_init (apr_pool_t *p)
#endif
+
{
DIR *dp;
struct dirent *entry;
@@ -796,6 +799,16 @@ static int pyth_metric_init (apr_pool_t *p)
#endif
}
+#if PY_MAJOR_VERSION >= 3
+static int pyth_metric_init (apr_pool_t *p) {
+ if (PyInit_metric_init(p) == NULL) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+#endif
+
static apr_status_t pyth_metric_cleanup ( void *data)
{
PyObject *pcleanup, *pobj;
@@ -913,11 +926,7 @@ static g_val_t pyth_metric_handler( int metric_index )
mmodule python_module =
{
STD_MMODULE_STUFF,
-#if PY_MAJOR_VERSION >= 3
- (int (*)(apr_pool_t *))PyInit_metric_init,
-#else
pyth_metric_init,
-#endif
NULL,
NULL, /* defined dynamically */
pyth_metric_handler,
--
2.47.0

1080
0002-2to3-pass.patch Normal file

File diff suppressed because it is too large Load Diff

534
0003-Ruff-pass.patch Normal file
View File

@ -0,0 +1,534 @@
From 0be29755dcea7e19bc347b273fa38787ecb57252 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Terje=20R=C3=B8sten?= <terjeros@gmail.com>
Date: Mon, 14 Oct 2024 20:27:57 +0200
Subject: [PATCH 3/3] Ruff pass
---
.../apache_status/apache_status.py | 5 +--
gmond/python_modules/cpu/cpu_stats.py | 3 --
gmond/python_modules/db/DBUtil.py | 6 ++--
gmond/python_modules/db/mysql.py | 2 +-
gmond/python_modules/db/redis.py | 4 +--
gmond/python_modules/db/riak.py | 9 +++---
gmond/python_modules/disk/diskstat.py | 4 +--
gmond/python_modules/disk/multidisk.py | 4 +--
gmond/python_modules/memcached/memcached.py | 6 ++--
gmond/python_modules/memory/mem_stats.py | 3 --
.../python_modules/network/multi_interface.py | 2 +-
gmond/python_modules/network/netstats.py | 4 +--
gmond/python_modules/network/tcpconn.py | 6 ++--
gmond/python_modules/network/traffic1.py | 4 +--
gmond/python_modules/nfs/nfsstats.py | 6 ++--
gmond/python_modules/process/procstat.py | 32 +++++++++----------
gmond/python_modules/ssl/entropy.py | 5 ++-
gmond/python_modules/varnish/varnish.py | 2 +-
gmond/python_modules/vm_stats/vm_stats.py | 1 -
gmond/python_modules/xen/xenstats.py | 2 --
20 files changed, 50 insertions(+), 60 deletions(-)
diff --git a/gmond/python_modules/apache_status/apache_status.py b/gmond/python_modules/apache_status/apache_status.py
index fba14ee..d375d74 100755
--- a/gmond/python_modules/apache_status/apache_status.py
+++ b/gmond/python_modules/apache_status/apache_status.py
@@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-
import os
-import threading
import time
-import urllib.request, urllib.error, urllib.parse
+import urllib.request
+import urllib.error
+import urllib.parse
import traceback
import re
import copy
diff --git a/gmond/python_modules/cpu/cpu_stats.py b/gmond/python_modules/cpu/cpu_stats.py
index 16d6165..ab518cc 100644
--- a/gmond/python_modules/cpu/cpu_stats.py
+++ b/gmond/python_modules/cpu/cpu_stats.py
@@ -1,6 +1,3 @@
-import sys
-import traceback
-import os
import re
import time
import copy
diff --git a/gmond/python_modules/db/DBUtil.py b/gmond/python_modules/db/DBUtil.py
index 66f8a78..c7e7473 100644
--- a/gmond/python_modules/db/DBUtil.py
+++ b/gmond/python_modules/db/DBUtil.py
@@ -28,7 +28,7 @@ pure python collections.defaultdict substitute
#from collections import defaultdict
try:
from collections import defaultdict
-except:
+except ImportError:
class defaultdict(dict):
def __init__(self, default_factory=None, *a, **kw):
if (default_factory is not None and
@@ -79,9 +79,9 @@ def longish(x):
try:
return int(x)
except ValueError:
- if(x.endswith(',')):
+ if x.endswith(','):
return longish(x[:-1])
- if(is_hex(x.lower()) == True):
+ if is_hex(x.lower()):
return hexlongish(x)
#print "X==(%s)(%s)(%s)" %(x, x[:-1],hexlongish(x)), sys.exc_info()[0]
return longish(x[:-1])
diff --git a/gmond/python_modules/db/mysql.py b/gmond/python_modules/db/mysql.py
index 065a6cd..5aae1cf 100644
--- a/gmond/python_modules/db/mysql.py
+++ b/gmond/python_modules/db/mysql.py
@@ -354,7 +354,7 @@ def get_stat(name):
logging.debug("fetching %s" % name)
try:
return mysql_stats[label]
- except:
+ except KeyError:
logging.error("failed to fetch %s" % name)
return 0
else:
diff --git a/gmond/python_modules/db/redis.py b/gmond/python_modules/db/redis.py
index 9101b49..285a625 100755
--- a/gmond/python_modules/db/redis.py
+++ b/gmond/python_modules/db/redis.py
@@ -34,7 +34,7 @@ def metric_handler(name):
if metric_handler.auth is not None:
s.send("*2\r\n$4\r\nAUTH\r\n$%d\r\n%s\r\n" % (len(metric_handler.auth), metric_handler.auth))
result = s.recv(100)
- if not 'OK' in result:
+ if 'OK' not in result:
return 0
s.send("*1\r\n$4\r\nINFO\r\n")
#logging.debug("sent INFO")
@@ -83,7 +83,7 @@ def metric_handler(name):
v = cps
#logging.debug("submittincg metric %s is %s" % (n, int(v)))
metric_handler.info[n] = int(v) # TODO Use value_type.
- except Exception as e:
+ except Exception:
#logging.debug("caught exception %s" % e)
pass
s.close()
diff --git a/gmond/python_modules/db/riak.py b/gmond/python_modules/db/riak.py
index 499a04f..a399931 100755
--- a/gmond/python_modules/db/riak.py
+++ b/gmond/python_modules/db/riak.py
@@ -24,7 +24,9 @@ import os
import sys
import threading
import time
-import urllib.request, urllib.error, urllib.parse
+import urllib.request
+import urllib.error
+import urllib.parse
import traceback
import json
@@ -44,7 +46,7 @@ def floatable(str):
try:
float(str)
return True
- except:
+ except ValueError:
return False
@@ -102,7 +104,6 @@ class UpdateMetricThread(threading.Thread):
def metric_of(self, name):
val = 0
- mp = name.split("_")[0]
if name in self.metric:
_Lock.acquire()
val = self.metric[name]
@@ -1062,6 +1063,6 @@ if __name__ == '__main__':
except KeyboardInterrupt:
time.sleep(0.2)
os._exit(1)
- except:
+ except Exception:
traceback.print_exc()
os._exit(1)
diff --git a/gmond/python_modules/disk/diskstat.py b/gmond/python_modules/disk/diskstat.py
index 79962ca..aea335f 100644
--- a/gmond/python_modules/disk/diskstat.py
+++ b/gmond/python_modules/disk/diskstat.py
@@ -386,7 +386,7 @@ def get_stat(name):
try:
return stats[dev][label]
- except:
+ except Exception:
logging.warning('failed to fetch [' + dev + '] ' + name)
return 0
else:
@@ -394,7 +394,7 @@ def get_stat(name):
try:
return stats[label]
- except:
+ except Exception:
logging.warning('failed to fetch ' + name)
return 0
diff --git a/gmond/python_modules/disk/multidisk.py b/gmond/python_modules/disk/multidisk.py
index b26bf59..5ad59b5 100644
--- a/gmond/python_modules/disk/multidisk.py
+++ b/gmond/python_modules/disk/multidisk.py
@@ -108,8 +108,8 @@ def metric_init(params):
global descriptors
f = open('/proc/mounts', 'r')
- for l in f:
- line = l.split()
+ for buff in f:
+ line = buff.split()
if line[3].startswith('ro'):
continue
elif Remote_Mount(line[0], line[2]):
diff --git a/gmond/python_modules/memcached/memcached.py b/gmond/python_modules/memcached/memcached.py
index 8bdb57c..b5c3df4 100644
--- a/gmond/python_modules/memcached/memcached.py
+++ b/gmond/python_modules/memcached/memcached.py
@@ -26,7 +26,7 @@ def floatable(str):
try:
float(str)
return True
- except:
+ except ValueError:
return False
@@ -58,7 +58,7 @@ class UpdateMetricThread(threading.Thread):
return
try:
self.join()
- except:
+ except Exception:
pass
def run(self):
@@ -396,6 +396,6 @@ if __name__ == '__main__':
except KeyboardInterrupt:
time.sleep(0.2)
os._exit(1)
- except:
+ except Exception:
traceback.print_exc()
os._exit(1)
diff --git a/gmond/python_modules/memory/mem_stats.py b/gmond/python_modules/memory/mem_stats.py
index b0cdc16..0a6dd6a 100644
--- a/gmond/python_modules/memory/mem_stats.py
+++ b/gmond/python_modules/memory/mem_stats.py
@@ -1,6 +1,3 @@
-import sys
-import traceback
-import os
import re
diff --git a/gmond/python_modules/network/multi_interface.py b/gmond/python_modules/network/multi_interface.py
index e4b1b04..c9f898f 100644
--- a/gmond/python_modules/network/multi_interface.py
+++ b/gmond/python_modules/network/multi_interface.py
@@ -94,7 +94,7 @@ def metric_init(params):
Desc_Skel = {
'name' : 'XXX',
'call_back' : get_delta,
- 'time_max' : 60,
+ 'time_max' : time_max,
'value_type' : 'float',
'format' : '%.0f',
'units' : '/s',
diff --git a/gmond/python_modules/network/netstats.py b/gmond/python_modules/network/netstats.py
index ba0c56f..ec65d1e 100644
--- a/gmond/python_modules/network/netstats.py
+++ b/gmond/python_modules/network/netstats.py
@@ -2,11 +2,11 @@
#
# /proc/net/netstat
-import sys
import re
import time
import copy
-import string
+
+NAME_PREFIX = 'netstat_'
PARAMS = {}
diff --git a/gmond/python_modules/network/tcpconn.py b/gmond/python_modules/network/tcpconn.py
index b97d0ed..cf55a6d 100644
--- a/gmond/python_modules/network/tcpconn.py
+++ b/gmond/python_modules/network/tcpconn.py
@@ -31,6 +31,8 @@
#******************************************************************************/
import os
+import threading
+import time
OBSOLETE_POPEN = False
try:
@@ -39,8 +41,6 @@ except ImportError:
import popen2
OBSOLETE_POPEN = True
-import threading
-import time
_WorkerThread = None # Worker thread object
_glock = threading.Lock() # Synchronization lock
@@ -230,7 +230,7 @@ class NetstatThread(threading.Thread):
def shutdown(self):
self.shuttingdown = True
- if self.popenChild != None:
+ if self.popenChild is not None:
try:
self.popenChild.wait()
except OSError as e:
diff --git a/gmond/python_modules/network/traffic1.py b/gmond/python_modules/network/traffic1.py
index 9f1078f..c5fdcba 100644
--- a/gmond/python_modules/network/traffic1.py
+++ b/gmond/python_modules/network/traffic1.py
@@ -67,8 +67,8 @@ class UpdateTrafficThread(threading.Thread):
def update_metric(self):
f = open(self.proc_file, "r")
- for l in f:
- a = l.split(":")
+ for buff in f:
+ a = buff.split(":")
dev = a[0].lstrip()
if dev != self.target_device:
continue
diff --git a/gmond/python_modules/nfs/nfsstats.py b/gmond/python_modules/nfs/nfsstats.py
index 618b1be..2d3d279 100644
--- a/gmond/python_modules/nfs/nfsstats.py
+++ b/gmond/python_modules/nfs/nfsstats.py
@@ -10,8 +10,6 @@
# 2) the code is structured in a way intended to make it easy to repurpose
# the code for extracting other information out of /proc
-import os
-import stat
import re
import time
import syslog
@@ -262,7 +260,7 @@ def metric_init(params):
else:
tests_passed = False
break
- except:
+ except Exception:
tests_passed = False
break
if not tests_passed:
@@ -362,7 +360,7 @@ def get_value(name):
for i in range(0, len(descriptors)):
if descriptors[i]['name'] == name:
break
- contents = file(descriptors[i]['file']).read()
+ contents = open(descriptors[i]['file']).read()
m = re.search(descriptors[i]['re'], contents, flags=re.MULTILINE)
m_value = m.group(1)
diff --git a/gmond/python_modules/process/procstat.py b/gmond/python_modules/process/procstat.py
index aad5229..e5c3f9a 100644
--- a/gmond/python_modules/process/procstat.py
+++ b/gmond/python_modules/process/procstat.py
@@ -128,14 +128,14 @@ PROCESSES = {}
def readCpu(pid):
try:
- stat = file('/proc/' + pid + '/stat', 'rt').readline().split()
+ stat = open('/proc/' + pid + '/stat', 'rt').readline().split()
#logging.debug(' stat (' + pid + '): ' + str(stat))
utime = int(stat[13])
stime = int(stat[14])
cutime = int(stat[15])
cstime = int(stat[16])
return (utime + stime + cutime + cstime)
- except:
+ except Exception:
logging.warning('failed to get (' + str(pid) + ') stats')
return 0
@@ -152,8 +152,8 @@ def get_pgid(proc):
if '.pid' in val[-4:]:
if os.path.exists(val):
logging.debug(' pidfile found')
- ppid = file(val, 'rt').readline().strip()
- pgid = file('/proc/' + ppid + '/stat', 'rt').readline().split()[4]
+ ppid = open(val, 'rt').readline().strip()
+ pgid = open('/proc/' + ppid + '/stat', 'rt').readline().split()[4]
else:
raise Exception('pidfile (' + val + ') does not exist')
@@ -195,10 +195,10 @@ def get_pgroup(ppid, pgid):
p_list = []
for stat_file in glob.glob('/proc/[1-9]*/stat'):
try:
- stat = file(stat_file, 'rt').readline().split()
+ stat = open(stat_file, 'rt').readline().split()
if stat[4] == pgid:
p_list.append(stat[0])
- except:
+ except Exception:
# likely the pid has exited. this is normal.
pass
@@ -225,7 +225,7 @@ def get_rss(pids):
try:
statm = open('/proc/' + p + '/statm', 'rt').readline().split()
#logging.debug(' statm (' + p + '): ' + str(statm))
- except:
+ except Exception:
# Process finished, ignore this mem usage
logging.warning(' failed getting statm for pid: ' + p)
continue
@@ -261,7 +261,7 @@ def test(params):
print(' PID, ARGS')
for pid in pids:
# Read from binary file containing command line arguments
- args = file('/proc/' + pid + '/cmdline', 'rt').readline().replace('\0', ' ')
+ args = open('/proc/' + pid + '/cmdline', 'rt').readline().replace('\0', ' ')
print((' ' + pid + ' ' + args))
logging.debug('success testing')
@@ -283,9 +283,9 @@ def update_stats():
logging.debug(' updating for ' + proc)
# setup storage lists
- if not proc in stats:
+ if proc not in stats:
stats[proc] = {}
- if not proc in last_val:
+ if proc not in last_val:
last_val[proc] = {}
#####
@@ -347,7 +347,7 @@ def get_stat(name):
try:
return stats[proc][label]
- except:
+ except Exception:
logging.warning('failed to fetch [' + proc + '] ' + name)
return 0
else:
@@ -355,7 +355,7 @@ def get_stat(name):
try:
return stats[label]
- except:
+ except Exception:
logging.warning('failed to fetch ' + name)
return 0
else:
@@ -420,7 +420,7 @@ def metric_init(params):
def display_proc_stat(pid):
try:
- stat = file('/proc/' + pid + '/stat', 'rt').readline().split()
+ stat = open('/proc/' + pid + '/stat', 'rt').readline().split()
fields = [
'pid', 'comm', 'state', 'ppid', 'pgrp', 'session',
@@ -438,14 +438,14 @@ def display_proc_stat(pid):
print('%15s: %s' % (f, stat[i]))
i += 1
- except:
+ except Exception:
print(('failed to get /proc/' + pid + '/stat'))
print((traceback.print_exc(file=sys.stdout)))
def display_proc_statm(pid):
try:
- statm = file('/proc/' + pid + '/statm', 'rt').readline().split()
+ statm = open('/proc/' + pid + '/statm', 'rt').readline().split()
fields = [
'size', 'rss', 'share', 'trs', 'drs', 'lrs', 'dt'
@@ -457,7 +457,7 @@ def display_proc_statm(pid):
print('%15s: %s' % (f, statm[i]))
i += 1
- except:
+ except Exception:
print(('failed to get /proc/' + pid + '/statm'))
print((traceback.print_exc(file=sys.stdout)))
diff --git a/gmond/python_modules/ssl/entropy.py b/gmond/python_modules/ssl/entropy.py
index 71193c6..bb9f67c 100644
--- a/gmond/python_modules/ssl/entropy.py
+++ b/gmond/python_modules/ssl/entropy.py
@@ -7,7 +7,6 @@
# (it can reuse the pool of bits).
# Therefore if you are running SSL on the box you want to know this.
-import sys
entropy_file = "/proc/sys/kernel/random/entropy_avail"
@@ -20,8 +19,8 @@ def metrics_handler(name):
except IOError:
return 0
- for l in f:
- line = l
+ for buff in f:
+ line = buff
return int(line)
diff --git a/gmond/python_modules/varnish/varnish.py b/gmond/python_modules/varnish/varnish.py
index b1a8573..e5c1b75 100755
--- a/gmond/python_modules/varnish/varnish.py
+++ b/gmond/python_modules/varnish/varnish.py
@@ -143,7 +143,7 @@ def metric_init(lparams):
Desc_Skel = {
'name' : 'XXX',
'call_back' : 'XXX',
- 'time_max' : 60,
+ 'time_max' : time_max,
'value_type' : 'float',
'format' : '%f',
'units' : 'XXX',
diff --git a/gmond/python_modules/vm_stats/vm_stats.py b/gmond/python_modules/vm_stats/vm_stats.py
index 2e1e8b8..8eb9c11 100644
--- a/gmond/python_modules/vm_stats/vm_stats.py
+++ b/gmond/python_modules/vm_stats/vm_stats.py
@@ -3,7 +3,6 @@
#
# /proc/vmstat
-import sys
import re
import time
import copy
diff --git a/gmond/python_modules/xen/xenstats.py b/gmond/python_modules/xen/xenstats.py
index bdb3750..1c328e4 100755
--- a/gmond/python_modules/xen/xenstats.py
+++ b/gmond/python_modules/xen/xenstats.py
@@ -18,8 +18,6 @@
# MA 02110-1301, USA.
import libvirt
-import os
-import time
descriptors = list()
conn = libvirt.openReadOnly("xen:///")
--
2.47.0

View File

@ -0,0 +1,62 @@
From 21656da69738482cca947cb70ad9ef25ac95cbfa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Terje=20R=C3=B8sten?= <terjeros@gmail.com>
Date: Mon, 14 Oct 2024 20:36:13 +0200
Subject: [PATCH 4/4] Use raw strings
---
gmond/python_modules/memory/mem_stats.py | 2 +-
gmond/python_modules/network/netstats.py | 4 ++--
gmond/python_modules/vm_stats/vm_stats.py | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gmond/python_modules/memory/mem_stats.py b/gmond/python_modules/memory/mem_stats.py
index 0a6dd6a..522268e 100644
--- a/gmond/python_modules/memory/mem_stats.py
+++ b/gmond/python_modules/memory/mem_stats.py
@@ -26,7 +26,7 @@ def metrics_handler(name):
if name == 'mem_swap_used':
return metrics_handler('mem_swap_total') - metrics_handler('mem_swap_free')
for line in file:
- parts = re.split("\s+", line)
+ parts = re.split(r"\s+", line)
if parts[0] == metric_map[name]['name'] + ":":
# All of the measurements are in kBytes. We want to change them over
# to Bytes
diff --git a/gmond/python_modules/network/netstats.py b/gmond/python_modules/network/netstats.py
index ec65d1e..3805f4b 100644
--- a/gmond/python_modules/network/netstats.py
+++ b/gmond/python_modules/network/netstats.py
@@ -46,7 +46,7 @@ def get_metrics():
for line in file:
if re.match("(.*): [0-9]", line):
count = 0
- metrics = re.split("\s+", line)
+ metrics = re.split(r"\s+", line)
metric_group = metrics[0].replace(":", "").lower()
if metric_group not in stats_pos:
continue
@@ -202,7 +202,7 @@ def metric_init(params):
# Lines with
if not re.match("(.*): [0-9]", line):
count = 0
- mapping = re.split("\s+", line)
+ mapping = re.split(r"\s+", line)
metric_group = mapping[0].replace(":", "").lower()
stats_pos[metric_group] = dict()
for metric in mapping:
diff --git a/gmond/python_modules/vm_stats/vm_stats.py b/gmond/python_modules/vm_stats/vm_stats.py
index 8eb9c11..fc5a241 100644
--- a/gmond/python_modules/vm_stats/vm_stats.py
+++ b/gmond/python_modules/vm_stats/vm_stats.py
@@ -46,7 +46,7 @@ def get_metrics():
# convert to dict
metrics = {}
for line in file:
- parts = re.split("\s+", line)
+ parts = re.split(r"\s+", line)
metrics[parts[0]] = parts[1]
# update cache
--
2.47.0

View File

@ -0,0 +1,27 @@
From 1d9688e7059d0a93c27bf4e74f26ad3cf1120837 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Terje=20R=C3=B8sten?= <terjeros@gmail.com>
Date: Mon, 4 Nov 2024 20:06:47 +0100
Subject: [PATCH 5/5] First loop might contain non integer input
---
gmond/python_modules/network/netstats.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gmond/python_modules/network/netstats.py b/gmond/python_modules/network/netstats.py
index 3805f4b..76f6b68 100644
--- a/gmond/python_modules/network/netstats.py
+++ b/gmond/python_modules/network/netstats.py
@@ -52,6 +52,10 @@ def get_metrics():
continue
new_metrics[metric_group] = dict()
for value in metrics:
+ try:
+ value = int(value)
+ except ValueError:
+ value = -1
# Skip first
if count > 0 and value >= 0 and count in stats_pos[metric_group]:
metric_name = stats_pos[metric_group][count]
--
2.47.0

View File

@ -1,31 +0,0 @@
From ab909037aa30bc200d467eecb1c189565604ba6a Mon Sep 17 00:00:00 2001
From: Adam Tygart <adam.tygart@gmail.com>
Date: Fri, 28 Feb 2020 10:17:20 -0600
Subject: [PATCH] Fix XSS from OBB-1005024
---
graph_all_periods.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/graph_all_periods.php b/graph_all_periods.php
index 4e90ccba..9185d646 100644
--- a/graph_all_periods.php
+++ b/graph_all_periods.php
@@ -10,12 +10,12 @@
$data->assign("refresh", $conf['default_refresh']);
$data->assign("conf", $conf);
$data->assign("embed",
- isset($_REQUEST['embed']) ? $_REQUEST['embed'] : NULL);
+ isset($_REQUEST['embed']) ? sanitize($_REQUEST['embed']) : NULL);
$data->assign("mobile",
- isset($_REQUEST['mobile']) ? $_REQUEST['mobile'] : NULL);
-$data->assign("h", isset($_GET['h']) ? $_GET['h'] : NULL);
-$data->assign("g", isset($_GET['g']) ? $_GET['g'] : NULL);
-$data->assign("m", isset($_GET['m']) ? $_GET['m'] : NULL);
+ isset($_REQUEST['mobile']) ? sanitize($_REQUEST['mobile']) : NULL);
+$data->assign("h", isset($_GET['h']) ? sanitize($_GET['h']) : NULL);
+$data->assign("g", isset($_GET['g']) ? sanitize($_GET['g']) : NULL);
+$data->assign("m", isset($_GET['m']) ? sanitize($_GET['m']) : NULL);
$data->assign("html_g",
isset($_GET['g']) ? htmlspecialchars($_GET['g']) : NULL);
$data->assign("html_m",

View File

@ -1,11 +1,11 @@
<?php <?php
/* #
/etc/ganglia/conf.php # /etc/ganglia/conf.php
#
You can use this file to override default settings. # You can use this file to override default settings.
#
For a list of available options, see /usr/share/ganglia/conf_default.php # For a list of available options, see /usr/share/ganglia/conf_default.php
*/ #
?> ?>

1413
ganglia-3.7.2-185ab6.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
--- gmond/python_modules/apache_status/apache_status.py.orig 2015-08-19 09:34:42.310000000 +1200
+++ gmond/python_modules/apache_status/apache_status.py 2015-08-19 09:35:33.989000000 +1200
@@ -86,6 +86,8 @@
for sck in split_line[1]:
metrics[ Scoreboard_bykey[sck] ] += 1
else:
+ if len(split_line) == 1:
+ continue
if long_metric_name in Metric_Map:
metric_name = Metric_Map[long_metric_name]
else:

View File

@ -0,0 +1,32 @@
diff --git a/configure.ac b/configure.ac
index fe7983b..d0a6d18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -319,22 +319,17 @@ if test x"$enable_python" = xyes; then
if test -n "$PYTHON_BIN"; then
# find out python version
AC_MSG_CHECKING(Python version)
- PyVERSION=`$PYTHON_BIN -c ['import sys; print sys.version[:3]'`]
- PyMAJVERSION=`$PYTHON_BIN -c ['import sys; print sys.version[:1]'`]
+ PyVERSION=`$PYTHON_BIN -c ['import sys; print("%s.%s%s" % (sys.version_info.major, sys.version_info.minor, sys.abiflags))'`]
+ PyMAJVERSION=`$PYTHON_BIN -c ['import sys; print(sys.version_info.major)'`]
AC_MSG_RESULT($PyVERSION)
PYTHON_VERSION=$PyVERSION
AC_SUBST(PYTHON_VERSION)
-
- PyEXEC_INSTALLDIR=`$PYTHON_BIN -c "import sys; print sys.exec_prefix"`
- if test -f "$PyEXEC_INSTALLDIR/include/python/Python.h"; then
- PYTHON_INCLUDES="-I$PyEXEC_INSTALLDIR/include/python"
+ PyINC_DIR=`$PYTHON_BIN -c ['import sysconfig; print(sysconfig.get_paths()["include"])'`]
+ if test -f "$PyINC_DIR/Python.h"; then
+ PYTHON_INCLUDES="-I$PyINC_DIR"
else
- if test -f "$PyEXEC_INSTALLDIR/include/python$PyVERSION/Python.h"; then
- PYTHON_INCLUDES="-I$PyEXEC_INSTALLDIR/include/python$PyVERSION"
- else
PYTHON_INCLUDES=""
enable_python="no"
- fi
fi
AC_SUBST(PYTHON_INCLUDES)
else

View File

@ -0,0 +1,33 @@
--- ganglia-3.7.2/gmond/gmond.c~ 2015-07-01 21:49:35.000000000 +0200
+++ ganglia-3.7.2/gmond/gmond.c 2024-02-05 19:54:03.584404224 +0100
@@ -2060,7 +2060,7 @@
debug_msg("failed to allocate gzip stream");
goto close_accept_socket;
}
- apr_status_t r = apr_socket_data_set(client, strm, GZIP_KEY, &zstream_destroy);
+ apr_status_t r = apr_socket_data_set(client, strm, GZIP_KEY, (int (*)(void *))&zstream_destroy);
if (r != APR_SUCCESS)
{
debug_msg("failed to set socket user data");
diff --git a/gmetad/rrd_helpers.c b/gmetad/rrd_helpers.c
index 740799a..3f39071 100644
--- a/gmetad/rrd_helpers.c
+++ b/gmetad/rrd_helpers.c
@@ -199,7 +199,7 @@ reconnect:
static int
RRD_update( char *rrd, const char *sum, const char *num, unsigned int process_time )
{
- char *argv[3];
+ const char *argv[3];
int argc = 3;
char val[128];
@@ -235,7 +235,7 @@ RRD_create( char *rrd, int summary, unsigned int step,
unsigned int process_time, ganglia_slope_t slope)
{
const char *data_source_type = "GAUGE";
- char *argv[128];
+ const char *argv[128];
int argc=0;
int heartbeat;
char s[16], start[64];

126
ganglia-3.7.2-pcre2.patch Normal file
View File

@ -0,0 +1,126 @@
From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000041
--- ganglia.orig/configure.ac
+++ ganglia/configure.ac
@@ -520,14 +520,20 @@
echo "Added -L$libpcrepath/${LIB_SUFFIX} to LDFLAGS"
fi
if test x"$libpcre" == xyes ; then
- AC_CHECK_HEADERS([pcre/pcre.h pcre.h])
- AC_CHECK_LIB(pcre, pcre_compile)
- if test x"$ac_cv_lib_pcre_pcre_compile" = xyes; then
- echo "Found a suitable pcre library"
- else
- echo "libpcre not found, specify --with-libpcre=no to build without PCRE support"
- exit 1;
- fi
+ AC_CHECK_HEADERS([pcre2.h], [], [], [[#define PCRE2_CODE_UNIT_WIDTH 8]])
+ LIBS="$LIBS -lpcre2-8"
+ AC_MSG_CHECKING([for pcre2_match_data_create in -lpcre2-8])
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[#define PCRE2_CODE_UNIT_WIDTH 8
+ #include <pcre2.h>
+ ]],
+ [[pcre2_match_data *md;
+ md = pcre2_match_data_create (16, NULL);]])],
+ [AC_DEFINE([HAVE_LIBPCRE], [1], [Define if the PCRE2 library is available])
+ AC_MSG_RESULT([yes])
+ AC_MSG_RESULT([Found a suitable pcre library])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([libpcre not found, specify --with-libpcre=no to build without PCRE support], [1])])
else
echo "building without PCRE support"
fi
--- ganglia.orig/gmond/gmond.c
+++ ganglia/gmond/gmond.c
@@ -38,11 +38,8 @@
#include <apr_version.h>
#ifdef HAVE_LIBPCRE
-#if defined (HAVE_PCRE_PCRE_H)
-#include <pcre/pcre.h>
-#else
-#include <pcre.h>
-#endif
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
#endif
#include "cmdline.h" /* generated by cmdline.sh which runs gengetopt */
@@ -2650,10 +2647,11 @@
if(name_match != NULL)
{
- pcre *pcre_re;
- const char *pcre_err_ptr;
- int pcre_err_offset;
- int pcre_ovector[PCRE_OVECCOUNT];
+ pcre2_code *pcre_re;
+ pcre2_match_data *pcre_md;
+ int pcre_err_ptr;
+ size_t pcre_err_offset;
+ size_t *pcre_ovector;
int pcre_rc;
apr_hash_index_t *hi;
@@ -2662,9 +2660,9 @@
const char *key;
int found = 0;
- if((pcre_re = pcre_compile(name_match, 0, &pcre_err_ptr, &pcre_err_offset, NULL)) == NULL)
+ if((pcre_re = pcre2_compile((PCRE2_SPTR)name_match, PCRE2_ZERO_TERMINATED, 0, &pcre_err_ptr, &pcre_err_offset, NULL)) == NULL)
{
- err_msg ("pcre_compile failed on %s\n", name_match);
+ err_msg ("pcre2_compile failed on %s\n", name_match);
exit (1);
}
@@ -2676,6 +2674,8 @@
exit(EXIT_FAILURE);
}
+ pcre_md = pcre2_match_data_create(PCRE_OVECCOUNT, NULL);
+
for(hi = apr_hash_first(p, metric_callbacks);
hi;
hi = apr_hash_next(hi))
@@ -2683,17 +2683,17 @@
Ganglia_metric_callback *cb;
apr_hash_this(hi, (const void**)&key, NULL, &val);
- if((pcre_rc = pcre_exec(pcre_re, NULL, key, strlen(key), 0, 0, pcre_ovector, PCRE_OVECCOUNT)) < 1)
+ if((pcre_rc = pcre2_match(pcre_re, (PCRE2_SPTR)key, strlen(key), 0, 0, pcre_md, NULL)) < 1)
{
switch(pcre_rc)
{
- case PCRE_ERROR_NOMATCH:
+ case PCRE2_ERROR_NOMATCH:
break;
case 0:
/* output vector not big enough */
default:
/* unexpected error */
- err_msg ("unexpected pcre_exec error\n");
+ err_msg ("unexpected pcre2_match error\n");
exit (1);
}
}
@@ -2703,6 +2703,8 @@
char *title_tmpl = cfg_getstr ( metric, "title");
float value_threshold = cfg_getfloat( metric, "value_threshold");
+ pcre_ovector = pcre2_get_ovector_pointer(pcre_md);
+
if(title_tmpl != NULL)
{
struct iovec *ptrs;
@@ -2772,6 +2774,8 @@
if (!found)
err_msg("Unable to find any metric information for '%s'. Possible that a module has not been loaded.\n", name_match);
+ pcre2_match_data_free(pcre_md);
+ pcre2_code_free(pcre_re);
}
else
#endif

View File

@ -1,13 +0,0 @@
--- gmond/sflow.c.orig 2016-12-02 09:56:38.744353600 +0000
+++ gmond/sflow.c 2016-12-02 09:47:45.666353600 +0000
@@ -303,7 +303,8 @@
char mtitle_buf[SFLOW_MAX_METRIC_NAME_LEN];
if(ok || sflowCFG.submit_null_str) {
set_metric_name_and_title(&mname, &mtitle, mname_buf, mtitle_buf, metric_prefix, tag);
- fmsg.id = vmsg.id = gmetric_uint;
+ //fmsg.id = vmsg.id = gmetric_uint;
+ fmsg.id = vmsg.id = gmetric_string;
fmsg.Ganglia_metadata_msg_u.gfull.metric.type = "string";
vmsg.Ganglia_value_msg_u.gstr.metric_id.name = mname;
vmsg.Ganglia_value_msg_u.gstr.str = (ok ? (char *)val : sflowCFG.null_str);

View File

@ -0,0 +1,176 @@
diff --git a/gmond/modules/python/mod_python.c b/gmond/modules/python/mod_python.c
index ed5a401..484429e 100644
--- a/gmond/modules/python/mod_python.c
+++ b/gmond/modules/python/mod_python.c
@@ -29,6 +29,10 @@
*
* Author: Brad Nicholes (bnicholes novell.com)
* Jon Carey (jcarey novell.com)
+*
+* Modified for Python3 support, based on code at https://docs.python.org/3.5/howto/cporting.html
+* Tom Crane (T.Crane@rhul.ac.uk), June 2024.
+*
******************************************************************************/
#include <Python.h>
@@ -51,12 +55,23 @@
/*
* Backward compatibility for 2.1 to 2.4
*/
+#if PY_MAJOR_VERSION < 3
#if PY_MINOR_VERSION < 5
#define Py_ssize_t int
#if PY_MINOR_VERSION < 3
#define PyInt_AsUnsignedLongMask PyInt_AsLong
#endif
#endif
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+# define PyInt_AsLong(x) (PyLong_AsLong((x)))
+# define PyInt_Check(x) (PyLong_Check((x)))
+# define PyString_Check(x) (PyUnicode_Check((x)))
+# define PyString_AsString(x) (PyUnicode_AsUTF8((x)))
+# define PyInt_AsUnsignedLongMask(x) (PyLong_AsUnsignedLongMask((x)))
+# define PyString_FromString(x) (PyUnicode_FromString((x)))
+#endif
/*
* Declare ourselves so the configuration routines can find and know us.
@@ -540,7 +555,57 @@ static PyMethodDef GangliaMethods[] = {
{NULL, NULL, 0, NULL}
};
+struct module_state {
+ PyObject *error;
+};
+
+#if PY_MAJOR_VERSION >= 3
+#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
+#else
+#define GETSTATE(m) (&_state)
+static struct module_state _state;
+#endif
+
+static PyObject *
+error_out(PyObject *m) {
+ struct module_state *st = GETSTATE(m);
+ PyErr_SetString(st->error, "something bad happened");
+ return NULL;
+}
+
+#if PY_MAJOR_VERSION >= 3
+
+static int ganglia_traverse(PyObject *m, visitproc visit, void *arg) {
+ Py_VISIT(GETSTATE(m)->error);
+ return 0;
+}
+
+static int ganglia_clear(PyObject *m) {
+ Py_CLEAR(GETSTATE(m)->error);
+ return 0;
+}
+
+
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "ganglia",
+ NULL,
+ sizeof(struct module_state),
+ GangliaMethods,
+ NULL,
+ ganglia_traverse,
+ ganglia_clear,
+ NULL
+};
+
+#define INITERROR return NULL
+
+PyMODINIT_FUNC PyInit_metric_init(apr_pool_t *p)
+#else
+#define INITERROR return
+
static int pyth_metric_init (apr_pool_t *p)
+#endif
{
DIR *dp;
struct dirent *entry;
@@ -563,29 +628,41 @@ static int pyth_metric_init (apr_pool_t *p)
if (!path) {
err_msg("[PYTHON] Missing python module path.\n");
- return -1;
+ INITERROR;
}
if (access(path, F_OK))
{
/* 'path' does not exist */
err_msg("[PYTHON] Can't open the python module path %s.\n", path);
- return -1;
+ INITERROR;
}
if (access(path, R_OK))
{
/* Don't have read access to 'path' */
err_msg("[PYTHON] Can't read from the python module path %s.\n", path);
- return -1;
+ INITERROR;
}
/* Init Python environment */
/* Set up the python path to be able to load module from our module path */
Py_Initialize();
- Py_InitModule("ganglia", GangliaMethods);
+#if PY_MAJOR_VERSION >= 3
+ PyObject *module = PyModule_Create(&moduledef);
+#else
+ PyObject *module = Py_InitModule("ganglia", GangliaMethods);
+#endif
+ if (module == NULL)
+ INITERROR;
+ struct module_state *st = GETSTATE(module);
+ st->error = PyErr_NewException("ganglia.Error", NULL, NULL);
+ if (st->error == NULL) {
+ Py_DECREF(module);
+ INITERROR;
+ }
PyObject *sys_path = PySys_GetObject("path");
PyObject *addpath = PyString_FromString(path);
PyList_Append(sys_path, addpath);
@@ -598,7 +675,7 @@ static int pyth_metric_init (apr_pool_t *p)
/* Error: Cannot open the directory - Shouldn't happen */
/* Log? */
err_msg("[PYTHON] Can't open the python module path %s.\n", path);
- return -1;
+ INITERROR;
}
i = 0;
@@ -712,7 +789,11 @@ static int pyth_metric_init (apr_pool_t *p)
memset (mi, 0, sizeof(*mi));
python_module.metrics_info = (Ganglia_25metric *)metric_info->elts;
+#if PY_MAJOR_VERSION >= 3
+ return module;
+#else
return 0;
+#endif
}
static apr_status_t pyth_metric_cleanup ( void *data)
@@ -832,7 +913,11 @@ static g_val_t pyth_metric_handler( int metric_index )
mmodule python_module =
{
STD_MMODULE_STUFF,
+#if PY_MAJOR_VERSION >= 3
+ (int (*)(apr_pool_t *))PyInit_metric_init,
+#else
pyth_metric_init,
+#endif
NULL,
NULL, /* defined dynamically */
pyth_metric_handler,

Binary file not shown.

View File

@ -0,0 +1,169 @@
From:
https://bugzilla.redhat.com/show_bug.cgi?id=2180500
diff --git a/api/host.php b/api/host.php
index 5eb026c..5cee9ec 100644
--- a/api/host.php
+++ b/api/host.php
@@ -87,7 +87,7 @@ switch ( $_GET['action'] ) {
$reports["excluded_reports"] = array_unique($reports["excluded_reports"]);
$additional_cluster_img_html_args = array();
$additional_cluster_img_html_args['h'] = $hostname;
- $additional_cluster_img_html_args['st'] = $cluster[LOCALTIME];
+ $additional_cluster_img_html_args['st'] = $cluster['LOCALTIME'];
$additional_cluster_img_html_args['m'] = $metricname;
$additional_cluster_img_html_args['r'] = $range;
$additional_cluster_img_html_args['s'] = $sort;
@@ -152,7 +152,7 @@ switch ( $_GET['action'] ) {
$graph_arguments['z'] = $size;
$graph_arguments['jr'] = $jobrange;
$graph_arguments['js'] = $jobstart;
- $graph_arguments['st'] = $cluster[LOCALTIME];
+ $graph_arguments['st'] = $cluster['LOCALTIME'];
# Adding units to graph 2003 by Jason Smith <smithj4@bnl.gov>.
if ($v['UNITS']) {
$graph_arguments['vl'] = $metrics[$cluster_url]['UNITS'];
diff --git a/dwoo/Dwoo/Core.php b/dwoo/Dwoo/Core.php
index 8ec104b..fc62cde 100644
--- a/dwoo/Dwoo/Core.php
+++ b/dwoo/Dwoo/Core.php
@@ -1250,7 +1250,7 @@ class Dwoo_Core
}
unset($varstr);
- while (list($k, $sep) = each($m[1])) {
+ foreach($m[1] as $k => $sep){
if ($sep === '.' || $sep === '[' || $sep === '') {
// strip enclosing quotes if present
$m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);
@@ -1425,7 +1425,7 @@ class Dwoo_Core
$cur = $this->scope;
}
- while (list($k, $sep) = each($m[1])) {
+ foreach($m[1] as $k => $sep){
if ($sep === '.' || $sep === '[' || $sep === '') {
if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) {
$cur = $cur[$m[2][$k]];
@@ -1470,7 +1470,7 @@ class Dwoo_Core
$cur =& $this->scope;
$last = array(array_pop($m[1]), array_pop($m[2]));
- while (list($k, $sep) = each($m[1])) {
+ foreach($m[1] as $k => $sep){
if ($sep === '.' || $sep === '[' || $sep === '') {
if (is_array($cur) === false) {
$cur = array();
diff --git a/dwoo/Dwoo/Data.php b/dwoo/Dwoo/Data.php
index c5f292e..d841546 100644
--- a/dwoo/Dwoo/Data.php
+++ b/dwoo/Dwoo/Data.php
@@ -71,7 +71,7 @@ class Dwoo_Data implements Dwoo_IDataProvider
public function mergeData(array $data)
{
$args = func_get_args();
- while (list(,$v) = each($args)) {
+ foreach($args as $v){
if (is_array($v)) {
$this->data = array_merge($this->data, $v);
}
@@ -90,7 +90,7 @@ class Dwoo_Data implements Dwoo_IDataProvider
{
if (is_array($name)) {
reset($name);
- while (list($k,$v) = each($name))
+ foreach($name as $k => $v)
$this->data[$k] = $v;
} else {
$this->data[$name] = $val;
diff --git a/dwoo/plugins/builtin/blocks/textformat.php b/dwoo/plugins/builtin/blocks/textformat.php
index fb0f422..61ec1d6 100644
--- a/dwoo/plugins/builtin/blocks/textformat.php
+++ b/dwoo/plugins/builtin/blocks/textformat.php
@@ -67,7 +67,7 @@ class Dwoo_Plugin_textformat extends Dwoo_Block_Plugin
// gets paragraphs
$pgs = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->buffer));
- while (list($i,) = each($pgs)) {
+ foreach($pgs as $i){
if (empty($pgs[$i])) {
continue;
}
diff --git a/dwoo/plugins/builtin/functions/capitalize.php b/dwoo/plugins/builtin/functions/capitalize.php
index d04f39b..de57c20 100644
--- a/dwoo/plugins/builtin/functions/capitalize.php
+++ b/dwoo/plugins/builtin/functions/capitalize.php
@@ -25,7 +25,7 @@ function Dwoo_Plugin_capitalize(Dwoo_Core $dwoo, $value, $numwords=false)
} else {
$bits = explode(' ', (string) $value);
$out = '';
- while (list(,$v) = each($bits)) {
+ foreach($bits as $v){
if (preg_match('#^[^0-9]+$#', $v)) {
$out .= ' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
} else {
diff --git a/host_view.php b/host_view.php
index ca05c8d..3b54b35 100644
--- a/host_view.php
+++ b/host_view.php
@@ -329,7 +329,7 @@ $cluster_url = rawurlencode($clustername);
$baseGraphArgs = "c=$cluster_url&amp;h=" . $user['hostname']
. "&amp;r=" . $user['range'] . "&amp;z=$size&amp;jr=$jobrange"
- . "&amp;js=$jobstart&amp;st=$cluster[LOCALTIME]";
+ . "&amp;js=$jobstart&amp;st=" . $cluster['LOCALTIME'];
if ($user['cs'])
$baseGraphArgs .= "&amp;cs=" . rawurlencode($user['cs']);
if ($user['ce'])
diff --git a/lib/GangliaAuth.php b/lib/GangliaAuth.php
index 01ca10d..bda8f84 100644
--- a/lib/GangliaAuth.php
+++ b/lib/GangliaAuth.php
@@ -94,7 +94,7 @@ class GangliaAuth {
}
protected function getMagicQuotesGpc() {
- return get_magic_quotes_gpc();
+ return false;
}
}
?>
diff --git a/metric_group_view.php b/metric_group_view.php
index 13dc0a1..f526545 100644
--- a/metric_group_view.php
+++ b/metric_group_view.php
@@ -105,7 +105,7 @@ $cluster_url = rawurlencode($clustername);
$baseGraphArgs = "c=$cluster_url&amp;h=$hostname"
. "&amp;r=$range&amp;z=$size&amp;jr=$jobrange"
- . "&amp;js=$jobstart&amp;st=$cluster[LOCALTIME]";
+ . "&amp;js=$jobstart&amp;st=$cluster['LOCALTIME']";
if ($cs)
$baseGraphArgs .= "&amp;cs=" . rawurlencode($cs);
if ($ce)
diff --git a/mobile_helper.php b/mobile_helper.php
index d9e20cb..2b384ad 100644
--- a/mobile_helper.php
+++ b/mobile_helper.php
@@ -268,7 +268,7 @@ foreach ($metrics as $metric_name => $metric_attributes) {
else {
$metric_graphargs = "c=".rawurlencode($clustername)."&amp;h=".rawurlencode($hostname)."&amp;v=".rawurlencode($metric_attributes['VAL'])
."&amp;m=$metric_name&amp;r=".rawurlencode($range)."&amp;z=$size&amp;jr=$jobrange"
- ."&amp;js=$jobstart&amp;st=$cluster[LOCALTIME]";
+ ."&amp;js=$jobstart&amp;st=$cluster['LOCALTIME']";
if ($cs)
$metric_graphargs .= "&amp;cs=" . rawurlencode($cs);
if ($ce)
diff --git a/physical_view.php b/physical_view.php
index 8d5c3bc..a0d4111 100644
--- a/physical_view.php
+++ b/physical_view.php
@@ -99,7 +99,7 @@ function physical_racks() {
else {
ksort($racks);
reset($racks);
- while (list($rack,) = each($racks)) {
+ foreach($racks as $rack){
# In our convention, y=0 is close to the floor. (Easier to wire up)
krsort($racks[$rack]);
}

View File

@ -0,0 +1,121 @@
diff --git a/Makefile b/Makefile
index 6d2dd1b..a3ab48a 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ PHPCBF = phpcbf
##########################################################
# Gweb version
-GWEB_VERSION = 3.7.5
+GWEB_VERSION = 3.7.7
DIST_NAME = ganglia-web
DIST_DIR = $(DIST_NAME)-$(GWEB_VERSION)
diff --git a/cluster_view.php b/cluster_view.php
index 998ad65..fed4ed8 100644
--- a/cluster_view.php
+++ b/cluster_view.php
@@ -372,7 +372,7 @@ function get_cluster_overview($showhosts,
$overview["cluster_load"] = join(", ", $cluster_load);
$avg_cpu_num = find_avg($clustername, "", "cpu_num");
- if ($avg_cpu_num == 0)
+ if ((float)$avg_cpu_num == 0)
$avg_cpu_num = 1;
$cluster_util =
sprintf("%.0f%%",
diff --git a/ganglia.php b/ganglia.php
index 262b88e..3d1b325 100644
--- a/ganglia.php
+++ b/ganglia.php
@@ -350,7 +350,7 @@ function Gmetad () {
}
if ($debug) print "<br/>DEBUG: Creating parser\n";
- if ( isset($context) && is_array($context) && isset($SKIP_GMETAD_CONTEXTS) && is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
+ if ( is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
return TRUE;
}
$parser = xml_parser_create();
diff --git a/get_ganglia.php b/get_ganglia.php
index 50e5fe8..d9c4f2e 100644
--- a/get_ganglia.php
+++ b/get_ganglia.php
@@ -7,7 +7,7 @@
# If we are in compare_hosts, views and decompose_graph context we shouldn't attempt
# any connections to the gmetad
-if (! in_array($context, $SKIP_GMETAD_CONTEXTS) ) {
+if (! ( is_array($SKIP_GMETAD_CONTEXTS) && in_array($context, $SKIP_GMETAD_CONTEXTS) ) ) {
if (! Gmetad($conf['ganglia_ip'], $conf['ganglia_port']) )
{
print "<H4>There was an error collecting ganglia data ".
diff --git a/graph.php b/graph.php
index e8a7a9c..bf34014 100644
--- a/graph.php
+++ b/graph.php
@@ -1552,7 +1552,7 @@ if ($sourcetime) {
// Fix from Phil Radden, but step is not always 15 anymore.
if ($range == "month")
- $rrdtool_graph['end'] = floor($rrdtool_graph['end'] / 672) * 672;
+ $rrdtool_graph['end'] = floor((int)$rrdtool_graph['end'] / 672) * 672;
///////////////////////////////////////////////////////////////////////////////
// Are we generating aggregate graphs
diff --git a/meta_view.php b/meta_view.php
index aa79e15..e6490af 100644
--- a/meta_view.php
+++ b/meta_view.php
@@ -119,7 +119,7 @@ foreach ( $sorted_sources as $source => $val )
$clusname = $source == $self ? '' : $source;
$avg_cpu_num = find_avg($clusname, "", "cpu_num");
- if ($avg_cpu_num == 0) $avg_cpu_num = 1;
+ if ((float)$avg_cpu_num == 0) $avg_cpu_num = 1;
$cluster_util = sprintf("%.0f", ((double) find_avg($clusname, "", "load_one") / $avg_cpu_num ) * 100);
$sources[$source]["name"] = $name;
diff --git a/mobile_helper.php b/mobile_helper.php
index db45bb7..d9e20cb 100644
--- a/mobile_helper.php
+++ b/mobile_helper.php
@@ -266,7 +266,7 @@ foreach ($metrics as $metric_name => $metric_attributes) {
} else if (isset($reports[$metric_name]) and $reports[$metric])
continue;
else {
- $metric_graphargs = "c=".rawurlencode($clustername)."&amp;h=".rawurlencode($hostname)."&amp;v=".rawurlencode($metric_attributes[VAL])
+ $metric_graphargs = "c=".rawurlencode($clustername)."&amp;h=".rawurlencode($hostname)."&amp;v=".rawurlencode($metric_attributes['VAL'])
."&amp;m=$metric_name&amp;r=".rawurlencode($range)."&amp;z=$size&amp;jr=$jobrange"
."&amp;js=$jobstart&amp;st=$cluster[LOCALTIME]";
if ($cs)
diff --git a/pie.php b/pie.php
index 0e94bbe..24afad9 100644
--- a/pie.php
+++ b/pie.php
@@ -276,7 +276,11 @@ $to = 0;
$x; //PHPCS
$y; //PHPCS
- $pie_count = count( $angles );
+ if is_null( $angles ) {
+ $pie_count = 0;
+ } else {
+ $pie_count = count( $angles );
+ }
$PIE_THICKNESS = ($this->diameter * 0.075);
for( $j = ($this->center_y+$PIE_THICKNESS); $j > $this->center_y; $j-- ) {
diff --git a/templates/default/footer.tpl b/templates/default/footer.tpl
index af9fb5e..548a8e4 100644
--- a/templates/default/footer.tpl
+++ b/templates/default/footer.tpl
@@ -92,7 +92,7 @@ Loading view, please wait...<img src="img/spinner.gif" />
<div align="center" class="footer" style="font-size:small;clear:both;" {if $hide_footer} style="visibility:hidden;display:none;" {/if}>
<hr />
Ganglia Web Frontend version {$webfrontend_version}
-<a href="http://ganglia.sourceforge.net/downloads.php?component=ganglia-webfrontend&amp;version={$webfrontend_version}">Check for Updates.</a><br />
+<a href="https://github.com/ganglia/ganglia-web" target="_blank">Check for Updates.</a><br />
Ganglia Web Backend <i>({$webbackend_component})</i> version {$webbackend_version}
<a href="http://ganglia.sourceforge.net/downloads.php?component={$webbackend_component}&amp;version={$webbackend_version}">Check for Updates.</a><br />

BIN
ganglia-web-3.7.6.tar.gz Normal file

Binary file not shown.

View File

@ -1,132 +0,0 @@
diff --git a/conf_default.php.in b/conf_default.php.in
index 9efa9ef..f7602cd 100644
--- a/conf_default.php.in
+++ b/conf_default.php.in
@@ -135,6 +135,7 @@ $conf['cpu_gnice_color'] = "fff261";
# Colors for the MEMORY report graph
#
$conf['mem_used_color'] = "5555cc";
+$conf['mem_available_color'] = "2030F4";
$conf['mem_shared_color'] = "0000aa";
$conf['mem_cached_color'] = "33cc33";
$conf['mem_slab_color'] = "66e533";
diff --git a/functions.php b/functions.php
index be9fa4a..afbb586 100644
--- a/functions.php
+++ b/functions.php
@@ -1121,8 +1121,8 @@ function build_aggregate_graph_config ($graph_type,
$line_width,
$hreg,
$mreg,
- $glegend,
- $exclude_host_from_legend_label,
+ $glegend = NULL,
+ $exclude_host_from_legend_label = false,
$sortit = true) {
global $conf, $index_array, $hosts, $grid, $clusters, $debug, $metrics;
diff --git a/graph.d/mem_report.php b/graph.d/mem_report.php
index d443965..58d167d 100644
--- a/graph.d/mem_report.php
+++ b/graph.d/mem_report.php
@@ -48,6 +48,8 @@ function graph_mem_report ( &$rrdtool_graph ) {
$bmem_slab_defs = '';
$bmem_buffers_defs = '';
$bmem_used_cdef = "CDEF:'bmem_used'='bmem_total','bmem_free',-,'bmem_cached',-";
+ $bmem_available_defs = '';
+ $bmem_realused_cdef = '';
if (file_exists("$rrd_dir/mem_shared.rrd")) {
$bmem_used_cdef .= ",'bmem_shared',UN,0,'bmem_shared',IF,-";
@@ -67,6 +69,12 @@ function graph_mem_report ( &$rrdtool_graph ) {
."CDEF:'bmem_buffers'=mem_buffers,1024,* ";
}
+ if (file_exists("$rrd_dir/mem_available.rrd")) {
+ $bmem_realused_cdef = "CDEF:'bmem_realused'='bmem_total','bmem_available',- ";
+ $bmem_available_defs = "DEF:'mem_available'='${rrd_dir}/mem_available.rrd':'sum':AVERAGE "
+ ."CDEF:'bmem_available'=mem_available,1024,* ";
+ }
+
$series = "DEF:'mem_total'='${rrd_dir}/mem_total.rrd':'sum':AVERAGE "
."CDEF:'bmem_total'=mem_total,1024,* "
.$bmem_shared_defs
@@ -76,6 +84,8 @@ function graph_mem_report ( &$rrdtool_graph ) {
."CDEF:'bmem_cached'=mem_cached,1024,* "
.$bmem_slab_defs
.$bmem_buffers_defs
+ .$bmem_available_defs
+ .$bmem_realused_cdef
."$bmem_used_cdef "
."AREA:'bmem_used'#${conf['mem_used_color']}:'Use${rmspace}' ";
@@ -188,6 +198,22 @@ function graph_mem_report ( &$rrdtool_graph ) {
}
}
+ if (file_exists("$rrd_dir/mem_available.rrd")) {
+ $series .= "LINE2:'bmem_realused'#${conf['mem_available_color']}:'Avail${rmspace}' ";
+
+ if ( $conf['graphreport_stats'] ) {
+ $series .= "CDEF:available_pos=bmem_available,0,INF,LIMIT "
+ . "VDEF:available_last=available_pos,LAST "
+ . "VDEF:available_min=available_pos,MINIMUM "
+ . "VDEF:available_avg=available_pos,AVERAGE "
+ . "VDEF:available_max=available_pos,MAXIMUM "
+ . "GPRINT:'available_last':' ${space1}Now\:%6.1lf%s' "
+ . "GPRINT:'available_min':'${space1}Min\:%6.1lf%s${eol1}' "
+ . "GPRINT:'available_avg':'${space2}Avg\:%6.1lf%s' "
+ . "GPRINT:'available_max':'${space1}Max\:%6.1lf%s\\l' ";
+ }
+ }
+
$series .= "LINE2:'bmem_total'#${conf['cpu_num_color']}:'Total${rmspace}' ";
if ( $conf['graphreport_stats'] ) {
diff --git a/header.php b/header.php
index 91af0a2..729fe27 100644
--- a/header.php
+++ b/header.php
@@ -263,7 +263,7 @@ if ($initgrid or $gridwalk)
# Use cookie so we dont have to pass gridstack around within this site.
# Cookie values are automatically urlencoded. Expires in a day.
if ( !isset($_COOKIE["gs"]) or $_COOKIE["gs"] != $gridstack_str )
- setcookie("gs", $gridstack_str, time() + 86400);
+ setcookie("gs", $gridstack_str, time() + 86400, NULL, NULL, true, true);
}
# Invariant: back pointer is second-to-last element of gridstack. Grid stack
diff --git a/lib/GangliaAuth.php b/lib/GangliaAuth.php
index 4a4d1da..01ca10d 100644
--- a/lib/GangliaAuth.php
+++ b/lib/GangliaAuth.php
@@ -82,14 +82,14 @@ class GangliaAuth {
// this is how a user 'logs in'.
public function setAuthCookie($user, $group=null) {
- setcookie('ganglia_auth', json_encode( array('user'=>$user, 'group'=>$group, 'token'=>$this->getAuthToken($user)) ) );
+ setcookie('ganglia_auth', json_encode( array('user'=>$user, 'group'=>$group, 'token'=>$this->getAuthToken($user)) ), NULL, NULL, NULL, true, true );
$this->user = $user;
$this->group = $group;
$this->tokenIsValid = true;
}
public function destroyAuthCookie() {
- setcookie('ganglia_auth', '', time());
+ setcookie('ganglia_auth', '', time(), NULL, NULL, true, true);
self::$auth = null;
}
diff --git a/templates/default/cluster_host_metric_graphs.tpl b/templates/default/cluster_host_metric_graphs.tpl
index dbd80ab..95bc8aa 100644
--- a/templates/default/cluster_host_metric_graphs.tpl
+++ b/templates/default/cluster_host_metric_graphs.tpl
@@ -42,7 +42,7 @@
{/foreach}
{/if}
{/if}
- {if $index % $hostcols == 0}
+ {if $index % max(1, $hostcols) == 0}
</tr><tr>
{/if}
{math "$index + 1" assign="index"}

View File

@ -1,55 +1,85 @@
%global gangver 3.7.2 %global gangver 3.7.2
%global webver 3.7.5 %global webver 3.7.6
%global systemd 1 %global systemd 1
%global _hardened_build 1 %global _hardened_build 1
%global with_python 1
%global py2 0 %global py2 0
Summary: Distributed Monitoring System %global py3 1
Name: ganglia
Version: %{gangver} Summary: Distributed Monitoring System
Release: 4 Name: ganglia
License: BSD Version: %{gangver}
URL: http://ganglia.sourceforge.net/ Release: 5
Source0: http://downloads.sourceforge.net/sourceforge/ganglia/ganglia-%{version}.tar.gz License: BSD
Source1: https://github.com/ganglia/ganglia-web/archive/%{webver}/ganglia-web-%{webver}.tar.gz URL: http://ganglia.sourceforge.net/
Source2: gmond.service Source0: http://downloads.sourceforge.net/sourceforge/ganglia/ganglia-%{version}.tar.gz
Source3: gmetad.service Source1: https://github.com/ganglia/ganglia-web/archive/%{webver}/ganglia-web-%{webver}.tar.gz
Source4: ganglia-httpd24.conf.d Source2: gmond.service
Source5: ganglia-httpd.conf.d Source3: gmetad.service
Source6: conf.php Source4: ganglia-httpd24.conf.d
Patch0: ganglia-web-3.7.2-path.patch Source5: ganglia-httpd.conf.d
Patch1: ganglia-3.7.2-apache.patch Source6: conf.php
Patch2: ganglia-3.7.2-sflow.patch Patch0: ganglia-3.7.2-185ab6.patch
Patch3: ganglia-3.7.2-tirpc-hack.patch Patch1: ganglia-3.7.2-gcc14-cast.patch
Patch4: ganglia-web-5ee6b7.patch Patch10: ganglia-3.7.2-tirpc-hack.patch
Patch5: CVE-2019-20378_CVE-2019-20379.patch Patch20: ganglia-web-3.7.2-path.patch
Patch21: ganglia-web-3.7.6-pr-379.patch
Patch22: ganglia-web-3.7.6-php8.patch
Patch30: ganglia-gmond-python2to3.patch
Patch31: 0002-2to3-pass.patch
Patch32: 0003-Ruff-pass.patch
Patch33: 0004-Use-raw-strings.patch
Patch34: 0005-First-loop-might-contain-non-integer-input.patch
Patch35: 0001-Fix-return-value-from-mod_python-init.patch
Patch40: ganglia-3.7.2-autoconf-python3.patch
Patch50: ganglia-3.7.2-pcre2.patch
%if 0%{?systemd} %if 0%{?systemd}
BuildRequires: systemd BuildRequires: systemd
%endif %endif
BuildRequires: rpcgen libtirpc-devel autoconf automake libtool BuildRequires: rpcgen
BuildRequires: apr-devel >= 1 expat-devel freetype-devel gcc libart_lgpl-devel BuildRequires: libtirpc-devel
BuildRequires: libconfuse-devel libmemcached-devel libpng-devel BuildRequires: autoconf
%if 0%{?py2} BuildRequires: automake
BuildRequires: python2-devel} BuildRequires: libtool
%endif BuildRequires: apr-devel >= 1
BuildRequires: rrdtool-devel rsync /usr/bin/pod2man /usr/bin/pod2html make BuildRequires: cyrus-sasl-devel
BuildRequires: php php-gd BuildRequires: expat-devel
BuildRequires: freetype-devel
BuildRequires: gcc
BuildRequires: libart_lgpl-devel
BuildRequires: libconfuse-devel
BuildRequires: libmemcached-devel
BuildRequires: libpng-devel
BuildRequires: make
BuildRequires: pcre2-devel
%{?py3:BuildRequires: python3-devel}
BuildRequires: rrdtool-devel
BuildRequires: rsync
BuildRequires: /usr/bin/pod2man
BuildRequires: /usr/bin/pod2html
%description %description
Ganglia is a scalable, real-time monitoring and execution environment Ganglia is a scalable, real-time monitoring and execution environment
with all execution requests and statistics expressed in an open with all execution requests and statistics expressed in an open
well-defined XML format. well-defined XML format.
%package web %package web
Summary: Ganglia Web Frontend Summary: Ganglia Web Frontend
Version: %{webver} Version: %{webver}
Requires: rrdtool php php-gd %{name}-gmetad = %{gangver}-%{release} Requires: rrdtool
Requires: php
Requires: php-gd
Requires: %{name}-gmetad = %{gangver}-%{release}
Requires: php-xml
%description web %description web
This package provides a web frontend to display the XML tree published This package provides a web frontend to display the XML tree published
by ganglia, and to provide historical graphs of collected by ganglia, and to provide historical graphs of collected
metrics. This website is written in the PHP. metrics. This website is written in the PHP.
%package gmetad %package gmetad
Summary: Ganglia Metadata collection daemon Summary: Ganglia Metadata collection daemon
Requires: %{name} = %{gangver}-%{release} Requires: %{name} = %{gangver}-%{release}
%if 0%{?systemd} %if 0%{?systemd}
Requires(post): systemd Requires(post): systemd
Requires(preun): systemd Requires(preun): systemd
@ -63,12 +93,13 @@ Requires(preun): /sbin/service
Ganglia is a scalable, real-time monitoring and execution environment Ganglia is a scalable, real-time monitoring and execution environment
with all execution requests and statistics expressed in an open with all execution requests and statistics expressed in an open
well-defined XML format. well-defined XML format.
This gmetad daemon aggregates monitoring data from several clusters to This gmetad daemon aggregates monitoring data from several clusters to
form a monitoring grid. It also keeps metric history using rrdtool. form a monitoring grid. It also keeps metric history using rrdtool.
%package gmond %package gmond
Summary: Ganglia Monitoring daemon Summary: Ganglia Monitoring daemon
Requires: %{name} = %{gangver}-%{release} Requires: %{name} = %{gangver}-%{release}
%if 0%{?systemd} %if 0%{?systemd}
Requires(post): systemd Requires(post): systemd
Requires(preun): systemd Requires(preun): systemd
@ -78,58 +109,100 @@ Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service Requires(preun): /sbin/service
%endif %endif
%description gmond %description gmond
Ganglia is a scalable, real-time monitoring and execution environment Ganglia is a scalable, real-time monitoring and execution environment
with all execution requests and statistics expressed in an open with all execution requests and statistics expressed in an open
well-defined XML format. well-defined XML format.
This gmond daemon provides the ganglia service within a single cluster This gmond daemon provides the ganglia service within a single cluster
or Multicast domain. or Multicast domain.
%if 0%{?py2} %if 0%{?py2}
%package -n python2-ganglia-gmond %package python2-gmond
Summary: Ganglia Monitor daemon python DSO and metric modules Summary: Ganglia Monitor daemon python DSO and metric modules
Requires: ganglia-gmond python2 Requires: ganglia-gmond
%{?python_provide:%python_provide python2-ganglia-gmond} Requires: python2
Provides: ganglia-gmond-python = %{version}-%{release} %{?python_provide:%python_provide python2-gmond}
%description -n python2-ganglia-gmond # Remove before F30
Provides: ganglia-python = %{version}-%{release}
%description python2-gmond
Ganglia is a scalable, real-time monitoring and execution environment Ganglia is a scalable, real-time monitoring and execution environment
with all execution requests and statistics expressed in an open with all execution requests and statistics expressed in an open
well-defined XML format. well-defined XML format.
This package provides the gmond python DSO and python gmond modules,
which can be loaded via the DSO at gmond daemon start time.
%endif
%if 0%{?py3}
%package python3-gmond
Summary: Ganglia Monitor daemon python3 DSO and metric modules
Requires: ganglia-gmond
Requires: python3
%{?python_provide:%python_provide python3-gmond}
Provides: gmond-python = %{version}-%{release}
%description python3-gmond
Ganglia is a scalable, real-time monitoring and execution environment
with all execution requests and statistics expressed in an open
well-defined XML format.
This package provides the gmond python DSO and python gmond modules, This package provides the gmond python DSO and python gmond modules,
which can be loaded via the DSO at gmond daemon start time. which can be loaded via the DSO at gmond daemon start time.
%endif %endif
%package devel %package devel
Summary: Ganglia Library Summary: Ganglia Library
Requires: %{name} = %{gangver}-%{release} apr-devel libconfuse-devel Requires: %{name} = %{gangver}-%{release}
Requires: apr-devel
Requires: libconfuse-devel
%description devel %description devel
The Ganglia Monitoring Core library provides a set of functions that The Ganglia Monitoring Core library provides a set of functions that
programmers can use to build scalable cluster or grid applications programmers can use to build scalable cluster or grid applications
%prep %prep
%setup -q %setup -q
%patch -P 0 -p1
%patch -P 1 -p1
%patch -P 30 -p1
%{?py3:%patch -P 31 -p1}
%{?py3:%patch -P 32 -p1}
%{?py3:%patch -P 33 -p1}
%{?py3:%patch -P 34 -p1}
%{?py3:%patch -P 35 -p1}
%patch -P 40 -p1
%patch -P 10 -p1
%patch -P 50 -p1
# fix broken systemd support
install -m 0644 %{SOURCE2} gmond/gmond.service.in install -m 0644 %{SOURCE2} gmond/gmond.service.in
install -m 0644 %{SOURCE3} gmetad/gmetad.service.in install -m 0644 %{SOURCE3} gmetad/gmetad.service.in
%patch 1 -p0 # web part
%patch 2 -p0
%patch 3 -p1
%setup -q -T -D -a 1 %setup -q -T -D -a 1
mv ganglia-web-%{webver} web mv ganglia-web-%{webver} web
pushd web pushd web
%patch 0 -p1 %patch -P 20 -p1
%patch 4 -p1 %patch -P 21 -p1
%patch 5 -p1 %patch -P 22 -p1
popd popd
%build %build
touch Makefile.am touch Makefile.am
aclocal -I m4 aclocal -I m4
autoheader autoheader
automake --add-missing --copy --foreign 2>/dev/null automake --add-missing --copy --foreign 2>/dev/null
libtoolize --automake --copy libtoolize --automake --copy
automake --add-missing --copy --foreign automake --add-missing --copy --foreign
autoconf -f || exit 1 autoconf -f || exit 1
pushd libmetrics
aclocal -I m4
autoheader
automake --add-missing --copy --foreign 2>/dev/null
libtoolize --automake --copy
automake --add-missing --copy --foreign
autoconf -f || exit 1
popd
export CFLAGS="%{optflags} -fcommon" export CFLAGS="%{optflags} -fcommon"
%configure \ %configure \
--enable-setuid=ganglia \ --enable-setuid=ganglia \
@ -138,28 +211,44 @@ export CFLAGS="%{optflags} -fcommon"
--with-memcached \ --with-memcached \
--disable-static \ --disable-static \
--enable-shared \ --enable-shared \
--with-libpcre=no \ --with-libpcre=yes \
%if 0%{?with_python}
--enable-python \
%if 0%{?py2} %if 0%{?py2}
--with-python=%{__python2} \ --with-python=%{__python2} \
%endif
%if 0%{?py3}
--with-python=%{__python3} \
%endif
%else %else
--disable-python \ --disable-python \
%endif %endif
--sysconfdir=%{_sysconfdir}/ganglia --sysconfdir=%{_sysconfdir}/ganglia
# Remove rpaths
%{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool %{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
%{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool %{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
## Default to run as user ganglia instead of nobody
%{__perl} -pi.orig -e 's|nobody|ganglia|g' \ %{__perl} -pi.orig -e 's|nobody|ganglia|g' \
gmond/gmond.conf.html ganglia.html gmond/conf.pod gmond/gmond.conf.html ganglia.html gmond/conf.pod
%{__perl} -pi.orig -e 's|.*setuid_username.*|setuid_username ganglia|' \ %{__perl} -pi.orig -e 's|.*setuid_username.*|setuid_username ganglia|' \
gmetad/gmetad.conf.in gmetad/gmetad.conf.in
## Don't have initscripts turn daemons on by default
%{__perl} -pi.orig -e 's|2345|-|g' gmond/gmond.init gmetad/gmetad.init %{__perl} -pi.orig -e 's|2345|-|g' gmond/gmond.init gmetad/gmetad.init
make %{?_smp_mflags} make %{?_smp_mflags}
%install %install
make install DESTDIR=%{buildroot} make install DESTDIR=%{buildroot}
%if 0%{?py2}
mkdir -p %{buildroot}%{_libdir}/ganglia/python_modules} ## Create directory structures
%endif %{?with_python:mkdir -p %{buildroot}%{_libdir}/ganglia/python_modules}
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/rrds mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/rrds
## Install services
%if 0%{?systemd} %if 0%{?systemd}
install -Dp -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/gmond.service install -Dp -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/gmond.service
install -Dp -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/gmetad.service install -Dp -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/gmetad.service
@ -167,41 +256,66 @@ install -Dp -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/gmetad.service
install -Dp -m 0755 gmond/gmond.init %{buildroot}%{_sysconfdir}/init.d/gmond install -Dp -m 0755 gmond/gmond.init %{buildroot}%{_sysconfdir}/init.d/gmond
install -Dp -m 0755 gmetad/gmetad.init %{buildroot}%{_sysconfdir}/init.d/gmetad install -Dp -m 0755 gmetad/gmetad.init %{buildroot}%{_sysconfdir}/init.d/gmetad
%endif %endif
## Build default gmond.conf from gmond using the '-t' flag
LD_LIBRARY_PATH=lib/.libs gmond/gmond -t | %{__perl} -pe 's|nobody|ganglia|g' \ LD_LIBRARY_PATH=lib/.libs gmond/gmond -t | %{__perl} -pe 's|nobody|ganglia|g' \
> %{buildroot}%{_sysconfdir}/ganglia/gmond.conf > %{buildroot}%{_sysconfdir}/ganglia/gmond.conf
%if 0%{?py2}
%if 0%{?with_python}
## Python bits
# Copy the python metric modules and .conf files
mkdir -p %{buildroot}%{_sysconfdir}/ganglia/conf.d
cp -p gmond/python_modules/conf.d/*.pyconf %{buildroot}%{_sysconfdir}/ganglia/conf.d/ cp -p gmond/python_modules/conf.d/*.pyconf %{buildroot}%{_sysconfdir}/ganglia/conf.d/
cp -p gmond/modules/conf.d/*.conf %{buildroot}%{_sysconfdir}/ganglia/conf.d/ cp -p gmond/modules/conf.d/*.conf %{buildroot}%{_sysconfdir}/ganglia/conf.d/
cp -p gmond/python_modules/*/*.py %{buildroot}%{_libdir}/ganglia/python_modules/ cp -p gmond/python_modules/*/*.py %{buildroot}%{_libdir}/ganglia/python_modules/
%endif %endif
## Web bits
pushd web pushd web
make install DESTDIR=%{buildroot} make install DESTDIR=%{buildroot}
install -p -m 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/ganglia/conf.php install -p -m 0644 %{SOURCE6} %{buildroot}%{_sysconfdir}/ganglia/conf.php
ln -s ../../..%{_sysconfdir}/%{name}/conf.php \ ln -s ../../..%{_sysconfdir}/%{name}/conf.php \
%{buildroot}%{_datadir}/%{name}/conf.php %{buildroot}%{_datadir}/%{name}/conf.php
popd popd
## httpd config
install -Dp -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf install -Dp -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/httpd/conf.d/%{name}.conf
## Various clean up after install:
## Don't install the status modules and example.conf
rm -f %{buildroot}%{_sysconfdir}/ganglia/conf.d/{modgstatus,example}.conf rm -f %{buildroot}%{_sysconfdir}/ganglia/conf.d/{modgstatus,example}.conf
## Disable the diskusage module until it is configured properly
## mv %{buildroot}%{_sysconfdir}/ganglia/conf.d/diskusage.pyconf \
## %{buildroot}%{_sysconfdir}/ganglia/conf.d/diskusage.pyconf.off
## Remove unwanted files from web dir
rm -rf %{buildroot}%{_datadir}/%{name}/{Makefile*,debian,ganglia-web.spec*,ganglia-web} rm -rf %{buildroot}%{_datadir}/%{name}/{Makefile*,debian,ganglia-web.spec*,ganglia-web}
rm -rf %{buildroot}%{_datadir}/%{name}/{conf_default.php.in,version.php.in} rm -rf %{buildroot}%{_datadir}/%{name}/{conf_default.php.in,version.php.in}
rm -rf %{buildroot}%{_localstatedir}/lib/%{name}-web/conf/sql rm -rf %{buildroot}%{_localstatedir}/lib/%{name}-web/conf/sql
## Included as doc
rm -rf %{buildroot}%{_datadir}/%{name}/{README,TODO,AUTHORS,COPYING} rm -rf %{buildroot}%{_datadir}/%{name}/{README,TODO,AUTHORS,COPYING}
## House cleaning
rm -f %{buildroot}%{_libdir}/*.la rm -f %{buildroot}%{_libdir}/*.la
# Remove execute bit
chmod 0644 %{buildroot}%{_datadir}/%{name}/header.php chmod 0644 %{buildroot}%{_datadir}/%{name}/header.php
%if 0%{?py2} %{?with_python:chmod 0644 %{buildroot}%{_libdir}/%{name}/python_modules/*.py}
chmod 0644 %{buildroot}%{_libdir}/%{name}/python_modules/*.py}
%endif
chmod 0644 %{buildroot}%{_datadir}/%{name}/css/smoothness/jquery-ui-1.10.2.custom.css chmod 0644 %{buildroot}%{_datadir}/%{name}/css/smoothness/jquery-ui-1.10.2.custom.css
chmod 0644 %{buildroot}%{_datadir}/%{name}/css/smoothness/jquery-ui-1.10.2.custom.min.css chmod 0644 %{buildroot}%{_datadir}/%{name}/css/smoothness/jquery-ui-1.10.2.custom.min.css
%if 0%{?py2}
sed -i '1{\@^#!@d}' %{buildroot}%{_libdir}/%{name}/python_modules/*.py} # Remove shebang
%endif %{?with_python:sed -i '1{\@^#!@d}' %{buildroot}%{_libdir}/%{name}/python_modules/*.py}
%pre %pre
## Add the "ganglia" user
/usr/sbin/useradd -c "Ganglia Monitoring System" \ /usr/sbin/useradd -c "Ganglia Monitoring System" \
-s /sbin/nologin -r -d %{_localstatedir}/lib/%{name} ganglia 2> /dev/null || : -s /sbin/nologin -r -d %{_localstatedir}/lib/%{name} ganglia 2> /dev/null || :
%if 0%{?systemd}
%if 0%{?systemd}
%post gmond %post gmond
%systemd_post gmond.service %systemd_post gmond.service
@ -219,6 +333,7 @@ sed -i '1{\@^#!@d}' %{buildroot}%{_libdir}/%{name}/python_modules/*.py}
%postun gmetad %postun gmetad
%systemd_postun_with_restart gmetad.service %systemd_postun_with_restart gmetad.service
%else %else
%post gmond %post gmond
@ -238,8 +353,10 @@ if [ "$1" = 0 ]; then
/sbin/service gmond stop >/dev/null 2>&1 || : /sbin/service gmond stop >/dev/null 2>&1 || :
/sbin/chkconfig --del gmond /sbin/chkconfig --del gmond
fi fi
%endif %endif
# https://fedoraproject.org/wiki/Packaging:Directory_Replacement#Scriptlet_to_replace_a_symlink_to_a_directory_with_a_directory
%pretrans web -p <lua> %pretrans web -p <lua>
path = "/usr/share/ganglia/lib/Zend" path = "/usr/share/ganglia/lib/Zend"
st = posix.stat(path) st = posix.stat(path)
@ -253,7 +370,7 @@ end
%{_libdir}/libganglia*.so.* %{_libdir}/libganglia*.so.*
%dir %{_libdir}/ganglia %dir %{_libdir}/ganglia
%{_libdir}/ganglia/*.so %{_libdir}/ganglia/*.so
%{?py2:%exclude %{_libdir}/ganglia/modpython.so} %{?with_python:%exclude %{_libdir}/ganglia/modpython.so}
%files gmetad %files gmetad
%dir %{_localstatedir}/lib/%{name} %dir %{_localstatedir}/lib/%{name}
@ -283,17 +400,22 @@ end
%{_mandir}/man1/gstat.1* %{_mandir}/man1/gstat.1*
%{_mandir}/man1/gmetric.1* %{_mandir}/man1/gmetric.1*
%dir %{_sysconfdir}/ganglia %dir %{_sysconfdir}/ganglia
%if 0%{?py2} %{?with_python:%dir %{_sysconfdir}/ganglia/conf.d}
%dir %{_sysconfdir}/ganglia/conf.d}
%endif
%config(noreplace) %{_sysconfdir}/ganglia/gmond.conf %config(noreplace) %{_sysconfdir}/ganglia/gmond.conf
%if 0%{?py2} %{?with_python:%config(noreplace) %{_sysconfdir}/ganglia/conf.d/*.conf}
%config(noreplace) %{_sysconfdir}/ganglia/conf.d/*.conf} %{?with_python:%exclude %{_sysconfdir}/ganglia/conf.d/modpython.conf}
%exclude %{_sysconfdir}/ganglia/conf.d/modpython.conf}
%endif
%if 0%{?py2} %if 0%{?py2}
%files -n python2-ganglia-gmond %files python2-gmond
%dir %{_libdir}/ganglia/python_modules/
%{_libdir}/ganglia/python_modules/*.py*
%{_libdir}/ganglia/modpython.so*
%config(noreplace) %{_sysconfdir}/ganglia/conf.d/*.pyconf*
%config(noreplace) %{_sysconfdir}/ganglia/conf.d/modpython.conf
%endif
%if 0%{?py3}
%files python3-gmond
%dir %{_libdir}/ganglia/python_modules/ %dir %{_libdir}/ganglia/python_modules/
%{_libdir}/ganglia/python_modules/*.py* %{_libdir}/ganglia/python_modules/*.py*
%{_libdir}/ganglia/modpython.so* %{_libdir}/ganglia/modpython.so*
@ -319,6 +441,11 @@ end
%dir %attr(0755,apache,apache) %{_localstatedir}/lib/%{name}-web/dwoo/compiled %dir %attr(0755,apache,apache) %{_localstatedir}/lib/%{name}-web/dwoo/compiled
%changelog %changelog
* Mon Jan 06 2025 liweigang <liweigang.lwg@gmail.com> - 3.7.2-5
- upgrade to ganglia web 3.7.6
- add patch to improve with PHP 8
- improve Python 3 support
* Fri Dec 13 2024 litian <dev11105@linx-info.com> - 3.7.2-4 * Fri Dec 13 2024 litian <dev11105@linx-info.com> - 3.7.2-4
- fix %patchN is deprecated warning - fix %patchN is deprecated warning