Labels

administration (2) advocacy (1) arm (1) artist (1) author (1) bash (1) biology (1) birthday (2) book (1) caleb (2) comedy (1) command line (1) computer (1) configuration (3) convention (1) cooking (1) customer service (1) debugging (1) desktop (1) emotion (1) equality (2) essay (1) exercise (1) family (1) fedora (14) festival (1) food (3) free software (1) ftl (1) gaming (7) gay (2) git (5) gnome (1) google (3) gripes (1) hacking (1) hardware (4) health (1) hiking (1) holiday (2) homosexuality (3) humor (1) kde (1) kernel (2) keyboard (1) kindle (4) laptop (3) linux (23) marriage (1) movie (2) music (3) mutt (1) news (1) online (1) open source (1) opinions (2) packaging (2) perl (1) philosophy (1) phishing (1) phone (2) physics (1) podcasting (3) politics (1) present (1) problem (2) programming (19) rachel (2) rails (1) RIchard Feynman (1) rights (1) rpm (1) ruby (8) rumor (1) school (2) science (4) search (1) seasons (1) security (1) space (1) subversion (3) super heroes (2) systemd (1) technology (1) television (1) test driven development (1) university (2) update (1) upgrade (1) utility (1) video (1) virtual machine manager (1) virtualization (2) weekend (1) work (1) zombies (1)

Friday, August 29, 2014

Get Your Battery's Serial Number From A Terminal

For my work laptop (Lenovo T530) I've been seeing the battery life quickly declining in the past few weeks. I've been meaning to check the warranty on it but, every time I think about it, I'm ON the laptop at work and don't want to have to undock it to get the serial number.

I figured I'd just get it from the command line somehow. And that's what I found using the upower command.

O_o (1) [J:0/1113] mcpierce@mcpierce-laptop:acpi $ upower -h
Usage:
  upower [OPTION...] UPower tool

Help Options:
  -h, --help           Show help options

Application Options:
  -e, --enumerate      Enumerate objects paths for devices
  -d, --dump           Dump all parameters for all objects
  -w, --wakeups        Get the wakeup data
  -m, --monitor        Monitor activity from the power daemon
  --monitor-detail     Monitor with detail
  -i, --show-info      Show information about object path
  -v, --version        Print version of client and daemon

The first thing to do is to enumerate the list of power devices available using the -e or --enumerate command line option:

^_^ [J:0/1115] mcpierce@mcpierce-laptop:acpi $ upower --enumerate
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/battery_BAT0

Here we can see two devices relating to power: battery_BAT0 and line_power_AC. And I'm going to go out on a limb here and say that battery_BAT0 is the one we want to interrogate.

So now we ask it for information using the -i or --show-info command line option:

