Wednesday, June 03, 2015

Testing your Syslogd Remote config

Test, test, test; right?

So you've configured syslogd or, increasingly, rsyslogd .  How do you trivially test?

It's really simple.
  1. make sure nc or ncat (netcat) are installed.  It's a common tool, but maybe you don't have it on this host.  It's with nmap on my EL6 host, but a standalone on EH5.  Because EL7 has to reinvent everything, nc is in mnap-ncat.  So here's your install:

    yum install {/usr,}/bin/{nc,ncat}

    Honestly, that's the easiest way.
  2. Launch tshark on the log forwarder:

    # tshark -plni any udp and port 514
  3. Now hit it.  Here's your nc invocation:

    # ncat -u loghost 514 <<< "test logger receipt"
  4. And here's how it looks:
    # tshark -plni any udp and port 514
    Running as user "root" and group "root". This could be dangerous.
    Capturing on Pseudo-device that captures on all interfaces
      0.000000 192.168.112.6 -> 192.168.10.251 Syslog 64 test logger receipt\n
      0.000301 192.168.10.251 -> 192.168.16.133 Syslog 83 USER.NOTICE: Jun  3 22:25:07 test logger receipt
      0.000389 192.168.10.251 -> 192.168.10.250 Syslog 83 USER.NOTICE: Jun  3 22:25:07 test logger receipt
    ^C
    
Fun fun?

Hey, look!  Our logger box is happily forwarding stuff out, too.  Double-win!


Labels: , , , ,

Tuesday, May 26, 2015

Logfile Rotation, and Counting Cars

Recently, fads changed in logfile rotation -- what a hot topic!

In RHEL5, it seems, logfiles were rotated very simply:  1, 2, 3.  Maybe gzipped too:  1.gz, 2.gz, 3.gz . This is a very simple arrangement:

  1. It's simpler to predict for humans:  3 follows 2 as often as 2.gz follows 1.gz .  
  2. It's simpler to use as a rotational algorithm
  3. This means it's simpler to use in scripting and automation.
But the new fad is worrisome:  Logs are rotated with date suffixes, as if we can't 'head -1' or 'tail -1', and maybe need the filename to reflect one of the dates on the logfiles;  the last day it was around, because 'tail -1' is so hard, perhaps?

Now logs end up like:

/var/log/messages-20150501
/var/log/messages-20150508
/var/log/messages-20150522

Hey, now -- what happened to the logfile from 20150515?  Well, it wasn't required, as logrotate will skip rotating a logfile which wasn't full enough and thus worthy of rotation. 

If we believe it takes slightly more effort to calculate a timestamp than to simply increment a counter, we have a process evolved to where it's harder, dumber, and useless.

I'll bet this started with someone who enjoys and uses systemd.

