Showing posts with label hpux. Show all posts
Showing posts with label hpux. Show all posts

Thursday, November 13, 2008

Getting CPU Information From Various Flavours Of Linux And Unix

Hey there,

Today, in keeping with yesterday's theme of covering a fairly specific topic and trolling it around the seamy underbelly of the world of Unix and Linux, we're going to take a look at how to grab CPU information from your Unix or Linux box. I try to cover the major distros here, but (of course) my resources are limited and (except for the HP-UX example below) I've personally run and verified all of the results of the commands put out in this post today. If you crave additional information about your particular Operating System and the CPU(s) on it, check out some of our earlier posts on CPU usage, monitoring, etc, for all sorts of Unix/Linux varieties. Hopefully, you'll find some useful information in the growing archives of this sprawling morass of letters and numbers (by which I, of course, mean this blog ;)

On to today's business! For each OS, we'll be listing the OS name, followed by a practical line of code that you should, hopefully, be able to cut-and-paste onto your own system to get your specific information. Also, for each, we'll list the actual output that my trials produced, except for the HP-UX exception already noted.

1. Listing out CPU information on Solaris (Note that these "virtual" CPU's are actually real):

host # psrinfo -v| awk 'BEGIN{cpua=0;cpub=0}{if ( $0 ~ /Status.*processor/ ) {print $0;cpua=1} else if ( cpua == 1 ) {printf"%s ", $1;cpua=0;cpub=1} else if ( cpub == 1 ) {penult=NF-1;print $penult,$NF;cpub=0}}'|sed 's/,$//'
Status of virtual processor 0 as of: 11/12/2008 13:53:47
on-line 650 MHz
Status of virtual processor 1 as of: 11/12/2008 13:53:47
on-line 650 MHz


2. Listing out CPU information on SUSE and/or RedHat Linux:

host # cat /proc/cpuinfo|egrep 'processor|model name'|awk -F":" 'BEGIN{i=0}{if ( ! i%2 ) {printf"%s %d: ", $1,$2;i++} else {print $2;i=0}}'

processor 0: Intel(R) Xeon(TM) CPU 3.40GHz
processor 1: Intel(R) Xeon(TM) CPU 3.40GHz
processor 2: Intel(R) Xeon(TM) CPU 3.40GHz
processor 3: Intel(R) Xeon(TM) CPU 3.40GHz


3. Listing out CPU information on AIX 5.x:

host /# pmcycles -m
CPU 0 runs at 1200 MHz
CPU 1 runs at 1200 MHz
CPU 2 runs at 1200 MHz
CPU 3 runs at 1200 MHz
CPU 4 runs at 1200 MHz
CPU 5 runs at 1200 MHz
CPU 6 runs at 1200 MHz
CPU 7 runs at 1200 MHz


4. Listing out CPU information on HP-UX (as generally as possible). This bit of code is sewn together from exemplary commands on SysDigg's HP-UX CPU Info Page, since I can't get my hands on an HP-UX box right now, and the information gathering process is more convoluted than any of the preceding distro's (We're not even going to begin to talk about the new Itanium processors and/or differentiate between virtual and physical CPU's/Cores, etc. This is for a HP9000/800 model box):

host # pc=`ioscan -k |grep processor |wc –l `
host # pt=$(grep -i $(model |tr "/" " " \|awk '{print $NF}') \/usr/sam/lib/mo/sched.models |awk '{print $NF}')
host # ps=`echo "itick_per_usec/D" | adb /stand/vmunix /dev/mem | tail -1`
host # echo "Processor count: $pc - CPU Type: $pt - Speed: ${ps}Mhz"
Processor count: 2 - CPU Type: PA8700 - Speed: 750Mhz


Phew... Hopefully, the HP-UX information is correct (if not, please write in as I'd be glad to credit anyone with the correct answer if they can get to an HP-UX machine before I can :)

And, that's that. Quick and painless today ;) I promise to chew your virtual ear off tomorrow as I rant and rage for no apparent reason other than to possibly foment passive-aggressive revolution amongst the working class. Actually, whatever I have to write about tomorrow probably won't be "that" moving ;)

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Thursday, August 21, 2008

Displaying System Information On Linux Or Unix With Cfg2html

Hey There,

Today's post is about a program I got turned on to at work, and which makes our script on linux server information reporting seem a bit lackluster. Then again, there's something to be said for not having "too much" information ;) What we're going to look at today is something you (and your technical colleagues) might love (or hate -- check out a message board or two to keep an accurate reading on the heated and irregular pulse of the user community at large ;) This is definitely not something the higher-ups are going to want to deal with. I'm sure they'd love to know it's available, but (and once you check it out, you'll agree) it doesn't contain the requisite number of pie-charts and 3-dimensional lines to impress a board of directors ;)

