May 062015
 

box_1
I spotted these Plug and Play IP Cameras (IP900) at K-Mart for $30 a pop, so decided to grab a few to see what they are like.

A quick look at the box reveals the following about the camera –

  • Allows for Live Viewing and Remote Recording
  • Motion Detection and Tilt Rotation Capability
  • Two-way Audio, with a Built-in Microphone, Speaker, and Talk-back Function
  • View Footage Via Free Smartphone App
  • The Plug and Play IP Security Camera Aims to Reduce the Likelihood of Theft
  • Live Viewing and Remote Recording is a Convenient Way to Protect your Property and Loved Ones

When I opened the box, I found –

  • The Camera itself
  • A 5V 2A power supply with 100CM cable
  • A 90CM cable
  • An application CD
  • A mounting bracket with screws
  • Instruction booklets
    Contents

On first appearances, they look like FOSCAM FI8918W clones.

According to the Quick Start Booklet, the specifications of the camera are:

  • CMOS sensor with a 3.6mm Lens
  • 802.11 b/g/n WiFi
  • 355′ Pan Angle
  • 90′ Tilt Angle
  • IR Distance of up to 10 metres
  • MicroSD Card up to 32GB

Setup is very easy, just need to plug the power suppply into the camera and hook up the network cable from the camera to your router.
Once the camera has finished booting up, you can run the Search tool from the application CD to start setting up the camera.

When you start the Search Tool, it will scan your network for your cameras, and display them in the Cameras box.
As you can see, I currently have 3 cameras on my network. Clicking on one of them in the Cameras box will bring up the details in the Information box on the right.
IP Cam Search Tool

Clicking on Open on the bottom right will open up the web inteface for the Web Cam. The default username is admin with no password. After logging in, you will be presented with this page.
web1
If you want to use the IE controls, you’ll need to install the oPlayer file from the Application CD.

Compared to the “Server Push Mode” controls, The IE controls gives you a few more options to control the camera like Frame Rate (from 1-30 fps), Enabling/Disabling the OSD, and being able to take videos, pictures, control the IR LED and flashing green Signal Lamp on the front, and listen to what the camera is hearing. You can switch the resolution between 640×480 and 320×240 on this screen too.
Differences between controls

Clicking on the “Tools” button on the bottom brings up the control panel on the web interface where you can set up the date and time, change the admin username and password (which you should do right away!), set up the WiFi capability and network settings of the Cam, as well as the email alerting, and motion detection settings.
All of these settings can also be managed from the PC IE View application on the Application CD.
Web Control Panel

Remote access is provided through a “cloud” provider – hence the need to change the username and password.
Once you’ve downloaded the Android app p2pipc, you can use it to search for cameras by tapping the “Tap here to add camera”, and then tapping “Search”. As long as you’re on the same network as the camera, the app will display the cameras that are on the network and allow you to add them to the app. Once the cameras are added to the app, you will be able to access the cameras as long as the camera can connect to the internet.

The quality of the snapshots are fairly clear in both day light and low light. You could easily make a face out from ~7 meters, which should be fine for an indoor camera.

Conclusion?

These cameras are great value for $30, allowing for eyes and ears while you’re away from the home. The resolution is only 640×480 but there’s still enough detail to make out faces in the event of something happening. You can take photos on the mobile app if need be, and can also do motion recording and set the camera up to email you if there’s any motion occurring in view of the camera. Recording to SD card is also supported, however I have not had the chance to try that out yet. If there’s enough interest in this post, perhaps I will blog my results with this camera.

Share
May 042015
 

I’ve had some issues with some of my VMWare guests crashing for some odd reason.
The guests were my pfSense routers, so when they crashed, the house lost internet which was causing some issues as you could imagine!

Since I couldn’t work out why the guests kept crashing at first, I configured Zabbix to just reboot the virtual machines each time they went down so that the internet connectivity would be restored automatically. This meant that the emails that told me that my routers had crashed would actually be sent so that I would know that my internet had a hiccup, and for me to check to make sure any downloads I had running either finished properly, or that I had to redownload.

