Friday, June 20, 2014

Restore SMS Backup Plus to Messages on CM11 (KitKat 4.4.3)



As all tech husbands and partners know, it's in your best interests to make sure your better half's tech works correctly.

So, being that I had to move the wifey's phone to CM11 to make BLN work, I thought it would be a good move to put mine on CM11 as well (so that it can be the test monkey when I have to perform trial and error to make something work).

So - we're both merrily using our CM11 loaded devices when we realise we can't restore messages using good old SMS Backup+.

As it turns out, Google has changed the SMS database security on KitKat and by default SMS Backup+ won't be able to write correctly to the Messages database.

So, scouring the internet revealed a lot of people recommending "join the SMS Backup+ community on Google+ and then you'll be able to access the Beta program which will fix the issue".

Well, that beta program seems to no longer exist.

So, what do you do?

Head over to the play store and grab yourself a copy of AppOps.
Make sure you use the one with no space in the name.

This program allows you to change an applications permissions to ensure it will work correctly for you on KitKat.

Be aware that you will need root access on your phone (not an issue if you're on CyanogenMod as it has root automagically - even if you're on a stock ROM, rooting is sooo easy these days!).

As it turns out, SMS Backup+ isn't given the permissions it needs to do it's job properly on KitKat by default.

So, once installed, fire up AppOps and scroll over to Personal.
Select SMS Backup+ from the list and scroll down to Write SMS DB.

You will notice that by default this is set to Denied.

Set it to Allowed and kick off your SMS Backup+ restore again and you're back in business.


Samsung Galaxy S4 Mini (i9195) Back Light (BLN) - How to Make it Work



The time had finally come to replace the old faithful HTC Desire S (Saga) for the missus so after much looking around we landed on the Samsung Galaxy S4 Mini.

It ticks all the boxes for what we needed it to do but upon arrival we noticed it was missing one small but important feature we've taken for granted on every phone we've ever had between us (and yes - going back to our late 90's Nokia's as well!).

Believe it or not, the S4 mini doesn't include a notification LED.

Luckily, being an Android phone, there's always a way to fix things :)

To start the adventure, pretty much everything I read advised that BLN requires a patched kernel that has BLN support enabled.

So, wanting to stay on the stock ROM (touchwiz), I began the laborious task of finding a patched kernel that would work.

Amazingly, I found two!

There are two patched ROMs floating around. namely:
f4ktion_1.3.0-eur_lte-ML1
and
Vikinger-JB4.2-STOCK-eur_lte-18.01.2014

So, I gained root, installed CWM and flashed the kernel through CWM.

Then I installed BLN from Google Play which reported that the patched kernel was ok.

And....... Nothing.

Of note though, the Vikinger kernel absolutely kills your battery super fast.

So, at this stage, I thought ok, I'll downgrade the ROM to an ML1 ROM as that's what the patched f4ktion kernel was based on.

Still no dice.

At this point I arrived at the conclusion that (despite the odd person claiming they had BLN working on a touchwiz ROM but never replied to anyone that asked HOW?!) that the ROM itself must need to support for BLN as well.

As what is turning out to be a regular thing, I ended up finding out that CyanogenMod 11 has full kernel and ROM support for BLN included (when you install it the CM11 kernel will overwrite your existing one).

