2019-07-24 Alternative multips plugins for Munin

I learned about multips and multips_memory today but found that I couldn’t use them for my purposes.

The main problem is that both of them depend on the process name. Let me illustrate the problem:

# ps -eo rss,comm
...
29908 /home/alex/farm
30836 /home/alex/farm
 7596 /home/alex/farm
24156 /home/alex/farm
...

But I want to match on the command name:

# ps -eo rss,command
...
29908 /home/alex/farm/communitywiki2.pl
30836 /home/alex/farm/campaignwiki2.pl
 7596 /home/alex/farm/emacswiki2.pl
24156 /home/alex/farm/oddmuse2.pl

Furthermore, I can’t rely on awk splitting and looking at $2 because I want to match on the arguments as well. These three processes are distinct:

# ps -eo rss,command|grep gopher|grep -v grep
 4008 /home/alex/perl5/perlbrew/perls/perl-5.26.1/bin/perl /home/alex/farm/gopher-server.pl --setsid --user=alex --group=alex --host=alexschroeder.ch --port=79 --log_level=3 --log_file=/home/alex/farm/finger-server.log --pid_file=/home/alex/farm/finger-server.pid --wiki=/home/alex/farm/wiki.pl --wiki_dir=/home/alex/alexschroeder --wiki_pages=alex --wiki_pages=About --wiki_pages=Contact
26240 /home/alex/perl5/perlbrew/perls/perl-5.26.1/bin/perl /home/alex/farm/gopher-server.pl --setsid --user=alex --group=alex --host=alexschroeder.ch --port=7443 --log_level=3 --log_file=/home/alex/farm/gopher-server-ssl.log --pid_file=/home/alex/farm/gopher-server-ssl.pid --wiki=/home/alex/farm/wiki.pl --wiki_dir=/home/alex/alexschroeder --wiki_pages=SiteMap --wiki_pages=About --wiki_pages=Gopher --menu=Moku_Pona_Updates --menu_file=/home/alex/.moku-pona/updates.txt --menu=Moku_Pona_Sites --menu_file=/home/alex/.moku-pona/sites.txt --wiki_cert_file=/var/lib/dehydrated/certs/alexschroeder.ch/fullchain.pem --wiki_key_file=/var/lib/dehydrated/certs/alexschroeder.ch/privkey.pem
19776 /home/alex/perl5/perlbrew/perls/perl-5.26.1/bin/perl /home/alex/farm/gopher-server.pl --setsid --user=alex --group=alex --host=alexschroeder.ch --port=70 --log_level=3 --log_file=/home/alex/farm/gopher-server.log --pid_file=/home/alex/farm/gopher-server.pid --wiki=/home/alex/farm/wiki.pl --wiki_dir=/home/alex/alexschroeder --wiki_pages=SiteMap --wiki_pages=About --wiki_pages=Gopher --menu=Moku_Pona_Updates --menu_file=/home/alex/.moku-pona/updates.txt --menu=Moku_Pona_Sites --menu_file=/home/alex/.moku-pona/sites.txt

That’s a Gopher server listening on ports 70 (Gohper), 79 (Finger), and 7443 (TLS Gopher).

Anyway, I made some changes.

For multips I got rid of the overly restricted regular expressions:

# diff /usr/share/munin/plugins/multips /etc/munin/plugins/alex_multips
8,9c8,9
< multips - Munin plugin to monitor number of processes. Which processes
< are configured in client-conf.d
---
> alex_multips - Munin plugin to monitor number of processes. Which
> processes are configured in client-conf.d
19,25c19,20
<   [multips]
<      env.names pop3d imapd sslwrap
<      env.regex_imapd ^[0-9]* imapd:
<      env.regex_pop3d ^[0-9]* pop3d:
< 
< The regex parts are not needed if the name given in "names" can be
< used to grep with directly.
---
>   [alex_multips]
>      env.names perl6
26a22,23
> The regexp environment variables have been removed.
>      
30,31c27
< configured regular expressions.  The regular expressions are
< interpreted by "grep" (and not egrep or perl).
---
> command name.
80d75
< 		eval REGEX='"${regex_'$name'-\<'$name'\>}"'
84c79
< 		echo "$fieldname.info Processes matching this regular expression: /$REGEX/"
---
> 		echo "$fieldname.info Processes matching $name"
95d89
< 	eval REGEX='"${regex_'$name'-\<'$name'\>}"'
98c92
< 		$PGREP -f -l "$name" | grep "$REGEX" | wc -l
---
> 		$PGREP -f -l "$name" | wc -l
101c95
< 		/usr/ucb/ps auxwww | grep "$REGEX" | grep -v grep | wc -l
---
> 		/usr/ucb/ps auxwww | grep -v grep | wc -l
103c97
< 		ps auxwww | grep "$REGEX" | grep -v grep | wc -l
---
> 		ps auxwww | grep -v grep | wc -l

For multips_memory I got rid of the overly restricted regular expressions, but this time in the awk script at the end, and I use command instead of comm in the ps format.

# diff /usr/share/munin/plugins/multips_memory /etc/munin/plugins/alex_multips_memory
8c8
< multips_memory - Munin plugin to monitor memory usage of processes. Which
---
> alex_multips_memory - Munin plugin to monitor memory usage of processes. Which
15c15
<   ps -eo rss,comm
---
>   ps -eo rss,command
19c19
< You must specify what process names to monitor:
---
> You must specify what commands to monitor:
21c21
<   [multips_memory]
---
>   [alex_multips_memory]
28d27
< 
42,43c41,43
< /etc/munin/plugins or /etc/opt/munin/plugins), eg. multips_memory_rss and
< multips_memory_vsize as symlinks to multips_memory and configure them thus:
---
> /etc/munin/plugins or /etc/opt/munin/plugins), eg. multips_memory_rss
> and multips_memory_vsize as symlinks to alex_multips_memory and
> configure them thus:
58d57
< 
77,81d75
< Only the executable name is matched against (ps -eo comm)1, and it must
< be a full string match to the executable base name, not substring,
< unless you enter a name such as ".*apache" since RE meta characters in
< the names are active.
< 
95a90,91
> Switching from comm to command by Alex Schroeder <alex@gnu.org>
> 
129,130d124
< 		eval REGEX='^$name$';
< 
132c126
< 		echo "$fieldname.info For /$REGEX/"
---
> 		echo "$fieldname.info For /$name/"
140c134
< 	ps -eo $monitor,comm | gawk '
---
> 	ps -eo $monitor,command | gawk '
143c137
< $2 ~ /^'"$name"'$/ { total = total + ($1*1024); }
---
> '"/$name/"'        { total = total + ($1*1024); }

For configuration, I use the same regular expressions for both plugins:

[alex_multips*]
env.names gridmapper-server alexschroeder campaignwiki communitywiki emacswiki face food halberdsnhelmets helmut hex-describe hug linearb mark megadungeon monones names oddmuse paper small-sites software soweli-lukin tarballs text-mapper traveller trunk gopher-server.*port=79 gopher-server.*port=70 gopher-server.*port=7443 perl6

Tags:

Comments


Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.