Zabbix has the ability to run remote commands on hosts via SSH, and my VMWare hosts had SSH enabled so I could run commands that I needed to reboot the hosts when the hosts went down.

Finding the VM

First thing I needed to do was to find the ID of the VM that I needed to reboot.
To get those, I needed to SSH onto my VM host and run the command vim-cmd vmsvc/getallvms | grep pfsense-2 which outputs this –
70 pfsense-2 [vmhost-500gb] pfsense-2/pfsense-2.vmx freebsd64Guest vmx-08 pfSense backup node
This command gave me the ID of 70 that I needed to use to reboot the VM from the command line.

Configuring the Zabbix Action

In order to run a command when a host went down, I created a new action to be run when a certain host goes down.
I used the following 3 conditions –
(A) Trigger value = PROBLEM
(B) Trigger = Template ICMP Ping: Template ICMP Ping is unavailable by ICMP
(C) Host = pfsense-2

This would make sure that the actions that run are only for the host that I have the ID for

In the Operations section of the action, I created a new step with the following settings –

Operation Type: Remote Command
Target : vmhost
Type : SSH
Username : root
Password : password
Port : 22
Commands : /bin/vim-cmd vmsvc/power.off 70 && /bin/vim-cmd vmsvc/power.on 70

The commands that I have used instructs VMWare to forcefully power off the VM with an ID of 70 – which in this case is my pfsense-2 guest, and then power it back on.

This was done on an ESX 5.1 host, but should work on anything newer as long as SSH is enabled.

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Apr 272015
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

My Mobile Phone provider sends me bills via email which is all good and dandy, but for some odd reason the email addresses that the bills are sent from are never the same.
They change the number on the end like this –

billing2@online2.provider.com
billing3@online3.provider.com
billing4@online4.provider.com

This makes GMail’s filtering useless as it cannot filter by only domain, or so I thought.

After some Googling, I found out that you can actually use the following RegEx in the GMail search bar to search via domain of the email sender – (online2|online3|online4).provider.com

Using the RegEx, I got all the emails from *@online.provider.com, which means that I can now automatically label all the emails that come from my Mobile Phone provider using a filter, or so I hope.
I’ve set up the filter now, just waiting on a bill to come through so I can verify that it works :)

Edit:
Updated the example to a better example, and This is what I found in case anyone was wondering

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Apr 222015
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

I’ve wanted to get some temperature stats for some of my boxes for a while now to replace my aging Cacti install.
Since I already had Zabbix, that was the first place I looked for the functionality, however it does not have any templates set up out of the box, so I decided to set up my own templates for Temperature monitoring via SNMP.

I’m using Zabbix 2.2 at the moment, but the instructions should be applicable to 2.4 as well.
I’m using the Linux SNMP agent to get the temperature stats – the relevant packages on Debian are snmpd and lm-sensors.

First Things first

We need to install the snmp daemon if not already installed – apt-get install snmpd lm-sensors
After installing those the snmp daemon and lm-sensors, you may need to run sensors-detect to make sure the sensors are configured correctly.

Once the snmp daemon and lm-sensors is configured, running a snmpwalk for temperatures should result in something like this –

