monitor issues pt.2

This one doesn't look good. My main monitor, a SyncMaster 2493HM is idicating, that it is going to die soon, if I read the symptoms right. The last time a saw the power light rapidly blinking was here. I hope that I am able to repair it like my old one, too.

Update: Fixed link

2011/11/01 10:29 · Julian Knauer

Telephone fraud detection

Recently I received an email from a fellow student about a project in the media I was heavily involved. During this project my team and I worked for a small telecommunication company (www.toplink.de) in cooperation with the Hochschule Darmstadt to develop a solution to stop telephone fraud. Telecommunication fraud has become a serious problem for all providers and their customers and produce high costs. There are different types of fraud, e.g. compromised customer phone boxes to do calls to special telephone numbers. The problem with this is the customer has to pay for it even if it is not his fault and the provider needs to keep his customers happy. So there has to be a solution to detect those anomalies in calling behavior to react in a short-time and prevent further damage. The software we developed analyses the CDR1), which have to be logged by every provider. They contain alot of information about the caller and callee, e.g. duration, type of call termination, route, and a lot more. These are the data which were discussed to be saved by the german data retention law over a long time.

My part in this project was to write a parser to read the CDR into our system, so I wrote a framework to read and provide a plugin interface to analyse the data objects. Every CDR entry is transformed into a object for easier data handling during programming. With the plugin interface you can create a filter chain, where you can feed the result of one filter into another to work with. The main challange is how to analyse customers without storing too much information and without invading their privacy. With the capability to chain filters you can minimize the needed data to detect frauds. After I finished the framework my fellow students were able to write filters in Python. The simple plugin API and the object oriented aspect of the CDR I introduced, a easy and fast way to implement all kind of filter techniques is provided.

Press releases:

Update:

Update:

And again a publication in the media, this time it is availble as scanned page from a newspaper called “Wirtschaftsecho”2) Scanned page from Wirtschaftsecho (german).

2011/10/16 16:44 · Julian Knauer · 0 Comments

Automated Android SDCard Backup

Backstory

Recently my rooted3) HTC Desire decided to kill my SDCards. It is about a half a year now, when I rebooted my phone and the SDCard was unresponsive, even with a external card reader I wasn't able to get anything from this SDCard. My new SDCard now worked for the last half a year, when all of a sudden the card was recognized with errors and couldn't be mounted by my phone again. Luckily, this time I was able to backup the SDCard

    $ dd if=/dev/sdh of=htc-desire-sdcard-$(date +%s).dd
I than had testdisk4) do its magic and repair the image. I needed to rewrite the MBR and FAT of the image. Putting it back into my phone and booting it up, it did a fsck and than everything worked fine again. Until… a few days later… it broke again… and I needed to recover it again!

Backing Up!

So let's get to the part where I automated the backup process. I wanted to backup the contents every time I connect the phone via USB to my PC and the first option came to my mind was: udev. What I did first, I created a udev rule for the case I plug in the phone.

ACTION=="add", RUN+="/usr/local/sbin/htc-backup.sh", SUBSYSTEM=="usb", ATTR{product}=="Android Phone"
The above rule is very generic and would match any phone connected to my USB ports. But I kept it simple5) and it works for me. When the udev daemon loads the rule. It watches every device add event for the module USB, if there is a device with the product name “Android Phone”. If it matches any device it executes the script /usr/local/sbin/htc-backup.sh.
#!/bin/sh
 
/opt/android-sdk/platform-tools/adb pull /mnt/sdcard /var/backup/others/htc-desire/sdcard
To backup my SDCard I use the adb tool from the andoird-sdk, because I don't have to interact with my phone and enable the right USB mode and with the pull command it uses rsync to only copy the changes to the backup directory.

It is just a simple but effective solution, but if you have any suggestions how I could improve it to have my backup organized a little bit better. Please leave me a comment.

2011/09/22 11:23 · Julian Knauer

Cable modem stats

