Blog Archives

Siri – Controls My Car

Siri - Vehicle Start

Siri - Vehicle Start

Yes, it really does control my car! 😉

I created a new ruby plugin that is used by plamoni’s “Siri Proxy”, a proxy server for Apple’s Siri assistant. This proxy server allows for the creation of custom plugins that can intercept recognized speech and perform virtually any function imaginable (programmable, scriptable).

The “Siri Proxy” plugin I wrote handles interaction with a php script that runs on my web server. The php script, which I developed months ago for personal use, allows me to send commands to my car which has a Viper SmartStart module installed.

Current commands accepted are: “Vehicle Arm”, “Vehicle Disarm”, “Vehicle Start”, “Vehicle Stop”, “Vehicle Pop Trunk”, and “Vehicle Panic”.

–UPDATE: Now it also responds to more conversational commands such as “Start my car”, “Lock my car”, “Pop my trunk”, etc…

I may change the command wording a bit later.  This was just a proof of concept. We’ll see.

Technical Details:

  • Siri Proxy & DNSMasq box – Ubuntu 11.04 Server VM
    Ruby 1.9.3
  • LAMP server – Ubuntu 10.04 LTS Server
Code:

More info upon request, demo video coming soon!

–UPDATE: Video Proof Can Be Found Here

–UPDATE 2: Video Proof With My Car

Posted in apple, do it yourself, siri viper plugin, technology Tagged with: , , , , , , , , , , , , , , , , , , , , ,

Nagios Plugin – Juice Box Midspan XP POE

This script checks the status of a SEI Juice Box XP Midspan power-over-ethernet (POE) injector via SNMP.

It provides information on Voltage, Temperature, Power Delivered, Power Allocated, and Power Available.

#!/usr/bin/perl -w
###########################################################################################################
##
## Filename: check_snmp_poe_juicebox_xp.pl
## Description: This script checks the status of a Juice Box XP mid-span power-over-ethernet (POE) injector.
## Author: Brandon Fiquett (brandon@fiquett.com)
## Date: 2011-06-18
## Version: 1.0
##
############################################################################################################

## —————————————————————————————-(Includes)-START

use strict;
use Getopt::Long;
use Net::SNMP;
use lib “/usr/local/nagios/libexec”;

## —————————————————————————————-(Includes)-END

## —————————————————————————————-(Declarations)-START

## OIDs
my $juiceBoxMainSystemVoltage = “1.3.6.1.4.1.20364.3.1.2.1.0”; ## juiceBoxMainSystemVoltage (millivolts)
my $juiceBoxMainTemperature = “1.3.6.1.4.1.20364.3.1.2.2.0”; ## juiceBoxMainTemperature (Celsius)
my $juiceBoxMainPowerAvailable = “1.3.6.1.4.1.20364.3.1.2.3.0”; ## juiceBoxMainPowerAvailable
my $juiceBoxMainPowerDelivered = “1.3.6.1.4.1.20364.3.1.2.4.0”; ## juiceBoxMainPowerDelivered
my $juiceBoxMainAllocatedPower = “1.3.6.1.4.1.20364.3.1.2.5.0”; ## juiceBoxMainAllocatedPower
my $juiceBoxMainNetworkControllerFirmware = “1.3.6.1.4.1.20364.3.1.2.11.0”; ## juiceBoxMainNetworkControllerFirmware
my $juiceBoxMainSystemControllerFirmware = “1.3.6.1.4.1.20364.3.1.2.12.0”; ## juiceBoxMainSystemControllerFirmware

## ARGS
my $host = “”;
my $timeout = 15;
my $community = “public”;
my $type = “”;
my $min_warning = -1;
my $max_warning = -1;
my $min_critical = -1;
my $max_critical = -1;
my $verbose = undef;
my $celsius = undef;

## Result Strings
my $result = “”;
my $status = “”;
my $snmp_result = undef;
my $exit_level = 0; ## OK
my $exit_code = “”;
my $value = “”;

