Fun with PXE

At one of my previous positions, I was in charge of the PXE server.  I like PXE, so I set up a PXE server here, too.

It was a lot easier at my current place of employment, because I had access to the routers and the DHCP server.  It ended up being a straightforward Windows Deployment Services install.  I’m not only serving up boot and install images but also Acronis Recovery Media.  🙂

Alas, at the previous place, I was not allowed access to routers or DHCP.  This meant I had a lot of ‘splainin’ to do, and apparently it broke some of the network guys’ brains, so…

PXE uses DHCP (option 60). You can run PXE on a network with separate PXE and DHCP servers, but PXE does need to listen on DHCP.

It kind of goes like this:

PXE Client:  DHCPREQUEST, p.s. I'm a PXE Client.
DHCP Server:  DHCPACK, Here's your IP! p.s., PXE over there ->
PXE Server:  DHCPACK, Hello, I'll be your PXE server today. 

Note:  That second DHCPACK does not contain an IP number.  It only contains PXE information. (So, dude who kept demanding that I look at the scope of the IP addresses I was handing out?  You fail Reading/Listening Comprehension 101.)

So you’re going to need to make changes to the DHCP server (to specify to PXE clients where to get PXE services) and possibly the routers as well (to specify the PXE server as a DHCP helper).  You also need to make sure that the PXE server is answering on the DHCP ports (open them in the firewall).  If you have separate PXE and DHCP servers, the PXE server doesn’t need to serve up IP numbers, but it does need to answer (DHCPACK, option 60).

This is a pretty good description of how someone else got it working.

1 Comment

Filed under sysadmin

“Saving Alan Idle” is now up at Escape Pod

WOOHOO!  My story “Saving Alan Idle” is now available as both HTML and a podcast.  I’m so excited!

http://escapepod.org/2013/07/05/ep403-saving-alan-idle/

Thanks to everyone who helped me critique it, including, but not limited to: Gary David Henderson, Beth Dawkins, Matthew Quinn, Terra LeMay, Woodrow Jarvis Hill, Michelle Dupler, and Sandy Parsons.

4 Comments

Filed under short fiction

Nagios Event Handlers on Windows

Nagios event handlers are WHERE IT’S AT, BABY, YEAH!  There are some services that I can just automagically restart without any problems.  (WSUS, SQL Agent, etc.) This way, instead of notifying me, Nagios can just fix the problem for me and We Need Never Know.

These instructions assume I’m running NSClient++.

The script is

@echo off
net start %1
@exit 0

(This is kept intentionally minimal so it’ll be reusable.)  I’m referring to this in nsclient.ini, under the “; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>” header.

restartwsus=scripts\runcmd.bat wsusservice

On the Nagios server, I’ve defined the check in commands.cfg as:

define command{
 command_name restartwsus
 command_line /usr/lib/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c restartwsus
}

and in the service definition as:

define service{
        use                     generic-service
        host_name               wsusserver
        service_description     WSUS
        contacts                me
        notification_options    w,c,r
        notification_period     24x7
        notification_interval   0
        check_command           check_nt!SERVICESTATE!-d SHOWALL -l WsusService
        event_handler           restartwsus
        }

It looks like this is copy and paste-able.

Comments Off on Nagios Event Handlers on Windows

Filed under monitoring

A script for migrating to a new server

I stripped out a piece of company-specific logic, but…

List the databases you want to move in a file named “control.txt.”  (To migrate the entire server, paste the output of “select name from sys.databases where name not in (‘master’, ‘msdb’, ‘model’, ‘tempdb’).”)

Replace the example values in the below script with real information:


@ECHO ON

set controlfile=control.txt

set newipmdf=\\newserver\g$
set newipldf=\\newserver\e$
set oldserver=oldserver\Prod1
set oldmdfpath=d:\prod1
set newmdfpath=g:\data
set copymdfpath=m:\data
set newserver=newserver
set oldlogpath=e:\prod1
set newlogpath=e:\log
set copylogpath=l:\log
set movedmdfpath=%oldmdfpath%\moved
set movedldfpath=%oldlogpath%\moved