^_^ [J:0/1116] mcpierce@mcpierce-laptop:acpi $ upower --show-info /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               LGC
  model:                45N1011
  serial:               XXXXX
  power supply:         yes
  updated:              Fri 29 Aug 2014 09:20:05 AM EDT (1932 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    energy:              72.25 Wh
    energy-empty:        0 Wh
    energy-full:         72.25 Wh
    energy-full-design:  93.6 Wh
    energy-rate:         2.82857 W
    voltage:             12.854 V
    percentage:          100%
    capacity:            77.1902%
    technology:          lithium-ion

As we can see in the output the serial number for the laptop batter is listed, along with the vendor tag and model number.

Friday, September 27, 2013

Happy 30th Birthday, GNU!

On 27 September 1983 Richard M. Stallman posted the following message to a newsgroup:

From CSvax:pur-ee:inuxc!ixn5c!ihnp4!houxm!mhuxi!eagle!mit-vax!mit-eddie!RMS@MIT-OZ
From: RMS%MIT-OZ@mit-eddie
Newsgroups: net.unix-wizards,net.usoft
Subject: new Unix implementation
Date: Tue, 27-Sep-83 12:35:59 EST
Organization: MIT AI Lab, Cambridge, MA

Free Unix!

Starting this Thanksgiving I am going to write a complete
Unix-compatible software system called GNU (for Gnu's Not Unix), and
give it away free(1) to everyone who can use it.
Contributions of time, money, programs and equipment are greatly
needed.

To begin with, GNU will be a kernel plus all the utilities needed to
write and run C programs: editor, shell, C compiler, linker,
assembler, and a few other things.  After this we will add a text
formatter, a YACC, an Empire game, a spreadsheet, and hundreds of
other things.  We hope to supply, eventually, everything useful that
normally comes with a Unix system, and anything else useful, including
on-line and hardcopy documentation.

GNU will be able to run Unix programs, but will not be identical
to Unix.  We will make all improvements that are convenient, based
on our experience with other operating systems.  In particular,
we plan to have longer filenames, file version numbers, a crashproof
file system, filename completion perhaps, terminal-independent
display support, and eventually a Lisp-based window system through
which several Lisp programs and ordinary Unix programs can share a screen.
Both C and Lisp will be available as system programming languages.
We will have network software based on MIT's chaosnet protocol,
far superior to UUCP.  We may also have something compatible
with UUCP.


Who Am I?

I am Richard Stallman, inventor of the original much-imitated EMACS
editor, now at the Artificial Intelligence Lab at MIT.  I have worked
extensively on compilers, editors, debuggers, command interpreters, the
Incompatible Timesharing System and the Lisp Machine operating system.
I pioneered terminal-independent display support in ITS.  In addition I
have implemented one crashproof file system and two window systems for
Lisp machines.


Why I Must Write GNU

I consider that the golden rule requires that if I like a program I
must share it with other people who like it.  I cannot in good
conscience sign a nondisclosure agreement or a software license
agreement.

So that I can continue to use computers without violating my principles,
I have decided to put together a sufficient body of free software so that
I will be able to get along without any software that is not free.


How You Can Contribute

I am asking computer manufacturers for donations of machines and money.
I'm asking individuals for donations of programs and work.

One computer manufacturer has already offered to provide a machine.  But
we could use more.  One consequence you can expect if you donate
machines is that GNU will run on them at an early date.  The machine had
better be able to operate in a residential area, and not require
sophisticated cooling or power.

Individual programmers can contribute by writing a compatible duplicate
of some Unix utility and giving it to me.  For most projects, such
part-time distributed work would be very hard to coordinate; the
independently-written parts would not work together.  But for the
particular task of replacing Unix, this problem is absent.  Most
interface specifications are fixed by Unix compatibility.  If each
contribution works with the rest of Unix, it will probably work
with the rest of GNU.

If I get donations of money, I may be able to hire a few people full or
part time.  The salary won't be high, but I'm looking for people for
whom knowing they are helping humanity is as important as money.  I view
this as a way of enabling dedicated people to devote their full energies to
working on GNU by sparing them the need to make a living in another way.


For more information, contact me.
Arpanet mail:
  RMS@MIT-MC.ARPA

Usenet:
  ...!mit-eddie!RMS@OZ
  ...!mit-vax!RMS@OZ

US Snail:
  Richard Stallman
  166 Prospect St
  Cambridge, MA 02139

Tuesday, September 10, 2013

Git/Subversion Error: "Index mismatch: [hash] != [hash]"

The Problem

Our source code is stored in a Subversion repository (it's an Apache project) and I use Git to clone that repo for work. This morning I attempted to update my local repo when the following happened:

^_^ [J:0/1003] mcpierce@mcpierce-laptop:Qpid (upstream) $ git svn rebase
Index mismatch: e5893616e68dba2bd8a730609d872f19517e0536 != 93c1bfda2ff4e72a1ae1fbc8374d42ebe107e1f5
rereading 695961e1cc7749916959f1f74db659e90e0d2dcc
 M qpid/cpp/src/qpid/broker/SessionState.h
 M qpid/cpp/src/qpid/broker/SemanticState.cpp
 M qpid/cpp/src/qpid/broker/SessionState.cpp
Author: pmoravec not defined in .git/authors.txt file

The user "pmoravec" was recently added as a committer to the project and his first commit apparently threw my git clone of the subversion repository off.

The Solution

For me it was a simple solution. I simply had to pull down the updated authors.txt file from Apache that included pmoravec and replace the one in my git repo:

^_^ [J:0/1029] mcpierce@mcpierce-laptop:Qpid (master) $ wget http://git.apache.org/authors.txt

Done and one, now I'm back to work.

Thursday, August 22, 2013

Puppet: Defining A System, Adding A Package And Launching A Service

Previously I wrote a simple blog post about setting up a Puppet master and agent. In this post I'm going to write about how to add a simple service to your puppet master that will be installed (if necessary) and started (if necessary) on systems.

Step 1: Define the system on your Puppet master

Before your Puppet master can do its work, it needs to first know what needs to be done and to whom.

In your /etc/puppet/manifests directory you'll want to create two files with the following content (remember: in my case the Puppet master's name is earth and the Puppet client's name is halo):

site.pp

  import 'nodes.pp'
 
  filebucket { main: server => "earth.gateway.2wire.net" }
 
  File { backup => main }
  Exec { path => "/usr/bin:/usr/sbin:/bin:/sbin" }

nodes.pp

  # nodes.pp
 
  node default {
    include ntp
  }
 
  node 'halo.gateway.2wire.net' inherits default {
  

  }

In this example the default system definition will install the sudo module. The definition for a server will inherit that definition and add to it the ntp module. And finally the definition for halo inherits the server definition and adds to it the bip module.

In later posts I'll expand on the above to do more involved server definitions, specifically add modules that include files. But let's not get ahead of ourselves.

Step 3: Add the module definition

Before Puppet can do anything on the client it has to have more details on, in this case, the ntp module.

To do that we first create the file /etc/puppet/modules/tests/init.pp with the following content:

  class { 'ntp': }

Next we'll create the file /etc/puppet/modules/ntp/manifests/init.pp with the following content:

  class ntp {
 
    package { ntp: ensure => installed }
 
    file { "/etc/ntp.conf":
      owner => root,
      group => root,
      mode => 640,
      require => Package["ntp"],
    }


    service { 'ntp':
      name => 'ntpd',
      ensure => running,
      enable => true,
      subscribe => File['/etc/ntp.conf'],
    }
 
  }


In the configuration we ensure the package is installed, that, if the file /etc/ntp.conf exists, the configuration is owned by user root and group root, that it has the proper file modes, and that if it doesn't exist the package named ntp is installed to provide it.

The service stanza adds to the above a check for the actual service itself. If Puppet doesn't see a process named "ntpd" then it knows that the service isn't up and will launch it for you.

Conclusion

That's it! If you then launch the puppet agent on your client machine, you should see it apply the above configuration by installed the package named ntp.

Sunday, August 18, 2013

A Simple Puppet 3.1 Setup

Recently I got the notion of setting up a puppetized configuration system for my computers at home. I have two machines:
  • earth - a Linux desktop, which will be the puppet client
  • halo - a Linux server, which will be the puppet server as well as a client

My biggest frustration, though, was find a simple tutorial that would help me get Puppet up and running, the two machines talking, and a configuration pushing down onto the client.

So after pulling from a few separate sources, here's what I found works. In a future post I'll write about how, after more frustration, I was able to get configurations pushing down onto the systems and how I setup version control on the puppet configurations themselves.

Step 1: Install Puppet (Fedora 19)

Not the hardest part, but you do need to be aware of what packages are out there. The two packages are puppet and puppet-server. The former is what you need on any system that will act as a client or agent, the latter on any system that will be offering up puppetized data.

So, obviously, I installed puppet on halo, and puppet and puppet-server on earth.

Step 2: Configuring The Puppet Master

This is the first part that gave me headaches. Since I don't want to deal with external certificates, I just wanted something that would work for me in my private network.

What I did was to configure earth to be it's own certificate authority with the following in /etc/puppet/puppet.conf:
[main]
    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl

    # self-signing certificates
    server = earth.gateway.2wire.net
    certname = earth.gateway.2wire.net

[master]
    reports = store, http
    modulepath=/etc/puppet/modules:/usr/share/puppet/modules

[agent]
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig

Step 3: Exchanging SSL Certificates With The Agent

Here is where there was a decided lack of examples online. And the Puppet website didn't help at all, especially with recovering things after a failure occurred.

The steps to follow are:
  1. unless you have your own DNS, add the fully qualified hostnames of each machine in the other's /etc/hosts file; i.e., for me I had to put earth.gateway.2wire.net in halo's file, and halo.gateway.2wire.net in earth's, then
  2. open two terminals on your puppet master (in my case, on earth) and one on your puppet agent (in my case, on halo), then
  3. start up in one puppet master terminal a master using the command line:
    1. puppet master --no-daemonize --verbose
  4. on the puppet agent terminal start an agent using the command line:
    1. puppet agent -t --no-daemonize --verbose
  5. you'll see some messages about exchanging the SSL credentials and then a note that no certificate is waiting, at which point in the other puppet master terminal window you'll do:
    1. puppet cert sign halo.gateway.2wire.net
At this point your machines will have shared SSL credentials and will be able to talk to each other.

Step 4: How To Recover If Something Goes Wrong

If you start getting messages about the keys being wrong on the agent side, the easiest thing to do is to delete the /var/lib/puppet/ssl/ directories on BOTH machines. This way you no longer have any data about the other system and can start over with a clean slate.

Sunday, August 4, 2013

Grouping Channels In Weechat By Network

One of the things that's kept me from switching from Xchat to Weechat for IRC was that I couldn't keep my channels grouped together by network. Where I work we have internal IRC channels with the same name as public IRC channels, and it was confusing to look at the window and figure out which was internal or not.

Fortunately, I found a way to change that in Weechat and so have switched over to it exclusively. Here's how:

Install the buffers.pl plugin.

The buffers plugin lets you configure how the various buffers are displayed.

  /script install buffers.pl

Tell buffers.pl to show the IRC network name.

By default buffers.pl only shows the channel name (#name). To group channels together, you need to enable showing the fullly qualified channel name (network#name):

  /set buffers.look.short_names off

Sort channels by name and not numbers.

This groups the channels together by their server name. Otherwise they're grouped by the order in which they were opened. So if you open a channel in Freenode, say, after opening one in OFTC then the channel in Freenode will fall after OFTC and not get put with the other Freenode channels.

  /set buffers.look.sort name

That's it! Now your channels are grouped together by network.

Tuesday, July 9, 2013

Fedora 19: Nouveau Drivers Are Fixed!

At work a few months ago I got a new laptop: a Lenovo T530 with the Optimus Technology display chipset:
For more taxing multimedia and gaming use, NVIDIA's line of NVS with Optimus graphics cards provide the graphical processing boost you need. Optimus technology automatically configures your system to provide for the most optimal experience with your games or applications while also maintaining battery life.
The problem that I hit was that the Nouveau drivers would NOT work nicely with this video setup. If I disabled the nVidia hardware and run only the Intel video chipset things worked beautifully, but I could not use my docking station since it doesn't support external displays. If I enabled the nVidia hardware only then I could drive my external monitors but couldn't go into standby mode, couldn't dock and then undock, and inevitably the display would get borked (BZ#948079).

To deal with the problem, I had no choice but to start using the closed-source nVidia drivers. They're freely licensed, but being closed source just goes against the spirit of what I support. And it also has the annoying habit of requiring me to run the nVidia configuration tool when I dock my laptop in order to enable the external monitors rather than just switching to them automatically, which is what the nouveau drivers do.

So when I upgraded my laptop with Fedora 19 (Schroedinger's Cat), I was happy to find that the bug had, at some point, been quietly fixed!