Thread: Re: [HACKERS] Re: [PORTS] pgmonitor and Solaris
> How about the following: > > ilsefe2:~$ /usr/ucb/ps -aux|head -1 > USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND > Broken Pipe > ilsefe2:~$ /usr/ucb/ps -aux|grep mathijs > mathijs 7255 0.1 0.2 2432 1816 pts/0 S 00:12:41 0:00 -bash > mathijs 7775 0.1 0.1 960 728 pts/0 S 00:24:29 0:00 grep mathijs > mathijs 7344 0.0 0.1 1064 912 pts/0 T 00:14:56 0:00 man ps > mathijs 7359 0.0 0.1 1040 808 pts/0 T 00:14:57 0:00 sh -c more -s /tmp > mathijs 7360 0.0 0.1 1184 968 pts/0 T 00:14:57 0:00 more -s /tmp/mp3Ha > ilsefe2:~$ ps -U mathijs -o user,pid,pcpu,pmem,vsz,rss,tty,s,stime=START -o time,comm > USER PID %CPU %MEM VSZ RSS TT S START TIME COMMAND > mathijs 7359 0.0 0.1 1040 808 pts/0 T 00:14:57 0:00 sh > mathijs 7255 0.1 0.2 2432 1816 pts/0 S 00:12:41 0:00 -bash > root 7816 0.1 0.1 1080 840 pts/0 O 00:28:13 0:00 ps > mathijs 7344 0.0 0.1 1064 912 pts/0 T 00:14:56 0:00 man > mathijs 7360 0.0 0.1 1184 968 pts/0 T 00:14:57 0:00 more > > > It doesn't use any extra extra programs, nor the somewhat deprecated /usr/ucb/ps > command. The only problem I see may be the alignment of some fields. The ps > command itself is listed because the user mathijs was running it... Sure 'ps -U' will work, but it was reported that on Solaris, plain ps can't show the postgres status display, while ucb/ps can. I don't need specific columns. What I need is the postgres status parameters, and if possible, a user restriction to ps for performance reasons. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> On Wed, Mar 28, 2001 at 05:33:05PM -0500, Bruce Momjian allegedly wrote: >> Sure 'ps -U' will work, but it was reported that on Solaris, plain ps >> can't show the postgres status display, while ucb/ps can. I don't need >> specific columns. What I need is the postgres status parameters, and if >> possible, a user restriction to ps for performance reasons. Looking at the sendmail code, it seems they use SPT_REUSEARGV (what we call PS_USE_CLOBBER_ARGV) technique on Solaris. Possibly the problem is simply that line 65 in src/backend/utils/misc/ps_status.c fails to cover Solaris as one of the possible options: #elif defined(__linux__) || defined(_AIX4) || defined(_AIX3) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix)|| defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) #define PS_USE_CLOBBER_ARGV Can someone check whether adding an appropriate Solaris symbol (which one?) fixes the problem? The coding technique embodied in lines 63-67 pretty much sucks anyway, since this platform-specific knowledge ought to be out in the port.h files rather than hidden in the guts of the system. I don't want to touch it right now, but I think we ought to have things like #define PS_STATUS_TECHNIQUE PS_USE_CLOBBER_ARGV in the port.h files, rather than these massive #ifdefs. regards, tom lane
FYI, the WU-FTPD code (2.6.0 or better) has a couple of more platforms including UnixWare. The UnixWare code will need /dev/kmem permission to change it's stuff, so I don't know whether we want to do this or not, but if people are looking at the ps stuff, please look at this as well. Larry Rosenman -- Larry Rosenman http://www.lerctr.org/~ler/ Phone: +1 972 414 9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 US >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 3/28/01, 5:23:16 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote regarding Re: [HACKERS] Re: [PORTS] pgmonitor and Solaris : > > On Wed, Mar 28, 2001 at 05:33:05PM -0500, Bruce Momjian allegedly wrote: > >> Sure 'ps -U' will work, but it was reported that on Solaris, plain ps > >> can't show the postgres status display, while ucb/ps can. I don't need > >> specific columns. What I need is the postgres status parameters, and if > >> possible, a user restriction to ps for performance reasons. > Looking at the sendmail code, it seems they use SPT_REUSEARGV (what we > call PS_USE_CLOBBER_ARGV) technique on Solaris. Possibly the problem is > simply that line 65 in src/backend/utils/misc/ps_status.c fails to > cover Solaris as one of the possible options: > #elif defined(__linux__) || defined(_AIX4) || defined(_AIX3) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) > #define PS_USE_CLOBBER_ARGV > Can someone check whether adding an appropriate Solaris symbol (which > one?) fixes the problem? > The coding technique embodied in lines 63-67 pretty much sucks anyway, > since this platform-specific knowledge ought to be out in the port.h > files rather than hidden in the guts of the system. I don't want to > touch it right now, but I think we ought to have things like > #define PS_STATUS_TECHNIQUE PS_USE_CLOBBER_ARGV > in the port.h files, rather than these massive #ifdefs. > regards, tom lane
Mathijs Brands <mathijs@ilse.nl> writes: > PS_USE_CLOBBER_ARGV -is- used on Solaris. I just checked. Hm. But 7.1 postgres backends fail to change their ps display? Does sendmail change its ps display on your machine? regards, tom lane
Larry Rosenman <ler@lerctr.org> writes: > FYI, the WU-FTPD code (2.6.0 or better) has a couple of more platforms > including UnixWare. The UnixWare code will need /dev/kmem permission to > change it's stuff, so I don't know whether we want to do this or not, but > if people are looking at the ps stuff, please look at this as well. Well, *I* sure wouldn't run Postgres with write permission on /dev/kmem. Especially not just to make ps_status work... regards, tom lane
I tend to agree, but wanted someone else's opinion. LER >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 3/28/01, 5:51:13 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote regarding Re: [ADMIN] Re: [HACKERS] Re: [PORTS] pgmonitor and Solaris : > Larry Rosenman <ler@lerctr.org> writes: > > FYI, the WU-FTPD code (2.6.0 or better) has a couple of more platforms > > including UnixWare. The UnixWare code will need /dev/kmem permission to > > change it's stuff, so I don't know whether we want to do this or not, but > > if people are looking at the ps stuff, please look at this as well. > Well, *I* sure wouldn't run Postgres with write permission on /dev/kmem. > Especially not just to make ps_status work... > regards, tom lane
* Tom Lane <tgl@sss.pgh.pa.us> [010328 16:07] wrote: > Larry Rosenman <ler@lerctr.org> writes: > > FYI, the WU-FTPD code (2.6.0 or better) has a couple of more platforms > > including UnixWare. The UnixWare code will need /dev/kmem permission to > > change it's stuff, so I don't know whether we want to do this or not, but > > if people are looking at the ps stuff, please look at this as well. > > Well, *I* sure wouldn't run Postgres with write permission on /dev/kmem. > Especially not just to make ps_status work... Wow... is this all for "pgmonitor"? sorry, just my opinion... If it for pgmonitor then you guys ought to just mark it broken on these platforms, the non-"ps based" solution could have been implemented with all the time wasted trying to get the "ps based" hack working. :( -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] Daemon News Magazine in your snail-mail! http://magazine.daemonnews.org/
Mathijs Brands <mathijs@ilse.nl> writes: > mathijs 297 0.1 0.2 6120 3352 pts/1 S 01:59:18 0:00 /opt/pgsql/bin/./postgres mathijs localhost template1 idle The interesting point about this is that the 7.0.3-on-2.7 installation *is* managing to change its PS display. So either Solaris 2.8 retrogressed (different predefined symbols maybe?), or we broke the code since 7.0.3. Anyway I think the right thing to look at is why the 7.1 install is not managing to update the display. regards, tom lane
> > On Wed, Mar 28, 2001 at 05:33:05PM -0500, Bruce Momjian allegedly wrote: > >> Sure 'ps -U' will work, but it was reported that on Solaris, plain ps > >> can't show the postgres status display, while ucb/ps can. I don't need > >> specific columns. What I need is the postgres status parameters, and if > >> possible, a user restriction to ps for performance reasons. > > Looking at the sendmail code, it seems they use SPT_REUSEARGV (what we > call PS_USE_CLOBBER_ARGV) technique on Solaris. Possibly the problem is > simply that line 65 in src/backend/utils/misc/ps_status.c fails to > cover Solaris as one of the possible options: > > #elif defined(__linux__) || defined(_AIX4) || defined(_AIX3) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix)|| defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) > #define PS_USE_CLOBBER_ARGV > > Can someone check whether adding an appropriate Solaris symbol (which > one?) fixes the problem? > > The coding technique embodied in lines 63-67 pretty much sucks anyway, > since this platform-specific knowledge ought to be out in the port.h > files rather than hidden in the guts of the system. I don't want to > touch it right now, but I think we ought to have things like > > #define PS_STATUS_TECHNIQUE PS_USE_CLOBBER_ARGV > > in the port.h files, rather than these massive #ifdefs. Added to TODO: * Move platform-specific ps status display info from ps_status.c to ports -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> Mathijs Brands <mathijs@ilse.nl> writes: > > PS_USE_CLOBBER_ARGV -is- used on Solaris. I just checked. > > Hm. But 7.1 postgres backends fail to change their ps display? > Does sendmail change its ps display on your machine? Seems we could easily use the sendmail display to populate the ps display defines/ports. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
> Larry Rosenman <ler@lerctr.org> writes: > > FYI, the WU-FTPD code (2.6.0 or better) has a couple of more platforms > > including UnixWare. The UnixWare code will need /dev/kmem permission to > > change it's stuff, so I don't know whether we want to do this or not, but > > if people are looking at the ps stuff, please look at this as well. > > Well, *I* sure wouldn't run Postgres with write permission on /dev/kmem. > Especially not just to make ps_status work... Agreed. If that is what is required, I think you can forget ps status on that platform. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Alfred Perlstein <bright@wintelcom.net> writes: > If it for pgmonitor then you guys ought to just mark it broken on > these platforms, the non-"ps based" solution could have been > implemented with all the time wasted trying to get the "ps based" > hack working. :( My thoughts exactly ;-) ... I'm willing to give advice about this, but not to do any legwork myself. PS status display does have some utility with or without pgmonitor, but not enough to do a lot of work for. regards, tom lane
Bruce Momjian wrote: > > Larry Rosenman <ler@lerctr.org> writes: > > > FYI, the WU-FTPD code (2.6.0 or better) has a couple of more platforms > > > including UnixWare. The UnixWare code will need /dev/kmem permission to > > > change it's stuff, so I don't know whether we want to do this or not, but > > > if people are looking at the ps stuff, please look at this as well. > > > > Well, *I* sure wouldn't run Postgres with write permission on /dev/kmem. > > Especially not just to make ps_status work... > > Agreed. If that is what is required, I think you can forget ps status > on that platform. Bruce, have you taken a look at my statistics collector stuff yet? The view pgstat_activity shows datid, datname, procpid, usesysid, usename and current_query per backend. The code still needs some more work, but as it is it's ready to apply as soon as 7.1 is out the door. All that is totally OS independant, restricts the display of querystrings to postgres superusers and works remotely. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
On Wed, Mar 28, 2001 at 06:48:27PM -0500, Tom Lane allegedly wrote: > Mathijs Brands <mathijs@ilse.nl> writes: > > PS_USE_CLOBBER_ARGV -is- used on Solaris. I just checked. > > Hm. But 7.1 postgres backends fail to change their ps display? > Does sendmail change its ps display on your machine? template1=# \set VERSION = 'PostgreSQL 7.0.3 on sparc-sun-solaris2.7, compiled by gcc 2.95.2' DBNAME = 'template1' USER = 'mathijs' PORT = '5432' ENCODING = 'SQL_ASCII' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = '>> ' HISTSIZE = '500' template1=# [1]+ Stopped psql template1 jumpstart.l3.ilse.nl:/export/home/mathijs >/usr/ucb/ps auxww|grep post mathijs 297 0.1 0.2 6120 3352 pts/1 S 01:59:18 0:00 /opt/pgsql/bin/./postgres mathijs localhost template1 idle mathijs 319 0.1 0.1 944 696 pts/3 S 01:59:45 0:00 grep post mathijs 25810 0.0 0.1 5736 2160 pts/1 S 20:44:34 0:00 /opt/pgsql/bin/./postmaster template1=# \set VERSION = 'PostgreSQL 7.1RC1 on sparc-sun-solaris2.8, compiled by GCC 2.95.3' DBNAME = 'template1' USER = 'mathijs' PORT = '5432' ENCODING = 'SQL_ASCII' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = '>> ' template1=# ^Z[1] + Stopped (SIGTSTP) psql template1 $ /usr/ucb/ps auxww|grep post mathijs 8072 0.1 1.4 5552 3352 pts/2 S 01:01:43 0:00 ./postmaster -D /export/home/mathijs/pgtest/data mathijs 8074 0.1 0.3 976 672 pts/2 S 01:01:55 0:00 grep post mathijs 8067 0.1 0.8 4912 1984 pts/2 S 01:01:37 0:00 ./postmaster -D /export/home/mathijs/pgtest/data I guess it doesn't work :( Of course, it's also possible it doesn't work on Solaris 8, but does on 7. I'll check this and if this is the case, I'll post it. Regards, Mathijs -- It's not that perl programmers are idiots, it's that the language rewards idiotic behavior in a way that no other language or tool has ever done. Erik Naggum
On Wed, Mar 28, 2001 at 07:12:39PM -0500, Tom Lane allegedly wrote: > Mathijs Brands <mathijs@ilse.nl> writes: > > mathijs 297 0.1 0.2 6120 3352 pts/1 S 01:59:18 0:00 /opt/pgsql/bin/./postgres mathijs localhost template1 idle > > The interesting point about this is that the 7.0.3-on-2.7 installation > *is* managing to change its PS display. So either Solaris 2.8 > retrogressed (different predefined symbols maybe?), or we broke the code > since 7.0.3. > > Anyway I think the right thing to look at is why the 7.1 install is not > managing to update the display. > > regards, tom lane Here's 7.1: template1=# \set VERSION = 'PostgreSQL 7.1RC1 on sparc-sun-solaris2.7, compiled by GCC 2.8.1' DBNAME = 'template1' USER = 'mathijs' PORT = '5432' ENCODING = 'SQL_ASCII' PROMPT1 = '%/%R%# ' PROMPT2 = '%/%R%# ' PROMPT3 = '>> ' template1=# ^Z [1]+ Stopped ./psql template1 ilsedb:~/pgtest/bin$ /usr/ucb/ps auxww|grep post mathijs 29830 0.1 0.2 6328 3976 pts/4 S 02:18:16 0:00 ./postmaster -D /export/home/mathijs/pgtest/data mathijs 29832 0.1 0.1 960 704 pts/4 S 02:18:28 0:00 grep post mathijs 29823 0.0 0.1 5696 2176 pts/4 S 02:18:03 0:00 ./postmaster -D /export/home/mathijs/pgtest/data No go... Mathijs -- It's not that perl programmers are idiots, it's that the language rewards idiotic behavior in a way that no other language or tool has ever done. Erik Naggum
On Wed, Mar 28, 2001 at 05:33:05PM -0500, Bruce Momjian allegedly wrote: > Sure 'ps -U' will work, but it was reported that on Solaris, plain ps > can't show the postgres status display, while ucb/ps can. I don't need > specific columns. What I need is the postgres status parameters, and if > possible, a user restriction to ps for performance reasons. My mistake. Have a look at this snippet from the ps manpage: | args The command with all its arguments as a string. The | implementation may truncate this value to the field | width; it is implementation-dependent whether any | further truncation occurs. It is unspecified whether | the string represented is a version of the argument | list as it was passed to the command when it started, | or is a version of the arguments as they may have been | modified by the application. Applications cannot | depend on being able to modify their argument list and | having that modification be reflected in the output of | ps. The Solaris implementation limits the string to | 80 bytes; the string is the version of the argument | list as it was passed to the command when it started. Note the last line... The following must also seem familiar ;) | The Hermit Hacker <scrappy@hub.org> writes: | > On Wed, 29 Apr 1998, Bruce Momjian wrote: | >> No reason for the exec(). I believe the only advantage is that it gives | >> us a separate process name in the 'ps' listing. I have looked into | >> simulating this. | > Under FreeBSD, there is: | > setproctitle(3) - set the process title for ps 1 | > This isn't available under Solaris though, last I checked... | | Setting the process title from C is messy, but there is a readily | available reference. The Berkeley sendmail distribution includes code | to emulate setproctitle on practically every platform. See conf.h and | conf.c in any recent sendmail release. Warning: it's grotty enough to | make a strong man weep. Don't read near mealtime ;-) | | regards, tom lane Regards, Mathijs -- It's not that perl programmers are idiots, it's that the language rewards idiotic behavior in a way that no other language or tool has ever done. Erik Naggum
Tom Lane previously wrote: > Looking at the sendmail code, it seems they use SPT_REUSEARGV (what > we call PS_USE_CLOBBER_ARGV) technique on Solaris. Possibly the > problem is simply that line 65 in > src/backend/utils/misc/ps_status.c fails to cover Solaris as one of > the possible options: > > #elif defined(__linux__) || defined(_AIX4) || defined(_AIX3) > || defined(__sgi) || (defined(sun) && !defined(BSD)) > || defined(ultrix) || defined(__ksr__) || defined(__osf__) > || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) > #define PS_USE_CLOBBER_ARGV > Can someone check whether adding an appropriate Solaris symbol > (which one?) fixes the problem? Tom Lane writes: > The interesting point about this is that the 7.0.3-on-2.7 > installation *is* managing to change its PS display. So either > Solaris 2.8 retrogressed (different predefined symbols maybe?), or > we broke the code since 7.0.3. > > Anyway I think the right thing to look at is why the 7.1 install is > not managing to update the display. The identifier sun is not set if the compiler is in -Xc mode. It would be safer to use to use __sun which is defined in all compiler modes. The symbols defined in all modes are __sun, __unix, __SUNPRO_C=0x500 (or 400, 420, etc.), __`uname -s`_`uname -r` (e.g. __SunOS_5_8), __sparc (SPARC), __sparcv9 (SPARC with -xarch=v9|v9a), __i386 (x86), __BUILTIN_VA_ARG_INCR, __SVR4. That applies to the native compiler. Perhaps someone else could establish what Solaris specific defines are available in gcc. -- Pete Forman -./\.- Disclaimer: This post is originated WesternGeco -./\.- by myself and does not represent pete.forman@westerngeco.com -./\.- opinion of Schlumberger, Baker http://www.crosswinds.net/~petef -./\.- Hughes or their divisions.
On Wed, Mar 28, 2001 at 06:23:16PM -0500, Tom Lane allegedly wrote: > > On Wed, Mar 28, 2001 at 05:33:05PM -0500, Bruce Momjian allegedly wrote: > >> Sure 'ps -U' will work, but it was reported that on Solaris, plain ps > >> can't show the postgres status display, while ucb/ps can. I don't need > >> specific columns. What I need is the postgres status parameters, and if > >> possible, a user restriction to ps for performance reasons. > > Looking at the sendmail code, it seems they use SPT_REUSEARGV (what we > call PS_USE_CLOBBER_ARGV) technique on Solaris. Possibly the problem is > simply that line 65 in src/backend/utils/misc/ps_status.c fails to > cover Solaris as one of the possible options: > > #elif defined(__linux__) || defined(_AIX4) || defined(_AIX3) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix)|| defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) > #define PS_USE_CLOBBER_ARGV > > Can someone check whether adding an appropriate Solaris symbol (which > one?) fixes the problem? PS_USE_CLOBBER_ARGV -is- used on Solaris. I just checked. ilsedb:~$ uname -a SunOS ilsedb 5.7 Generic_106541-11 sun4u sparc SUNW,Ultra-80 ilsedb:~$ cat test.c #include <stdio.h> main() { printf("%d\n", __svr4__); } ilsedb:~$ gcc -o test test.c ilsedb:~$ ./test 1 Regards, Mathijs -- It's not that perl programmers are idiots, it's that the language rewards idiotic behavior in a way that no other language or tool has ever done. Erik Naggum