diff --git a/SOURCES/0001-avoiding-triggering-automounts-bug-1670060.patch b/SOURCES/0001-avoiding-triggering-automounts-bug-1670060.patch new file mode 100644 index 0000000..f1627f3 --- /dev/null +++ b/SOURCES/0001-avoiding-triggering-automounts-bug-1670060.patch @@ -0,0 +1,26 @@ +From cc95940e4c0d5f8916d95e627a494c321b95d139 Mon Sep 17 00:00:00 2001 +From: Ondrej Dubaj +Date: Tue, 26 Feb 2019 08:36:14 +0100 +Subject: [PATCH] avoiding triggering automounts, bug #1670060 + +--- + sadc.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/sadc.c b/sadc.c +index fb3254d..cfb9809 100644 +--- a/sadc.c ++++ b/sadc.c +@@ -283,6 +283,9 @@ void sa_sys_init(void) + + for (i = 0; i < NR_ACT; i++) { + ++ if ( ! (act[i]->options & AO_COLLECTED ) ) ++ continue; ++ + if (act[i]->f_count) { + /* Number of items is not a constant and should be calculated */ + act[i]->nr = (*act[i]->f_count)(act[i]); +-- +2.17.1 + diff --git a/SOURCES/0001-ignoring-autofs-as-real-filesystem-by-counting-numbe.patch b/SOURCES/0001-ignoring-autofs-as-real-filesystem-by-counting-numbe.patch new file mode 100644 index 0000000..6d1fc4b --- /dev/null +++ b/SOURCES/0001-ignoring-autofs-as-real-filesystem-by-counting-numbe.patch @@ -0,0 +1,83 @@ +From f18b5d452e11bad46473d019e41fb7e43a5708ca Mon Sep 17 00:00:00 2001 +From: Ondrej Dubaj +Date: Thu, 28 Feb 2019 15:29:08 +0100 +Subject: [PATCH] ignoring autofs as real filesystem by counting number of + valid filesystems and getting all valid filesystems + +(cherry-picked from commit 5b5339d06c4f50730e5cc679e0854ce716f39117) +--- + rd_stats.c | 35 +++++++++++++++++++++++++++++++---- + 1 file changed, 31 insertions(+), 4 deletions(-) + +diff --git a/rd_stats.c b/rd_stats.c +index c054b58..8114428 100644 +--- a/rd_stats.c ++++ b/rd_stats.c +@@ -1915,9 +1915,9 @@ void read_bus_usb_dev(struct stats_pwr_usb *st_pwr_usb, int nbr) + void read_filesystem(struct stats_filesystem *st_filesystem, int nbr) + { + FILE *fp; +- char line[512], fs_name[128], mountp[256]; ++ char line[512], fs_name[128], mountp[256], type[128]; + int fs = 0, skip = 0, skip_next = 0; +- char *pos = 0; ++ char *pos = 0, *pos2 = NULL; + struct stats_filesystem *st_filesystem_i; + struct statvfs buf; + +@@ -1941,6 +1941,20 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr) + if (pos == NULL) + continue; + ++ /* ++ * Find second field separator position, ++ * read filesystem type, ++ * if filesystem type is autofs, skip it ++ */ ++ memset(type, 0, sizeof(type)); ++ pos2 = strchr(pos + 1, ' '); ++ if (pos2 == NULL) ++ continue; ++ ++ sscanf(pos2 + 1, "%127s", type); ++ if(strcmp(type, "autofs") == 0) ++ continue; ++ + /* Read current filesystem name */ + sscanf(line, "%127s", fs_name); + /* +@@ -2411,9 +2425,9 @@ int get_usb_nr(void) + int get_filesystem_nr(void) + { + FILE *fp; +- char line[512], fs_name[MAX_FS_LEN], mountp[256]; ++ char line[512], fs_name[MAX_FS_LEN], mountp[256], type[128]; + int fs = 0, skip = 0, skip_next = 0; +- char *pos = 0; ++ char *pos = 0, *pos2 = NULL; + + struct statvfs buf; + +@@ -2438,6 +2452,19 @@ int get_filesystem_nr(void) + pos = strchr(line, ' '); + if (pos == NULL) + continue; ++ /* ++ * Find second field separator position, ++ * read filesystem type, ++ * if filesystem type is autofs, skip it ++ */ ++ memset(type, 0, sizeof(type)); ++ pos2 = strchr(pos + 1, ' '); ++ if (pos2 == NULL) ++ continue; ++ ++ sscanf(pos2 + 1, "%127s", type); ++ if(strcmp(type, "autofs") == 0) ++ continue; + + /* Read filesystem name and mount point */ + sscanf(line, "%127s", fs_name); +-- +2.17.2 + diff --git a/SOURCES/0001-man-use-correct-preposition.patch b/SOURCES/0001-man-use-correct-preposition.patch new file mode 100644 index 0000000..4dcd9ff --- /dev/null +++ b/SOURCES/0001-man-use-correct-preposition.patch @@ -0,0 +1,25 @@ +From 7498b3b9ab25a0075a24bb30dfc08fa6a0f7f81a Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Thu, 28 Mar 2019 13:44:45 +0100 +Subject: [PATCH] man: use correct preposition + +--- + man/sar.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/sar.in b/man/sar.in +index 4ea6ca0..88181ce 100644 +--- a/man/sar.in ++++ b/man/sar.in +@@ -336,7 +336,7 @@ The following values are displayed: + .B MBfsfree + .RS + .RS +-Total amount a free space in megabytes (including space available only to privileged user). ++Total amount of free space in megabytes (including space available only to privileged user). + .RE + + .B MBfsused +-- +2.17.2 + diff --git a/SOURCES/0001-pidstat-Now-handle-processes-with-spaces-in-their-na.patch b/SOURCES/0001-pidstat-Now-handle-processes-with-spaces-in-their-na.patch new file mode 100644 index 0000000..0a99ef5 --- /dev/null +++ b/SOURCES/0001-pidstat-Now-handle-processes-with-spaces-in-their-na.patch @@ -0,0 +1,120 @@ +From c16eb6cf753d5df0779c284126d7356d2377fdb3 Mon Sep 17 00:00:00 2001 +From: Sebastien GODARD +Date: Mon, 22 Oct 2018 18:06:48 +0200 +Subject: [PATCH] pidstat: Now handle processes with spaces in their name + properly + +pidstat had a bug which made it unable to handle processes with spaces +in their name, eg: + +$ cat /proc/5768/stat +5768 (Plex New Transc) S 1264 1252 1252 0 -1 1077960704 17317 0 18 0 +9260 137 0 0 15 -5 8 0 1430749 186589184 16704 18446744073709551615 1 1 +0 0 0 0 0 0 8404998 18446744073709551615 0 0 17 1 0 0 22 0 0 0 0 0 0 0 0 +0 0 + +This patch fixes the problem. + +Reported by Chris Grindstaff (@cgrinds). + +Signed-off-by: Sebastien GODARD +--- + pidstat.c | 59 +++++++++++++++++++++++++++++++++++------------------------ + 1 file changed, 35 insertions(+), 24 deletions(-) + +diff --git a/pidstat.c b/pidstat.c +index bc22aa8..af48f29 100644 +--- a/pidstat.c ++++ b/pidstat.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -307,9 +308,10 @@ void read_proc_meminfo(void) + int read_proc_pid_stat(unsigned int pid, struct pid_stats *pst, + unsigned int *thread_nr, unsigned int tgid) + { +- FILE *fp; +- char filename[128], format[256], comm[MAX_COMM_LEN + 1]; +- size_t len; ++ int fd, sz, rc, commsz; ++ char filename[128]; ++ static char buffer[1024 + 1]; ++ char *start, *end; + + if (tgid) { + sprintf(filename, TASK_STAT, tgid, pid); +@@ -318,36 +320,45 @@ int read_proc_pid_stat(unsigned int pid, struct pid_stats *pst, + sprintf(filename, PID_STAT, pid); + } + +- if ((fp = fopen(filename, "r")) == NULL) ++ if ((fd = open(filename, O_RDONLY)) < 0) + /* No such process */ + return 1; + +- sprintf(format, "%%*d (%%%ds %%*s %%*d %%*d %%*d %%*d %%*d %%*u %%lu %%lu" +- " %%lu %%lu %%lu %%lu %%lu %%lu %%*d %%*d %%u %%*u %%*d %%lu %%lu" +- " %%*u %%*u %%*u %%*u %%*u %%*u %%*u %%*u %%*u %%*u %%*u %%*u %%*u" +- " %%*u %%u %%*u %%*u %%*u %%lu %%lu\\n", MAX_COMM_LEN); +- +- fscanf(fp, format, comm, +- &pst->minflt, &pst->cminflt, &pst->majflt, &pst->cmajflt, +- &pst->utime, &pst->stime, &pst->cutime, &pst->cstime, +- thread_nr, &pst->vsz, &pst->rss, &pst->processor, +- &pst->gtime, &pst->cgtime); ++ sz = read(fd, buffer, 1024); ++ close(fd); ++ if (sz <= 0) ++ return 1; ++ buffer[sz] = '\0'; + +- fclose(fp); ++ if ((start = strchr(buffer, '(')) == NULL) ++ return 1; ++ start += 1; ++ if ((end = strrchr(start, ')')) == NULL) ++ return 1; ++ commsz = end - start; ++ if (commsz >= MAX_COMM_LEN) ++ return 1; ++ memcpy(pst->comm, start, commsz); ++ pst->comm[commsz] = '\0'; ++ start = end + 2; ++ ++ rc = sscanf(start, ++ "%*s %*d %*d %*d %*d %*d %*u %lu %lu" ++ " %lu %lu %lu %lu %ld %ld %*d %*d %u %*u %*d %lu %lu" ++ " %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u" ++ " %*u %u %*u %*u %*lu %lu %ld\n", ++ &pst->minflt, &pst->cminflt, &pst->majflt, &pst->cmajflt, ++ &pst->utime, &pst->stime, &pst->cutime, &pst->cstime, ++ thread_nr, &pst->vsz, &pst->rss, &pst->processor, ++ &pst->gtime, &pst->cgtime); ++ ++ if (rc < 14) ++ return 1; + + /* Convert to kB */ + pst->vsz >>= 10; + pst->rss = PG_TO_KB(pst->rss); + +- strncpy(pst->comm, comm, MAX_COMM_LEN); +- pst->comm[MAX_COMM_LEN - 1] = '\0'; +- +- /* Remove trailing ')' */ +- len = strlen(pst->comm); +- if (len && (pst->comm[len - 1] == ')')) { +- pst->comm[len - 1] = '\0'; +- } +- + pst->pid = pid; + pst->tgid = tgid; + return 0; +-- +2.14.4 + diff --git a/SPECS/sysstat.spec b/SPECS/sysstat.spec index 0d1ef2c..8df4360 100644 --- a/SPECS/sysstat.spec +++ b/SPECS/sysstat.spec @@ -1,7 +1,7 @@ Summary: Collection of performance monitoring tools for Linux Name: sysstat Version: 10.1.5 -Release: 17%{?dist}.1 +Release: 18%{?dist} License: GPLv2+ Group: Applications/System URL: http://sebastien.godard.pagesperso-orange.fr/ @@ -64,6 +64,14 @@ Patch36: 0020-Fix-162-sadc-crashes-on-a-mtab-file-with-really-long.patch Patch37: 0021-Increase-maximum-fs-name-length-to-128.patch # backport -f flag (force fdatasync() after append to sa file) Patch38: 0001-sadc-Add-a-f-flag-to-force-fdatasync-use.patch +# don't call filesystem count functions when we are not collecting fs statistics +Patch39: 0001-avoiding-triggering-automounts-bug-1670060.patch +# skip autofs when gathering filesystem statistics +Patch40: 0001-ignoring-autofs-as-real-filesystem-by-counting-numbe.patch +# small manpage fix +Patch41: 0001-man-use-correct-preposition.patch +# fix CPU usage reporting +Patch42: 0001-pidstat-Now-handle-processes-with-spaces-in-their-na.patch Requires: /etc/cron.d, fileutils, grep, sh-utils, textutils Requires(post): systemd, systemd-sysv @@ -132,6 +140,10 @@ The cifsiostat command reports I/O statistics for CIFS file systems. %patch36 -p1 %patch37 -p1 %patch38 -p1 +%patch39 -p1 +%patch40 -p1 +%patch41 -p1 +%patch42 -p1 iconv -f windows-1252 -t utf8 CREDITS > CREDITS.aux mv CREDITS.aux CREDITS @@ -193,8 +205,12 @@ fi %{_localstatedir}/log/sa %changelog -* Mon Jun 03 2019 Michal Sekletár - 10.1.5-17.1 -- add -f flag to force fdatasync() after sa file update (#1716502) +* Thu Mar 28 2019 Michal Sekletár - 10.1.5-18 +- add -f flag to force fdatasync() after sa file update (#1662094) +- don't call filesystem count functions when we are not collecting fs statistics (#1670060) +- skip autofs when gathering filesystem statistics (#1670060) +- fix use of incorrect preposition in sar man page (#1624410) +- fix CPU usage reporting (#1618688) * Mon Jun 25 2018 Michal Sekletar - 10.1.5-17 - fix potential buffer overflow identified by cppcheck (#1543238)