So, I headed over and grabbed the CM11 ROM from get.cm (the CM codename for the i9195 is serranoltexx), flashed it (don't forget Google Apps) , installed BLN and holy shit batman!
It works!

Being CyanogenMod, the ROM already includes root so there's one less thing to worry about :)

Interestingly, a CM11 ROM is about 200MB in size.
That's a bit better than the average 1.6GB Touchwiz ROM.

Now, for anyone who hasn't used a CyanogenMod ROM in a while, they've come a long way.
Apps are stable and all hardware works correctly on the 9195.

In addition, pretty much every little nicety that exists on Touchwiz is present on CM11 as well.
And if something's not there, you can be guaranteed there's an app or widget on the Play Store that will bring it back (we haven't found one yet).

The only problem I encountered on CM11 was restoring SMS's through SMS Backup +.
To fix this, check out my post Restore SMS Backup Plus to Messages on CM11 (KitKat 4.4.3).

So, there you have it.

Unless you're a lucky so and so who somehow manages to get BLN working on a Touchwiz ROM, as usual CyanogenMod is here to save the day :)

Enter the Chromecast

Tiny but huge.

Whether you're just after a device to wirelessly display your screen at a meeting or run your entire home media centre from your phone, the Chromecast dongle is your new best friend.

What is unique about the Chromecast that makes it special?

Two Words:
Cheap Convenience.

Need to show your mates a YouTube clip on the big screen? Just whip out your phone and Chromecast it.

Want to watch a video using your phone as the playback device?
Ezstream will take care of that.


Wednesday, June 18, 2014

Webview Netflow Reporter

Geesh things change quickly in IT.

I was blown away by Webview Netflow Reporter four weeks ago but I have found that it has issues with actually displaying interfaces that are receiving flows visible in the GUI.

The good news is that there is an even better pair of open source netflow collection and reporting tools called nfDump and NfSen that work together to collect netflow data, display whatever you wish to see in a GUI and supports alerting as well.

We've just run it up at work and it has now replaced our commercial platform from Fluke.

Read more about nfSen in this post.

Need a netflow reporting platform but got no budget?
Problem solved!

This product will collect, draw and drill down on conversations to help you determine what traffic is using your expensive WAN links.

To get started, you'll need to build yourself a Linux box of VM, enable the LAN interface etc. and make sure you've got a working internet connection.

First, grab yourself a download link for a copy of Webview Netflow Reporter from http://wvnetflow.sourceforge.net/#download


Substitute the link where the brackets are on the line below and copy and paste down to but not including the validation steps section (this script is an updated copy of that provided at http://wvnetflow.sourceforge.net/INSTALL.centos)

wget (get link to 1.0.7d)

cd ~

gunzip -c wvnetflow-1.07d.tar.gz | tar -xf -
cd ~/wvnetflow-1.07d


yum --assumeyes install rsyslog gcc byacc libtool make patch zlib-devel httpd rrdtool-perl perl-GD perl-Net-DNS



wget -O - http://cpanmin.us --no-check-certificate | perl - --self-upgrade

cpanm Net::SNMP Spreadsheet::WriteExcel Net::Patricia

cd ~/wvnetflow-1.07d

wget http://iweb.dl.sourceforge.net/project/wvnetflow/flowd-sequence/cweinhold-flowd-sequence.tar.gz
gunzip -c cweinhold-flowd-sequence.tar.gz | tar -xf -
cd cweinhold-flowd-sequence
./configure
make install
mkdir -p /var/empty/dev
groupadd _flowd
useradd -g _flowd -c "flowd privsep" -d /var/empty _flowd

cd ~/wvnetflow-1.07d

wget https://flow-tools.googlecode.com/files/flow-tools-0.68.5.1.tar.bz2
bzcat flow-tools-0.68.5.1.tar.bz2 | tar -xf -
cd flow-tools-0.68.5.1/
patch -p1 <../optional-accessories/flow-tools-patches/patch.flow-tools.scan-and-hash
CC='gcc -fPIC' ./configure
make
make install

cd lib

ln -s /usr/local/flow-tools/lib/libft.a libft.a
cd ../contrib
wget http://net.doit.wisc.edu/~plonka/Cflow/Cflow-1.053.tar.gz
gunzip -c Cflow-1.053.tar.gz | tar -xf -
cd Cflow-1.053
perl Makefile.PL
make
make test
make install

sed -i.bak -e '/GLOBAL DIRECTIVES/i $AddUnixListenSocket /var/empty/dev/log\n' /etc/rsyslog.conf


cat <<EOT >/etc/rsyslog.d/40-flowd.conf

\$umask 0000
\$FileCreateMode 0644

:programname, isequal, "flowd" /var/log/flowd

:programname, isequal, "flowd" ~
EOT


chcon -t etc_t /etc/init.d/rsyslog



service rsyslog restart


cd ~/wvnetflow-1.07d

mkdir -p /opt/netflow/tmp /opt/netflow/data /opt/netflow/cache /opt/netflow/capture /usr/local/webview
cp -Rp flowage www utils /usr/local/webview
cp etc/webview.conf /etc
chmod 777 /usr/local/webview/www/flow/graphs

chcon -t httpd_sys_script_exec_t /usr/local/webview/www/flow/*.cgi


cp etc/flowd-2055.conf /usr/local/etc/

cp etc/init.d/flowd-centos /etc/init.d/flowd
chmod 755 /etc/init.d/flowd
ln -s /etc/init.d/flowd /etc/init.d/flowd-2055
chkconfig --add flowd-2055
service flowd-2055 start

iptables -I INPUT -p udp --dport 2055 -j ACCEPT

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save

crontab -l > /tmp/newcron

cat <<EOT >>/tmp/newcron

0 * * * * /usr/local/webview/utils/flow-expire-perl -E 10G -e 9000 -w /opt/netflow/capture/2055


*/5 * * * * /usr/local/webview/utils/flowd2ft 2055 >> /var/log/flowd2ft-2055.log 2>&1


#*/5 * * * * perl /usr/local/webview/flowage/flowage.pl > /tmp/flowage.stdout 2> /tmp/flowage.stderr


0 0 * * * find /opt/netflow/capture -name 'summary-*' -mtime +14 -exec rm -f {} \;


0  2 * * * find /opt/netflow/capture -name '*.rrd' -mtime +30 -exec rm -f {} \;

15 2 * * * find /opt/netflow/capture -depth -type d -empty -exec rmdir {} \;

#*/15 * * * * /usr/local/webview/flowage/monitor/monFlows.pl >> /var/log/monFlows.log 2>&1


0 0 1 * * /usr/local/bin/sudo mv -f /var/log/flow-expire.log /var/log/flow-expire.old

0 0 1 * * /usr/local/bin/sudo mv -f /var/log/flowd2ft-2055.log /var/log/flowd2ft-2055.old
0 0 1 * * /usr/local/bin/sudo mv -f /var/log/monFlows.log /var/log/monFlows.old
EOT
crontab /tmp/newcron


sed -i.bak -e'/UserDir: The name/ i\

Alias /webview "/usr/local/webview/www"\
\
<Directory /usr/local/webview/www>\
    Options Indexes Includes FollowSymLinks ExecCGI\
    order allow,deny\
    SetEnv no-gzip 1\
    allow from all\
</Directory>\
\
AddHandler cgi-script .cgi\
' /etc/httpd/conf/httpd.conf

service httpd restart



####### validation steps ########


#Edit: /usr/local/webview/flowage/flowage.cfg

#to set SNMP Read String

# If running CentOS, disable SELinux
# http://www.cyberciti.biz/faq/howto-turn-off-selinux/

# check if flowd is running

ps -fC flowd 

# check that flows are being received

ls -lR /dev/shm/

# check that flow files are being moved to the capture directory

ls -lR /opt/netflow/capture/

# view iptables rule list -- make sure port 2055 is seeing traffic

iptables -L INPUT -v

# make sure web server is running

service httpd status

# once you're sure you have flow data in the capture directory, run one of the web scripts

wget -O - 'http://127.0.0.1/webview/flow/adhoc.cgi?quiet=1&test=1&output=ascii'

# if that looks works (you see some IP addresses in the output), run flowage once from the CLI

/usr/local/webview/flowage/flowage.pl

# if that looks good (you see flow files being processed and rrd files be created), then uncomment

# the */5 and */15 flowage crontab entrys and you're all set!
# nano /tmp/newcron

Sunday, June 8, 2014

Cacti - Let's Dance.

Ok - for a really long time people have been carrying on about Open Source network monitoring and how good it is bla bla bla.

Well, I've been around long enough to see that while Open Source apps have their place in an FCAPS management platform, there isn't an Open Source app that ticks all these boxes (ESPECIALLY from a network perspective).

Once you start digging, you'll notice that most Open Source "Network" monitoring and management apps should REALLY be called "Server" monitoring and management apps.

It really does shit me to tears how often the word "Network" is used to incorrectly describe anything else (servers, workstations, end user devices) simply because they connect to a network.

While there are a number of good commercial Network management applications out there (HP IMC, a handful from Manage Engine) and some bad ones (Cisco PRIME)...

Anyway, todays focus is on Cacti.

Cacti itself is a great graphing tool which is basically a modern day version of the venerable MRTG.

Cacti has one awesome feature though which is plugin support.

Add some plugins and all of a sudden you've got yourself threshold monitoring and alerting, live bandwidth monitoring and all sorts of goodness.

Now, Cacti is a bit of a bitch to install.

Thankfully, there's a really good guide / script that covers how to install cacti with all useful plugins over at:

http://networkstatic.net/cacti-network-management-installation-tutorial/

I used to have a modified version of the above links script in this post but honestly, save yourself a lot of time and pain and just download CactiEZ.


http://cactiez.cactiusers.org/

CactiEZ is a pre-rolled ISO where you basically install it on a VM, set a password and IP address, choose which plugins you wish to enable through the GUI and you're up and going.

I have Cacti running in a commercial environment running from the Cacti EZ installer and it just works.

In fact, it does everything our previous installation of PRTG did but has even more features.

Installation is a breeze.

Once you're at the first-time configuration GUI, my advice is to check all add-ons and plug-ins (except the Barracuda device plug-in unless you have a specific need for this) even if you don't need them straight away.

Now, before you start adding devices, here's a hot tip - CactiEZ has 1 minute averages configured out of the box.

Those who want / need this understand how important that is.

To enable 1 minute average reporting go to Console -> Templates -> Data Templates and select Interface - Traffic.

In the associated RRA's list select all and click save.


Now, speaking of adding devices, Cacti has an auto subnet discover feature (although it's somewhat hidden).

To enable it, go to Console -> Configuration -> Settings -> Misc and perform the following:

Under Discover -> Subnets to Scan enter your subnet information.
Next, configure your SNMP Communities string to the read-only string you've configured campus wide (right?) and set the discovery schedule to your desired interval.

Newly discovered devices will appear in the Devices area which you can then filter and begin monitoring.