So here's a fix.  I used it only today, so it's been tested a whopping once, (aka twice as long as systemd), but it may actually work (hey, systemd works as an eyesore of a monolithic failbot very well, thanks, so you lay off; it's the kind of drooling, three-legged marmoset that any loving mother would be proud to hang on the fridge, albeit the back).

So you've fixed the config in logrotate so it'll name things like we have a clue:
echo nodateext > /etc/logrotate.d/aa-nodateext
(Please don't ask me why we're not hacking up /etc/logrotate.conf like someone too clueless about enterprise linux to know better. I may hurt you.)

Once you've corrected the behaviour, it's time to clean up the mess.  This script seeks out badly-named logfiles - most of them - and renames them properly.  That's it.

Yeah, it looks like crap.  It's quick, and I did it when I had some spare time today.  And now I intend to run it on a bajillion machines tomorrow.  I may even hook it into the %post script in my bish-logrotate-no_dateExt_you_Idiots RPM.  It could be the perfect quick-fix.

::::::::::::::
remediate-logfile-names.sh
::::::::::::::
#!/bin/sh
# -*- compile-command: "sh remediate-logfile-names.sh" -*-
# $Id: remediate-logfile-names.sh,v 1.2 2015/05/26 17:16:07 root Exp $

# locate the logrotate files we care about
find /etc/logrotate.d \
    -name \*~ -prune -o \
    -name \*.rpm\* -prune -o \
    -name syslo\* -prune -o \
    -type f \
    | sort \
    | \
    xargs -n1 sed -ne '
# prune the open-bracket on many logfile spec lines
/^\//{s/[{]//;p
} ' \
    | \
    while read fn trash; do
        case $fn in
            (/*)
                find $fn-201[0-9][0-9][0-9][0-9][0-9] -type f 2>/dev/null | \
                    grep -n "$fn" \
                    | awk -F: -v gz=${gz:0} '
{
  f=gensub(/-201.*$/,"",1,$2)"."$1
  print "mv "$2" "f
}
'
                ;;
            (compress)
                gz=1
                ;;
        esac
    done \
        | tee /dev/stderr \
        | sh

And that's about it.   Enjoy.  And if you want to know why you don't just hand-hack logrotate.conf, then toss me a comment.  

 - bish

Labels: , , ,

Sunday, February 24, 2013

Packaging protobuf-c for EL5

How boring a title that is!  Okay, we're RPMing up Protobuf-c - a c binding for the protobuf kit from Google - for EL5.  We need it to do something far more interesting later -- so these are the giants whose shoulders we stand upon.

I cheated;  let's be honest about that, and just how much I cheat to make my life easier.  It's a lot!  In this case, I stole the protobuf-c RPM as built in RHbz593559 for EL6, and which is supposed to be started for EL5 but hasn't dropped yet.  So we'll just finish that port.

  1. Go get it:
    wget http://download.fedoraproject.org/pub/epel/6/SRPMS/protobuf-c-0.15-2.el6.src.rpm
  2. Unpacking it is harder because of a strange change to the package format, where they seem to ignore compatibility.  So we need to do an rpm2cpio|cpio instead of a trivial rpm-i .  It's no big deal, but watch for it:
    rpm2cpio protobuf-c-0.15-2.el6.src.rpm | cpio -idumv
  3. Because the EL6 one has problems, we need to patch around those, but they're trivial;  it's surprising that we see this in what should be a quality product.  I worry about just how many people have this kind of blinders on.
    @@ -10,6 +10,7 @@
     Source1:        http://protobuf-c.googlecode.com/svn/tags/%{version}/LICENSE
    
     BuildRequires:  protobuf-devel
    +BuildRoot:     %{_tmppath}/%{name}-root
    
     %description
     Protocol Buffers are a way of encoding structured data in an efficient yet@@ -41,9 +41,13 @@
     make check
    
     %install
    +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
     make install DESTDIR=$RPM_BUILD_ROOT
     rm -f $RPM_BUILD_ROOT/%{_libdir}/libprotobuf-c.la
    
    +%clean
    +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
    +
     %post -p /sbin/ldconfig
     %postun -p /sbin/ldconfig
  4. now build:
    rpmbuild -ba protobuf-c.spec
And that's kinda it.  Can you see how simple a package-port this is?

Can you see how simple code-compatibility things we learned in first-year CompSci are being ignored here to our detriment?  This is so disappointing, and it wouldn't be a problem if I haven't had this very same conversation with someone in a position to fix it.

Labels: , , , , ,

Monday, June 11, 2012

Upgrading Cobbler from 2.0 to 2.2 -- and overcoming WSGI woes

If you've used Cobbler for a while, you'll want to upgrade it.  Naturally!

There's a problem with the upgrade, though:  the 2.0 version seems to use mod_python, and the new one uses mod_wsgi.  No problem, right?  So you install mod_wsgi as part of the process:


# service httpd start
Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/cobbler.conf:
Invalid command 'WSGIScriptAliasMatch', perhaps misspelled or defined by a
module not included in the server configuration
                                                           [FAILED]
So your server won't start.  Yay!

What's really going on is

  1. mod_python and mod_wsgi don't play well together
  2. mod_wsgi is impotent on install and needs activation
  3. mod_python is still the go-to for rendering the configs, which now use syntax it can't handle
The remedy is simple:
  1. remove mod_python.  It can't be used, so let's get it out to avoid dep- and other issues.

    rpm -e mod_python
  2. create a mod_wsgi config

    cat > /etc/httpd/conf.d/05-load-wsgi.conf
    LoadModule wsgi_module modules/mod_wsgi.so
    
    
    
  3. restart httpd

    service httpd restart
And that's it:

Stopping httpd:                                            [FAILED]
Starting httpd:                                            [  OK  ]

And you're back up and running.

Is it disappointing that it doesn't Just Work?  For sure.  Could you figure it out if you were a mod_python user or an expert, and knew the hell WSGi was?  Maybe.  But I'm not, and I think that as an app user it's not really on me to be an expert.  You may argue how proficient one needs to be to use any device, but I'm thinking it's not ready for prime-time yet.  Boo!

Labels: , , , , , , ,

Saturday, March 03, 2012

Diffing Configs After an RPM install

Some daemon not starting?  Think you may have mucked with the config and you don't know how?  Let's talk about stashing your configs in an SCM, you lamer, or maybe doing a backup every month or so?  (ha, gotcha) For now, let's find out what you've done.
[root@gator ~]# mkdir /tmp/bz75819
[root@gator ~]# yumdownloader --destdir !$ `rpm -qf --qf "%{name}\n" /etc/httpd/conf/httpd.conf`
yumdownloader --destdir /tmp/bz75819 `rpm -qf --qf "%{name}\n" /etc/httpd/conf/httpd.conf`
[root@gator ~]# rpm2cpio /tmp/bz75819/*.rpm | cpio -tv | grep /etc/httpd/conf/httpd.conf
6573 blocks
-rw-r--r--   1 root     root        33726 Oct 20 14:05 ./etc/httpd/conf/httpd.conf
[root@gator ~]# rpm2cpio /tmp/bz75819/*.rpm | cpio -i --to-stdout */etc/httpd/conf/httpd.conf | diff -u - /etc/httpd/conf/httpd.conf
6573 blocks
--- -   2012-03-03 16:05:07.411845000 -0800
+++ /etc/httpd/conf/httpd.conf  2012-03-03 16:05:01.000000000 -0800
@@ -131,7 +131,7 @@
 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
 #
 #Listen 12.34.56.78:80
-Listen 80
+#Listen 80

 #
 # Dynamic Shared Object (DSO) Support
So that's what you've done.  Yeah, it looks contrived, but I saw that this week.  So when I see it again this week, I know what to do.

Have you ever needed to find out just what you've changed in a config since a package has been installed?

Labels: , , , , , ,

Sunday, October 30, 2011

Emacs goes Too Far

I like emacs.  I will learn to like the latest release.  Given my thoughts on the source of it all, I should expect some surprise in every release, and so far I've been lucky.  Colour me surprised at the emacs 23.1 which we get with RHEL6 and Centos6.  Its new features and updated lisp parts falls flat on its face the first time I load two files at invocation (or hit'o' in a dired):
It splits the window horizontally.
I don't know who thought that was a great idea, but it's got two problems:  First, it's going to turn off emacs noobs who wonder what the hell happened to their editor and how to make it stop, which is something the anti-emacs crowd has been pushing as a theme the whole time.  The second part, much like the first, is that is makes the editor look like ass and work like crap.  So we're also looking to make it fucking stop.

The popular fix is to tune the criteria for auto-splitting windows out of whack.

--- .emacs~     2011-09-11 16:15:56.000000000 -0700
+++ .emacs      2011-10-30 05:01:43.000000000 -0700
@@ -367,3 +367,7 @@
  '(font-lock-builtin-face ((((type tty) (class color)) (:foreground "light blue" :weight light))))
  '(nxml-attribute-value-face ((t (:inherit nxml-delimited-data-face))))
  '(nxml-delimited-data-face ((((class color) (background light)) (:foreground "LightBlue")))))
+
+;; witty and biting comment about sudden feature changes that look like
+;; broken parts that frighten noobs here.  I probably said Fuck again.
+(setq split-height-threshold 0)
+(setq split-width-threshold nil)

Instead of saying "don't ever split the window horizontally, you whackjob app," we just say "sorry you can't split the window horizontally because our criteria is now impossible to match."  That's the fix.  Now, your fancy old Emacs does exactly what it used to, and you don't have to worry about it looking bad and scaring the officemates back into the 1960s with vi.

I should roll a fix for it on the system level, so that it avoids it for all users of a particular system.  Stay tuned and, if it doesn't appear soon, beat me.

Labels: , , , ,

Saturday, July 16, 2011

Cobbler 2.0.11 Hack to Limit Rsync Bandwidth

I was having a problem with one of my cobbler app installs, where the rsync run would overload the already-loaded network signal. This is a pipe where we're already doing a lot of management, because the physical premises are not conducive to an upgrade (and we're not doing QoS yet; I know, I know).

