Archive for the 'TIps and Tricks' Category

Managing Complex Configurations with XML ENTITY

Monday, May 13th, 2013

UPDATE: Alejandro discovered that this method doesn’t work if you use Scheduled Outages as the webUI will write back the file as a single one and not preserve the ENTITY imports.

While we have made some serious strides toward making the OpenNMS configuration more modular, from my own humble contribution of include files in eventconf.xml, to breaking up datacollection-config.xml and snmp-graph.properties, we still have some way to go to finish it for the rest of the application.

However, you can leverage a shortcut built into the XML standard to help manage files that can get complex. It allows you to import XML from one file to another.

It does have a limitation. Unlike the work we did with datacollection-config, etc., where we combined different parts of a configuration (generic resources, MIB object groups and system definitions) into separate files, this will only work if you can life whole sections out into other files.

One example would be the poller-configuration.xml file where you can remove entire sections. Here’s how you do it.

First, at the top of the file, you have to define the files you want to include:

<!DOCTYPE root [
  <!ENTITY pkg_Network-Connectivity SYSTEM "./etc/poller-configuration.d/pkg_Network-Connectivity.xml" >
  <!ENTITY pkg_StrafePing           SYSTEM "./etc/poller-configuration.d/pkg_strafePing.xml" >
  <!ENTITY pkg_Generic-Management   SYSTEM "./etc/poller-configuration.d/pkg_Generic-Management.xml" >
]>

This will create a reference to the particular files you want to include. Then, to use them, you simply reference them at the proper place in the file:

<poller-configuration threads="900"
                      serviceUnresponsiveEnabled="false"
                      xmlrpc="false"
                      pathOutageEnabled="true">
  <node-outage status="on" pollAllIfNoCriticalServiceDefined="true">
    <critical-service name="ICMP"/>
  </node-outage>

  <!-- Layer 3 network connectivity -->
  &pkg_Network-Connectivity;

   <!-- Layer 3 network diagnostics for jitter and latency -->
  &pkg_StrafePing;

  <!-- Monitor for management agents and remote administration -->
  &pkg_Generic-Management;

Note that the ENTITY definitions come before the start of the “normal” XML for the file, i.e. in front of the initial <poller-configuration> tag.

This can make the management of unwieldy files a little easier.

Again, this only works for code that you can lift out in its entirety. In the case of poller-configuration.xml we still put the <monitor> tags down at the bottom of the main file.

Ubuntu and the Huawei Mobile Broadband E173

Friday, May 10th, 2013

I was recently in Sweden where we are doing a large project that I one day hope to tell every one of my three readers about in detail, but for now suffice it to say that they will have lots and lots of bandwidth in the coming months. However, in the apartment where I stay when I am there, there is no broadband network access, so they loaned me a mobile broadband modem.

Since Ubuntu is my distro of choice and the modem, the Hauwei E173, is fairly old, I figured it would just be “plug and play”. Jeff, who also visits the client, uses Fedora and said he had no problems.

However, when I inserted the device, nothing happened, or at least nothing appeared to happen.

I did manage to get it working, somewhat, so I thought I’d share my experience in case it helps someone else.

Now, what is supposed to happen, I believe, is that the device should show up in Network Manager as a Mobile Broadband device. I could never get this to work. During my investigation I found out that when you initially plug in the device it is mounted as a USB hard drive, and a program called “usb_modeswitch” is supposed to change it to a modem. Most of the information I found on the web was on getting that to work, but after a lot of trial and error it appears that it is working – Network Manager is just not picking up the change.

The device appears like this:

Bus 003 Device 002: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800 (HSPA modem)

and dmesg shows the following output:

[ 4374.333592] usb 3-2: new high-speed USB device number 2 using xhci_hcd
[ 4374.354876] usbserial_generic 3-2:1.0: generic converter detected
[ 4374.355374] usb 3-2: generic converter now attached to ttyUSB0
[ 4374.355636] usbserial_generic 3-2:1.1: generic converter detected
[ 4374.355875] usb 3-2: generic converter now attached to ttyUSB1
[ 4374.362284] Initializing USB Mass Storage driver...
[ 4374.362498] usbcore: registered new interface driver usb-storage
[ 4374.362505] USB Mass Storage support registered.
[ 4375.436354] generic ttyUSB0: generic converter now disconnected from ttyUSB0
[ 4375.436478] usbserial_generic 3-2:1.0: device disconnected

So it looks like the device is attached as a usb-storage device and then disconnected.

How I managed to get it to work, somewhat, was to install the “wvdial” program. First, I created a file called /etc/wvdial.conf:

[Dialer defaults]
Modem = /dev/ttyUSB0

[Dialer telia]
Modem = /dev/ttyUSB0
Baud = 115200
Init2 = AT+CGDCONT=1,"IP","online.telia.se"
Phone = *99#
Username = *
Password = *
New PPPD = yes
Auto DNS = 1

[Dialer pin]
Modem = /dev/ttyUSB0
Baud = 115200
Init1 = AT+CPIN=xxxx

where “xxxx” is replaced with the PIN for the device, and now when I run “wvdial telia” I get the following output:

# wvdial telia
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CGDCONT=1,"IP","online.telia.se"
AT+CGDCONT=1,"IP","online.telia.se"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected.  Waiting for prompt.
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Fri May 10 07:43:25 2013
--> Pid of pppd: 887
--> Using interface ppp0
--> local  IP address 90.x.x.x
--> remote IP address 10.64.64.64
--> primary   DNS address 195.67.199.27
--> secondary DNS address 195.67.199.28

At this point, I can use Thunderbird for mail and Chrome/Firefox to browse the web. To stop the session I just hit ctrl-C in that window:

^CCaught signal 2:  Attempting to exit gracefully...
--> Terminating on signal 15
--> Connect time 42.0 minutes.
--> Disconnecting at Fri May 10 08:25:29 2013

Now certain programs, such as Empathy, that seem to check with Network Manager on whether or not there is a network connection, don’t work. But for the small amount of time I find myself in the apartment and in need of network access, it will do.

Hope this helps, and if anyone has suggestions on what I’ve done wrong with Network Manager, let me know. Note that I am running Ubuntu 12.04 LTS on my laptop – perhaps it works better with later versions.

Neat Trick: Holiday Notifications

Wednesday, June 29th, 2011

I got an interesting question from a support customer today. Due to the Fourth of July holiday this weekend, they wanted to send all notifications to the On Call destination path, but starting on Tuesday morning at midnight they wanted them to go back to normal.

I thought of an easy way to do this. Copy the notifications.xml file to notifications.normal.xml and to notifications.oncall.xml. Edit the latter file and change all of the <destinationPath> tags to point to the On Call path.

Since changes to the notifications.xml file do not require a restart, all they have to do is to set up a cron to copy the “oncall” version of the file to notifications.xml when the holiday starts, and another cron entry to copy the “normal” version back when the holiday ends.

Easy peasy.