mkdir %movedmdfpath%
mkdir %movedldfpath%

net use m: %newipmdf%
net use l: %newipldf%

SETLOCAL DISABLEDELAYEDEXPANSION
FOR /F %%L IN (%controlfile%%) DO (
  SET "line=%%L"
  SETLOCAL ENABLEDELAYEDEXPANSION
  ECHO !line!
  sqlcmd -E -S!oldserver! -Q"EXEC master.dbo.sp_detach_db @dbname = N'!line!'"
  copy "!oldmdfpath!\!line!.mdf" !copymdfpath!
  copy "!oldlogpath!\!line!_log.ldf" !copylogpath!
  sqlcmd -E -S!newserver! -Q"CREATE DATABASE [!line!] ON ( FILENAME = N'!newmdfpath!\!line!.mdf' ),( FILENAME = N'!newlogpath!\!line!_log.ldf' ) FOR ATTACH"
  move "!oldmdfpath!\!line!.mdf" !movedmdfpath!
  move "!oldlogpath!\!line!_log.ldf" !movedldfpath!
  ENDLOCAL
)
ENDLOCAL

net use m: /z
net use l: /z

(The redacted data was a sharding-related item–updating a metadata table with the new location.  You can, of course, add your own logic after the attach, if needed.)

As always, I’ve included a downloadable version here.

Comments Off on A script for migrating to a new server

Filed under scripting

Nagios Twitter Notifications – working again!

Yeah.

Twitter changed their authentication, and my old Twitter notifications (based on Ed Voncken’s work) seized up and failed.  I had to update the python tweepy library to get them to work.

pip install tweepy –upgrade

And they’re back!

I love Twitter notifications, BTW.  <3

Comments Off on Nagios Twitter Notifications – working again!

Filed under monitoring

“Digital Death”

The WisCON panel description:

Who gets your ebooks when you die? Your Twitter feed? The baby book that mostly exists on LJ? Do you have an estate plan for all these intangible but valuable assets? When you go, do you want your pages taken down or kept up for all time? Who do you trust to preserve or annihilate your online presence? The legal status of digital media is still a little fuzzy. With more of us and our parents moving that direction, we should think about this not just for ourselves, but our elders. What is the digital equivalent of inheriting grandad’s books, or is it even possible now? Join the discussion on legacies, files, and virtual tombstones.

Yeah, I was on that 8am panel.  😉  With another sysadmin, mind you!  The two sysadmins had two basic approaches to the topic:

  • Love your data.  Cuddle your data.  Back up your data.
  • Embrace bit rot.  All things die, including your data.  Don’t get attached to data, because Buddha says attachment leads to suffering.

I’ll open with my final comment, which is that this is not for you.  It’s a form of consideration for your survivors, and they’ll decide what’s valuable or not in the end.

What if your family is hostile, and doesn’t see the value in what you consider valuable?  Well, if you disagree strenuously, make your works public domain and put them online.  I put a lot of family photos on Flickr, Creative Commons Attributions No Derivatives so my family could download any of them without contortions.  I also had a friend at one point who died, and her mother found out she wrote fan fiction with same-sex romances in it, and her mother embraced that as part of who her daughter was.  (The moderator suggested that “I love my dead slash-writing daughter!” was a whole other possible panel topic.)  That could have gone in a completely different direction, though.

Frankly, I’m not really that concerned about my ebooks, movies, music, etc.  I’m more concerned about my facebook/twitter/personal websites, particularly the obituary sites I put up for my parents.  So my greatest concern with that is the technical know-how associated with maintaining them.  I’d rather they be left up, though, because I had another friend who was sick but didn’t intend to die, and she pre-scheduled a lot of WordPress posts that were tied to her Twitter and Facebook, and those started rolling in after she died.  “New music!” and a link to her playing.  Our first reaction was, “Wahhhhh,” but after a couple of months it was kind of nice.

On the opposite end, I have another friend who has an arrangement with a buddy that if he dies, the buddy will come in and wipe his hard drive so his Mom won’t find his porn or nekkid pictures.