Lanton Vhengani was also having the same problem back in 2008, and although Mr DeHaan was considering adding a switch to the rsync invocation from within the cobbler app, it's not yet appeared.  Lanton found the section where the rsync invocation is literally called out, and provided a great patch hint for the source.  It still works under 2.0.11 .
diff -uBb /usr/lib/python2.4/site-packages/cobbler/action_reposync.py\~ /usr/lib/python2.4/site-packages/cobbler/action_reposync.py
--- /usr/lib/python2.4/site-packages/cobbler/action_reposync.py~        2011-04-20 08:40:48.000000000 -0400
+++ /usr/lib/python2.4/site-packages/cobbler/action_reposync.py 2011-07-16 22:00:22.000000000 -0400
@@ -220,6 +220,7 @@
         if not repo.mirror.endswith("/"):
             repo.mirror = "%s/" % repo.mirror

+        spacer = " --bwlimit=50"
         # FIXME: wrapper for subprocess that logs to logger
         cmd = "rsync -rltDv %s --delete --exclude-from=/etc/cobbler/rsync.exclude %s %s" % (spacer, repo.mirror, dest_path)
         rc = utils.subprocess_call(self.logger, cmd)
restart cobblerd before testing, and there you go:  Bandwidth isn't pinned and the boss is happier.  That's a pretty small setting there, but I'll open it up after Centos6 comes down completely -- the periodic kicks the pipe will take when 1-2 RPMs are updated will be so small I can push it up a bit higher.

