May 282015
 

I recently saw a $5 NAS at my local MSY store. At first I couldn’t believe my eyes, $5 for a NAS?
Surely they were mistaken, and the price was just an error. But sure enough, it scanned as $5 and I was on my merry way shortly after I paid for it.

When I got home, I inspected my Cheap and Nasty find – a Ritmo branded external hard drive enclosure that could be connected via LAN or USB.
Ritmo CE-3590

The box tells me that it can Store and share files, has an intuitive “wed” (I think they mean web…) control interface, a heatsink to prevent the drive from overheating, can connect with both USB and Ethernet, fits any 3.5 inch hard disk, and has LED Status indicators.

Ritmo CE-3590 back

Let’s open the box shall we?

Contents of the box

Inside, you get:

  • The NAS itself
  • A yellow handled screw driver
  • 4 Hard drive screws
  • A short SATA Data cable
  • A short SATA Power cable
  • A standard kettle power cord
  • A 12V 3.5A power brick
  • An instruction manual
  • NAS Stand

Installing a hard drive is a simple matter of undoing the 4 screws on the blank side of the nas, undoing the 2 screws on the back side of the NAS, and then sliding out the side covers. On the side of the NAS are the mounting holes for the hard drive.
Uncovered NAS

It's flashing at me...
After installing the hard drive and re-installing the covers, I connected the NAS to my network, and to its power supply, plugged it in and powered it on. I was expecting a bang, but was (un?)pleasantly disappointed. The NAS boots up with some bright blue lights on the front to indicate that it is powered on and ready to service me.

I got the NAS IP address from my router, and logged onto the web interface.
I was greeted by something that looked like it was from 1999.
Wow. Much New

I skipped the installation wizard to jump straight into the guts of the NAS. On the left hand menu under System, I could set up the Web Admin username and password, set up the time of the NAS, and also set up some other options on the NAS itself.
System Menu

The Network Config menu let me set whether the NAS uses DHCP to get its IP address or I could set a static IP for the NAS. It also comes with a DHCP server and a Dynamic DNS client, however the client seems to only be for changeip.com.
Network Menu

The Share Manage menu lets me configure the Windows shares on the NAS. Since I don’t have many Windows machines, I haven’t set any shares up.
Share Menu

The UPNP server lets me set up where the DLNA server will get its media from. This seems to work well enough to stream SD content. Some HD Content seems to stream with a bit of jitter, but otherwise still watchable.
DLNA Menu

There’s also a FTP Server setup. This is what I’ve been using to get files on and off the NAS.
FTP Menu
Performance of the FTP server is rubbish, however for $5, what can you expect?
I tested the speed by copying a 100 megabyte file to and from my desktop computer.
I got a fairly constant 5 megabytes a second when I was copying to the NAS.
Copying from the NAS back to my computer was done at a slightly lower 3 megabytes a second.
CPU usage when copying to and from the NAS was quite high, which probably contributes to the low read/write speed.

Device Config lets you see how much space is used on the hard drive, what hard drive is in the NAS, and also allows you to eject the Hard drive…I guess that means that theoretically you could hot swap the drive ? I’m not sure yet.
Device Menu

The Downloader is the Bittorrent client. It seems to be included just so it can be advertised as a feature. The CPU on the NAS itself won’t be able to do more than 1 bittorrent download at a time. I added 2 torrents to the list and the CPU was pegged at 100% the whole time the 2 torrents were downloading.
Downloader Menu

The tools menu allowed me to reboot the NAS, update it (No idea where I would get firmware from), Reset it to factory defaults, and show the log file. My log file seems to only contain logs from the FTP server.
Tools Menu

For $5, this is a bargain, if the power supply holds up. There are features on the NAS that are actually useful, even though this NAS seems to be from 2010 judging from the firmware version. I’m using it to store some files that aren’t important enough to backup, but take enough space on my desktop to bother me. It takes a little while for the files to transfer, but once the files are there, the NAS is sitting there happily serving me the files when I need them.

The only feature lacking from this NAS is NFS support. If it had that then I’d be a happy camper, but even without NFS support, it serves its purpose of sharing out an old 200GB SATA drive that I had lying around doing nothing.

Tune in next week to see what else I can make this NAS do

