October 2014
M T W T F S S
« Mar    
 12345
6789101112
13141516171819
20212223242526
2728293031  
134

Refs

Categories

Archives

profile for slm on Stack Exchange, a network of free, community-driven Q&A sites

[one-liner]: Why is Conky reporting a lower CPU frequency, when my CPU frequency is actually much higher?

Background

If you’ve every dealt with Conky you may have gotten a little confused when you’re trying to get it to display your CPU frequency like so:

1
${freq_g cpu0} Ghz

… and Conky is reporting your CPU frequency as 1.12GHz when in fact it’s actually much higher than that, say 2.67GHz. Most likely this is being caused by the CPU governing features that are present in most modern hardware. Here’s a behind the scenes 5 second tour of seeing what’s going on within your Linux Kernel.

Solution

First, from the conky man page.

cpu (cpuN)

CPU usage in percents. For SMP machines, the CPU number can
be provided as an argument. ${cpu cpu0} is the total usage, and ${cpu
cpuX} (X >= 1) are individual CPUs.

freq_g (n)

Returns CPU #n’s frequency in GHz. CPUs are counted from 1.
If omitted, the parameter defaults to 1.

You most likely have something like SpeedStep enabled which is acting like a governor on a car, regulating the speed of the cores inside your CPU. You can confirm that this is going on by looking at the output of this command:

1
2
3
4
5
6
7
8
9
% less /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 37
model name      : Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz
stepping        : 5
cpu MHz         : 1199.000
...

The 2 numbers that matter are the 2.67GHz, that the GHz that my CPU is rated to operate at followed by the number 1199.00, this is what my CPU is allowed to run at by the governor setup on my Linux laptop.

You can see what governor is currently configured like so:


…. Continue reading → [one-liner]: Why is Conky reporting a lower CPU frequency, when my CPU frequency is actually much higher? »»

[one-liner]: Checking out a HDD's Health using the Command Line Tool udisk

Background

Here’s a quick tip for checking out the overall health of your computer’s hard drive. It makes use of a little known tool called udisks which provides access to information about storage devices from the D-Bus interface.

Solution

Before we jump into udisks here are some resources that might prove useful when dealing with the design/architecture of udisks.

To see which drives are currently under udisks watchful eye, you can use the following command:

1
2
3
4
5
6
7
8
9
10
11
12
% sudo udisks --enumerate
/org/freedesktop/UDisks/devices/dm_2d0
/org/freedesktop/UDisks/devices/dm_2d1
/org/freedesktop/UDisks/devices/dm_2d2
/org/freedesktop/UDisks/devices/sda1
/org/freedesktop/UDisks/devices/sda2
/org/freedesktop/UDisks/devices/sda3
/org/freedesktop/UDisks/devices/sda4
/org/freedesktop/UDisks/devices/sda5
/org/freedesktop/UDisks/devices/sda6
/org/freedesktop/UDisks/devices/sr0
/org/freedesktop/UDisks/devices/sda

This output shows that I have several partitions that are currently bing monitored, the last bit in the path tells you which device, i.e. sda1, sda2, sda3, etc. These are partitions /dev/sda1, /dev/sda2, etc.

Now on to the actual health output. This next command will show you the overall health of device /dev/sda, i.e. my primary HDD on my laptop:


…. Continue reading → [one-liner]: Checking out a HDD’s Health using the Command Line Tool udisk »»

Analyzing the Popularity and Install Base of Various Programming Languages

Background

We’ve been having some discussions at work recently, trying to determine what programming languages & frameworks to use on a new project we’ll be ramping up shortly. It’s always fun to have these discussions because there really is an amazing amount of choice available today. It also can be exhausting because everyone has their favorites, and people can tend to get wrapped up in what they want to do vs. what’s the right choice.

Me? I try to be somewhere in the middle, but it’s human nature to want to stay with what you know, and have your choices picked.

So it can be a bit of a balancing act trying to stay objective. It’s usually best to try and focus on the data where possible and not get into discussions about less concrete aspects. To that end, I’ve found the following sites pretty helpful in putting programming language popularity into perspective.