user@debian:~$ snmpwalk -v 2c -c public 127.0.0.1 1.3.6.1.4.1.2021.13.16.2
iso.3.6.1.4.1.2021.13.16.2.1.1.1 = INTEGER: 1
iso.3.6.1.4.1.2021.13.16.2.1.1.2 = INTEGER: 2
iso.3.6.1.4.1.2021.13.16.2.1.1.16 = INTEGER: 16
iso.3.6.1.4.1.2021.13.16.2.1.1.17 = INTEGER: 17
iso.3.6.1.4.1.2021.13.16.2.1.1.18 = INTEGER: 18
iso.3.6.1.4.1.2021.13.16.2.1.2.1 = STRING: "Core 0"
iso.3.6.1.4.1.2021.13.16.2.1.2.2 = STRING: "Core 1"
iso.3.6.1.4.1.2021.13.16.2.1.2.16 = STRING: "temp1"
iso.3.6.1.4.1.2021.13.16.2.1.2.17 = STRING: "temp2"
iso.3.6.1.4.1.2021.13.16.2.1.2.18 = STRING: "temp3"
iso.3.6.1.4.1.2021.13.16.2.1.3.1 = Gauge32: 39000
iso.3.6.1.4.1.2021.13.16.2.1.3.2 = Gauge32: 36000
iso.3.6.1.4.1.2021.13.16.2.1.3.16 = Gauge32: 39000
iso.3.6.1.4.1.2021.13.16.2.1.3.17 = Gauge32: 42000
iso.3.6.1.4.1.2021.13.16.2.1.3.18 = Gauge32: 4294965296

It looks like gibberish at a glance, but it’s actually telling us that it can detect 5 sensors.
The top 5 lines – the ones that have INTEGER are the identifiers for the sensors,
The next 5 lines – the ones that have STRING are the names of the sensors,
and the last 5 lines are the values of the sensors to 3 decimal places, just without the actual decimal point.

So that’s the Linux part all set up. On to Zabbix…

Zabbix Configuration

Regex

First up, we need to setup a RegEx to catch the sensors we want to monitor. In my case, I wanted to monitor all of them so I used the following regex which I named Sensors for Discovery –
^(temp[0-9]*|Core [0-9]*)$
The RegEx configuration is located in the Admin Tab, then drop down the menu on the right to get to “Regular expressions”

Template

Once that is done, we’ll need to create a new template. I’ve called mine “Template SNMP Sensors” and added it into the group “Templates”.
Create a new Discovery rule on the Template with the following settings
discovery rule