Share
May 252015
 

For my current task at work – moving away from CA Spectrum to Zabbix – I’ve had to integrate NMIS with Zabbix for SMS alerting as we wanted all alerts to filter through Zabbix for easy tracking of SMSes, and also for the ServiceNow integration functions that I have built into my Zabbix instance.

To build the integration between NMIS and Zabbix, I had to create a custom script that NMIS would call which would then send an SNMP trap to Zabbix for processing.

On the Zabbix side, I needed to set up snmptt to process the traps so that Zabbix will recognise them as traps and action them as alerts.

The following sections will detail the bits I’ve setup to get this integration working

NMIS Configuration

NMIS Alert Script

This script is what NMIS calls when an alert is generated.

I’ve named this script “snmptrap.pm”, it’s based off the example script in / on the appliance.
If you name it something different, make sure you update the relevant lines in the script file.

package Notify::snmptrap; ## Update this if you change the name

require 5;

use strict;

use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);

use Exporter;
use JSON::XS;
use File::Path;
use Net::SNMP;

$VERSION = 1.00;

@ISA = qw(Exporter);

@EXPORT = qw(
snmptrap ## Update this if you change the name
);

@EXPORT_OK = qw( );

my $dir = "/tmp/customsnmptrap"; ## This is the log directory, and can also be changed

sub sendNotification {
my %arg = @_;
my $contact = $arg{contact};
my $event = $arg{event};
my $message = $arg{message};

my $trapdestination = "10.0.0.5"; ## This should be your Zabbix server IP Address
my $trapcommunity = "public"; # Use your community string here
my $oid = "1.3.6.1.4.1.4818.1"; # I've used the OPMANTEK MIB OID here, but you can use your own if you want

if ( not -d $dir ) {
my $permission = "0770";

my $umask = umask(0);
mkpath($dir,{verbose => 0, mode => oct($permission)});
umask($umask);
}

# add the time now to the event data.
$event->{time} = time;

$event->{email} = $contact->{Email};
$event->{mobile} = $contact->{Mobile};

my ($sess, $err) = Net::SNMP->session(
-hostname => $trapdestination,
-version => 1, #trap() requires v1
-port => 162
);

if (!defined $sess) {
print "Error connecting to target ". $trapdestination . ": ". $err;
next;
}

my @vars = qw();
my $varcounter = 1;

push (@vars, $oid . '.' . $varcounter);
push (@vars, OCTET_STRING);

# This is where you set up the variables for the SNMP Trap message
push (@vars,$event->{level}.' : '.$event->{node}.' : '.$event->{element}.' : '.$event->{event});

my $result = $sess->trap(
-varbindlist => \@vars,
-enterprise => $oid,
-specifictrap => 1,
);

if (! $result)
{
print "An error occurred sending the trap: " . $sess->error();
}

my $fcount = 1;
my $file ="$dir/$event->{startdate}-$fcount.json";
while ( -f $file ) {
++$fcount;
$file ="$dir/$event->{startdate}-$fcount.json";
}

my $mylog;
$mylog->{contact} = $contact;
$mylog->{event} = $event;
$mylog->{message} = $message;

open(LOG,">$file") or logMsg("ERROR, can not write to $file");
print LOG JSON::XS->new->pretty(1)->encode($mylog);
close LOG;
# good to set permissions on file.....
}
1;

NMIS Alert Configuration

Now NMIS needs to be setup to call the new snmptrap.pm script when an alert is generated.
To setup NMIS, you’ll need to locate the escalation that requires the SNMP trap.
Open the escalations table by going to Setup --> Emails, Notifications and Escalation.
In the escalation table, find the alert that you need SNMP traps for, and add this to the escalation level that requires traps –
snmptrap:Contact – Replace Contact with a contact in NMIS.

Zabbix Configuration

Once NMIS has been setup to send traps to the Zabbix server, some configuration needs to be done on the Zabbix side.

SNMPTT Configuration

You’ll need to set up SNMPTT to receive SNMP traps from the OID you’re using in the snmptrap script.
In this example, I’m just going to set up a catchall to catch the SNMP traps, however you can use SNMPTT to parse different traps and generate different alerts.

