Operating System - Linux
1819814 Members
2712 Online
109607 Solutions
New Discussion юеВ

Using adb for querying kernel

 
Jim Krol
Advisor

Using adb for querying kernel

I would like to query the kernel on a regular basis to see the current nflocks and nfile being used (not the current max allowable). I know I can use Glance and GPM to get this info, but, I want to don't want to have to watch these tools all day. I'd like to write a script that will query for these 2 kernel parameters. Also, where would you look to find the available parameters for querying the kernel via adb...like, where would I look to find vx_cur_inodes and similar parameters (I have been using 'echo vx_cur_inodes/D|adb -k /stand/vmunix /dev/mem')?
6 REPLIES 6
IT_2007
Honored Contributor

Re: Using adb for querying kernel

Peter Godron
Honored Contributor

Re: Using adb for querying kernel

Hi,
title of the link :
"AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs"

Applicable in HP-UX forum ?
IT_2007
Honored Contributor

Re: Using adb for querying kernel

Peter,

Agree. But it may give idea about adb. May be I am wrong.

Thanks.
A. Clay Stephenson
Acclaimed Contributor

Re: Using adb for querying kernel

The general answer for where to find the kernel parameters is to do an "nm /stand/vmunix > mylist". You can then examine mylist with vi or with grep narrow your search. Bear in mind, that you can use the command-line version of glance to extract the data in a more portable way.

If it ain't broke, I can fix that.
Geoff Wild
Honored Contributor

Re: Using adb for querying kernel

Try this script:

# cat /usr/local/bin/hpmem
#!/bin/ksh
#
# Taken from the HP/UniGraphics FAQ
# You must be ROOT to execute this since it uses adb to
# examine the running kernel
#
GetKernelSymbol()
{
echo "$1/D" | \
adb $hpux /dev/kmem | \
tr "\012" " " | \
awk -F: '{print $3}'|\
read kval
}
hpux=/hp-ux
rev=$(uname -r | cut -d. -f2)
if ((rev > 9)); then hpux=/stand/vmunix ;fi
/bin/uname -a
# if 11iv2 or higher - get cpu this way
ver=$(uname -r | cut -d. -f3)
if ((ver > 22)); then
kval=`echo "processor_count/D" | adb /stand/vmunix /dev/kmem |tail -1|awk -F: '{print $2}' `
else
GetKernelSymbol "processor_count"
fi
print CPU Count: $kval
GetKernelSymbol "itick_per_tick"
let speed=kval/10000
print CPU Speed: $speed MHz
if ((rev > 10)); then
print CPU HW Support: `getconf HW_CPU_SUPP_BITS`-bit
print Kernel Support: `getconf KERNEL_BITS`-bit
GetKernelSymbol "memory_installed_in_machine"
else
GetKernelSymbol "physmem"
fi
# if 11iv2 or higher - get memory this way
ver=$(uname -r | cut -d. -f3)
if ((ver > 22)); then
kernel=$(/usr/sbin/kcpath -x)
hexval=$(echo "phys_mem_pages/A" | adb $kernel /dev/kmem|tail +2|awk '{print $2}')
REAL_MEM=$(echo ${hexval}=D|adb)
mb=$(expr ${REAL_MEM} / 256)
else
let mb=kval*4/1024 # convert pages to MB
fi
print RAM Size: $mb MB
GetKernelSymbol "bufpages"
let mb=kval*4/1024 # convert pages to MB
print bufpages: $mb MB
GetKernelSymbol "maxuprc"
print maxuprc: $kval
GetKernelSymbol "maxvgs"
print maxvgs: $kval
GetKernelSymbol "maxfiles"
print maxfiles: $kval
GetKernelSymbol "max_thread_proc"
print max_thread_proc: $kval
GetKernelSymbol "nfile"
print nfile: $kval
GetKernelSymbol "nproc"
print nproc: $kval
GetKernelSymbol "ninode"
print ninode: $kval
GetKernelSymbol "vfd_cw"
print shmmax: $kval
GetKernelSymbol "shmmni"
print shmmni: $kval
GetKernelSymbol "dbc_max_pct"
print dbc_max_pct: $kval

For a single item:

echo "active_processor_count/D" | adb -o /stand/vmunix /dev/kmem



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
macdonaldak
Visitor

Re: Using adb for querying kernel

Thanks for all this info.

I have found that running glance the following way will also give me the info:
glance -j 900 -t -f /path/to/myfile.txt

I just grep for nflocks and nfile.