Labels: , , , ,

Sunday, May 08, 2011

Cheap Mutex with Fuser

On one box, I have a cronjob which runs every minute.  The cron task grabs a snapshot from a web cam, saves it in a monster tree, based on date and time, and then pushes it up to a larger 'mother ship' computer for it to process.  Don't get creeped out -- it's a time-laps movie of a building being built.

Anyway, it's that last rsync that sucks.  It's pushing stuff about 500mi away, and it's over SBC lines, so it's crunchy as hell.  Often, the VPN will die and take out not one but four sockets at once.  Of course, with cron, that means 4 email messages and one more every minute until that VPN comes back up.

So here's a cheap-ass mutex thing:

#!/bin/sh
lckfile=/tmp/foo
exec 2>${lckfile}
wget -O- http://www.cnn.com/
fuser ${lckfile}
echo $?

if ! fuser ${lckfile}
then
    fuser ${lckfile} > ${lckfile}
else
    touch /tmp/foot
fi
rm -f \
     /tmp/foop \
     /tmp/foot \
     ${lckfile}

fuser ${lckfile} ; echo $?

There.  This is a working demo I used to build the eventual thing, so the implementation varied as much as YMMV, but that's the guts of it.

Enjoy, kids. And yes, I enjoy foo.

Labels: , , , ,

Tuesday, April 12, 2011

NoStorage and Kickstart - How to Specify Multiple HBA Modules