The script (which is available for free) is called cfg2html and, from my experience so far, I must say it does a fantastic job of reporting what's reportable and making for a very easy-to-read html server analysis (even if I do have to page-down 50 times to look at absolutely everything it reports on). You can pick up the latest (but not necessarily most stable) version at the cfg2html main site. This is an excellent place to go and grab it, but, since it does always have the latest version, you run the risk of picking up a newer (meaning not quite as thoroughly tested) release that you may not want.

If you're looking for stability, and/or a major release, check out the cfg2html Yahoo group. I'm not sure why this is their main site for stable releases, but it's an option that I've never seen used by a free software distributor, so far, and that makes it (at the very least) interesting. There's probably a very good reason. And I'll make myself nuts trying to figure out what it is unless I just drop it... immediately ;)

The cfg2html latest release page and the cfg2html stable release page (which is redirected to from both come.to and freshmeat.net) both have links to downloads tested to run on HP-UX 10 and 11, Solaris, AIX, SCO Unix, SUSE, Debian, Ubuntu and Red Hat) Linux, NT4.0, Windows 2000, certain Brocade switches and OpenWRT/Freifunk routers. You can also find plugins for AP R/3, Oracle, Informix, Samba (with or without SWAT), ITO and NNM, XP-Surestore Storage, EVA, SureStore E, SuperDome, OLA/R, SCM, AutoRAID, FC60, Tip/X, MC/SG, and Dataprotector/OmniBack. Your download size will vary depending on what you need, but the basic setup doesn't get much larger than 900Kb (Which is actually pretty large when you consider that it's a "script"! ...Actually there are probably some extra binary components to a few of the more eccentric entries in the series. The script I used was only about 40 or 50 Kb.)

If that list of options isn't extensive enough for you, you'll be glad to know that sourceforge.net hosts a separate project exclusively for cfg2html for IBM AIX and another, more specific, revision of the original product, called ora2thml which is more heavily geared toward Oracle configuration reporting. And, just to prove it's a small world, ora2html is in the midst of getting together support for AIX.

Random Interesting Fact: The term "acronym" is almost always used incorrectly. An acronym is any combination of letters, which can be pronounced like a word (actually, it should, technically, be a "real" word, but we've let that slip long ago), consisting of the initials of other words. Self Contained Underwater Breathing Apparatus (SCUBA) or White Anglo-Saxon Protestant (WASP) are acronyms. NT, XP, SCM, NNM, CFG, etc are just groups of initials. People who prefer to avoid conflict sometimes refer to them as abbreviations, although that is generally a bit of a stretch, as well ;)

Snapping right back to (One of my favorite acronyms ;) cfg2html, I've posted some screen shots below of the run-time output (taken from the internet public domain -- Shoot me an email if you deserve credit, since I couldn't find who it actually belonged to) and sections of the actual output from a box I got to test it out on. I think you'll agree that the results are impressive, if not overwhelming and possibly suffocating ;)

Click the picture below to see the run-time output from some guy's server in its original size:

cfg2html runtime

And, just after and below this sentence, click the following pictures for larger versions of a portion of the cfg2html TOC output and two out of 50-odd pages of copious details:

cfg2html report header


cfg2html kernel parameter report


cfg2html hardware report

Like I mentioned, if you're looking for something less severe, check out our old post on reporting Linux system information (and maybe even check out our famously lame collections of sar graph scripts for Unix (follow the links near the top of the article to get all the other scripts) and their all-in-one counterpart Linux sar graphing script.

If you want it all and you've gotta have it now (or as soon as you figure out how to make the html format itself the way you want it to ;), I'd highly recommend checking cfg2html out for yourself.

In a future post, we'll look at ways to configure it other than the "everything under the sun" method we've employed today.

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Monday, August 11, 2008

Changing Solaris Run Levels And Clearing Up Some Common Misconceptions

Hey there,