Create a file in /etc/snmp called snmptt.conf.catch
In that file, put the following lines in
EVENT general .* "SNMP Catchall" Normal
FORMAT ZBXTRAP $aA $ar

You’ll also need to modify /etc/snmp/snmptt.ini to add the newly created file to the snmptt_conf_files configuration variable.
This can be done by appending the path to the list like this –

snmptt_conf_files = < /etc/snmp/snmptt.conf.catch
END

If there are already lines there, then add the line to the block of text right before the last END

Zabbix Item Configuration

I've used the basic snmptrap.fallback method to catch all traps, but you can set up specific alerts in SNMPTT to generate different messages.
On the NMIS server, add an item of type SNMP Trap, and with a key of snmptrap.fallback.
This item will now get any SNMP traps from the Server, you can create a trigger if required to alarm on the SNMP traps, or just keep them for history.

Share
May 212015
 

One of the reason why I bought the IP camera in the first place was to replace a USB webcam that I was using to do some motion detection. The camera was plugged into a virtual machine and wasn’t very reliable so when I saw the IP Camera, it crossed my mind that it would be a nice cheap replacement for the webcam.

The first thing I needed to to do was configure the username and password on the IP Camera itself. This is to ensure that no one can log in to the webcam from the cloud service.

Configuring the IP Camera

I will be doing any setup for the IP Camera on the web interface as it’s a platform agnostic way of setting it up.
Log in to the camera by directing your browser to http://:99/ and entering your password.
The default credentials are “Admin” with a blank password.

Click on sign in on one of the modes, I’ve used the Chrome mode.
Menu

Click on the settings button in the bottom right hand corner, and then click on Users Settings in the right hand menu.
settings button
If you want to, you can change the name of the admin user here, I’ve set a password for my admin user here.
Click on Submit. The IP Camera will now reboot for the settings to take effect.

Configuring Motion

I’ll be using Motion for more than one device so I will configure it using separate configuration files for the camera in preparation for other cameras to also be added in. It’s possible to use a single configuration file if you want, but if there is a possibility of adding more cameras later on, it would be easier to start with multiple configuration files off the bat.

Configuring the Motion Daemon

There’s a few settings that I’ll be changing from the default Motion configuration.
First thing you should change is the line in /etc/default/motion. Change it to read from no to yes.

Next, we’ll have a look at motion.conf.
The following lines in there that I will be commenting out so that Motion doesn’t look for a local device. It’s possible that you don’t need to comment these line;s out, but I prefer to be thorough to ensure nothing unexpected happens.
videodevice /dev/video0
v4l2_palette 17
input -1
norm 0

There’s also a few lines you’ll need to update.
There are a couple of lines that set the resolution. By default, they are at 320 and 240.

width 320
height 240

Update these 2 lines to 640 and 480 like so

width 640
height 480

I’m also going to up the framerate from framerate 2 to framerate 30 to get some smoother video, Keep in mind that this is just a maximum framerate.

We’ll update the server options next so that you can access the control panel from another computer on the network.
There is a couple of lines like this –

stream_localhost on
webcontrol_localhost on

These needs to be changed to off like so –
stream_localhost off
webcontrol_localhost off

At the bottom of the configuration file, you will see some thread lines. We’ll need to uncomment one so we can put the settings for our first camera into one of the files.
From

; thread /etc/motion/thread1.conf

To

thread /etc/motion/thread1.conf

thread1.conf

If you’re only intending to use one camera then you don’t need to create this file, you’ll just need to do the following in the main motion.conf file.

In this file, we’ll need to set the URL for the camera itself.
Put this into a new file named /etc/motion/thread1.conf

netcam_url http://192.168.2.16:99/videostream.cgi?user="YOUR ADMIN USER HERE"&pwd="YOUR ADMIN PASSWORD HERE"

Replace the username and password with your own.
Save the file, and then you should be able to start motion with /etc/init.d/motion start
Then, using a player like VLC and browsing to the address of the computer running motion on port 8081 should get you a stream of the IP Camera.

Share
May 182015
 

One of my current projects at work is to build up Zabbix as an alerting solution.
This includes using Zabbix to raise incidents in ServiceNow for any alerts that come through.