Solution

TIOBE

The first site on my list is TIOBE. I’d never heard of this site until recently. A good friend of mine, James, suggested it. It would seem to offer the most accurate analysis of where programming languages are with respect to one another. You can see how various programming languages stack up against each other and whether they’re rising or falling year over year.

langpop

The next site on my list is langpop. It takes a more traditional approach of looking at which languages are “popular”. This is a loaded word, but I like langpop’s approach of assessing popularity by looking at the following areas:

  • Yahoo Search results for “language programming”
  • Job postings on Craigslist – language programmer -“job wanted” site:craigslist.org
  • Programming Language Books available on Powell’s Books
  • Projects on Freshmeat via their new API
  • Google Code Search
  • Data from Del.icio.us“language programming”
  • Data from Ohlohnumber of people committing code in a particular language
  • Data from programming.reddit.com
  • Data from Slashdot
  • Freenode IRC – number of users per a given programming languages channel every few hours
  • plus others….
Builtwith

Builtwith is another site that I find useful, but its focus isn’t just programming languages. It has a mix of languages, frameworks, widgets, and platforms, such as JQuery, Apache, Amazon CloudFront, etc. The interface doesn’t really allow you to compare specific solutions but it is helpful in seeing if a particular technology is trending up or down and also what types of penetration a technology has over another. There is a lot of data to mull over however, and it’s definitely worth a look.


…. Continue reading → Analyzing the Popularity and Install Base of Various Programming Languages »»

How to Analyze Network Performance using iperf on Fedora, CentOS & Windows

I’ve been experiencing some slow network connections between a couple of Linux systems (CentOS), Window systems (Server 2008R2), and a NAS device (Netgear ReadyNAS) and wanted to confirm that my network connections weren’t the source of the problem. To limit any variability due to different tools, I decided to use iperf, which can run on all my previously mentioned operating systems.

In addition to iperf, I also used scp to copy a 100MB file from one Linux machine to another just to confirm what iperf was reporting.

Downloading Iperf

Iperf is available in most major distribution repos, I was able to install it on my CentOS systems from the EPEL and/or RPMForge repositories.

NOTE: The source can be downloaded from the iperf’s sourceforge page here.

For windows I was able to find a pre-built executable on the ivaturi.org blog. NOTE: I’m also providing the pre-built executable here on my site as well.

Generating a 100MB Sample File

1
2
3
4
5
## generate a 100MB file
% dd if=/dev/zero of=100mb.dat  bs=100M  count=1
 
% ls -l 100mb.dat 
-rw-rw-r-- 1 saml saml 104857600 Jan 27 21:10 100mb.dat

My Procedure

My testing followed the following general format:

client
  • traceroute to server
  • scp 100mb file to server

NOTE: I then started iperf on the server and then on the client. For simplicity I’m only going to show the results after the iperf client has finished sending all it’s data.

iperf results
  • (on server): iperf -s
  • (on client): iperf -c

NOTE: In each test below, the server was the system that received data, and the client was the one sending it. For example, I was logged onto a client system (grinchy), and ran the scp command, copying the 100mb.dat file to the server (skinner).

1
2
3
## on client (grinchy)
% scp 100mb.dat skinner:~
100mb.dat                                                           100%  100MB   2.1MB/s   00:47

TEST #1: Wireless (Netgear WGT624 108Mbps G)


…. Continue reading → How to Analyze Network Performance using iperf on Fedora, CentOS & Windows »»

[one-liner]: Determining a CD/DVD Drive's Write Speed Capabilities under Fedora/CentOS/RHEL

Background

Here’s a quick primer on how to determine the capabilities of a CD/DVD drive you may have on your Linux laptop or desktop using the little known command wodim. In truth, wodim is actually the app behind cdrecord & dvdrecord, which are little more than aliases.

NOTE: it’s available as wodim-1.1.11-3.fc14.x86_64 in the default Fedora 14 yum repository.

1
2
3
4
5
6
7
8
9
10
% which cdrecord
/usr/bin/cdrecord
 
