- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get CPU speeds and RAM without cstm or root
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 12:04 AM - last edited on тАО01-01-2013 07:06 PM by Cathy_xu
тАО04-07-2005 12:04 AM - last edited on тАО01-01-2013 07:06 PM by Cathy_xu
How to get CPU speeds and RAM without cstm or root
I've see posts asking similar questions, I figured I'd share. I found one similar post and that got me going. I used inline perl.
I wrote code to collect inventory across our enterprise, at some point I'll post the inventory source for AIX, Solaris, Linux, and HP-UX, likely to sourceforge. I can get 3+ machines a minute without any agent code, well other than SSH. I prefer to work without privilege when possible, thus I needed a solution. I have worked towards threading my code so I can collect across 300 machines in under 5 mintes. I am collectiong performance information, kernel parameters, software packages, patches, LVM, filesystems, ..etc.
We've seen cstm hang, and frankly it takes too long when it works right.
I got tired of trying to work around the issue, this works on 11.00, 11.11, and 11.22.
Please note on IA64 you'll have to use the perl out of /opt/perl_64/bin, on PARISC it seems you can use the 32 bit perl.
for RAM:
perl -e 'local($PSTAT,$PSTAT_STATIC,$mem_info,$PSTAT_STRUCT)=(239,2,"\0"x120,"LI4L");
syscall($PSTAT,$PSTAT_STATIC,$mem_info,length($mem_info),1,0);
print "RAM=".int((unpack($PSTAT_STRUCT,$mem_info))[4]*((unpack($PSTAT_STRUCT,$mem_info))[5])/(1024*1024))."\n";'
for CPU speeds:
perl -e 'local($PSTAT, $PSTAT_PROCESSOR)=(239,10);
local($struct_pst_processor)=("L30");
local($cpu_info, $cpu_ticks);
$cpu_info = "\0" x 120;
syscall($PSTAT, $PSTAT_PROCESSOR, $cpu_info, length($cpu_info), 1, 0);
($cpu_ticks)=(unpack($struct_pst_processor, $cpu_info))[26];
print "speed=".int($cpu_ticks/10000)."\n";'
Tom Ferony - Union Pacific Railroad tomferony@up.com
P.S.This thread has been moved from HP-UX>System Administration to HP-UX > languages- HP Forums Moderator
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 12:10 AM
тАО04-07-2005 12:10 AM
Re: How to get CPU speeds and RAM without cstm or root
Very helpful. I've bookmarked this for future reference. Thanks.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 12:13 AM
тАО04-07-2005 12:13 AM
Re: How to get CPU speeds and RAM without cstm or root
It takes into account that you might not be root, and leaves out what it cannot fetch
From http://mirrors.develooper.com/hpux/faq.html
http://mirrors.develooper.com/hpux/ux
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 12:14 AM
тАО04-07-2005 12:14 AM
Re: How to get CPU speeds and RAM without cstm or root
Quite cool, but I have 2560 MB's of ram and your script returned 2550 MB - Not a big deal. The CPU speed hit the nail on the head!
thanks
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 12:40 AM
тАО04-07-2005 12:40 AM
Re: How to get CPU speeds and RAM without cstm or root
I'm using this great script:
http://www.cfg2html.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 01:22 AM
тАО04-07-2005 01:22 AM
Re: How to get CPU speeds and RAM without cstm or root
As far as memory goes, the attached c program runs a lot quicker then yuor perl script - and doesn't need root.
Output like:
$ /usr/local/bin/memdetail
Memory Stat total used avail %used
physical 10080.0 8445.1 1634.9 84%
active virtual 7313.6 1179.7 6133.9 16%
active real 5818.8 569.8 5248.9 10%
memory swap 7707.8 1715.5 5992.2 22%
device swap 28080.0 6852.3 21227.7 24%
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2005 02:33 AM
тАО04-07-2005 02:33 AM
Re: How to get CPU speeds and RAM without cstm or root
Inventory - I'm not distributing any code at all to any box on five different UNIX platforms (Zero Code Deployment), all I have is secure shell access via keys. The data is stored in a database to allow for cross referencing, comparisions, change history, graphing of sar data, ..etc. I'll try to attach a little sample of the "output".
Connectivity - I even have the ability to connect via SSH, and X-windows without code deployment to the client, all in a browser. The Xwindows stuff is slight of hand with perl acting like a one time inetd (to customize resolution and color depth), Xvnc using xdmcp, Xvnc applet, and javascript (to open a new window and get color depth and resolution). For SSH I'm using mindterm, which allows for copying of files etc.
Recovery - Upon the same framework I have built a failover/disaster recovery system that allows us to recover 300GB databases to off site boxes in less than 10 minutes. No volume groups defined on the target at all, but I do have full audits if PVIDs are on disks on the remote boxes. Here I have to deploy a little code, a tiny program called sudo to escalate my privileges.
I feel that this approach scales much better.
I have permission to post all of my code I just need to clean it up, well and get the time. ;)
Tom Ferony - Union Pacific Railroad
tomferony@up.com