When kickstarting, you have the option of using 'nostorage' on the PXE command line to prevent storage HBA drivers from loading -- you can do the same to NICs, but it's not as interesting, not as common and the command line is dumber.
default linux
prompt 0
timeout 1
label linux
     kernel /images/centos55-x86_64/vmlinuz
     ipappend 2
     append initrd=/images/centos55-x86_64/initrd.img ksdevice=eth0 lang= kssendmac nostorage text ks=http://archive/cblr/svc/op/ks/system/Bish-PXETest
See that?  NoStorage.  Okay.

So what if you want to use the same kickstart for different machines?  For different HBAs ?  Normally you're screwed.  This won't work, either:
device scsi ahci
device scsi mptspi
device scsi cciss
Specifying the HBA drivers on multiple lines should work, but it's not that simple -- doing so makes it choose the first one and ignore every other invocation of the device line.  This does work, though:
device scsi ahci:mptspi:cciss
See the colons? There you go.  It allows/forces you to choose the order, so plan carefully.

Labels: , , , , ,

Saturday, October 30, 2010

Maintaining Repos in Kickstarted Machines After Install

After you've installed a machine, its install-time repository config in /etc/yum.repos.d is pretty much set.

Bah, I say! Bah! Just keep it updated.

Kickstart (cobbler):
#set yumconfcronfilename = "/etc/cron.daily/50-yum-config-stanza"
cat << EOECYCS > $yumconfcronfilename
#!/bin/sh
$yum_config_stanza

sed -ne '
        /^baseurl=/{
                s/baseurl=/repomd /
                s://:__:
                s:/: :
                s:__://:
                p
        }
        ' /etc/yum.repos.d/cobbler-config.repo \
          > /etc/apt/sources.list.d/cobbler-config.list
EOECYCS
chmod a+x $yumconfcronfilename
If you're not running cobbler, set it into place by hand:
cat << EOECYCS > /etc/cron.daily/50-yum-config-stanza
#!/bin/sh
wget "http://archive/cblr/svc/op/yum/profile/centos5-i386-minimal" --output-document=/etc/yum.repos.d/cobbler-config.repo

sed -ne '
 /^baseurl=/{
  s/baseurl=/repomd /
  s://:__:
  s:/: :
  s:__://:
  p
 }
 ' /etc/yum.repos.d/cobbler-config.repo \
   > /etc/apt/sources.list.d/cobbler-config.list
EOECYCS

chmod a+x /etc/cron.daily/50-yum-config-stanza
That's dereferenced for you. The actual profile's going to be way off, though, so don't use that one verbatim. Find your own:
awk -F/ '/^url/{print $NF}' anaconda-ks.cfg
As usual, watch carefully for the way in which the 'new', 'better' blogspot editor makes an artistic puree of the quoted stuff;  grain of salt, kids.

Labels: , , , , , , , , , ,

Saturday, October 16, 2010

Gargoyle OpenWRT Router Management Utility Reviewed, Briefly

I stumbled across what looked to be another WRT54GL-compatible flash upgrade for routers.  Neat!  I've been looking for a new base, on which to build the minor customizations I do, for a while now.  Ever since OpenWRT went all Kamikaze and dropped NVRAM support, thus becoming valueless and useless to me, I've been in need of another source to tune.

Enter Gargoyle.  It's mainly a set of UI tools, like X-WRT, built on an OpenWRT 8.09 Kamikaze platfo--

F A I L

That was far too quick, and I'm disappointed they chose a platform that renders their product similarly valueless for me.  Its feature set looked really impressive:
  • easy QoS config with sensible throttle rules (and, new, improved monitor/throttle points, it seems)
  • easy monitoring of pipe drains, on a per-machine basis too
  • simplified bridging setup -- which is a potential pain in the ass they've totally alleviated
  • lazy?  Go buy a new router with Gargoyle installed.  Click, Buy, Sign for the Fedex.  How easy is that?
In all, to believe the (believable) brochure, it looks like a project in motion and active; just missing a market due to the reduced potential in the upstream product they're improving.  Hobbyists with 1-2 routers, probably at their own location so they're easy to reach and personally reconfigure after the upgrades render them non-routing vegetables, may find this useful.  Those of you who are either hobbyists with routers providing the routing at offsite locations, or those who have more than 1-2 routers total, may want to consider something which effectively uses the non-volatile RAM within the units to store settings in such a way that it survives the upgrade.

