[Nagiosplug-devel] Segmentation fault (int pos) in check_procs

Баталов Григорий gbatalov at crystals.ru
Tue Aug 24 08:14:48 CEST 2010


Thomas Guyot-Sionnest <dermoth at aei.ca> wrote:

> I've found the clause in nagios-plugins-1.4.15/plugins/check_procs.c:
> >
> > int pos; /* number of spaces before 'args' in `ps` output */
> > ...
> > if ( cols >= expected_cols ) {
> >    resultsum = 0;
> >    asprintf (&procargs, "%s", input_line + pos);
> >    strip (procargs);
> > ...
> >
> > So I wonder how this variable (pos) is supposed to be initialized.
> > On my system (tinycore linux 3.0) it gives different huge numbers
> > like 166949407, 166949462, etc. and corresponding asprintf segfaults.
> > Should I explicitly initialize it with "int pos=0;" or something?
>
> This variable should be initialized by a scanf call using the macros
> PS_FORMAT and PS_VARLIST - this is system-specific.


Ah, that's it!
I used to redefine ps command because configure can't detect it correctly
(TinyCore Linux includes busybox' version).

$ configure
--with-ps-varlist="&procpid,&procppid,&procvsz,&procrss,procprog"
--with-ps-cols=5 --with-ps-format="%d %d %d %d %s"
--with-ps-command="/bin/ps -o pid,ppid,vsz,rss,comm,args"

According to your config I should replace it with

$ configure
--with-ps-varlist="&procpid,&procppid,&procvsz,&procrss,procprog,&pos"
--with-ps-cols=6 --with-ps-format="%d %d %d %d %s %n"
--with-ps-command="/bin/ps -o pid,ppid,vsz,rss,comm,args"

Now it works as expected, thank you!
--
Grigory Batalov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nagios-plugins.org/archive/devel/attachments/20100824/5ec1a068/attachment.html>


More information about the Devel mailing list