Solved

get hardware information of HP-UX

Posted on 2006-06-28
10
25,264 Views
Last Modified: 2013-12-06
Dear experts,

   I would like to know as a regular unix user, how what commands can get the information of HP-UX system
CPU clock speed (in MHz or GHz),
memory size (in MB or GB),
swap size (in MB or GB),
hard disk volume (in GB, not filesystem size)
System model (Such as J6700)
System Serial number (if possible)

   I want to put those commands into a script so end users can run it to get the information for the HP-UX they are login.
As root, I can get those information and I would like to know the commands for regular user.
Most important information is the CPU speed, physical memory size, swap size, and disk volume.

Thanks in advance.
0
Comment
Question by:wesly_chen
  • 5
  • 5
10 Comments
 
LVL 38

Author Comment

by:wesly_chen
ID: 17003483
I got the C program to get the physical memory size and compiled it for regular users.
http://www.faqs.org/faqs/hp/hpux-faq/section-284.html
0
 
LVL 4

Expert Comment

by:JulieBouillon
ID: 17003566
Hi,

If memory serve me well, you should try dmesg. At least for CPU info.
0
 
LVL 38

Author Comment

by:wesly_chen
ID: 17003727
As a regular user, dmesg get the following error:
-----------
$ dmesg

Jun 28 11:34
Can't read kernel memory
0
 
LVL 4

Expert Comment

by:JulieBouillon
ID: 17005345
Could you try with getconf ? It works for non root users.
eg.; getconf CPU_CHIP_TYPE

Unfortunatelly, the output is not very user friendly... See the man page for the list of available infos.
At the following address, you will find a script to show you how to determine the CPU -> http://unix.derkeiler.com/Mailing-Lists/HP-UX-Admin/2003-04/0003.html

Other command you can also use are:
 - model -> gives the model of your server
 - lsdev -> list device driver in the system
 - ioscan -> Won't work as non root -> scan I/O system and output a map

The last way that I can think of would be to extract the informations from /var/adm/syslog/syslog.log (default location). You should find ther part of what you are looking for.

I hope it helps.
0
 
LVL 38

Author Comment

by:wesly_chen
ID: 17005732
getconf CPU_CHIP_TYPE
or the script based on "getconf CPU_CHIP_TYPE"
is showing the CPU type, not CPU clock speed.

>  /var/adm/syslog/syslog.log
I can see physical memory size and the swap size. But not CPU clock speed.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:JulieBouillon
ID: 17007946
From the following site http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=54007&admit=-682735245+1151571433409+28353475

Could you try this:
 echo $(echo itick_per_tick/D | adb -k /stand/vmunix /dev/kmem | tail -1 | awk '{print $2/10000}')

I can't try it at the moment, so I'm not sure if it will run as non root user, especially since we access the kernel...
0
 
LVL 38

Author Comment

by:wesly_chen
ID: 17011957
it needs root previlege to run. I've that for sys admin.
0
 
LVL 4

Assisted Solution

by:JulieBouillon
JulieBouillon earned 300 total points
ID: 17014226
Ok, I got it now !
I wrote a small C program to obtain the numbers of CPU and the speed. You just need to compile it!
I only tested it under 11.11. I have not use pstat() since it is deprecated, but if your version is too old for this program, you should be able to modify it quite easilly by looking at pstat()'s man page.

------8<------
#include <sys/param.h>
#include <sys/pstat.h>

int main()
{
 struct pst_dynamic psd;
 int num_cpus = 0;
 struct pst_processor psp;
 int clock = 0;

 /* Determine how many processors are online and available */
 if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) != -1)
        num_cpus = psd.psd_proc_cnt;

 /* Report the speed of the first processor */
 if (pstat_getprocessor(&psp, sizeof(psp),1,0)) {
        clock = psp.psp_iticksperclktick / 10000;
 }

 printf("There is %d CPU(s) running at %d Mhz\n", num_cpus, clock);
}
------>8------
0
 
LVL 38

Author Comment

by:wesly_chen
ID: 17014904
This program works great for me.

I just wonder whether there is the similar system commands/scripts in HP-UX like
/usr/sbin/prtconf in IBM AIX
or
/usr/platform/`uname -m`/sbin/prtdiag  in Sun Solaris
or
/usr/sbin/dmidecode in Linux
(/usr/share/rhn/up2date_client/hardware.py in RedHat Enterprise Linux)

By the way, besides "/usr/sbin/swapinfo" (root only) or /var/adm/syslog/syslog.log , is there any command can show the swap size as regular user?
0
 
LVL 4

Accepted Solution

by:
JulieBouillon earned 300 total points
ID: 17015049
To find out what AIX or Solaris is on HP-UX or on Linux or on whatever Unix you're using, just go to -> http://bhami.com/rosetta.html

For the swap as non root user here is another small C program... You can have a look at all the info you can get with man pstat

------8<------
#include <sys/param.h>
#include <sys/pstat.h>

int main()
{
 struct pst_swapinfo pss;
 unsigned long swapsize = 0;
 unsigned long swapfree = 0;
 int i = 0;

 for (i = 0; pstat_getswap(&pss, sizeof(pss), (size_t)1, i); i++) {
        swapsize += pss.pss_nblksenabled;
        swapfree += pss.pss_nfpgs * 4;
 }

 printf("Swap size is %d (%d free)\n", swapsize, swapfree);
}
------>8------
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now