% which dvdrecord
/usr/bin/dvdrecord
 
% ls -l /usr/bin/|egrep "cdrecord|dvdrecord"
lrwxrwxrwx    1 root root          26 Jun 16 09:54 cdrecord -> /etc/alternatives/cdrecord
lrwxrwxrwx    1 root root          36 Jun 16 09:54 dvdrecord -> /etc/alternatives/cdrecord-dvdrecord
lrwxrwxrwx    1 root root          33 Jun 16 09:54 readcd -> /etc/alternatives/cdrecord-readcd

Notice that cdrecord & dvdrecord are just links? You can see what command they’re linked to with the following alternatives command:

1
2
3
4
5
6
7
8
9
10
11
# display commands behind cdrecord (and dvdrecord)
% alternatives --display cdrecord
cdrecord - status is auto.
 link currently points to /usr/bin/wodim
/usr/bin/wodim - priority 50
 slave cdrecord-dvdrecord: /usr/bin/wodim
 slave cdrecord-readcd: /usr/bin/readom
 slave cdrecord-cdrecordman: /usr/share/man/man1/wodim.1.gz
 slave cdrecord-dvdrecordman: /usr/share/man/man1/wodim.1.gz
 slave cdrecord-readcdman: /usr/share/man/man1/readom.1.gz