Initially, I thought that I would need to do lots of scripting, but it turns out I only had to write a simple script to allow Zabbix to raise incidents in ServiceNow.
This was largely thanks to pre-built Python modules that the community have built to allow easy integrations, namely ZabbixAPI and Python-Servicenow.

These 2 libraries made integration easy because they allowed me to concentrate more on the code to join the 2 systems rather than having to figure out how to make them talk to Python, and then talk to each other.

The integration itself will take an alert that is generated by Zabbix and insert the data into ServiceNow as an incident.

Configuring Zabbix

  1. Copy the snippet at the bottom of this post into a file in /usr/lib/zabbix/alertscripts. I’ve named mine servicenowapi.py.
  2. Create a new Media Type.
    Create a new media type by going to Administration => Media types, and click on Create media type.
    Give the Media Type a name, select Script for the Type, and put in the name of the file. Using my example, it would be servicenowapi.py
  3. Assign the new Media Type to a user.
    The user’s “Send to” for the media type will define the assignment group in ServiceNow.
    Click on Administration => Users, select Users in the drop down on the top right, and click on a user. Once you’re in the user’s configuration page, click on the Media tab, and then click on ‘Add’.
    Select the new Media Type from the type drop down, and then enter in the ServiceNow Assignment Group in the ‘Send To’ box, and click ‘Add’.
  4. Create or modify an existing action to start sending incidents to ServiceNow.
    Click on Configuration => Actions, and open up an Action. Click on the Operations Tab, and click on “New”.
    Click on “Add” in the Send To Users section, and choose the user that has the ServiceNow Media type set up.
    Select the ServiceNow action in the “Send only to” box, and then click on the “Add” button to add the action to the list of actions.
    Once the action has been setup, click on Save.

Once the alert is all set up, whenever the alert is triggered, the script should log an incident directly into ServiceNow.

servicenowapi.py

The below code should be copied and pasted into a file to be used as the script for the Media Type.

#!/usr/bin/python
import zapi
import datetime
import sys
import urllib2
import os
import servicenow.Connection
import servicenow.ServiceNow

##
## I've used logging for my own setup, but I've commented it out so that it won't spam a log file unless you uncomment it.
## Just make sure the location that you're storing the logfile is writable by the zabbix user
## In this example, I've used /usr/lib/zabbix/logfiles but this could be anywhere writable by the zabbix user
#f = open('/usr/lib/zabbix/logfiles/snow.log','a')
#f.write('\n\nScript Start :: '+datetime.datetime.now().ctime()+'\n\n')
#f.write(','.join(sys.argv)+'\n')

## Zabbix Passes the details via command line arguments.
assignmentgroup = sys.argv[1]
description = sys.argv[2]
detail = sys.argv[3]

## Set Up your Zabbix details
zabbixsrv = "127.0.0.1"
zabbixun = "Admin"
zabbixpw = "zabbix"

## Set up your ServiceNow instance details
## For Dublin+ instances, connect using JSONv2, otherwise use JSON
username = "username"
password = "password"
instance = "instance"
api = "JSONv2"

## I've configured Zabbix to only pass the Event ID in the message body.
## If you want more detail in the body of the incident in ServiceNow, you'll need to make sure that eventid is parsed out of detail correctly.
eventid = detail

#f.write('trying to connect to servicenow\n')
try:
conn = servicenow.Connection.Auth(username=username,password=password,instance=instance, api=api)
except:
print "Error Connecting to ServiceNow\n"
#f.write("Error Connecting to ServiceNow\n")

#f.write('trying to create incident instance\n')
try:
inc = servicenow.ServiceNow.Incident(conn)
except:
print "Error creating incident instance\n"
#f.write("Error creating incident instance\n")

#f.write('trying to create new incident\n')

## This is where the fun starts.
## You'll need to set up the following section with the correct form fields, as well as the default values
try:
newinc = servicenow.ServiceNow.Incident.create(inc, { \
"short_description":description, \
"description":detail, \
"priority":"3", \
"u_requestor":"autoalert", \
"u_contact_type":"Auto Monitoring", \
"assignment_group": assignmentgroup})
#f.write("\n\n"+str(newinc)+"\n\n")
except Exception as e:
print "Error creating new incident in ServiceNow\n"
print str(e)
#f.write("Error creating new incident in ServiceNow\n")
#f.write(str(e)+"\n")

