OSX :: CPU & Core Counting

A while back ago I blogged about  rudimentary Linux cpu and core lookups.  I figured I’d follow up with how you do this in OSX via “system_profiler SPHardwareDataType” as well.

zissou:~ jrad$ system_profiler SPHardwareDataType

Hardware:
Hardware Overview:
Model Name: iMac
 Model Identifier: iMac12,2
 Processor Name: Intel Core i7
 Processor Speed: 3.4 GHz
 Number of Processors: 1
 Total Number of Cores: 4
 L2 Cache (per Core): 256 KB
 L3 Cache: 8 MB
 Memory: 8 GB
 Boot ROM Version: IM121.0047.B1F
 SMC Version (system): 1.72f2
 Serial Number (system): D25J10LPDHJW
 Hardware UUID: 813A5897-1248-5460-84F6-062AE27929A7
Advertisements

Basketball Diaries :: Introduction & Jump Shot Development

Back in January when I started this blog, I mentioned my basketball hobby, and applying the concept of Win Learn Change to everything you possibly can in life using it as an example.  I figured that it would be a good idea for me to start blogging more about basketball and the progress I try to make with it.

Before going any further, I’d like to note that I’m not an extremely physically athletic, gifted, or talented individual in general.  I do however love the game of basketball very much, and enjoy playing it as an amateur.  I resumed basketball play in the summer of 2008 primarily to get in shape and develop a healthy weight by body mass indexing standards.  Before that, I played until the 8th grade (1992, man I’m old).  With such a time gap, there was lots on the court for me to develop and re-develop.  This challenge became more of an endeavor to me than a side project.  Regardless, I’m glad this hobby has not been an easy journey as the rewards from succeeding are highly enjoyable.  I definitely intend to keep this hobby going for myself as long as I physically can and will blog about it here and there along the way.

For the past couple of years I have made various strides with my game, such as being able to run the game defensively and offensively on and off the ball, and develop some sort of a rhythmic jump shot.  A consistent in-game jump shot has been (and still is) the hardest task for me to develop.  After watching JR Smith’s Nike video on shooting drills, a simple suggestion of tucking my elbow has made all the difference lately.  The problem is, whenever I adjust my shot in basketball, it almost feels like I’m starting over to a certain degree.  Starting over however turns into motivation, and eventually that turns into results.  At any rate, JR’s pointers have helped me a great deal, and I highly recommend them for anyone looking for help or new ways to improve their jump shot.

Clearing Memory Cache with Linux

Linux is usually pretty good at efficient memory management notably with freeing up cached memory.  At times when an application(s) is abusing your system, Linux may decide that cached memory is needed when in fact it’s not.  This in turn can and will eventually rob your server of free memory.  A way to combat this is to run this simple command:

sync; echo 3 > /proc/sys/vm/drop_caches

If you need to do this on a scheduled basis, you can turn the above line into a script, and create a cron job for it.  It’s a bad sign if  apps or system functions are hogging up free memory when it doesn’t need it, so it’d be better to investigate and troubleshoot that aspect of your system, rather than blindly clearing the memory cache of a system.

Parallel remote "shelling" via pdsh

Ever have a multitude of hosts you need to run a command (or series of commands) on?  We all know that forloop outputs are super fun to parse through when you need to do this, but why not do it better with a tool like pdsh.
A respected ex-colleague of mine made a great suggestion to start using pdsh instead of forloops and other creative make shift parallel shell processing.  The majority of my notes in this blog post are from him.  If he’ll allow me too, I’ll give him a shout out and cite his Google+ profile for anyone interested.
Pdsh is a parallel remote shell client available from sourceforge.  If you are using rpmforge CentOS repos you can pick it up there as well, but it may not be the most bleeding edge package available.
Pdsh lives on sourceforge, but the code is on google:
Usage docs:
Some quick tips on how to get started using pdsh:
  1. Set up your environment:
  2. export PDSH_SSH_ARGS_APPEND=”-o ConnectTimeout=5 -o CheckHostIP=no -o StrictHostKeyChecking=no” (Add this to your .bashrc to save time.)
  1. Create your target list in a text file, one hostname per line (in the examples below, this file is called “host-list”
  2. It would probably be a good idea to use “tee” to capture output.
    • man tee” if you need more information on tee.
  3. Run a test first to make sure your pdsh command works the way you think it will before potentially doing anything destructive:
    • sudo pdsh -R ssh -w ^host-list “hostname” | tee output-test-1
  4. Change your test run to do what you really want it to after a successful test.  e.g.:
    • sudo pdsh -R ssh -w ^host-list “/usr/bin/mycmd args” | tee output-mycmd-run-1
Obviously if you have Puppet Enterprise fully integrated within your environment, you can take advantage of powerful tools such as mcollective.  If you do not, pdsh is a great alternative.

Get Your grep-fu On

More sysadmin goodness from damonparker.org.

Search for red OR green:

grep ‘red|green’ files

Search for searchtext at the beginning of a line in files:

grep ‘^searchtext’ files

Search for searchtext at the end of a line in files:

grep ‘searchtext$’ files

Search files for blank lines:

grep ‘^$’ files

Search files for US formatted phone numbers (###-###-####):

grep ‘[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]’ files

or:

grep ‘[0-9]{3}-[0-9]{3}-[0-9]{4}’ files

Search for e-commerce or ecommerce in files:

grep e-*commerce files

Search for searchtext case-insenstively in files:

grep -i searchtext files

Chain two grep commands together for more advanced searches. Search for lines in files that contain both partial_name and function:

grep partial_name files | grep function

That one is great for searching source directories for a function definition when you can’t remember the completely function name.