Current `best' version is /usr/bin/wodim.

NOTE: they’re linked via the alternatives facility under Fedora which I’m not going to discuss in this post. Check out my previous post, 5 Minute Guide to Using the Alternatives Command on Fedora/CentOS/RHEL for more information.

Solution

Determining the CD/DVD Drive’s ID

There are 2 ways to accomplish this using wodim. The 1st makes use of the switch –devices. The 2nd makes use of the switch -scanbus.

–devicesLook for useable devices using the system specific functions, eg. probing with usual device nodes in /dev/*, and display the detections using symbolic device names in OS specific syntax.
-scanbusScan all SCSI devices on all SCSI busses and print the inquiry strings. This option may be used to find SCSI address of the CD/DVD-Recorder on a system. If some device types are invisible, try using dev=ATA: or similar option to give a hint about the device type you are looking for. The numbers printed out as labels are computed by: bus * 100 + target. On platforms and device systems without persistent SCSI number management the results are not reliable. Use the –devices option instead.

NOTE: In my case both methods worked fine on my system, but according to the man page for wodim, it looks like in general –devices may give better results!


…. Continue reading → [one-liner]: Determining a CD/DVD Drive’s Write Speed Capabilities under Fedora/CentOS/RHEL »»

Improving the Wordpress Plugin Statpress Reloaded's Performance

Since setting up this blog some 2+ years ago I’ve been using the WordPress plugin, Statpress Reloaded, to keep tabs on how much traffic it receives. It’s purely just for vanity sake. Now for anyone that’s used Statpress Reloaded, you’ll know that it’s a nice plugin for what it shows, mainly real-time stats, but it’s a dog when it comes to performance.

My instance had been getting slower and slower as Statpress Reloaded’s database table (wordpress.wp1_statpress) had been getting bigger and bigger until one day it just stopped working. Going into the MySQL console I could see new data was getting added but the table (250MB+) had just gotten too big.

This was a low priority task until tonight, I figured I’d hunker down and see if I could get it working again. Turns out fixing it so that it’s at least usable was pretty easy.

First I connected to my wordpress blog MySQL DB:

1
2
3
4
5
6
7
8
9
10
11
12
% mysql -u root -p wordpress
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2038049
Server version: 5.0.77 Source distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql>

Initially this was what my statpress table looked like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mysql> desc wp1_statpress;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | mediumint(9) | NO   | PRI | NULL    | auto_increment | 
| date         | tinytext     | YES  |     | NULL    |                | 
| time         | tinytext     | YES  |     | NULL    |                | 
| ip           | tinytext     | YES  |     | NULL    |                | 
| urlrequested | text         | YES  |     | NULL    |                | 
| agent        | text         | YES  |     | NULL    |                | 
| referrer     | text         | YES  |     | NULL    |                | 
| search       | text         | YES  |     | NULL    |                | 
| nation       | tinytext     | YES  |     | NULL    |                | 
| os           | tinytext     | YES  |     | NULL    |                | 
| browser      | tinytext     | YES  |     | NULL    |                | 
| searchengine | tinytext     | YES  |     | NULL    |                | 
| spider       | tinytext     | YES  |     | NULL    |                | 
| feed         | tinytext     | YES  |     | NULL    |                | 
| user         | tinytext     | YES  |     | NULL    |                | 
| timestamp    | tinytext     | YES  |     | NULL    |                | 
| threat_score | smallint(6)  | YES  |     | NULL    |                | 
| threat_type  | smallint(6)  | YES  |     | NULL    |                | 
+--------------+--------------+------+-----+---------+----------------+

I ran the following command which changes the column data types from tinytext (predominately) to much more specific data types (varchars). Switching the data types cuts down on the amount of work MySQL has to do when working with the different columns.

1
2
3
4
5
6
7
8
9
10
11
alter table wp1_statpress modify column date int(8) NULL NULL,
modify column time time NULL NULL,  
modify column ip varchar(15) NULL NULL,
modify column nation varchar(10) NULL NULL,
modify column os varchar(64) NULL NULL,
modify column browser varchar(64) NULL NULL,
modify column searchengine varchar(64) NULL NULL,
modify column spider varchar(64) NULL NULL,
modify column feed varchar(32) NULL NULL,
modify column user varchar(64) NULL NULL, 
modify column timestamp timestamp NULL NULL;

Additionally I added the following DB indexes, again to improve the overall performance of this table within MySQL:

1
2
3
4
5
6
7
8
9
10
alter table wp1_statpress add index spider_nation (spider, nation),
add index ip_date (ip, date), 
add index (agent(255)), 
add index (search(255)),
add index (referrer(255)),
add index feed_spider_os (feed, spider, os),                  
add index (os),
add index date_feed_spider (date, feed, spider),
add index feed_spider_browser (feed, spider, browser),
add index (browser);

Conclusions

Now my statpress table looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mysql> desc wp1_statpress;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | mediumint(9) | NO   | PRI | NULL    | auto_increment | 
| date         | int(8)       | YES  | MUL | NULL    |                | 
| time         | time         | YES  |     | NULL    |                | 
| ip           | varchar(15)  | YES  | MUL | NULL    |                | 
| urlrequested | text         | YES  |     | NULL    |                | 
| agent        | text         | YES  | MUL | NULL    |                | 
| referrer     | text         | YES  | MUL | NULL    |                | 
| search       | text         | YES  | MUL | NULL    |                | 
| nation       | varchar(10)  | YES  |     | NULL    |                | 
| os           | varchar(64)  | YES  | MUL | NULL    |                | 
| browser      | varchar(64)  | YES  | MUL | NULL    |                | 
| searchengine | varchar(64)  | YES  |     | NULL    |                | 
| spider       | varchar(64)  | YES  | MUL | NULL    |                | 
| feed         | varchar(32)  | YES  | MUL | NULL    |                | 
| user         | varchar(64)  | YES  |     | NULL    |                | 
| timestamp    | timestamp    | YES  |     | NULL    |                | 
| threat_score | smallint(6)  | YES  |     | NULL    |                | 
| threat_type  | smallint(6)  | YES  |     | NULL    |                | 
+--------------+--------------+------+-----+---------+----------------+

And I’m once again able to access my Statpress Reloaded charts. Previously the charts would take minutes to load, now they come up in under 60 seconds. Down the road I’ll probably have to address this problem again, I still have the ability to delete rows from my statpress table (2+ years of data), It’s currently > 1M rows…yes that’s 1 million!

1
2
StatPress table size: 230,13 MB (1033389 records)
StatPress current time: 2011-07-06 04:29:04

Additionally, there are other plugins that I may investigate switching to down the road:

but in the meantime Statpress Reloaded is working for me in an acceptable way.

References

links
local copies
Page 1 of 212