Unfortunately, basing their project on OpenWRT 8.09 limits their potential and cuts them out of a significant non-niche market.  SOHOs, branch offices, those who've grabbed a $50 router to use as a very capable $500 router, will find this product is not a suitable upgrade because of this early decision.  And the real pity here is that potentially a lot of work, by apparently a good and active bunch of very smart people, is rendered moot.

Labels: , ,

Friday, October 15, 2010

vconfig, invalid arguments and Favouritism

So I'm messing with vconfig;  really I'm letting the system do most of it, but it backs onto vconfig.

Explain to me why I can't vconfig a new vlan to an interface:

# service network stop ; service network start
Shutting down interface eth2.2401:  Removed VLAN -:eth2.2401:-
                                                   [  OK  ]
Shutting down interface eth2.2402:  Removed VLAN -:eth2.2402:-
                                                   [  OK  ]
Shutting down interface eth2.2403:  Removed VLAN -:eth2.2403:-
                                                   [  OK  ]
Shutting down interface eth2.2404:  Removed VLAN -:eth2.2404:-
                                                   [  OK  ]
Shutting down interface eth0:                      [  OK  ]
Shutting down interface eth1:                      [  OK  ]
Shutting down interface eth2:                      [  OK  ]
Shutting down loopback interface:                  [  OK  ]
Disabling IPv4 packet forwarding:  net.ipv4.ip_forward = 0
                                                   [  OK  ]
Bringing up loopback interface:                    [  OK  ]
Bringing up interface eth0:                        [  OK  ]
Bringing up interface eth1:
Determining IP information for eth1... done.
                                                   [  OK  ]
Bringing up interface eth2:                        [  OK  ]
Bringing up interface eth0.2401:                   [  OK  ]
Bringing up interface eth0.2403:  ERROR: trying to add VLAN #2403 to IF -:eth0:-  error: Invalid argument
ERROR: could not add vlan 2403 as eth0.2403 on dev eth0
                                                           [FAILED]
Bringing up interface eth2.2401:  Added VLAN with VID == 2401 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface eth2.2402:  Added VLAN with VID == 2402 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface eth2.2403:  Added VLAN with VID == 2403 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface eth2.2404:  Added VLAN with VID == 2404 to IF -:eth2:-
                                                   [  OK  ]
Bringing up interface br1:                         [  OK  ]
Bringing up interface br3:                         [  OK  ]

That's not the weirdest part:
# ifconfig | grep HW
br1       Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:00
eth0      Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:00
eth0.2401 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:00
eth1      Link encap:Ethernet  HWaddr 00:0C:29:78:8F:9E
eth2      Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2401 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2402 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2403 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
eth2.2404 Link encap:Ethernet  HWaddr 00:0C:29:5C:6D:14
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun2      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun3      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
# vconfig add eth0 2404
Added VLAN with VID == 2404 to IF -:eth0:-
# vconfig rem eth0.2404
Removed VLAN -:eth0.2404:-
# vconfig add eth0 2403
ERROR: trying to add VLAN #2403 to IF -:eth0:-  error: Invalid argument
For some reason, that exact vLAN is the one I can't apply to that interface.  The preceding one goes fine;  so does the one after.  That one?  No go.

Riddle me that.  And, once again. sorry if the format absolutely sucks.  I just can't figure out how to make this editor not chew up my blockquotes.

Labels: , ,

Thursday, September 30, 2010

Whither be Withered Stateless Linux?

I've been pocking at Stateless Linux for a while.

Probably since it was called Diskless Linux.  Names change.

Anyway, I stumbled over a stateless linux page referring to a tech preview in RHEL5, which sounds awesome.

Sadly it doesn't appear to be available.  "Install FC7," it says, not knowing that FC7's stereotypical 3-week support window closed at least a week ago, and thus any projects using it will simply not work.

