<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Thomas Guyot-Sionnest <span dir="ltr"><<a href="mailto:dermoth@aei.ca" target="_blank" style="color: rgb(42, 93, 176); ">dermoth@aei.ca</a>></span> wrote:<div class="im" style="color: rgb(80, 0, 80); ">
<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0,8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<div><div>> I've found the clause in nagios-plugins-1.4.15/plugins/check_procs.c:<br>><br>> int pos; /* number of spaces before 'args' in `ps` output */<br>> ...<br>> if ( cols >= expected_cols ) {<br>
>    resultsum = 0;<br>>    asprintf (&procargs, "%s", input_line + pos);<br>>    strip (procargs);<br>> ...<br>><br>> So I wonder how this variable (pos) is supposed to be initialized.<br>
> On my system (tinycore linux 3.0) it gives different huge numbers<br>> like 166949407, 166949462, etc. and corresponding asprintf segfaults.<br>> Should I explicitly initialize it with "int pos=0;" or something?<br>
<br></div></div>This variable should be initialized by a scanf call using the macros<br>PS_FORMAT and PS_VARLIST - this is system-specific.</blockquote><div><br></div></div><div>Ah, that's it!</div><div>I used to redefine ps command because configure can't detect it correctly (TinyCore Linux includes busybox' version).</div>
<div><br></div><div>$ 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"</div>
<div><br></div><div>According to your config I should replace it with</div><div><br></div><div>$ 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"</div>
<div><br></div><div>Now it works as expected, thank you!</div><div>--</div><font color="#888888"><div>Grigory Batalov</div></font></span><br>