I’ve used {#SNMPVALUE} for the Macro, and @Sensors for Discovery for the Regexp.
You can use any value for the Key, that is a value internal to Zabbix.
And to save you some typing, the SNMP OID that is in the image is .1.3.6.1.4.1.2021.13.16.2.1.2

Item Prototype

Once the Discovery Rule is setup, you will need to create an Item prototype.
Here’s one I prepared earlier
item prototype

Again, the Key is internal to Zabbix, however the [{#SNMPVALUE}] is essential.
And again, here’s the SNMP OID to save some typing – .1.3.6.1.4.1.2021.13.16.2.1.3.{#SNMPINDEX}

Apply the Template

Once the Discovery and Item Prototype is setup, you’ll need to apply the template to a server in order for Zabbix to discover the sensors.
Once the sensors are discovered, they should show up in latest data with some values. The discovery itself may take a while unless you adjust the Interval on the Discovery Rule in the Template.
latest data

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Apr 162015
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

I’ve been setting up SNMP Traps on Zabbix 2.4 to replace our current in place monitoring solution.
One of the hurdles that I’ve come across is trying to get all the traps setup.

An easy way of doing this is getting the MIB files for the traps that you’re getting, and converting them into configuration files for SNMPTT to use to parse the traps.
The snmpttconvertmib command will take a MIB file as an input, and spit out a configuration file suitable for SNMPTT.
Using an Oracle MIB file as an example –

snmpttconvertmib --in=ORACLE-ENTERPRISE-MANAGER-4-MIB.mib --out=/etc/snmp/snmptt.conf.ora-em4

This will produce a file for SNMPTT but Zabbix will not parse the traps yet as the FORMAT line isn’t quite what we need yet.
Next, we’ll use sed to do a global search and replace to make sure the FORMAT lines conform to the format that Zabbix requires.

sed -i 's/FORMAT/FORMAT ZBXTRAP $aA/g' /etc/snmp/snmptt.conf.ora-em4

The configuration file then needs to be added to the list of files that SNMPTT uses to parse the traps.
Open /etc/snmp/snmptt.ini file – assuming it’s in the default location – and scroll right down to the bottom of the file.
You will see the following lines –

snmptt_conf_files = < /etc/snmp/snmptt.conf

Add the file you've just created to the end like so -

snmptt_conf_files = < /etc/snmp/snmptt.conf
/etc/snmp/snmptt.conf.ora-em4

And you should start getting SNMP traps appearing in Zabbix - assuming you've already set up the item.

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Dec 222014
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

I recently had some issues with my single pfSense VM crashing, bringing down the whole entire network with it.

I thought the problem was flakey hardware, so I setup a second pfSense VM…and that crashed too.
So I decided to setup pfSense in high availability mode with CARP. The only problem there being that I’m on ADSL, with a single modem to share between 2 pfSense servers.

After I followed the CARP Guide from pfSense, I’d end up with 2 PPPoE sessions open. One from each pfSense server.

The solution to that was to change the WAN interface configuration on the backup CARP node to be a dial-on-demand configuration, and by disabling apinger by disabling Gateway Monitoring. With this configuration, since the backup node has no traffic directed at it, the WAN link stays down until the primary CARP node goes down. Then, the backup node will establish a PPPoE session to the internet.

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Dec 112014
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

I’ve had to calculate working time between 2 dates as part of a dashboarding project.
As a result, I’ve built a function to do this for me.

First though I needed the public holidays to make sure that public holidays weren’t counted.
As an example, I’ve only used a couple of days, formatted like ’24-04′.
I’ve stored this in an external php file called hols.php, however this can also be contained within the script.

$hols = array();

$hols[] = date("d-m",strtotime("last friday",easter_date())); // easter friday
$hols[] = date("d-m",strtotime("next monday",easter_date())); // easter monday;
?>

Then for the main function. This takes 2 dateTime objects to compare. If the start is after the end, then it will return 0.


function work_minutes($dtStart,$dtEnd) {
if($dtStart > $dtEnd) {
return 0;
}
include('hols.php');

$di1Day = new DateInterval('P1D');
$workStartHour = 7; // When the work day starts
$workEndHour = 17; // When the work day ends
$workMinutes = 0; // Initialise the running counter that keeps tracks of the minutes of working time

$diffDays = $dtStart->diff($dtEnd)->format("%a"); // Get the number of days between the 2 timestamps, and add a day to ensure that all the days are checked.

for($x = 0; $x <= $diffDays+1; $x++) {
if($dtStart->format('N') < 6) { // checks that it's on a monday-friday
if(!in_array($dtStart->format('d-m'),$hols)) { // checks that it's not a public holiday

// Create a couple of new DateTime objects to define the start and end of
// the working day. These will be used to compare against when looping
// through each day to calculate the working minutes.

$dtStartOfDay = new DateTime($dtStart->format('Y-m-d').' '.$workStartHour.':00:00');
$dtEndOfDay = new DateTime($dtStart->format('Y-m-d').' '.$workEndHour.':00:00');
$signStart = '';
$signEnd = '';

// Compare the start of the day, if the starting DateTime Object is before the start of the working day, then the script will calculate the working time from
// the start of the day rather than the starting DateTime Object as any time before the start of the working day is irrelevant.
// The end DateTime objects are compared in a similar way. If the end DateTime object is before the end of the working day, that is used to compare, otherwise
// the end of the day is used to compare.

if($dtStartOfDay >= $dtStart) {
if($dtEndOfDay <= $dtEnd){
$arrDiff = explode(' ',$dtStartOfDay->diff($dtEndOfDay)->format('%H %i));
$signStart = $dtStartOfDay->diff($dtEndOfDay)->format('%R');
} else {
$arrDiff = explode(' ',$dtStartOfDay->diff($dtEnd)->format('%H %i));
$signStart = $dtStartOfDay->diff($dtEnd)->format('%R');
}

// When the starting DateTime object provided is after the start of the working day, then that will be used to calculate working minutes.
} else {
if($dtEndOfDay <= $dtEnd){
$arrDiff = explode(' ',$dtStart->diff($dtEndOfDay)->format('%H %i));
$signEnd = $dtStart->diff($dtEndOfDay)->format('%R');
} else {
$arrDiff = explode(' ',$dtStart->diff($dtEnd)->format('%H %i));
$signEnd = $dtStart->diff($dtEnd)->format('%R');
}
}

// intDiff contains the amount of minutes that was calculated as the amount of time between the start DateTime/Start of the day and end DateTime/End of the day.
$intDiff = $arrDiff[0]*60+$arrDiff[1];
// if theres any negative values, e.g. Starting DateTime stamp was after the end DateTime, the value is ignored, otherwise it adds to the running tally.
if($signStart != '-' && $signEnd != '-') {
$workMinutes += $intDiff;
}
}
}
// Add a day, and loop again.
$dtStart->add($di1Day);
$dtStart->setTime($workStartHour,0);
}

return $workMinutes;
}

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Apr 302014
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

I have Spectrum integrated with Service Now in order to raise Incidents automatically when certain critical alerts come through on CA Spectrum

As a pre-requisite, Spectrum needs a user configured in Service Now with the ability to create records in the Incident table.

  1. Spectrum Configuration
  2. I have alarm notifiers setup to catch events that require an automated incident. The alarm notifier SetScript then calls a custom perl script in order to send the web services request to Service Now. The alarm notifiers are configured

    The SetScript has also been modified to parse out some extra parameters from the policy’s Notification Data. The notification data is accessed from the script through the variable “$NOTIFDATA”.
    I use a comma as a delimiter in the notification data to create fields, so the notification data within the policy looks like this

    Network Team,Network,Infrastructure

    The NOTIFDATA variable is expanded, and then assigned a variable inside the SetScript with the following bash script snippet

    declare -a ENOTIFDATA
    OldIFS=$IFS
    IFS=','
    for x in $NOTIFDATA; do
    ENOTIFDATA=( "${ENOTIFDATA[@]}" "$x" )
    done

    AssignmentGroup=${ENOTIFDATA[0]}
    Category=${ENOTIFDATA[1]}
    SubCat=${ENOTIFDATA[2]}

    The SetScript then calls the Perl script with some arguments. The perl script will make the calls to Service Now.

    $SPECROOT/custom/scripts/SNow/RaiseInc.pl $AID "$AssignmentGroup" "Autogenerated - A $SEV alarm has occurred on $MNAME" "$EVENTMSG" "$Category" "$SubCat" "$SEV"

  3. Perl Script
  4. The Perl script is built from examples available from ServiceNow.

    The following example will need to be modified to suit your environment – specifically the parameters as different organisations will have different configurations for ServiceNow.

    #!/usr/bin/perl

    #use lib '/usr/lib/perl5/custom';

    # declare usage of SOAP::Lite

    use SOAP::Lite;
    use feature 'switch';

    # specifying this subroutine, causes basic auth to use
    # its credentials when challenged
    sub SOAP::Transport::HTTP::Client::get_basic_credentials {
    # login as the itil user

    return 'spectrum_user' => 'spectrum_password';
    }

    # declare the SOAP endpoint here
    my $soap = SOAP::Lite
    -> proxy('https://instance.service-now.com/incident.do?SOAP');

    # calling the insert function
    my $method = SOAP::Data->name('insert')
    ->attr({xmlns => 'http://www.service-now.com/'});

    # create a new incident with the following short_description and category
    my @params = ( SOAP::Data->name(short_description => $ARGV[2]) );
    push(@params, SOAP::Data->name(u_requestor => 'Spectrum 9.3') );
    push(@params, SOAP::Data->name(contact_type => 'Auto Monitoring') );
    push(@params, SOAP::Data->name(description => $ARGV[3]) );
    push(@params, SOAP::Data->name(u_business_service => $ARGV[4]) );
    push(@params, SOAP::Data->name(assignment_group => $ARGV[1] ) );

    given ($ARGV[6]) {
    when ("MINOR") {
    push(@params, SOAP::Data->name(urgency => '3') );
    }
    when ("MAJOR") {
    push(@params, SOAP::Data->name(urgency => '3') );
    }
    when ("CRITICAL") {
    push(@params, SOAP::Data->name(urgency => '3') );
    }
    default {
    push(@params, SOAP::Data->name(urgency => '3') );
    }
    }

    # invoke the SOAP call
    my $result = $soap->call($method => @params);

    # print any SOAP faults that get returned
    print_fault($result);
    if ($result->fault) {
    exec 'echo Incident Raising Error. Please check spectrum logs | mail -h smtp.dmz.localnet -s "Issue Raising Incident" admin@example.com';
    }
    # print the SOAP response that get return
    print_result($result);

    # convenient subroutine for printing all results
    sub print_result {
    my ($result) = @_;
    }

    # convenient subroutine for printing all SOAP faults
    sub print_fault {
    my ($result) = @_;

    if ($result->fault) {
    print "faultcode=" . $result->fault->{'faultcode'} . "\n";
    print "faultstring=" . $result->fault->{'faultstring'} . "\n";
    print "detail=" . $result->fault->{'detail'} . "\n";
    }
    }


References
http://wiki.servicenow.com/index.php?title=Perl_Web_Services_Client_Examples

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Mar 102014
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

I’ve been trying to use Cacti to graph my ADSL’s Sync rate and SNR/Attenuation Ratios for the past few weeks as I’ve been having issues with my ADSL.

Originally, I was using a BigPond Thomson ST536v6, but unfortunately, the SNMP agent on the Thomson will only expose the Sync Rate, and not the SNR and Attenuation.

So I have decided to use an old SpeedStream 4200 instead. The default SNMP community string is ‘public’ but I wanted to change it to my private one.

To change the SNMP community string, you need to telnet onto the modem to change it.
telnet 192.168.254.254

Once you’ve telnetted in, you can show the current snmp settings with this command –
xsh> cfg snmp
The output will show you the current configuration.
snmp
comm#[0..6]
nam = ""
rd = n
wr = n
dsbl = n

These settings just mean that the default settings are applied.
To update the snmp community string, you need to use the following command –

cfg snmp{comm#0{nam=skynet
cfg snmp{comm#0{rd=y

Those 2 lines will set the community string to “skynet” and set the permissions to readonly.

After setting these, run the command cfg save to save the configuration, and then reboot the modem. This will allow the new settings to take affect.

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share
Dec 182013
 

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

In my recent FreeNAS blog post, I couldn’t access the FreeNAS web GUI with the Google Chrome Browser. Trying to access a page would present a 400 Bad Request - request header or cookie too large error.

After doing some research online, I found out that the way to solve this issue was to modify the nginx configuration to allow for large headers.

As this was FreeBSD, the configuration file for nginx was located at /etc/local/nginx/nginx.conf. In a Linux distribution, the file would likely be located in /etc/nginx/nginx.conf
In that file, we need to add this line within the server stanza.
large_client_header_buffers 4 16k;

I’ve modified my nginx.conf file so now it look like this –

<snip>
server {
server_name localhost;
listen 0.0.0.0:80;

large_client_header_buffers 4 16k;
<snip>

After modifying the configuration file, nginx needs to be restarted.
On FreeBSD, the command to restart nginx is /usr/local/etc/rc.d/nginx restart
On Linux, the command varies by distribution, but in general would be something like /etc/init.d/nginx restart

After restarting nginx, I was able to access the FreeNAS web interface with the Chrome Browser

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Share