So where did the Tech Preview go?  If it was a tech preview way back in 1992 or whenever RHEL5 was released, should it not be at least a tech preview now?

I worry that the Open Source Community has an attention span even shorter than mine.

Labels: , , , , ,

Wednesday, September 29, 2010

False Start on Cobbler Repos -> Apt RepoMD statements

Man, I know so little python.  And while I hate it, I see that it's a deficiency I need to fix.  That sucks, but I may just find it useful eventually.

So I was poking around, and started to extend cobbler to feed an apt sources.list files the same as it does for a yum repo file when a given profile or system has supplemental repos attached. 

But all I did was start.  The curve's a bit high since I know so little, and I have so many other things I have to do -- like, for money.

Here's a tiny patch so far.  I'll find the rest eventually:

--- kickgen.py  2010/09/29 03:40:45     1.1
+++ kickgen.py  2010/09/29 07:06:23
@@ -175,10 +175,15 @@
         blended = utils.blender(self.api, False, obj)
         if is_profile:
            url = "http://%s/cblr/svc/op/yum/profile/%s" % (blended["http_server"], obj.name)
+           lru = "http://%s/cblr/svc/op/apt/profile/%s" % (blended["http_server"], obj.name)
         else:
            url = "http://%s/cblr/svc/op/yum/system/%s" % (blended["http_server"], obj.name)
+           lru = "http://%s/cblr/svc/op/apt/system/%s" % (blended["http_server"], obj.name)

-        return "wget \"%s\" --output-document=/etc/yum.repos.d/cobbler-config.repo\n" % (url)
+        ulines = "wget \"%s\" --output-document=/etc/yum.repos.d/cobbler-config.repo\n" % (url)
+#        ulines += "wget \"%s\" --output-document=/etc/apt/sources.list.d/cobbler-config.list\n" % (lru)
+
+        return ulines

     def generate_kickstart_for_system(self, sys_name):
Yeah, that's all I've got.  Lose the comment on the ulines+= line, and then find out the part where /op/apt/system/ actually rolls the template snippet for the apt sources.list file.  I see it here and there but can't nail down the bit in the code.  Frustrating, almost as much as running out of frivolity time.


Learning is fun, when I have time.

Labels: , , ,

Tuesday, September 28, 2010

Kickstarting ESX VMs and Physical Hosts -- Knowing Which is Which

UPDATE: This method also does not work. Sorry.

Cobbler and kickstarting is my new cool toy.  I tinker with it FAR too much. I had a problem, though, that I need to install the vmware tools only on the VMs, and install smartmontools only on the physical hosts.  What's a guy to do?

After some digging, coding, hacking, testing, cursing, I finally discovered a decent switch I can use to identify a box by its mac.

Then I lost that code.

So I found another method.  This one's ugly as sin, but it may actually work.  Check this nasty-ass kung-fu:
#if ":".join($interfaces.eth0.mac_address.split(':')[0:3]) in "00:50:56 00:0C:29"
[code]
#end if
Yeah.  That's one ugly baby.  If Blogspot again truncates that line all to hell, remember the #if statement is all on the first line of 3.

Now to see how well it works.

Labels: , , , , , , , ,

Friday, September 24, 2010

TCPDump Top-Talkers script

I remember back in the days of cypress Linux, or Red October, that we in the MH office had a top talkers script.  It was good to see, for instance, that the streaming radio you were listening to didn't impact the network too noticeably.  I don't know what the network guys did out there, but I had a need to cook up something out East again.  So I googled it up, found a tcpdump cheat-sheet with it, and there ya go.  Top talkers:
tcpdump -tnn -c 20000 -i eth0  |\
   awk -F "." '{print $1"."$2"."$3"."$4}' |\
   sort | uniq -c | sort -nr |\
   awk ' $1 > 100 ' 
It's nothing like perfect, for it only shows the number of packets a machine's blowing out the NIC and not the size of each one, but that's something which we can add in, I figure.  It's quick, though, and gives a relatively useful ballpark figure, which is all I need today.

