Archive

Archive for September, 2006

Network UPS Tools (NUT) on Ubuntu

September 25, 2006 9 comments

NUT is a handy system for monitoring almost any UPS. Unfortunately the configuration process is tweaky and the included documentation is minimal and cryptic.

Here is a process that worked for me:

(Adapted from Engadget)

Open the Synaptic Package Manager (under the System->Administration menu) and search for ‘nut’. Select the package for installation and click on Apply.
Now log in as the superuser, then create and edit five configuration files:

sudo su

1: /etc/default/nut

nano /etc/default/nut

Change this:

# start upsd
START_UPSD=no

# start upsmon
START_UPSMON=no
to this:

# start upsd
START_UPSD=yes

# start upsmon
START_UPSMON=yes
(Ctrl-x, then y to exit and save)

2: /etc/nut/ups.conf

nano /etc/nut/ups.conf

The configuration is pretty simple. Check the compatibility list to find out what driver/upstype to specify. For my APC SmartUPS, I used the apcsmart driver, and serial port ttyS0:

[ups1]
driver=apcsmart
port=/dev/ttyS0

(Ctrl-x, then y to exit and save)
to test:

upsdrvctl start

I got this message:

Unable to open /dev/ttyS0: Permission denied

Current user id: nut (120)
Serial port owner: root (0)
Serial port group: dialout (20)
Mode of port: 0660

To resolve it permanently, a quick workaround is to add nut to the dialout group in Users and Groups (under the System->Administration menu).

Now test again:

upsdrvctl start

and I got:

Detected SMART-UPS 1000 [WS9730021313] on /dev/ttyS0

now stop upsdrvctl:

upsdrvctl stop

Done with that!

3: /etc/nut/upsd.conf

nano /etc/nut/upsd.conf

If you want to allow your local network, put in the network address (i.e. 10.0.1.0/24)

ACL all 0.0.0.0/0ACL remote 10.0.1.0/24

ACL localhost 127.0.0.1/32ACCEPT localhost

ACCEPT remote

REJECT all

(Ctrl-x, then y to exit and save)

4: /etc/nut/upsd.users

nano /etc/nut/upsd.users

Add the following:

[monuser]

password = changeme

allowfrom = local

upsmon master

(replace changeme with a good password)

5: /etc/nut/upsmon.conf

nano /etc/nut/upsmon.conf

Add the following:

MONITOR ups1@localhost 1 monuser changeme master
SHUTDOWNCMD "/sbin/shutdown -h +0"

(replace changeme with the good password you used in step 4)

Now start the service:

 /etc/init.d/nut start

and test the settings:

upsc ups1@localhost

You should get a slew of readings and settings from the ups:

battery.alarm.threshold: 0
battery.charge: 100.0
battery.charge.restart: 00
battery.date: 07/24/97
battery.packs: 000
battery.runtime: 2640
battery.runtime.low: 120
battery.voltage: 27.74
battery.voltage.nominal: 024
driver.name: apcsmart
driver.parameter.port: /dev/ttyS0
driver.version: 2.0.3
driver.version.internal: 1.99.7
input.frequency: 60.00
input.quality: FF
input.sensitivity: H
input.transfer.high: 132
input.transfer.low: 103
input.transfer.reason: S
input.voltage: 119.6
input.voltage.maximum: 120.2
input.voltage.minimum: 119.6
output.voltage: 119.6
output.voltage.target.battery: 115
ups.delay.shutdown: 020
ups.delay.start: 000
ups.firmware: 60.9.D
ups.id: UPS_IDEN
ups.load: 033.2
ups.mfr: APC
ups.mfr.date: 07/24/97
ups.model: SMART-UPS 1000
ups.serial: WS9730021313
ups.status: OL
ups.temperature: 029.7
ups.test.interval: 0
ups.test.result: NO
root@ubuntusrv:/etc# upsc ups1@localhost
battery.alarm.threshold: 0
battery.charge: 100.0
battery.charge.restart: 00
battery.date: 07/24/97
battery.packs: 000
battery.runtime: 2700
battery.runtime.low: 120
battery.voltage: 27.74
battery.voltage.nominal: 024
driver.name: apcsmart
driver.parameter.port: /dev/ttyS0
driver.version: 2.0.3
driver.version.internal: 1.99.7
input.frequency: 60.00
input.quality: FF
input.sensitivity: H
input.transfer.high: 132
input.transfer.low: 103
input.transfer.reason: S
input.voltage: 120.2
input.voltage.maximum: 120.2
input.voltage.minimum: 119.6
output.voltage: 120.2
output.voltage.target.battery: 115
ups.delay.shutdown: 020
ups.delay.start: 000
ups.firmware: 60.9.D
ups.id: UPS_IDEN
ups.load: 033.2
ups.mfr: APC
ups.mfr.date: 07/24/97
ups.model: SMART-UPS 1000
ups.serial: WS9730021313
ups.status: OL
ups.temperature: 029.7
ups.test.interval: 0
ups.test.result: NO

