fix(linux-local): limit column size to avoid filter issues (#5303)

Co-authored-by: Stéphane Duret <sduret@centreon.com>

Refs: CTOR-490
This commit is contained in:
omercier 2024-11-29 14:29:43 +01:00 committed by GitHub
parent 69144e3895
commit 4c42e0487c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 307 additions and 10 deletions

View File

@ -199,7 +199,7 @@ sub parse_output {
my ($stdout) = $options{custom}->execute_command( my ($stdout) = $options{custom}->execute_command(
command => 'ps', command => 'ps',
command_options => '-e -o state -o etime -o pid -o ppid -o comm:50 -o %a -w 2>&1' command_options => '-e -o state -o etime:15 -o pid:10 -o ppid:10 -o comm:50 -o args -w 2>&1'
); );
$self->{global} = { processes => 0 }; $self->{global} = { processes => 0 };
@ -394,35 +394,116 @@ Monitor disk I/O.
=item B<--filter-command> =item B<--filter-command>
Filter process commands (regexp can be used). Define which processes should be included based on the name of the executable.
This option will be treated as a regular expression.
=item B<--exclude-command> =item B<--exclude-command>
Exclude process commands (regexp can be used). Define which processes should be excluded based on the name of the executable.
This option will be treated as a regular expression.
=item B<--filter-arg> =item B<--filter-arg>
Filter process arguments (regexp can be used). Define which processes should be included based on the arguments of the executable.
This option will be treated as a regular expression.
=item B<--exclude-arg> =item B<--exclude-arg>
Exclude process arguments (regexp can be used). Define which processes should be excluded based on the arguments of the executable.
This option will be treated as a regular expression.
=item B<--filter-ppid> =item B<--filter-ppid>
Filter process ppid (regexp can be used). Define which processes should be excluded based on the process's parent process ID (PPID).
This option will be treated as a regular expression.
=item B<--filter-state> =item B<--filter-state>
Filter process states (regexp can be used). Define which processes should be excluded based on the process state.
This option will be treated as a regular expression.
You can use: 'zombie', 'dead', 'paging', 'stopped', You can use: 'zombie', 'dead', 'paging', 'stopped',
'InterrupibleSleep', 'running', 'UninterrupibleSleep'. 'InterrupibleSleep', 'running', 'UninterrupibleSleep'.
=item B<--warning-*> B<--critical-*> =item B<--warning-total>
Thresholds.
=item B<--critical-total>
Thresholds.
=item B<--warning-total-memory-usage>
Thresholds.
=item B<--critical-total-memory-usage>
Thresholds.
=item B<--warning-total-cpu-utilization>
Thresholds.
=item B<--critical-total-cpu-utilization>
Thresholds.
=item B<--warning-total-disks-read>
Thresholds.
=item B<--critical-total-disks-read>
Thresholds.
=item B<--warning-total-disks-write>
Thresholds.
=item B<--critical-total-disks-write>
Thresholds.
=item B<--warning-time>
Thresholds.
=item B<--critical-time>
Thresholds.
=item B<--warning-memory-usage>
Thresholds.
=item B<--critical-memory-usage>
Thresholds.
=item B<--warning-cpu-utilization>
Thresholds.
=item B<--critical-cpu-utilization>
Thresholds.
=item B<--warning-disks-read>
Thresholds.
=item B<--critical-disks-read>
Thresholds.
=item B<--warning-disks-write>
Thresholds.
=item B<--critical-disks-write>
Thresholds. Thresholds.
Can be: 'total', 'total-memory-usage', 'total-cpu-utilization', 'total-disks-read',
'total-disks-write', 'time', 'memory-usage', 'cpu-utilization', 'disks-read', 'disks-write'.
=back =back

View File

@ -0,0 +1,45 @@
*** Settings ***
Documentation Linux Local list-systemdservices
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Test Timeout 120s
*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=os::linux::local::plugin
${COND} ${PERCENT}\{sub\} =~ /exited/ && ${PERCENT}{display} =~ /network/'
*** Test Cases ***
Process ${tc}
[Tags] os linux local
${command} Catenate
... ${CMD}
... --mode=process
... --command-options='${CURDIR}${/}process_bin${/}${ps_output}'
... --command=cat
... --warning-total='${warning}'
... --critical-total='${critical}'
... --filter-command='${filter_command}'
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc ps_output filter_command warning critical expected_result --
... 1 ps-centreon.output cs.sapC4P_C00 ${EMPTY} ${EMPTY} OK: Number of current processes: 0 | 'processes.total.count'=0;;;0;
... 2 ps-centreon.output cs.sapC4P_C00 1:1 ${EMPTY} WARNING: Number of current processes: 0 | 'processes.total.count'=0;1:1;;0;
... 3 ps-centreon.output cs.sapC4P_C00 1:1 1:1 CRITICAL: Number of current processes: 0 | 'processes.total.count'=0;1:1;1:1;0;
... 4 ps-centreon.output cs.sapC4P_C00 0:0 0:0 OK: Number of current processes: 0 | 'processes.total.count'=0;0:0;0:0;0;
... 5 ps-centreon.output gorgone-proxy ${EMPTY} ${EMPTY} OK: Number of current processes: 5 | 'processes.total.count'=5;;;0;
... 6 ps-centreon.output gorgone-proxy 1:1 ${EMPTY} WARNING: Number of current processes: 5 | 'processes.total.count'=5;1:1;;0;
... 7 ps-centreon.output gorgone-proxy 1:1 1:1 CRITICAL: Number of current processes: 5 | 'processes.total.count'=5;1:1;1:1;0;
... 8 ps-centreon.output gorgone-proxy 5:5 5:5 OK: Number of current processes: 5 | 'processes.total.count'=5;5:5;5:5;0;
... 9 ps-sap.output cs.sapC4P_C00 ${EMPTY} ${EMPTY} OK: Process: [command => cs.sapC4P_C00] [arg => cs.sapC4P_C00 pf=/usr/sap/C4P/SYS/profile/C4P_C00_lunisapcsprd2] [state => S] duration: 3M 2w 5d 21h 51m 25s - Number of current processes: 1 | 'processes.total.count'=1;;;0;
... 10 ps-sap.output cs.sapC4P_C00 2:2 ${EMPTY} WARNING: Number of current processes: 1 | 'processes.total.count'=1;2:2;;0;
... 11 ps-sap.output cs.sapC4P_C00 2:2 2:2 CRITICAL: Number of current processes: 1 | 'processes.total.count'=1;2:2;2:2;0;
... 12 ps-sap.output cs.sapC4P_C00 1:1 1:1 OK: Process: [command => cs.sapC4P_C00] [arg => cs.sapC4P_C00 pf=/usr/sap/C4P/SYS/profile/C4P_C00_lunisapcsprd2] [state => S] duration: 3M 2w 5d 21h 51m 25s - Number of current processes: 1 | 'processes.total.count'=1;1:1;1:1;0;
... 13 ps-sap.output gorgone-proxy ${EMPTY} ${EMPTY} OK: Number of current processes: 0 | 'processes.total.count'=0;;;0;
... 14 ps-sap.output gorgone-proxy 2:2 ${EMPTY} WARNING: Number of current processes: 0 | 'processes.total.count'=0;2:2;;0;
... 15 ps-sap.output gorgone-proxy 2:2 2:2 CRITICAL: Number of current processes: 0 | 'processes.total.count'=0;2:2;2:2;0;
... 16 ps-sap.output gorgone-proxy 0:0 0:0 OK: Number of current processes: 0 | 'processes.total.count'=0;0:0;0:0;0;

View File

@ -0,0 +1,156 @@
S ELAPSED PID PPID COMMAND COMMAND
S 43-00:56:55 1 0 systemd /sbin/init
S 43-00:56:55 2 0 kthreadd [kthreadd]
I 43-00:56:55 3 2 rcu_gp [rcu_gp]
I 43-00:56:55 4 2 rcu_par_gp [rcu_par_gp]
I 43-00:56:55 5 2 slub_flushwq [slub_flushwq]
I 43-00:56:55 6 2 netns [netns]
I 43-00:56:55 10 2 mm_percpu_wq [mm_percpu_wq]
I 43-00:56:55 11 2 rcu_tasks_kthread [rcu_tasks_kthread]
I 43-00:56:55 12 2 rcu_tasks_rude_kthread [rcu_tasks_rude_kthread]
I 43-00:56:55 13 2 rcu_tasks_trace_kthread [rcu_tasks_trace_kthread]
S 43-00:56:55 14 2 ksoftirqd/0 [ksoftirqd/0]
I 43-00:56:55 15 2 rcu_preempt [rcu_preempt]
S 43-00:56:55 16 2 migration/0 [migration/0]
S 43-00:56:55 18 2 cpuhp/0 [cpuhp/0]
S 43-00:56:55 19 2 cpuhp/1 [cpuhp/1]
S 43-00:56:55 20 2 migration/1 [migration/1]
S 43-00:56:55 21 2 ksoftirqd/1 [ksoftirqd/1]
I 43-00:56:55 23 2 kworker/1:0H-events_highpri [kworker/1:0H-events_highpri]
S 43-00:56:55 26 2 kdevtmpfs [kdevtmpfs]
I 43-00:56:55 27 2 inet_frag_wq [inet_frag_wq]
S 43-00:56:55 28 2 kauditd [kauditd]
S 43-00:56:55 29 2 khungtaskd [khungtaskd]
S 43-00:56:55 30 2 oom_reaper [oom_reaper]
I 43-00:56:55 32 2 writeback [writeback]
S 43-00:56:55 33 2 kcompactd0 [kcompactd0]
S 43-00:56:55 34 2 ksmd [ksmd]
S 43-00:56:55 35 2 khugepaged [khugepaged]
I 43-00:56:55 36 2 kintegrityd [kintegrityd]
I 43-00:56:55 37 2 kblockd [kblockd]
I 43-00:56:55 38 2 blkcg_punt_bio [blkcg_punt_bio]
I 43-00:56:54 39 2 tpm_dev_wq [tpm_dev_wq]
I 43-00:56:54 40 2 edac-poller [edac-poller]
I 43-00:56:54 41 2 devfreq_wq [devfreq_wq]
I 43-00:56:54 43 2 kworker/1:1H-kblockd [kworker/1:1H-kblockd]
S 43-00:56:54 44 2 kswapd0 [kswapd0]
I 43-00:56:54 50 2 kthrotld [kthrotld]
S 43-00:56:54 52 2 irq/24-pciehp [irq/24-pciehp]
S 43-00:56:54 53 2 irq/25-pciehp [irq/25-pciehp]
S 43-00:56:54 54 2 irq/26-pciehp [irq/26-pciehp]
S 43-00:56:54 55 2 irq/27-pciehp [irq/27-pciehp]
S 43-00:56:54 56 2 irq/28-pciehp [irq/28-pciehp]
S 43-00:56:54 57 2 irq/29-pciehp [irq/29-pciehp]
S 43-00:56:54 58 2 irq/30-pciehp [irq/30-pciehp]
S 43-00:56:54 59 2 irq/31-pciehp [irq/31-pciehp]
S 43-00:56:54 60 2 irq/32-pciehp [irq/32-pciehp]
S 43-00:56:54 61 2 irq/33-pciehp [irq/33-pciehp]
S 43-00:56:54 62 2 irq/34-pciehp [irq/34-pciehp]
S 43-00:56:54 63 2 irq/35-pciehp [irq/35-pciehp]
S 43-00:56:54 64 2 irq/36-pciehp [irq/36-pciehp]
S 43-00:56:54 65 2 irq/37-pciehp [irq/37-pciehp]
S 43-00:56:54 66 2 irq/38-pciehp [irq/38-pciehp]
S 43-00:56:54 67 2 irq/39-pciehp [irq/39-pciehp]
S 43-00:56:54 68 2 irq/40-pciehp [irq/40-pciehp]
S 43-00:56:54 69 2 irq/41-pciehp [irq/41-pciehp]
S 43-00:56:54 70 2 irq/42-pciehp [irq/42-pciehp]
S 43-00:56:54 71 2 irq/43-pciehp [irq/43-pciehp]
S 43-00:56:54 72 2 irq/44-pciehp [irq/44-pciehp]
S 43-00:56:54 73 2 irq/45-pciehp [irq/45-pciehp]
S 43-00:56:54 74 2 irq/46-pciehp [irq/46-pciehp]
S 43-00:56:54 75 2 irq/47-pciehp [irq/47-pciehp]
S 43-00:56:54 76 2 irq/48-pciehp [irq/48-pciehp]
S 43-00:56:54 77 2 irq/49-pciehp [irq/49-pciehp]
S 43-00:56:54 78 2 irq/50-pciehp [irq/50-pciehp]
S 43-00:56:54 79 2 irq/51-pciehp [irq/51-pciehp]
S 43-00:56:54 80 2 irq/52-pciehp [irq/52-pciehp]
S 43-00:56:54 81 2 irq/53-pciehp [irq/53-pciehp]
S 43-00:56:54 82 2 irq/54-pciehp [irq/54-pciehp]
S 43-00:56:54 83 2 irq/55-pciehp [irq/55-pciehp]
I 43-00:56:54 84 2 acpi_thermal_pm [acpi_thermal_pm]
I 43-00:56:54 86 2 mld [mld]
I 43-00:56:54 87 2 ipv6_addrconf [ipv6_addrconf]
I 43-00:56:54 92 2 kstrp [kstrp]
I 43-00:56:54 97 2 zswap-shrink [zswap-shrink]
I 43-00:56:54 98 2 kworker/u5:0 [kworker/u5:0]
I 43-00:56:54 158 2 kworker/0:1H-kblockd [kworker/0:1H-kblockd]
S 43-00:56:54 161 2 scsi_eh_0 [scsi_eh_0]
I 43-00:56:54 164 2 ata_sff [ata_sff]
I 43-00:56:54 165 2 scsi_tmf_0 [scsi_tmf_0]
I 43-00:56:54 166 2 vmw_pvscsi_wq_0 [vmw_pvscsi_wq_0]
S 43-00:56:54 168 2 scsi_eh_1 [scsi_eh_1]
I 43-00:56:54 169 2 scsi_tmf_1 [scsi_tmf_1]
S 43-00:56:54 170 2 scsi_eh_2 [scsi_eh_2]
I 43-00:56:54 171 2 scsi_tmf_2 [scsi_tmf_2]
I 43-00:56:54 187 2 kdmflush/254:0 [kdmflush/254:0]
I 43-00:56:54 188 2 kdmflush/254:1 [kdmflush/254:1]
S 43-00:56:54 197 2 speakup [speakup]
S 43-00:56:53 223 2 jbd2/dm-0-8 [jbd2/dm-0-8]
I 43-00:56:53 224 2 ext4-rsv-conver [ext4-rsv-conver]
S 43-00:56:53 265 1 systemd-journal /lib/systemd/systemd-journald
S 43-00:56:53 289 1 systemd-udevd /lib/systemd/systemd-udevd
S 43-00:56:53 315 2 irq/60-vmw_vmci [irq/60-vmw_vmci]
S 43-00:56:53 316 2 irq/61-vmw_vmci [irq/61-vmw_vmci]
S 43-00:56:53 321 2 irq/62-vmw_vmci [irq/62-vmw_vmci]
S 43-00:56:53 326 2 irq/16-vmwgfx [irq/16-vmwgfx]
I 43-00:56:53 403 2 ext4-rsv-conver [ext4-rsv-conver]
I 43-00:56:53 411 2 cryptd [cryptd]
I 43-00:56:53 520 2 nfit [nfit]
S 43-00:56:53 568 1 systemd-timesyn /lib/systemd/systemd-timesyncd
S 43-00:56:53 570 1 VGAuthService /usr/bin/VGAuthService
S 43-00:56:53 571 1 vmtoolsd /usr/bin/vmtoolsd
S 43-00:56:52 770 1 cron /usr/sbin/cron -f
S 43-00:56:52 771 1 dbus-daemon /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
S 43-00:56:52 775 1 php-fpm8.1 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)
S 43-00:56:52 776 1 snmpd /usr/sbin/snmpd -LOw -u Debian-snmp -g Debian-snmp -I -smux mteTrigger mteTriggerConf -f
S 43-00:56:52 782 1 systemd-logind /lib/systemd/systemd-logind
S 43-00:56:52 785 1 centagent /usr/bin/centagent /etc/centreon-monitoring-agent/centagent.json
S 43-00:56:52 787 1 centreontrapd /usr/bin/perl /usr/share/centreon/bin/centreontrapd --logfile=/var/log/centreon/centreontrapd.log --severity=error --config=/etc/centreon/conf.pm --config-extra=/etc/centreon/centreontrapd.pm
S 43-00:56:52 790 1 agetty /sbin/agetty -o -p -- \u --noclear - linux
S 43-00:56:52 792 1 sshd sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
S 43-00:56:52 868 1 mariadbd /usr/sbin/mariadbd
S 43-00:56:52 869 1 apache2 /usr/sbin/apache2 -k start
S 43-00:56:52 876 775 php-fpm8.1 php-fpm: pool www
S 43-00:56:52 877 775 php-fpm8.1 php-fpm: pool www
S 43-00:56:51 895 1 cbwd /usr/sbin/cbwd /etc/centreon-broker/watchdog.json
S 43-00:56:51 902 1 centengine /usr/sbin/centengine /etc/centreon-engine/centengine.cfg
S 43-00:56:51 903 895 cbd /usr/sbin/cbd /etc/centreon-broker/central-broker.json
S 43-00:56:51 904 895 cbd /usr/sbin/cbd /etc/centreon-broker/central-rrd.json
S 43-00:56:50 1091 1 gpg-agent gpg-agent --homedir /tmp/www-data --use-standard-socket --daemon
I 42-04:51:03 76631 2 dio/dm-0 [dio/dm-0]
I 29-01:59:35 1255545 2 kworker/0:0H-kblockd [kworker/0:0H-kblockd]
S 7-01:47:04 3232231 1 polkitd /usr/lib/polkit-1/polkitd --no-debug
S 7-01:39:40 3234054 1 perl /usr/bin/perl /usr/bin/gorgoned --config=/etc/centreon-gorgone/config.yaml --logfile=/var/log/centreon-gorgone/gorgoned.log --severity=debug
S 7-01:39:40 3234057 3234054 gorgone-engine gorgone-engine
S 7-01:39:40 3234058 3234054 gorgone-cron gorgone-cron
S 7-01:39:40 3234059 3234054 gorgone-nodes gorgone-nodes
S 7-01:39:40 3234060 3234054 gorgone-audit gorgone-audit
S 7-01:39:40 3234061 3234054 gorgone-httpser gorgone-httpserver
S 7-01:39:40 3234062 3234054 gorgone-action gorgone-action
S 7-01:39:40 3234063 3234054 gorgone-dbclean gorgone-dbcleaner
S 7-01:39:40 3234064 3234054 gorgone-legacyc gorgone-legacycmd
S 7-01:39:40 3234065 3234054 gorgone-autodis gorgone-autodiscovery
S 7-01:39:40 3234068 3234054 gorgone-proxy gorgone-proxy
S 7-01:39:40 3234071 3234054 gorgone-proxy gorgone-proxy
S 7-01:39:40 3234082 3234054 gorgone-proxy gorgone-proxy
S 7-01:39:40 3234083 3234054 gorgone-proxy gorgone-proxy
S 7-01:39:40 3234086 3234054 gorgone-proxy gorgone-proxy
S 7-01:39:40 3234088 3234054 gorgone-statist gorgone-statistics
S 16:51:21 3806240 869 apache2 /usr/sbin/apache2 -k start
S 16:51:21 3806241 869 apache2 /usr/sbin/apache2 -k start
S 16:51:21 3806242 869 apache2 /usr/sbin/apache2 -k start
S 16:51:21 3806243 869 apache2 /usr/sbin/apache2 -k start
S 16:51:21 3806244 869 apache2 /usr/sbin/apache2 -k start
S 16:43:50 3806672 869 apache2 /usr/sbin/apache2 -k start
I 01:12:21 3864794 2 kworker/u4:1-ext4-rsv-conversion [kworker/u4:1-ext4-rsv-conversion]
I 01:12:21 3864795 2 kworker/0:0-cgroup_destroy [kworker/0:0-cgroup_destroy]
I 42:21 3866750 2 kworker/0:2 [kworker/0:2]
I 38:06 3866998 2 kworker/1:5-events_power_efficient [kworker/1:5-events_power_efficient]
I 24:50 3867811 2 kworker/u4:2-writeback [kworker/u4:2-writeback]
I 10:04 3868763 2 kworker/u4:0-events_unbound [kworker/u4:0-events_unbound]
I 07:03 3868932 2 kworker/1:1-ata_sff [kworker/1:1-ata_sff]
I 01:52 3869245 2 kworker/1:0-events [kworker/1:0-events]
S 00:00 3869359 792 sshd sshd: root@notty
S 00:00 3869364 1 systemd /lib/systemd/systemd --user
S 00:00 3869365 3869364 (sd-pam) (sd-pam)
R 00:00 3869384 3869359 ps ps -e -o state -o etime:15 -o pid:10 -o ppid:10 -o comm:50 -o args -w

View File

@ -0,0 +1,5 @@
S ELAPSED PID PPID COMMAND COMMAND
S 285-02:41:18 1710 1 apstartsrv /usr/sap/C4P/C00/exe/sapstartsrv pf=/usr/sap/C4P/SYS/profile/C4P_C00_lunisapcsprd2 -D -u c4padm
S 111-05:18:34 3241853 1 sapstart sapstart pf=/usr/sap/C4P/SYS/profile/C4P_C00_lunisapcsprd2
S 111-05:18:34 3241862 3241853 cs.sapC4P_C00 cs.sapC4P_C00 pf=/usr/sap/C4P/SYS/profile/C4P_C00_lunisapcsprd2
S 00:01 1022450 1022449 centreon_linux_ usr/bin/perl /usr/lib/centreon/plugins/centreon_linux_local.pl --plugin=os::linux::local::plugin --mode=process --warning-total= --critical-total=1:1 --warning-time= --critical-time= --filter-command=cs.sapC4P_C00 --filter-arg= --filter-state= --debug

View File

@ -5,6 +5,8 @@
7210SAS 7210SAS
7750SR 7750SR
ACS ACS
--add-cpu
--add-disk-io
--add-fc-fe-errors --add-fc-fe-errors
--add-qos-limit --add-qos-limit
--add-sysdesc --add-sysdesc
@ -45,7 +47,9 @@ cpu-utilization-5s
--critical-backend-congestions --critical-backend-congestions
--critical-backend-outstanding-io --critical-backend-outstanding-io
--critical-bytesallocatedpercentage --critical-bytesallocatedpercentage
--critical-cpu-utilization
--critical-na --critical-na
--critical-total-cpu-utilization
Datacore Datacore
datasource datasource
DC4 DC4
@ -67,6 +71,7 @@ fanspeed
FCCapacity FCCapacity
--filter-fs --filter-fs
--filter-imei --filter-imei
--filter-ppid
--filter-vdom --filter-vdom
--filter-vm --filter-vm
--force-64bits-counters --force-64bits-counters
@ -91,6 +96,7 @@ in-fcserror
in-mcast in-mcast
-InputFormat -InputFormat
interface-dsl-name interface-dsl-name
InterrupibleSleep
in-ucast in-ucast
IpAddr IpAddr
ipv4 ipv4
@ -173,6 +179,7 @@ physicaldrive
PKCS1 PKCS1
powershell powershell
powershell.exe powershell.exe
PPID
prct prct
Primera Primera
proto proto
@ -217,6 +224,7 @@ tower-cli
TrendMicro TrendMicro
UCD UCD
UDP UDP
UninterrupibleSleep
uniq uniq
uptime uptime
--urlpath --urlpath
@ -241,6 +249,8 @@ vSphere
--warning-backend-congestions --warning-backend-congestions
--warning-backend-outstanding-io --warning-backend-outstanding-io
--warning-bytesallocatedpercentage --warning-bytesallocatedpercentage
--warning-cpu-utilization
--warning-na --warning-na
--warning-total-cpu-utilization
WSMAN WSMAN
XPath XPath