Don’t count on encryption.  Even the best encryption standards get broken over time, so it’ll just make your hard drive a puzzle.  Then it turns out to be a case of whether or not someone thinks the drive is worth the effort.  (“Oh, it’s porn.  2D, how quaint!”)  Do think about the portability of your data (plain text, or HTML, which is plain text with a little markup that can be easily stripped out).

Obituary sites:  I wrote my Mom’s site because someone quoted my sister some exorbitant sum for an obituary online for some limited amount of time, and I said, “Bah, I’ll put it up on my own site.”  So I did, and it remains, and at least one friend of hers found out she was dead by googling her.  My father’s site… well.  My stepmother is not a native English speaker and was really upset, so the funeral home wrote the obituary and it didn’t mention that he had children.  My site for him outranks that other obituary in google–SEO REPRESENT.  However, antispam and upgrading the software is a thing, and does require technical know-how.  You might want a digital executor to be in charge of things like that.  In particular, the spambots will find the site and post 5000 links to “Buy Viagra!” if you let them, and that’ll feel like someone spraypainting on their headstones.  So be prepared.

Last but not least, I’ll reiterate that it’s not really about you.  If you believe in an afterlife, you’ll be in heaven and won’t be too concerned about your Facebook.  If you don’t, you won’t exist and won’t care about your Facebook.  It’s about being considerate to your survivors.

Comments Off on “Digital Death”

Filed under cons

Fun with VLFs

Virtual Log Files.  Your database’s log file is made up of one or more virtual log files.

Our databases have too many. Basically, our LDFs are fragmented.

What to do about this?  Well, Dave Levy has a script to reduce the number of VLFs, but it’s to run against a single database.  I have over 8000 databases.  Yeah.  That’s going to have to be scripted.  I know, job security and all, but that’s crazy.

Also, as a Sysadmin/Production DBA, I like scripts.  Consistent, repeatable.

I’m going to strip out some company-specific code that won’t do you any good, but if there’s a particular set of databases you want to target, list them in a maintenance table and work from that, not sys.databases.  (That’s why the check to see if the database really exists code is there.)  You’ll be able to tell that I shamelessly pasted bits and pieces of Dave Levy’s script.  For control, there’s a @maxlogcount variable that you can set crazy high.  Also, you can comment out the EXEC sp_executesql bits and uncomment the print bits for test/debug/just show me what you were going to do purposes.

declare @RowsToProcess int,
@CurrentRow int = 0,
@DBexists int,
@DBname varchar(80),
@logcount int,
@SQL nvarchar(max),
@file_name sysname,
@file_size int,
@shrink_command nvarchar(max),
@alter_command nvarchar(max),
@maxlogcount int

set @maxlogcount=100

CREATE TABLE #vlfcount(RowID int not null primary key identity(1,1), dbname varchar(80), vlfcount int, file_name varchar(255), file_size int )

INSERT into #vlfcount (dbname) SELECT name FROM sys.databases order by name
SET @RowsToProcess=@@ROWCOUNT

create table #scratch (Field tinyint, FileSize bigint, StartOffset bigint, FSeqNo int, Status tinyint, Parity tinyint, CreateLSN numeric(25,0))

WHILE @CurrentRow<@RowsToProcess
BEGIN
SET @CurrentRow=@CurrentRow+1
SELECT
@DBname=dbname
FROM #vlfcount
WHERE RowID=@CurrentRow
select @DBexists = @@ROWCOUNT from sys.databases where name=@DBname
if @DBexists = 1
BEGIN
set @SQL=’insert into #scratch exec (”dbcc loginfo (””’+@DBname+””’)”)’
–print @SQL
EXEC SP_EXECUTESQL @SQL
set @SQL=’update #vlfcount set vlfcount=(select count(field) from #scratch) where DBName=”’ + @DBName + ””
–print @SQL
EXEC SP_EXECUTESQL @SQL
set @SQL = ‘update #vlfcount set file_name=(select name FROM ‘ + @DBName + ‘.sys.database_files WHERE type_desc = ”log”) where DBName=”’ + @DBName + ””
–print @SQL
EXEC SP_EXECUTESQL @SQL
set @SQL = ‘update #vlfcount set file_size=(select (size / 128) FROM ‘ + @DBName + ‘.sys.database_files WHERE type_desc = ”log”) where DBName=”’ + @DBName + ””
–print @SQL
EXEC SP_EXECUTESQL @SQL
delete from #scratch
set @DBexists=0
END
END