sub CtoF { my $c = shift; $c =~ s/[^\d\.]//g; return (((9/5)*$c)+32); }

## —————————————————————————————-(Declarations)-END

## —————————————————————————————-(Main)-START

## —————————————————————————————-(Get Args)-START

Getopt::Long::Configure (‘no_ignore_case’);
$result = GetOptions (‘host|h=s’ => \$host,
‘timeout|t=i’ => \$timeout,
‘community|c=s’ => \$community,
‘type=s’ => \$type,
‘min_warning=i’ => \$min_warning,
‘max_warning=i’ => \$max_warning,
‘min_critical=i’ => \$min_critical,
‘max_critical=i’ => \$max_critical,
‘celsius’ => \$celsius,
‘verbose|v’ => \$verbose);
sub usage {
my $ret = “USAGE $0 [options]\n”;
$ret .= “-h –host\t\tNagios Macro: \$HOSTADDRESS\$\n”;
$ret .= “-c –community\t\tSNMP Community String (Default: $community)\n”;
$ret .= “-t –timeout\t\tTime out (Default: $timeout)\n”;
$ret .= “–type\t\t\tType (voltage,temp,pwr_available,pwr_delivered,pwr_allocated)\n”;
$ret .= “–celsius\t\tTemperature in Celsius\n”;
$ret .= “–min_warning\t\tMin Warning\n”;
$ret .= “–max_warning\t\tMax Warning\n”;
$ret .= “–min_critical\t\tMin Critical\n”;
$ret .= “–max_critical\t\tMax Critical\n”;
$ret .= “\n”;
return $ret;
}

## Verbose subroutine
sub verb { my $t=shift; print $t,”\n” if defined($verbose) ; }

alarm ($timeout + 1);

$SIG{‘ALRM’} = sub {
print (“WARNING: Check Timed-out\n”);
exit(3); ## UNKNOWN
};
if(not $result ) {
print “ERROR: Missing Need Parameters\n\n” . usage();
exit(3); ## UNKNOWN
}
if( $host eq “”) {
die “ERROR: No host given\n\n” . usage();
exit(3); ## UNKNOWN
}

if( $type eq “”) {
die “ERROR: No type given\n\n” . usage();
exit(3); ## UNKNOWN
}
## —————————————————————————————-(Get Args)-END

## —————————————————————————————-(Create new SNMP-session-object)-START

my($snmp_session, $error) = Net::SNMP->session( -hostname => $host,
-community => $community,
-timeout => $timeout,
);

if( ! defined $snmp_session) {
print “ERROR: Couldn’t create snmp session: $error\n”;
exit(3); ## UNKNOWN
}

## Set Timeout
$snmp_session->timeout($timeout);

## —————————————————————————————-(Create new SNMP-session-object)-END

## —————————————————————————————-(Request the actual values)-START

$snmp_result = $snmp_session->get_request( -varbindlist => [ $juiceBoxMainSystemVoltage,$juiceBoxMainTemperature,$juiceBoxMainPowerAvailable,$juiceBoxMainPowerDelivered,$juiceBoxMainAllocatedPower,$juiceBoxMainNetworkControllerFirmware,$juiceBoxMainSystemControllerFirmware]);
$snmp_session->close;

verb(“Juice Box POE Midspan Power Hub Information\n##########################################################”);
my $MainSystemVoltage = $snmp_result->{$juiceBoxMainSystemVoltage};
$MainSystemVoltage = $MainSystemVoltage / 1000;
verb(“System Voltage (volts): $MainSystemVoltage”);
my $MainTemperature = $snmp_result->{$juiceBoxMainTemperature};
$MainTemperature = CtoF($MainTemperature) if (! defined $celsius);
verb(“Temperature (” . ((defined $celsius)?”°C”:”°F”) . “): $MainTemperature”);
my $MainPowerAvailable = $snmp_result->{$juiceBoxMainPowerAvailable};
verb(“Power Available (Watts): $MainPowerAvailable”);
my $MainPowerDelivered = $snmp_result->{$juiceBoxMainPowerDelivered};
verb(“Power Delivered (Watts): $MainPowerDelivered”);
my $MainAllocatedPower = $snmp_result->{$juiceBoxMainAllocatedPower};
verb(“Allocated Power (Watts): $MainAllocatedPower”);
my $MainNetworkControllerFirmware = $snmp_result->{$juiceBoxMainNetworkControllerFirmware};
verb(“Network Controller Firmware: $MainNetworkControllerFirmware”);
my $MainSystemControllerFirmware = $snmp_result->{$juiceBoxMainSystemControllerFirmware};
verb(“System Controller Firmware: $MainSystemControllerFirmware”);
verb(“##########################################################”);

## Verifty no SNMP problems
if( (! defined $MainSystemVoltage) or ( ! defined $MainTemperature) or ( ! defined $MainPowerAvailable) or ( ! defined $MainPowerDelivered) or ( ! defined $MainAllocatedPower) or ( ! defined $MainNetworkControllerFirmware) or ( ! defined $MainSystemControllerFirmware)) {
print “SNMP ERROR in get-request: “.$snmp_session->error();
exit(3); ## UNKNOWN
}

## —————————————————————————————-(Request the actual values)-END

## —————————————————————————————-(Build the results)-START

if ($type eq “voltage”){
$value = $MainSystemVoltage;
$status = “Voltage ($MainSystemVoltage volts)”;
}elsif($type eq “temp”){
$value = $MainTemperature;
$status = “Temperature ($MainTemperature ” . ((defined $celsius)?”degrees C”:”degrees F”) . “)”;
}elsif($type eq “pwr_available”){
$value = $MainPowerAvailable;
$status = “Power Available ($MainPowerAvailable Watts)”;
}elsif($type eq “pwr_delivered”){
$value = $MainPowerDelivered;
$status = “Power Delivered ($MainPowerDelivered Watts)”;
}elsif($type eq “pwr_allocated”){
$value = $MainAllocatedPower;
$status = “Power Allocated ($MainAllocatedPower Watts)”;
}else{
$status = “ERROR: Not a valid type. (voltage,temp,pwr_available,pwr_delivered,pwr_allocated)”;
exit(3); ## UNKNOWN
}
if (( $min_warning eq -1 && $min_critical eq -1) | ($max_warning eq -1 && $max_critical eq -1)){
$status = “ERROR: Missing threshold(s)”;
$exit_level = 3; ## UNKNOWN
}else{
if (($min_critical ne -1 && $max_critical ne -1) && ($value = $max_critical)){
$exit_code = “CRITICAL ” . (($value $exit_level = 2; ## CRITICAL
}elsif (($min_warning ne -1 && $max_warning ne -1) && ($value = $max_warning)){
$exit_code = “WARNING ” . (($value $exit_level = 1; ## WARNING
}else{
$exit_code .= “OK”;
}
}
## —————————————————————————————-(Build the results)-END

## —————————————————————————————-(Main)-END

## —————————————————————————————-(Exit)-START

print “$status: $exit_code \n”;
exit($exit_level);

## —————————————————————————————-(Exit)-END

Click here to download

Posted in nagios Tagged with: , , , , , , , , , , ,
  • admin-photo
  •  
  • brandon fiquett
  • tech enthusiast, developer, engineer, scuba instructor, drone pilot, K2FIQ.

subscribe via email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4 other subscribers