## This script will retrieve the new incident number from servicenow and put it back into zabbix as an acknowledgement
try:
newincno = newinc["records"][0]["number"]
except:
print "unable to retrieve new incident number\n"
#f.write("unable to retrieve new incident number\n")

zabbix = zapi.ZabbixAPI(url='http://'+zabbixsrv+'/zabbix',user=zabbixun,password=zabbixpw)
zabbix.login()
#f.write('Acknowledging event '+eventid+'\n')
zabbix.Event.acknowledge({'eventids':[eventid],'message':newincno})

#f.write('\n\nScript End :: '+datetime.datetime.now().ctime()+'\n\n')
#f.close()

Share
May 142015
 

The OfficeOne IP Camera that I recently reviewed has the ability to periodically upload files to an FTP server.

This post will be on how to configure the camera itself to upload to an FTP server, which is pretty straight forward. All of the configuration will be done through the web interface to ensure cross platform compatibility.
I’ll also go over some of the other options of the FTP uploads.

Configuring the FTP Settings

  1. Navigate to your Webcam’s IP address. You can find this easily through the Search Tool if you’re using Windows. I believe OSX may have one on the application CD as well, however I don’t have a OSX device to test with.
  2. Login with your admin credentials…You’ve changed them, right ?!!?
  3. Click on FTP Service Settings
  4. Enter in your FTP server IP Address, and FTP Username and password.
  5. Click on Submit
  6. Click on Test to make sure that you get a Test ... Succeed message

If you don’t get a Test ... Succeed then try to access the ftp server with a client like FileZilla to make sure that the FTP server is running properly. It’s also a good idea to test that the user that you’re setting up can upload to the FTP server with FileZilla.

Uploading Continously

Once the FTP settings are set up correctly, you can set up the interval that the camera will wait between sending an image to the FTP Server.
This will continuously upload pictures to the FTP server so you can see any activity that’s happened regardless of motion being detected or not.
Setting the interval for 1 second results in approximately 3 Megabytes of images each minute.

Uploading only when a motion alarm is triggered

To set the camera up to upload only when motion is detected, you’ll need to set it up in the Alarm Service Settings.
In the Alarm Service Settings, tick the Upload Image on Alarm box, and then enter in an interval that the camera will upload to the FTP Server.
You will also need to select the times that the motion detection will be activated. In this screenshot, I have selected all the times so it will always upload to the FTP server.
Alarm Service Settings

To also get Video recordings uploaded, tick the After recording (FTP / SD card) Alarm box. However the video is in a .h260 format which I have not worked out how to view outside of the cam’s built in viewers just yet.

That’s It!

That pretty much covers the options of FTP Uploading from these cameras. Just simple images and/or videos from the cam itself to the FTP server. An SD Card is not required for this function to work either so you could potentially have a NAS to record everything the IP Cam sees if required.
If there’s anything I missed, feel free to drop me a comment and I’ll try to cover it in future posts.

Share
May 112015
 

I never noticed this before since I didn’t use Zabbix for production monitoring, but Zabbix out of the box does not have any alerts set up to tell you that an SNMP agent is unresponsive.
This isn’t an issue if you’re doing monitoring using the Zabbix Agent, or just monitoring server ups and downs, but when you’re using Zabbix to gather metrics such as CPU and Memory usage, this can become an issue.

The solution is to create a trigger for SNMP hosts to alert when Zabbix does not get any data for more than a certain amount of time.

Creating the trigger

I’ve chosen to create the trigger on the Template SNMP Generic template so that all SNMP devices will get this trigger.
To create the trigger, click on Configuration ==> Templates, and then find Template SNMP Generic. To the right, click on Triggers
Once the Triggers page has loaded, click on Create Trigger in the top right.
Give the trigger a name, and use the following Expression {Template SNMP Generic:sysUpTime.nodata(5m)}=1
Trigger Configuration
Optionally, give it a Description, and then set the Severity of the alert that you want to generate, and then click on Add.

The trigger should then apply to any devices that are linked to the Template SNMP Generic template.

Share
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 ethernet 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.

Share
Apr 272015
 

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

Share
Apr 222015
 

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

Share