Another test: Push and hold the test button on the smartups, or briefly unplug the ups from the wall. You should see messages pop up in the terminal window:

Broadcast Message from nut@ubuntusrv
(somewhere) at 13:58 …

UPS ups1@localhost on battery

Broadcast Message from nut@ubuntusrv
(somewhere) at 13:58 …

UPS ups1@localhost on line power

It is working!

To add a windows client, download and install WinNUT.

At the configuration tool,you can leave everything at the defaults. All you need to do is edit the configuration file. (Click the Edit button to the right of the Configuration File Path).

Enter the same line as in upsmon.conf, changing localhost to the actual IP address of the ubuntu machine, and use ‘slave’ instead of ‘master’:

MONITOR ups1@10.0.1.105 1 monuser changeme slave

(replace changeme with the good password you used in step 4)

You should be good to go.

Categories: DIY, Software, ubuntu

Trunking two trixbox servers to solve zap problems

September 20, 2006 Leave a comment

Updating trixbox (asterisk and/or zaptel) can be like rolling the dice when it comes to zaptel (Digium) cards. What was flawless operation in one version can be totally broken in a new one, with little or no warning. I got burned one time too many with the 1.2 update. There was suddenly horrendous echo that simply would not go away on my TDM400 FXO ports. I considered scrapping the thing and getting another type of FXO solution, but then decided to solve it with what I had on hand:

1) A new VMWare server (now Server1 – Production)
2) A clunky PC and a TDM400 card (now Server2 – Zap Server)

What I did was install a fresh new version of AsteriskAtHome 2.8 on the clunker with the TDM card in it. The PC is an old 500MHz Pentium III with an intel motherboard. I turned off all the other built-in devices on the motherboard, popped 384 MB of RAM, the TDM-400 card and a 15 GB HD drive in it.

I copied my old configuration (less the zap extensions) to a fresh install of 1.2 with updated versions of zaptel and asterisk on the VMWare server.

The beautiful thing about using VMWare is you can take snapshots of a known good configuration, and easily upgrade, back up, or move the system. It is very easy to add or copy additional development or testing servers as well.

The trick I used to get inbound calls from the PSTN  immediately transferred from Server2 to Server1 is made up of two parts:

1) Change the feature code on Server1 for simulating an inbound call from 7777 to another number. I chose 250.

2) Add two outbound routes on server 2 – one for local/emergency/toll free calls, and one for everything else. The first route goes out over the Zap FXO channels, and the other is routed to Server1 using the method I described earlier. Add a Misc Destination for Inbound calls that dials 250.Add an inbound Route for any DID/CID that goes to the Inbound Calls destination.

If you have any zap FXS channels you need to add Misc Destinations for them on Server1, and add them to the outbound route for Server2.

With this new configuration working smoothly, I still noticed some failed calls over the zap FXO channels. They were getting error messages from the CO that seemed to me that dialing was happening before the CO was ready. I added a 1 second pause manually into the dialplan in Extensions_Additional.config. I know full well it may get blown away if I monkey with FreePBX, but I don’t plan to. That’s the idea! I could have done this more simply with a minimal asterisk install, but I wanted to play around with different methods, and Trixbox/AAH allows for that. It ended up being pretty simple anyway. Now the zap channels are frozen in time on the Zap Server.
Here’s a chunk of that file as an example:

exten => _1888NXXXXXX,1,Set(EMERGENCYROUTE=YES)
exten => _1888NXXXXXX,n,Macro(dialout-trunk,2,ww${EXTEN},,)
exten => _1888NXXXXXX,n,Macro(dialout-trunk,3,ww${EXTEN},,)
exten => _1888NXXXXXX,n,Macro(outisbusy,)
exten => _NXXXXXX,1,Set(EMERGENCYROUTE=YES)
exten => _NXXXXXX,n,Macro(dialout-trunk,2,ww${EXTEN},,)
exten => _NXXXXXX,n,Macro(dialout-trunk,3,ww${EXTEN},,)
exten => _NXXXXXX,n,Macro(outisbusy,)
Each ‘w’ in a dial string is a half second pause.

Categories: Asterisk, DIY, networking, Software

Trixbox 1.1 on Via C3 Procedure

September 4, 2006 Leave a comment

You now have to jump through a few hoops to get Trixbox to install on a Via C3 (i586) platform. I developed this procedure and tested it with a Via Epia ME6000 600 MHz motherboard.

On my network I need to temporarily disable HAVP and Privoxy so that yum can function properly.

Boot from a Trixbox 1.1 CD
At the initial prompt, type:

i586 auto nofb

The following numbered lines are screens on the installer. (I had a mouse plugged in, so I got the graphical installer)

  1. Check media or skip, up to you
  2. NEXT
  3. English, NEXT
  4. US English, NEXT
  5. Custom NEXT
  6. Automatic partitioning NEXT
  7. Remove all partitions NEXT
  8. Yes
  9. NEXT
  10. NEXT
  11. Specify Network Settings (apache likes a FQDN), NEXT
  12. No firewall, SELinux Disables, NEXT, PROCEED
  13. NEXT
  14. Choose Time Zone, NEXT
  15. Enter root password twice, NEXT
  16. Uncheck everything but web server, NEXT
  17. NEXT
  18. Wait 10-15 minutes, remove CD and reboot

log in

/sbin/service httpd start

You should have a functioning CentOS 4.3 web server now.

Install prerequisites for trixbox:

yum -y install alsa-utils audiofile-devel bison cpp curl curl-devel cvs dhcp flex gcc gd glibc-devel glibc-headers glibc-kernheaders grub httpd kernel krb5-devel libcap libpcap libtermcap-devel libtiff libtiff-devel libxml2 lm_sensors mc mkisofs mysql mysql-devel mysql-server ncurses-devel newt-devel ntp openssl096b openssl-devel perl perl-libwww-perl perl-DBD-MySQL perl-DBI perl-Net-DNS perl-suidperl perl-Time-HiRes perl-XML-Parser php php-mysql php-gd php-mbstring readline readline-devel sendmail-cf subversion system-config-date system-config-keyboard rpm-build slang-devel sox vsftpd zlib-devel kernel-devel

while it’s doing that you can do these things:

In another ssh session:

mkdir /var/trixbox_load

(copy over trixbox.tar.gz from Trixbox 1.1 CD to /var/trixbox_load – I used Fugu on my mac to do this)

cd /var/trixbox_load/

tar -zxvf trixbox.tar.gz

nano install_parts.sh

change:

if [ `uname -m` = i586 ]
then
echo “Looks like a i586 machine…”
rpm -iv $LOAD_LOC/rpms/zaptel-1.2.6-1.1104.i586.rpm
rpm -iv $LOAD_LOC/rpms/zaptel-modules-2.6.9-34.0.1.EL-1.2.6-1.1104.i586.rpm
else
rpm -iv $LOAD_LOC/rpms/zaptel-1.2.6-1.1104.i686.rpm
rpm -iv $LOAD_LOC/rpms/zaptel-modules-2.6.9-34.0.1.EL-1.2.6-1.1104.i686.rpm
fi

to

rpm -iv $LOAD_LOC/rpms/zaptel-1.2.6-1.1104.i586.rpm
rpm -iv $LOAD_LOC/rpms/zaptel-modules-2.6.9-34.0.1.EL-1.2.6-1.1104.i586.rpm

Ctrl-X, Y to save

Wait for other installations to finish before proceeding.

./install_parts.sh 2>&1 | tee -a /root/install_asterisk.log

it will reboot itself twice

trixbox-update.sh

trixbox-update.sh update

reboot
Categories: Asterisk, DIY, Software