Today's post hearkens back to an earlier time, when I was administrating Solaris 2.4 and figured Sun had big plans for run level 4. It was, after all "reserved for future use." I don't know about you, but (to this day) when I see terminology like that, I tend to shy away from getting too comfortable with working in a cheap hack. My thinking was that, at some point (given Sun's policy at the time) they'd come up with a unique use for run level 4 and I'd have a whole lot of stuff set up to launch from there and my world would be thrown into chaos ;)

I no longer worry too much about the chaos (something, somewhere is going to break or I'll eventually be out of a job ;), but I still like to keep tabs on Solaris' "level 4" status updates and their command run-level policies. So, today, we'll take a brief look at "run level 4" and then look at a few commands, used to change run levels, that may not act as you would expect.

1. Run level 4: It is still, technically, reserved for future use on Solaris. However, the subtle difference in meaning over time has been stated more clearly with the last few releases. Now, about half of the places you look (on Sun's Documentation Site) list "run level 4" as being "user-defined." What this means, aside from the fact that any admin can make use of it if he or she deems it worthwhile, is that I spent a lot of time worrying about nothing. Of course, I'm willing to forgive, since I never had any use for "run level 4" anyway.

On most Linux and Unix distro's, run level 4 is considered open and user-definable. In a few instances, on HP-UX and Slakware, among others, run level 4 is the default run level for the X-Windows display manager. Generally, this is found on run level 5. But, before I go crazy over-explaining, check out Wikipedia's entry on run levels for virtually every system known to man :)

The only thing you have to make sure of, for the most part, if you want to use Solaris' run level 4 is that you create an entry for it in /etc/inittab. Something like:

s4:4:wait:/sbin/rc4 >/dev/msglog 2<>/dev/msglog </dev/console



would probably suffice for distributions up to, and including Solaris 9. If there are minor differences in your distribution, you can simply copy the line for "s3," paste it below and change all the 3's to 4's. Fairly simplistic, but without it, Solaris' init will never know to look there and will not know what you mean when you try to change to run level 4.

On Solaris 10, things are a little goofier, but in a good way. You can mess around with the inittab and set things up that way, but if you use the "out-of-the-box" configuration and stick with the Service Management Facility (SMF), you won't need to worry about that. SMF has no concept of run levels and doesn't need /etc/inittab. Since SMF handles the order of starting services (with dependencies), you don't need to have a "separate" run level to accomplish whatever end you were shooting for. You can add new services with SMF and then goof around, to your heart's content, with svcadm, svccfg, svc.configd, etc. You may find yourself longing for the "old ways" until you get used to it.

2. Some command run level changing commands and what they're limited to: Some of this stuff still surprises me, since it seems counter-intuitive, but I guess I've always been lucky in the way I start stuff up and shut it down (my apologies to Clint Eastwood for bastardizing his famous quote from "Unforgiven" ;) Plus, I'm a big fan of "init" :) We're going to forget run level 4 exists for most of this part since it rarely matters... technically...

a. init: This command can be used to bring Solaris to any run level you specify (0, 1, s, S, 2, 3, 4, 5 and 6). This is a bone of contention, if you ever have to get certified, but Sun says there are only 8 run levels, of which only 7 are used. If you count "s" and "S" as separate (even though they both do the same thing) I would back you up if your answer was 9.

b. reboot: This command can only bring the system to run level 6. However, you can make reboot take you to other places by terminating the getopts routine and adding a flag afterward, so that:

host # reboot -- -s

would allow you to use the reboot command to get into single user mode. Also, another reason this perplexes me as much as it does is that, technically, bringing the machine to run level 6 entails the system going through a series of run levels leading all the way to the default run level (which is 3, if you left it alone). Sun's answer is technically true, but somewhat misleading. The only thing you really "can't" do with reboot is stop at run levels 0, 1, 2 and 5 (unless you make one of them your default run level in /etc/inittab - not a good idea, especially for 0 and 5 ;)

c. shutdown: This command can only bring the system to run levels 0, 1, s/S, 5 or 6. This makes sense to a degree, since run level 6 is reboot, 5 is power-off and 0 is PROM. I don't understand why it can shut the system down to run level 1 (single user with all local filesystems mounted read-write) and s/S (single user with only / mounted read-only) and not shut it down to run level 2 (basic multi-user with network) from run level 3 (same multi-user with nfs and some additional network services) straight up. As noted above, regarding reboot, you can actually make this command take you to any run level except 2 (unless you set that as your default run level in /etc/inittab)

d. poweroff: This command can only bring the system to run level 5. Perfectly sensible.

e. halt: This command can only bring the system to run level 0. This makes sense, too.

f. uadmin: This command can only bring the system to run levels 0, 5 and 6 (see above regarding why run level 6 means you can also use this command to get to run level 3, or your system default run level, as well). This command is restricted to super-user access by default. For the longest time I thought it could get you to any run level straight off, although I never needed to use it except to dump the system. An interesting fact about uadmin is that it can accept arguments. Which means, if you're feeling moderately clever, you can make it go places Mother won't let it go, by fudging it a little. Consider the following, understanding that uadmin converts arguments into integers as such, and is invoked as "uadmin command function optarg":

commands:

1 = No Disk Sync
2 = Sync Disks

functions:

1 = A_REBOOT <-- Run level 6
2 = A_SHUTDOWN <-- Run level 0
5 = A_DUMP <-- Run level 5

optional arguments:

Try whatever you want out, if you can afford to. Be sure to enclose an argument with spaces in double quotes.

host # uadmin 1 1 "-s kernel/unix" <-- Basically any option you can pass to the PROM "boot" command, you can sneak in here!

also, there are multiple versions of uadmin available, depending on your Solaris release, so you may be looking at these set of options, which will get you to run levels 0, s/S, 1, 2, 5 and 6 (which gives you run level 3) as well as allowing you the optional argument:

uadmin 2 0: sync the filesystems and drops system to ok prompt
uadmin 2 1: sync the filesystems and reboots to multi-user mode
uadmin 2 2: sync the filesystems and reboots interactively
uadmin 2 3: sync the filesystems and reboots to single-user mode
uadmin 2 6: sync the filesystems and powers off the system

uadmin 1 0: do not sync filesystems and drops system to ok prompt
uadmin 1 1: do not sync filesystems and reboots to multi-user mode
uadmin 1 2: do not sync filesystems and reboots interactively
uadmin 1 3: do not sync filesystems and reboots to single-user mode
uadmin 1 6: do not sync filesystems and powers off the system

Now, let's kick back and let the raging debate about OS version-and-release accuracy begin ;)

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Saturday, July 5, 2008

Using LVM on AIX Unix. Part One Of No More Than Two.

Hey there,

As you may recall, we just completed a short series of posts on using LVM on Linux and Unix. At the time that I wrote it, I made mention (probably several times) of the similarities between LVM for Linux and HP-UX's brand. Also at that time, since I had hardly any experience with AIX, I was completely unaware that LVM was being used on that operating system.

If you need help with some of the basic concepts of LVM, please check out our older post on getting started with LVM and then check out the series listed above.

Now, I think I'm not allowed to get "too" excited about this, since this blog is mostly about Linux flavours and Solaris Unix (peppered with a little HP and one old post on AIX commands for the Unix user), but I thought I'd put this little series of posts (possibly not in totally sequential order -- Sometimes things come up that I'm compelled to write about ;) up for the AIX enthuisast who is thinking of using, or just beginning to use, LVM on AIX.

I hope this post is helpful to you. In any event, it should make for a good reference and might possibly be useful "later" :) Today, we'll look at LVM creation and display/monitoring commands for AIX and our next post will be on usage and destruction! Please note that all examples are mocked up and any variable that starts with Optional (such as OptionalVolumeGroupName) is an argument that you don't necessarily need to pass to the command.

Enjoy :)

AIX LVM Creation commands:

Create a Physical Volume (Note that Physical Volumes, in AIX, already exist - they just need to be allocated to Volume Groups):

host # lsvpcfg <-- To show the disks/vpaths and any Volume Groups they may already be associated with.
host # lspv|grep None <-- To show available Physical Volumes
host # cfgmgr <-- Use this interactively to allocate the Physical Volume for use with LVM.

Create a Volume Group:

host # mkvg -y VolumeGroupName HardDiskNumber <-- You can get the hard disk number from the lsdev command
host # varyonvg VolumeGroupName

Create a logical volume within a volume group:

host # mklv -y LogicalVolumeName -t FileSystemType VolumeGroup PhysicalPartion(PP) OptionalSpecificHardDriveDefinition
Ex:
host # mklv -y MylogicalVolume -t jfs MyVolumeGroup 8 <-- Note that the PP size is in MB.
or
host # mklv -y MylogicalVolume -t jfs MyVolumeGroup 8 /dev/DiskName

AIX LVM Display/Monitoring commands:

List out information about physical volumes:

host # lspv OptionalPhysicalVolumeName

List out Physical Volume information by Hard Disk:

host # lspv HardDiskNumber

List out Logical Volumes Within a Physical Volume:

host # lspv -l HardDiskNumber

List out Physical Partitions within a Physical Volume:

host # lspv -p HardDiskNumber

List out information about volume groups:

host # lsvg OptionalVolumeGroupName

List out properties of logical volumes within a volume group:

host # lsvg -l VolumeGroupName

List out properties, including hard drives, within a volume group:

host # lsvg -p VolumeGroupName

List out properties of a logical volume:

host # lslv OptionalLogicalVolumeName

List out Logical Volumes within a Physical Volume:

host # lslv -l OptionalLogicalVolumeName

List out Logical Volumes by Physical Volume:

host # lslv -p OptionalPhysicalVolumeName

List out mirrored Logical Volumes:

host # lslv -m OptionalLogicalVolumeName

List out hard disks in a vpath (Virtual Path). Necessary after Physical Volume Allocation to ensure everything went ok:

host # lsvpcfg

List out Fiber Channel adapters:

host # lsdev -Cc adapter
host # scfg -vl Number of fiber channel card

, Mike