1822582 Members
3425 Online
109643 Solutions
New Discussion юеВ

dmesg command

 
SOLVED
Go to solution
EDMS SST
Occasional Advisor

dmesg command

Hello,
I would like to use the physical memory output from the dmesg command in a script that monitors the free system memory. However, my dmesg is 'full' and I am trying to find a way to 'clear' it and get the memory report again. I have tried /usr/sam/lbin/getmem and it gives false output (report 512MB on systems with 2GB). I don't want to use syslog.log or OLDsyslog.log, for fear of the syslogd getting restarted, or the log files getting deleted by some well-meaning admin and the memory info getting lost. Running 10.20 on 9000's - is there a way to refresh dmesg?
Thanks
Eric Liszka
10 REPLIES 10
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: dmesg command

Hi Eric,
The dmesg buffer is circular and once it overflows the data is gone. A better way is to ask the kernel itself via adb.
Do this:
1) adb -k /stand/vmunix /dev/mem
2) physmem/D (this will print the physical memory
in 4k pages)
3) $q (this will exit adb)

Man adb for details. You could script the process and get the value anytime 'on the fly'.

Hope this helps, Clay
If it ain't broke, I can fix that.
Vincenzo Restuccia
Honored Contributor

Re: dmesg command

Try with STM command:
#echo "selclass qualifier memory;info;wait;infolog"|cstm
EDMS SST
Occasional Advisor

Re: dmesg command

Clay,
Thank you, that will do nicely......on all my systems except two.
On two systems the command just returns me to the shell with
no errors or output of any kind. I've got the same binary, and same
permissions on /stand/vmunix and /dev/mem. Any ideas on that one?
Thanks
Eric.
James R. Ferguson
Acclaimed Contributor

Re: dmesg command

Hi Erik:

On 10.x systems:

# echo "physmem/D"|adb -k /stand/vmunix /dev/kmem

On 11.x 32-bit systems:

# echo "phys_mem_pages/D"|adb /stand/vmunix /dev/kmem

On 11.x 64-bit systems:

echo "phys_mem_pages/D"|adb64 -k /stand/vmunix /dev/mem

...JRF...
Thierry Poels_1
Honored Contributor

Re: dmesg command

difference between 10.20 and 11.00? :)

try "phys_mem_pages/D" for 11.x
good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
A. Clay Stephenson
Acclaimed Contributor

Re: dmesg command

Hi Eric,
I think James answered your question. I suspect you have some 11x boxes mixed in rather than simply the 10.20 OS you mentioned.
If the suggestions made by James don't fix your problem then let us know what OS and machine type. There were a few patches for adb and you may need to install one.

Regards, Clay
If it ain't broke, I can fix that.
EDMS SST
Occasional Advisor

Re: dmesg command

Thank you,
These two are running 10.20, I was able to get into adb without the -k option but physmem and phys_mem_pages were bad values. According to uname -a:
HP-UX B.10.20 A 9000/898
on both systems.

Eric.
Bill Hassell
Honored Contributor

Re: dmesg command

It's a very good idea to capture all dmesg output. SInce it can easily fill up with other console messges, it must be captured via cron. The sample cron entry in /usr/newconfig (all sysadmins should remember this directory) has an example:

# log kernel diagnostic messages every 10 minutes
05,15,25,35,45,55 * * * * /usr/sbin/dmesg - >>/var/adm/dmesg.log

Note that the demsg - option is important as it asks only for changes since the last call to demsg. I use the logname: dmesg.log while the example in /usr/newconfig/var/spool/cron/crontab.root is /var/adm/messages.

Now there won't be any lost messages.

A note about cstm...a very important tool but not installed automatically. Install cstm (and it's siblings mstm and xstm) from the SupportPlus CDROM in the DIAGNOSTICS directory.


Bill Hassell, sysadmin
A. Clay Stephenson
Acclaimed Contributor

Re: dmesg command

Hi Eric,

Sorry I didn't see your last posting until now.
On the two errant boxes I would try this command.

echo "physmem/D" | adb /stand/vmunix /dev/kmem

You noted that the -k option was killin you so we will try it without the virtual to physical address mapping. Note that we are using a different mem device. I've never seen a case where adb would not run with -k.

Clay
If it ain't broke, I can fix that.
EDMS SST
Occasional Advisor

Re: dmesg command

Clay,
Thanks again! using /dev/kmem without the -k option did the trick.
Eric.