SET @CurrentRow=0
WHILE @CurrentRow<@RowsToProcess
BEGIN
SET @CurrentRow=@CurrentRow+1
SELECT
@DBname=dbname,
@logcount=vlfcount,
@file_name=file_name,
@file_size=file_size
FROM #vlfcount
WHERE RowID=@CurrentRow
if @logcount > @maxlogcount
begin
SELECT @shrink_command = ‘Use ‘ + @DBName + ‘;DBCC SHRINKFILE (N”’ + @file_name + ”’ , 0, TRUNCATEONLY)’
–PRINT @shrink_command
EXEC sp_executesql @shrink_command

SELECT @shrink_command = ‘Use ‘ + @DBName + ‘;DBCC SHRINKFILE (N”’ + @file_name + ”’ , 0)’
–PRINT @shrink_command
EXEC sp_executesql @shrink_command

SELECT @alter_command = ‘ALTER DATABASE [‘ + @DBname + ‘] MODIFY FILE (NAME = N”’ + @file_name + ”’, SIZE = ‘ + CAST(@file_size AS nvarchar) + ‘MB)’
–PRINT @alter_command
EXEC sp_executesql @alter_command
END
END

select MAX(vlfcount) as worst, AVG(vlfcount) as average from #vlfcount
select dbname, vlfcount from #vlfcount where vlfcount > @maxlogcount

drop table #scratch
drop table #vlfcount

As always, I’ve included a downloadable link here: Download.  Because smart quotes are not smart.

Comments Off on Fun with VLFs

Filed under scripting

Jabber Nagios Notifications – Working Again!

I like using non-email notifications, especially when monitoring, you know, email.  So I have notifications going out via twitter and google talk.  Of the three, the order of speediness is:

  1. Google Talk
  2. Twitter
  3. Email

So I was really sad when the google talk notifications stopped working late last week.  It took awhile for me to have time to fix them, though, and basically I just found a google groups post telling me what to do.  Namely, this at the top:

use IO::Socket::SSL;
{
no warnings ‘redefine’;
my $old_connect_SSL = \&IO::Socket::SSL::connect_SSL;
*IO::Socket::SSL::connect_SSL = sub {
my $sock = $_[0];
${*$sock}{_SSL_arguments}{SSL_cipher_list} = ‘RC4-MD5’;
goto $old_connect_SSL;
};
}

Merci beaucoups à Cédric Bouvier pour la correction!

2 Comments

Filed under monitoring

Goodbye, Blink.

I used to do web development. In Cold Fusion, a lot of the time. Cold Fusion is a language with tags that usually start with CF, like “<cf_query>”.

We had a customer who kept asking for the text to be bright red, huge, and blinking. (Not for the entire site, but for special words and phrases like “SALE!” and “ALL ITEMS 75% OFF!” and “YOU CAN’T GET A CHEAPER PRICE ANYWHERE ELSE ON THE INTERNET GUARANTEED!”) He did it often enough that we joked about writing a custom tag, <cf_ugly>.

Pronounced “see fugly.”

Usage:

Boss: Yeah, [Name] likes your changes, but he wants you to wrap the text about the promotion in a see fugly tag.
Dev: DAMMIT!!!! *goes to edit*

See fugly.  See fugly stop.  Stop, fugly, stop.

[Link:  Firefox May Drop Support for <blink> Tags, Finally.]

Comments Off on Goodbye, Blink.

Filed under web

Sale! “Ondine’s Curse”

“Ondine’s Curse” will appear in an upcoming issue of the ever-awesome Electric Velocipede.  Squee!

Comments Off on Sale! “Ondine’s Curse”

Filed under sale