HPE 9000 and HPE e3000 Servers

Re: Soucre Code To Get Server Serial Number?


Soucre Code To Get Server Serial Number?

Does anyone have a c source code to get the server serial number off L classes and above? I found the Sysinfo script that someone gave me that had a getsn that works. But I'm looking for source code. I tried the confstr man page and a few others to no avail. But this getsn works. Just wish I had some source to it. I've included it here.
Steven E. Protter
Exalted Contributor

Re: Soucre Code To Get Server Serial Number?

uname -i should give you the information you want.

A note from Harry D. Brown

uname -i is just as potentially inaccurate. If a system board was ever replaced, then this number is most likely to change. At one time HP engineers used to, when they remembered, moved the system number to the newer system board, but then there was a time when they were FORBIDDEN to move the numbers - of course screwing the serial number / system number relationship


Steven E Protter
Owner of ISN Corporation
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sunil Sharma_1
Honored Contributor

Re: Soucre Code To Get Server Serial Number?

I think you can use Nikle script for this.

*** Dream as if you'll live forever. Live as if you'll die today ***
Tobias Hartlieb
Trusted Contributor

Re: Soucre Code To Get Server Serial Number?


you can read the serial number by using the OnlineDiagnostic Software. Using the STM interface, one can do an 'information' on 'System' and gets it.
The commandline Interface of STM - cstm - can be scripted:
echo "sel d 1\ninfo;wait\nil\ns\n/tmp/cstm.txt\n\n" | /usr/sbin/cstm >/dev/null

grep 'System Serial' /tmp/cstm.txt

By the way, this only applies to the fairly new server types, i.e. L-class, A-class, N-class, and above (all servers, which have the device 'system' in the device map of STM).



Re: Soucre Code To Get Server Serial Number?

Okay, I guess I wasn't clear in my request. Uname -a returns the software serial number. I want the chassis serial number that's equal to the one on the outside on the chassis such as USM15343YK

I want source code, preferably in C so I can code this in a program to gather system information.

I know it can be done as the getsn program from HP does it. But since it's binary it's stand-alone. I want something I can encode into my C program.

I appreciate the fast response of everyone. I think I'm going to call it in directly to HP as some of their OS calls that are supposed to do this doesn't work.

Stan Sieler
Respected Contributor

Re: Soucre Code To Get Server Serial Number?

I'm interested in what
you find out ... I have no
idea how to get a serial
number like USM15343YK
(e.g., as reported by stm)

Ironically, the stm script
posted earlier DOESN'T
show the serial number
reported by uname!

If you can't get the fancy one, the following at least shows how to get the uname -a number from uname().

NOTE: Itanium HP-UX machines
don't seem to have a reportable serial number, as this has reported 0 on every
one we've tried it on! (boo!)



int main()
struct utsname uts;

if (uname(&uts) < 0)

printf ("sysname: %s\n", uts.sysname);

printf ("nodename: %s\n", uts.nodename);

printf ("release: %s\n", uts.release);

printf ("version: %s\n", uts.version);

printf ("machine: %s\n", uts.machine);

printf ("__idnumber: %s\n", uts.__idnumber);

return 0;
Michael Steele_2
Honored Contributor

Re: Soucre Code To Get Server Serial Number?

The system ID found with 'uname -i' and the L Class S/N are not the same thing. One is installed via SSCONFIG and used for licensing purposes and programmed into the system board, while the other appears under the left panel of the L Class server as you stand behind it. Right side if in front. Simply pull the plastic cover off of the cabinet to see the S/N. It should be a while label.

Early L Class servers all had this problem. It used to drive me up the wall because you can never start a HW ticket without the S/N.

The S/N will also appear on your original shipping manifest, can also be cross referenced by system handle with any software response center technician, or by the sales order number if you use a channel partner.
Support Fatherhood - Stop Family Law
Patrick Wessel
Honored Contributor

Re: Soucre Code To Get Server Serial Number?

I???m sorry but the part of code of getsn you are looking for is classified as ???company confidential???. Therefore you will not find the source code
There is no good troubleshooting with bad data
doug hosking
Esteemed Contributor

Re: Soucre Code To Get Server Serial Number?

# cat ser.c

char buf[81];
if (confstr(_CS_MACHINE_SERIAL, buf, sizeof(buf)) <= 0) {
printf(" machine serial number = %s\n", buf);
# cc ser.c
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (ser.o) was detected. The linked output may not run on a PA 1.x system.
# ./a.out
machine serial number = USSxxxxxxx
# model

This does not work on all systems, but clearly works on at least some L-class systems.