A while back now, I had the idea to write a tool to observe the status of my cable modem and came up with the following python script. It should work with the Scientific Atlanta cable modem, given to my by Unitymedia. It provides a system page, where no login credentials are required. The values read from the status page are stored in a rrd database and allows you to create nice graphs using rrdtool. I also prepared a little demo graph, where you can see, that I have been experiencing connection problems, by looking at the SNR6). You can also see, when they start fixing my port7). Modem stats

#!/usr/bin/env python
 
import urllib2
from BeautifulSoup import BeautifulSoup
from lxml import etree
from StringIO import StringIO
import sys, time
import rrdtool
import signal
 
# URL to the sytem status frame
URL = 'http://192.168.100.1/system.asp'
is_looping = False
 
def rrdNew(filename):
    ret = rrdtool.create(filename, "--step", "300", "--start", '0',
                     "DS:rpl:GAUGE:600:U:U",
                     "DS:tpl:GAUGE:600:U:U",
                     "DS:snr:GAUGE:600:U:U",
                     "RRA:MIN:0.5:1:600",
                     "RRA:MIN:0.5:6:700",
                     "RRA:MIN:0.5:24:775",
                     "RRA:MIN:0.5:288:797",
                     "RRA:AVERAGE:0.5:1:600",
                     "RRA:AVERAGE:0.5:6:700",
                     "RRA:AVERAGE:0.5:24:775",
                     "RRA:AVERAGE:0.5:288:797",
                     "RRA:MAX:0.5:1:600",
                     "RRA:MAX:0.5:6:700",
                     "RRA:MAX:0.5:24:775",
                     "RRA:MAX:0.5:444:797")
    if ret:
        print 'rrdNew:', rrdtool.error()
 
def rrdGraph(imgfile, rrdfile):
    print 're-generating graph...'
    rrdtool.graph(imgfile, "--start", "-1d", "--vertical-label=dBmV\dB",
              "--width", "600",
              "DEF:receive=%s:rpl:AVERAGE" %rrdfile,
              "DEF:transmit=%s:tpl:AVERAGE" %rrdfile,
              "DEF:signal=%s:snr:AVERAGE" %rrdfile,
              "AREA:receive#00FF00:Receive Power Level",
              "LINE1:transmit#0000FF:Transmit Power Level",
              "LINE1:signal#FF0000:Signal to Noise Ratio\\r",
              "CDEF:rpldbmv=receive,1,*",
              "CDEF:tpldbmv=transmit,1,*",
              "CDEF:snrdb=signal,1,*",
              "COMMENT:\\n",
              "GPRINT:rpldbmv:AVERAGE:Avg Receive Power Level\: %6.2lf dBmV",
              "GPRINT:rpldbmv:MAX:Max Receive Power Level\: %6.2lf dBmV\\r",
              "GPRINT:rpldbmv:MIN:Min Receive Power Level\: %6.2lf dBmV\\r",
              "COMMENT:\\n",
              "GPRINT:tpldbmv:AVERAGE:Avg Transmit Power Level\: %6.2lf dBmV",
              "GPRINT:tpldbmv:MAX:Max Transmit Power Level\: %6.2lf dBmV\\r",
              "GPRINT:tpldbmv:MIN:Min Transmit Power Level\: %6.2lf dBmV\\r",
              "COMMENT:\\n",
              "GPRINT:snrdb:AVERAGE:Avg Signal to Noise Level\: %6.2lf dB",
              "GPRINT:snrdb:MAX:Max Avg Signal to Noise Level\: %6.2lf dB\\r",
              "GPRINT:snrdb:MIN:Min Avg Signal to Noise Level\: %6.2lf dB\\r")
 
def rrdUpdate(rrdfile, data):
    print 'update data:', data
    ret = rrdtool.update(rrdfile, data)
    if ret:
        print 'rrdUpdate:', rrdtool.error()
 
