1833767 Members
2122 Online
110063 Solutions
New Discussion

IOCTL & PDC calls

 
Andrej Drobnic
New Member

IOCTL & PDC calls

I have very unique problem with HP-UX. I need to gather low-level information about HP-UX system. (memory banks, cpus, PCI devices, ...) this can be done by accessing PDC (machine/pdc_rqsts.h) but there is no API to access it in HP-UX. Note that i get all info i need with STM (part of OnlineDiag package). I need to do similar thing in C.
I tried doing some ioctl calls on /dev/diag/diag2 but so far with no success. Any help and example source code would be welcome.

Regards, Andrej
5 REPLIES 5
Tom Geudens
Honored Contributor

Re: IOCTL & PDC calls

Hi,
I'm no C guru, so I can't help you there ... but a lot of the things you need can be gotten in scripts :
# 32 of 64 bit kernel ...
getconf KERNEL_BITS
64

echo physmem/D | adb -k /stand/vmunix /dev/kmem
physmem:
physmem: 24576

for HP-UX 11.x systems running on 32 bit architecture:
example:

echo phys_mem_pages/D | adb /stand/vmunix /dev/kmem
phys_mem_pages:
phys_mem_pages: 24576

for HP-UX 11.x systems running on 64 bit architecture:
example:

echo phys_mem_pages/D | adb64 -k /stand/vmunix /dev/mem | tail -1 | awk '$2 > 0 {print $2 /256}'
phys_mem_pages:
phys_mem_pages: 262144

The results of these commands are in memory pages, multiply by 4096
to obtain the size in bytes.

To determine the amount of lockable memory:
example:

echo total_lockable_mem/D | adb -k /stand/vmunix /dev/mem
total_lockable_mem:
total_lockable_mem: 185280

To determine the number of free swap pages :
example:

echo swapspc_cnt/D | adb -k /stand/vmunix /dev/kmem
swapspc_cnt:
swapspc_cnt: 216447

This will display the number of free swap pages.
Multiply the number returned by 4096 for the number of free swap bytes.

To determine the processor speed:
example:
echo itick_per_usec/D | adb -k /stand/vmunix /dev/mem
itick_per_usec:
itick_per_usec: 360

To determine the number of processors in use:
example:
echo "runningprocs/D" | adb -k /stand/vmunix /dev/mem
runningprocs:
runningprocs: 2

To determine the number of pages of buffer cache ( 4Kb in size)
example:
echo bufpages/D | adb -k /stand/vmunix /dev/mem
bufpages:
bufpages: 18848

To display kernel parameters using adb use the parameter name :
example:
echo nproc/D | adb -k /stand/vmunix /dev/mem
nproc:
nproc: 276

To determine the kernel your booted from:
example:
10.x
echo 'boot_string/S' | adb /stand/vmunix /dev/mem
boot_string:
boot_string: disc(52.6.0;0)/stand/vmunix

11.x
echo 'boot_string/S' | adb64 -k /stand/vmunix /dev/mem
boot_string:
boot_string: disk(0/0/2/0.6.0.0.0.0.0;0)/stand/vmunix

You can off course also execute cstm in batch ... for example :
echo "selclass qualifier cpu;info;wait;infolog" | cstm > /tmp/procinfo

Hope this helps,
Tom
A life ? Cool ! Where can I download one of those from ?
Andrej Drobnic
New Member

Re: IOCTL & PDC calls

I know how to do all those things in C.. I also know how to get number of CPUs and CPU type. But this is not enough. I want to know how many memory banks are there, which of them are full.. and so on.

I cannot use stm because it's not part of HP-UX system. (not included in default installation) and it wouldn't work for most users who install our application.
Andrej Drobnic
New Member

Re: IOCTL & PDC calls

Anyone has some source code examples on how to use ioctl on other devices? /dev/config for example?
Joseph A Benaiah_1
Regular Advisor

Re: IOCTL & PDC calls

Andrej,

Information regarding this can be extracted in C using the pstat library:

/* mem.c
Program to list physical memory */

#include

main()
{
struct pst_static buf;
pstat_getstatic(&buf, sizeof(buf), 0, 0);
printf("Physical memory = %ld MB\n", buf.physical_memory/256);
exit(0);
}

Compile the program by typing:

cc mem.c -o mem

If you program regularly, you will find the man page on pstat useful.

Cheers,

Joseph.
Andrej Drobnic
New Member

Re: IOCTL & PDC calls

Well this was helpful to some degree. I already knew how to get memory size, CPU type, CPU speed, .. in C.

How to get motherboard information? Memory sockets? PCI devices? Temparatures? Fan Speeds?