Friday, December 5, 2008

Opsview between i386 and amd64

This is something you should never do!  But somehow I got myself into this situation, what a PITA.

My master server is i386, and the slave is amd64. 

These are the step to get it working - and have to be done each time you send updates to the slave.  So basically this is temporary until I have time to migrate my master to amd64.
  • Make sure all opsview apps are not running on either server
  • Install ia32libs on the slave
  • Upgrade to the latest opsview on the master.
  • Upgrade the slave to the latest version.
  • At this point your dpkg --configure -a will have failed - do the following
  • Edit /var/lib/dpkg/info/opsview-core.postinst and comment out the restart actions at the bottom
  • On the slave - go into /usr/local/nagios/bin/
  • chmod 700 nd02db; cp nd02db ndo2db.ARCH
  • Back on the master run dpkg --configure -a.  Just after it finishes copying the tar.gz to the slave - do this on the slave: cp ndo2db.ARCH ndo2db
  • Now your master will think it's succeeded finally.
  • Go to the slave and aptitude reinstall opsview-core opsview-base opsview-perl.
  • Again the dpkg --configure -a will fail.  Edit /var/lib/dpkg/info/opsview-core.postinst as before.
  • Run dpkg --configure -a on the slave and you should be fine
  • Make sure all your services are up and running.  Slaves should have opsview and opsview-agent running.

Thursday, November 27, 2008

OSX Automator, USB Drive Insertion or Mounted Volumes & Backup

I was looking for a way to trigger an event when a volume is mounted on my system when I came accross this auto detect mounted volumes post. I'm completely new to automator, so all I want it to do is kick off a shell script.

Now the shell script runs whenever any volume is mounted. But what happens to stdout & stderr when the script is triggered by automator? Well - it vanishes, so you need to redirect it somewhere useful. Early on in my script I redirect stdout and stderr to a log file:

exec > ~/Library/Logs/mount-event.out 2>&1


The script will not receive any incoming content or variables and the current working directory will be they users' home, so you just need to start from scratch.

Friday, June 6, 2008

MacOSX syslog & asl.db system slowdown

I noticed that if Firefox goes apeshit it chew up memory and log repeated errors to syslog that would cause the system to compete for disk I/O.

Aside from Firefox just being crap and loosing it, I found that I could prevent syslog from logging too much crap by reducing the logging level from NOTICE (5) to ERROR (3) - see man 1 syslog for other levels. These changes were inspired by a CodeSnippets post, though the instructions there appear to be far too complex than is needed.

Here's how to do it:

sudo /usr/libexec/PlistBuddy -c "Delete :ProgramArguments" /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo /usr/libexec/PlistBuddy -c "Add :ProgramArguments array" /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo /usr/libexec/PlistBuddy -c "Add :ProgramArguments:0 string '/usr/sbin/syslogd'" /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo /usr/libexec/PlistBuddy -c "Add :ProgramArguments:1 string '-c'" /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo /usr/libexec/PlistBuddy -c "Add :ProgramArguments:2 integer 3" /System/Library/LaunchDaemons/com.apple.syslogd.plist


Then you just need to restart syslog:
sudo launchctl stop com.apple.syslogd
sudo launchctl start com.apple.syslogd

Sunday, May 18, 2008

Debian Etch, mod_fcgid & php4

There are a fair few howto's out there with instructions on getting php4 & fcgid working together, but it seems none of them have been tested properly. PHP5 works easily following the instructions, but not PHP4 - so here's my extra notes to get it working.

I had to strace apache a few times to figure out exactly what was going on since it fcgid doesn't provide any useful logging. This can easily be done with "strace -f -p {pid_of_the_apache_process_answering_the_request} -e read=all -e write=all -o strace_output.txt" - this will give you something to look for when debugging.

The main difference between most of the existing howto's is the exec line in the php-fcgi-wrapper. Although "apt-get install php4-cgi" provides you with /usr/bin/php4-cgi - and it seems you would use this, you _don't_ use it. You need to use /usr/lib/cgi-bin/php4. You should be able to figure out the rest with the existing howto's.

Thursday, May 8, 2008

ClusterSSH in Leopard

Unfortunately the DarwinPorts way of installing ClusterSSH doesn't work, so you gotta do it manually. Good news is you don't have to re-invent the wheel. Someone has kindly posted the procedure at: http://lists.macosforge.org/pipermail/macports-users/2008-January/008336.html

Saturday, March 22, 2008

EpiaWiki > EpiaSound > Setting up Alsa

The following content is captured from web.archive.org because the original domain no longer exists. I copy the content here for reference as I found this useful when setting up my own Via EPIA EN12000 S/PDIF 5.1 system with Gentoo linux.


The content below is provided as-is, and is unchanged from the original text. If it doesn't work for you, then your guess is as good as mine as to why.





3.1 Setting up Alsa


Make sure your /usr/src/linux link points to the correct kernel, as Alsa and other packages use this to get the correct headers and modversions. Run emerge alsa-utils to get required alsa tools and the init script. If you are using the 2.4 kernel, you will need to run "ALSA_CARDS=via82xx ACCEPT_KEYWORDS=~x86 emerge alsa-driver" to get the drivers (2.6 includes the drivers). It is helpful to add ALSA_CARDS="via82xx" to your /etc/make.conf and "media-sound/alsa-driver ~x86", etc to your /etc/portage/package.keywords so you don't have to specify them every time.

Please refer to the official Gentoo ALSA guide (cache) if you have any questions.

3.1.2 Configuring Alsa

Now we need to configure it to auto start.
Here are some relavent via82xx module options:

ac97_clock - AC'97 codec clock base (default 48000Hz)
dxs_support - support DXS channels,
0 = auto (defalut), 1 = enable, 2 = disable,
3 = 48k only, 4 = no VRA
VIA8233/C,8235 only



The default of dxs_support=0 usually results in wierd sounding non-48Khz files so try one of the other options. Now we need to edit /etc/modules.d/alsa it should look something like this:

# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-via82xx
options snd-via82xx dxs_support=3

# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0

alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

alias /dev/mixer snd-mixer-oss
alias /dev/dsp snd-pcm-oss
alias /dev/midi snd-seq-oss

options snd cards_limit=1


Then run modules-update after which, you can type /etc/init.d/alsasound start to insert the alsa modules. rc-update add alsasound boot will load that every time you reboot.

3.1.3 Unmuting Alsa


Alsa is muted by default. Run alsamixer to view the mixer levels. Move left and right with the arrow keys, and press 'M' to unmute Master and PCM channels. Up and Down will adjust the volume levels. Press 'Esc' to exit. The alsasound boot script will restore mixer settings on reboot.

3.1.4 6 Channel Output (5.1)


Now how to switch to 5.1 out...

Once you switch the sound card to output 5.1, the functions of the jacks change.
Jack : Mode 1/Mode 2
Blue : Line-In/Rear-Out
Green : Line-Out/Front-Out
Pink : Mic-In/Center&Subwoofer-Out


3.1.5 Using the S/PDIF out


The EPIA-M can output S/PDIF through the RCA jack on the back. First you need to change a jumper on the motherboard before you can use this, it is near the RCA port, see your manual for details.

The S/PDIF output is controled through the IEC958 Playback AC97-SPSA mixer channel you can set the different options with the command amixer set 'IEC958 Playback AC97-SPSA' 0. The S/PDIF always outputs at maximum volume, the main and pcm mixers have no affect on it. Here are the different output options for IEC598 Playback:

0. PCM1
1. PCM2,PCM1 (rear)
2. Center and LFE
3. PCM3,Modem,Dedicated S/PDIF

Most people want to use 0.

To get AC3 passthrough with mplayer, use mplayer -ao alsa -ac hwac3

Also, if you haven't set the above mixer setting, then you should be able to use mplayer -ao alsa9:iec958 to get s/pdif output still.

3.2 OSS Kernel Module


The OSS sound driver is included in the kernel. Enable "VIA 82C686 Audio Codec" under sound in the menuconfig. The module will be called via82cxxx_audio.

3.3 VIA Combo Audio Driver


http://www.viaarena.com/?PageID=294 (cache) offers a oss driver that supports all of VIA's sound chips. It supports six channel audio and spdif out.

You can get viaaudiocombo for 2.6.1 here:
http://www.shipmail.org/~thomas/via/audio/ (cache)
this link is dead :-( however, you can still look at the cached copy and from there download the file

Saturday, February 2, 2008

Xen VM's & NAT Bridging

I have a dedicated box at an ISP that provide me a base IP for the box and a /29 range. I'm using Xen to create VM's on this box and I wanted to maximize the use of IP's for my hosts.

The default configuration one would use would result in 2 IP's being assigned to the Xen host.

Lets say I have a default IP of 1.2.3.4 on the main box, and the ISP has issued me 5.6.7.24/29, leaving me with 5.6.7.25-29 as usable IP's. One of the /29 range has to be applied to the base box to serve as a gateway, meaning that one IP is wasted (or you could say even 2 are wasted if you include the 1.2.3.4 address).

I didn't want to loose these 2 valuable IP's, so I used iptables with SNAT/DNAT to make use of all the assigned IP's.

The first steps were simple when I found this page: http://grml.org/xen/, so the bulk of the following code is copied from there.

Using a debian system, I entered the following extra config into my /etc/network/interfaces to make the Xen host listen to my public IP's and perform DNAT/SNAT to private IP addresses.
auto xenintbr
iface xenintbr inet static
pre-up brctl addbr xenintbr
post-down brctl delbr xenintbr
address 10.1.1.1
netmask 255.255.255.0
bridge_fd 0
bridge_hello 0
bridge_stp off

auto eth0:25
iface eth0:25 inet static
address 5.6.7.25
netmask 255.255.255.248
post-up iptables -t nat -A POSTROUTING -o eth0 -s 10.1.1.25 -j SNAT --to 5.6.7.25
post-up iptables -t nat -A PREROUTING -d 5.6.7.25 -j DNAT --to-destination 10.1.1.25


Next make xend set up the bridge correctly in /etc/xen/xend-config.sxp. This tells xend to set up the bridge between the guest and the bridge setup above, but instead of using the default network-bridge, we simply do routing, and let the iptables rules above perform the routing to the outside world.
(network-script    network-route)
(vif-bridge xenintbr)
(vif-script vif-bridge)


And in the guest machine configure the network on the private subnet.
auto eth0
iface eth0 inet static
address 10.1.1.25
netmask 255.255.255.0
gateway 10.1.1.1


You can check the status of the iptables rules with:
iptables -L -vn
iptables -t nat -L -vn

Wednesday, January 16, 2008

IPMI Reference

You can find the IP address of the ilom using the ipmitool on many systems:

# modprobe ipmi_si && modprobe ipmi_devintf
# ipmitool lan print 1

Sunday, January 6, 2008

Resizing Xen disk images

If you're in a situation where you're using disk images instead of LVM then you may occasionally need to resize your disks. It's really simple when you know how ;)

dd if=/dev/zero of=disk.img bs=1MB count=0 seek=20480
e2fsck -f -y disk.img
resize2fs -p disk.img


This will resize an existing image file to 20Gb.