def refresh():
    print 'refreshing...'
    try:
	page = urllib2.urlopen(URL)
    except:
        # Poor mans exception; no infos, just skip the processing
	print 'refresh aborted.'
	return
    soup = BeautifulSoup(page)
    # Remove   markups, because they break the XML parser.
    f = StringIO(str(soup.findAll('tbody')[0]).replace(' ', ''))
    dom = etree.parse(f)
    nodes = dom.xpath('//font')
    # We take every value we can get, but do not use them, yet
    modemvalues = []
    for i in xrange(0, len(nodes), 2):
        modemvalues.append((nodes[i].text, nodes[i+1].text.strip()))
    # Prepare the values and cut of the string at the end
    rpl = float(modemvalues[4][1].split(' ')[0]) # dBmV
    tpl = float(modemvalues[5][1].split(' ')[0]) # dBmV
    snr = float(modemvalues[6][1].split(' ')[0]) # dB
    rrdUpdate('modem.rrd', 'N:%f:%f:%f' %(rpl, tpl, snr))
 
def handler(signum, frame):
    global is_looping
    if signum == signal.SIGHUP:
        rrdGraph('modem.png', 'modem.rrd')
    elif signum == signal.SIGQUIT:
        print 'Graceful shutdown received. Please wait...'
        is_looping = False
    elif signum == signal.SIGUSR1:
        print 'Premature status update...'
        refresh()
 
if '-n' in sys.argv:
    print 'resetting database...'
    rrdNew('modem.rrd')
    sys.exit(0)
if '-g' in sys.argv:
    rrdGraph('modem.png', 'modem.rrd')
    sys.exit(0)
if '-l' in sys.argv:
    signal.signal(signal.SIGHUP, handler)
    signal.signal(signal.SIGQUIT, handler)
    signal.signal(signal.SIGUSR1, handler)
    print 'SIGHUP  handler registered: Will draw the graph when signaled.'
    print 'SIGQUIT handler registered: Graceful shutdown.'
    print 'SIGUSR1 handler registered: Force premature status update.'
    is_looping = True
    while is_looping:
        refresh()
        print 'Sleeping for 300 seconds...'
        time.sleep(300)
else:
    refresh()

Commandline switches:

./modemstatd.py -<Switch>

  Switch    Description
  ========= =================================================================
  -n        Create a new "modem.rrd" file. Overwrites the old one!
  -g        Render the graph and stores the image as "modem.png".
  -l        The script will loop and update the data every 300 seconds.

Signals (when looping):

kill -<SIGNAL> <pid>

  SIGNAL    Description
  ========= =================================================================
  HUP       Draws the graph and stores it as "modem.png".
  QUIT      Graceful shutdown, terminate the loop after the sleep finished.
  USR1      Premature update of modem status.

2011/03/10 11:36 · Julian Knauer

G15 NZBGet applet

About a year ago I've started a similar project for my G15 keyboard, but back than it was meant to communicate with hellaNZB. I never finished the project and it still lies dead within my Git Repository. The new project aims to control NZBGet, another NZB client. The result of my two days work can be viewed as screenshot or you can clone the repository found here: http://git.goatpr0n.de/g15nzbget/.

It's not fully functional so far, but it's about to become something. The main difficulty is to understand the xmlrpc-c documentation. IMHO it's bad, but I managed to get something out of it.

If you want to try it for your self, you have to satisfy the following requirements for the source to compile:

  1. create a config.h with the XMLRPC login credetials.
  2. get a copy of this code http://git.goatpr0n.de/libgc/ and place it under $g15nzbget_SOURCE_DIR/lib/libgc.
  3. to configure the project you need CMake.

Contents of config.h

#ifndef _CONFIG_H_
#define _CONFIG_H_

#define MAX_GROUP 200 // You don't need to change this

#define USERNAME "foobar"
#define PASSWORD "password"

#endif /* _CONFIG_H_ */

UPDATE: If created a wiki page for this project. It is linked g15nzbget and in the current HEAD of the source-tree there is no need to create a config.h on your own.

2010/09/16 21:42 · Julian Knauer

Older entries >>

Comments




If you can't read the letters on the image, download this .wav file to get them read to you.

Discussion

Enter your comment. Wiki syntax is allowed:
If you can't read the letters on the image, download this .wav file to get them read to you.
 
blog.txt · Last modified: 2010/02/02 17:56 by jpk
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0