Yay for google and tcpdump!

Labels: , ,

Sunday, September 05, 2010

Centos5-i386 -- LVM Root on a Kickstart?

I've gotta be doing something wrong.  But it looks good from so close to the problem.  Here's a snippet of the kickstart I'm using:

part pv.01  --size 32 --grow --asprimary
volgroup vg01 pv.01
logvol / --fstype ext3 --name=root --vgname=vg01 --size 10240
When it all comes down, though, it's a little screwed.  There's a pic.  The thing is, it's not really an LVM issue, since the space is there and the PV's been created.

A little investigation, though, shows the device /dev/vg01/root hasn't been created.  Simple fix?
lvm vgchange -a y
Then the devices are up.  It's too easy.  Bad news?  Can't happen in a kickstart.  The install pattern, as they say, is full, and it's missing the VG startup.

So where from here?

Labels: , ,

Sunday, August 29, 2010

Auto-Updating Distro profile in Cobbler

As part of a very short, unsuccessful Fedora 13 test, I found it advantageous to set up an auto-updating distro.  Okay, given the release behaviour of Fedora vs, say, RHEL, an auto-updating distro profile for a distro which doesn't actually update is kinda pointless.  Work with me here, though.

How to do this in Cobbler?  Create a repo, which we can update automatically, and link the distro to that:
cobbler repo add --name fedora13-os-x86_64 --arch x86_64 \
  --mirror rsync://mirrors.kernel.org/fedora/releases/13/Fedora/x86_64/os

cobbler import --name fedora13 --arch x86_64 \
  --path /var/www/cobbler/repo_mirror/fedora13-os-x86_64 \
  --available-as http://10.10.4.1/cblr/repo_mirror/fedora13-os-x86_64 \
  --breed redhat --kickstart /etc/cobbler/centos-X.ks
Too easy.  Blah blah, test often, blah blah, change the IP to suit, etc.

Labels: , , ,

Sunday, August 22, 2010

Hot Remove VMDKs in Linux VMs

We glue vHDDs onto VMs like crazy. It's like a sport or something. The awesome part is that I just found an article on Xtravirt showing you how to remove one.

Awesome.  So here's the process:
  1. umount the drive.
  2. pull the drive from /etc/fstab, if necessary.
  3. here's the magic.  Unlink the drive from the HBA:
    echo 1 > /sys/block/sdb/device/delete
    oh yeah. That hits the spot.
  4. remove the VMDK from the VM via the VIC.
And that's it.  Holy crap.


I'm not including this to take credit for it.  Personally, I never knew we had the power in Linux, yet, to yank a drive off the bus like that.  It's awesome, and it shows what kind of awesome power we have here.

Go see the article at its source:

vSphere: Hot Add or Remove a VMDK with a Linux VM | Xtravirt

Labels: , , , ,

Wednesday, August 18, 2010

Check the CommandLine Options in your PXE Booting Linux

I'm not sure if the grammar in the subject is the best it can be.

A question came up on a mailing list about command line options which can be passed to the linux installer at boot time.  The user in question is rolling out a series of new hosts with RocketRaid HBAs in them - for which I admire his courage where I gave up - and needs to push the driver disk to them at install time or they'll never see the root disks.  No, kickstart is not a viable option yet.

After some groveling through the options - and I suspect a RH employee who I fear had  to hold back for fear of breaching a Centos/RHEL condition - I think we got him exactly what he needs, which is awesome.

Want to look at those command line options in one go?  Try this:

zcat /tftpboot/images/centos5-x86_64/initrd.img | \
     cpio -iv --to-stdout sbin/loader|strings|less

Do that - adjusting for location - and start vgrepping.

For what it's worth, after jamming a fan onto my Adaptec 2405 (a Scythe Mini Kaze HTPC Silent Mini Fan 50MM 4500RPM 9.42CFM 26.09DBA 2 Pin W/ 3 Pin Adaptor, to be OCD about it) works like a charm.  Go get one of those and discard the HotPoint stuff, imho.

Labels: , , , , , , , ,