#!/usr/bin/perl -w # # obpbanner - print the OpenBoot PROM (OBP) banner from Solaris. Perl. # Works best on SPARC, not x86. # # 25-Jan-2006, ver 0.85 (check for newer versions) # # USAGE: obpbanner # # NOTE: # # This version is intentionally written in Perl to be both safe and simple. # The C version needed to be compiled and then set to be setgid to the # group sys. This Perl version simply calls "prtconf -vp", which may be # done as any user. # # THANKS: # Gary Riseborough # technical knowledge # Justin Wills # extensive testing (170+ servers) # # COPYRIGHT: Copyright (c) 2005 Brendan Gregg. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # (http://www.gnu.org/copyleft/gpl.html) # # 12-Mar-2005 Brendan Gregg Created this. # 25-Jan-2006 " " Tweaked style. use strict; # # Fetch prtconf data # my $prtconf = `/usr/sbin/prtconf -vp`; # # Straight values # my ($obp) = $prtconf =~ /\bversion:\s+'(OBP[^']*)'/; my ($bannername) = $prtconf =~ /\bbanner-name:\s+'([^']*)'/; my ($memsize, $memunit) = $prtconf =~ /Memory size: (\d+) (\w+)/; $memunit = "MB" if $memunit eq "Megabytes"; # # Keyboard check # my $keyboard; if ($prtconf =~ /\bname:\s+'[^']*keyboard'/) { $keyboard = "Keyboard Present"; } else { $keyboard = "No Keyboard"; } # # IDPROM values # my ($idprom) = $prtconf =~ /\bidprom:\s+(\S+)/; $idprom = defined $idprom ? $idprom : ""; $idprom =~ s/\.//g; ### Ethernet address, my (@Ether) = $idprom =~ /^....(..)(..)(..)(..)(..)(..)/; my $etheraddr = join(':',@Ether); ### HostID and Serial, my ($type0, $type1, $ether, $date, $hostid2) = $idprom =~ /^..(.)(.)(............)(........)(......)/; my $hostid = $type0.$type1.$hostid2; my $serial; if ("$type0$type1" eq "83") { # common $serial = hex "$type1$hostid2"; } else { # SS10, SS20, ... $serial = hex "$hostid2"; } ### Copyright string, #$crstr = "Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.\n"; # some logic could be here to base this string on OBP version / platform; # or it could be read from /dev/kmem - but that would require SGID to sys. my $crstr = ""; # # Default values # for my $var ($bannername, $obp, $etheraddr, $hostid) { $var = "???" if $var eq ""; } # # Print banner # print <