Operating System - Linux
1752579 Members
4290 Online
108788 Solutions
New Discussion юеВ

porting Solaris app to HPUX

 
yingbin
New Member

porting Solaris app to HPUX

Hi
Can anybody help for my porting issue? I am working on porting our application to HPUX 11i environment.
But I could not find correspondent syscall for Solaris kstat structure.
Here are some scenarios:
1. Network:
get network input trafifc:
ksname = (kstat_named_t *) kstat_data_lookup(ksp, "rbytes");
get network output traffic:
ksname = (kstat_named_t *) kstat_data_lookup(ksp, "obytes");
snap time:
newhrtime = ksp->ks_snaptime;

2. CPU:
collect CPU usages:
....//ksp come from kstat structure in Solaris
for ( ksp = kstatControlPtr->kc_chain; ksp; ksp = ksp->ks_next )
{
if ( strncmp(ksp->ks_name, "cpu_stat", 8 ) == 0 ) {
if ( kstat_read(kstatControlPtr, ksp, NULL) == -1 )
{
// Error....
}
memcpy(&cpu_stats[j], ksp->ks_data, sizeof(cpu_stats[j]));
j++;
}
....//we got cpu_stats array.
}
.....
/* Calculate CPU load distribution in idle, user and system states */
for ( int i = 0; i < ncpus && i < noofCpus; i++ )
{

newCpuIdleTimeCounter[i] = cpu_stats[i].cpu_sysinfo.cpu[CPU_IDLE];
newCpuUserTimeCounter[i] = cpu_stats[i].cpu_sysinfo.cpu[CPU_USER];
newCpuKernelTimeCounter[i] = cpu_stats[i].cpu_sysinfo.cpu[CPU_KERNEL];
newCpuWaitTimeCounter[i] = cpu_stats[i].cpu_sysinfo.cpu[CPU_WAIT];
.....

How do I use HPUX call to achieve same functionality?
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: porting Solaris app to HPUX

You will have to look at all of the pstat(2) variants. Most likely pstat_getprocessor() for your CPU stats?
yingbin
New Member

Re: porting Solaris app to HPUX

pstat has some CPU info. But the difficult part is in question 1. I could not get related info from google.
Peter Godron
Honored Contributor

Re: porting Solaris app to HPUX

Hi,
this will not help very much, but from another thread:
"Sadly HP-UX hides this data and requires you to buy e.g. Glance to access the data.
Nevertheless you can use plug-ins based on common user space Unix commands such as
uptime, ps, vmstat, iostat, sar, nfsstat etc."
rick jones
Honored Contributor

Re: porting Solaris app to HPUX

If you are running SNMP on the system you could issue MIB queries.

Take a look at the manual in docs.hp.com for DLPI - IIRC there is a stats message one could send to each driver to get their (link-level) stats which I suspect would match those from the lanadmin -g mibstats command.

You might also go poking about in /usr/include, but keep in mind that not everything one finds there is documented and so you may be on your own.

The DSPP - http://devresource.hp.com/ might be a good place to look.

BTW, wrt the CPU stats you get from kstat on solaris - they do _not_ include time spent processing interrupts. I found this the hard way porting netperf. Time spent processing interrupts is tracked independent of user/sys/idle. In http://www.netperf.org/svn/neperf2/src/netcpu_kstat10.c (IIRC that is the file) you can see the handwaving I had to do for that.

To see what I mean, run something interrupt intensive like netperf and bind the netperf or the netserver (depending on which way you are testing) to a CPU other than the one taking interrupts from the NIC. Run mpstat while netperf is running. Many's the time you will see (generally when the system is otherwise idle) the CPU taking interrups having its interrupt count quite large but still reporting 100% idle CPU.

Feel free to peruse the other netcpu files there for ideas for say HP-UX 11.23. Netperf though, strange as it may seem, does not try to extract networking stats from the system :)
there is no rest for the wicked yet the virtuous have no pillows