-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="14dd", ENV{ID_MODEL_ID}=="0002", PROGRAM="/lib/udev/kvm_monitor.pl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
# use Data::Dumper; $Data::Dumper::Sortkeys=1; | ||
# print Dumper \%ENV | ||
|
||
use constant VERSION => '0.92'; | ||
|
||
# Howto get the id from an attached KVM: | ||
# root> lsusb -v | grep iSerial | ||
# | ||
# Only the first 16 chars are used to identify the KVM, | ||
# the other half is a bit bogous on certain kvm's (ie kvm06). | ||
my %serial_to_name = qw( | ||
960f2408004ca12a kvm03 | ||
96132408034ca1d2 kvm04 | ||
96112408034ca1d6 kvm05 | ||
960d2408004ca12e kvm06 | ||
96132408004ca11e kvm07 | ||
96014404032675fa kvm08 | ||
96132408004ca132 kvm09 | ||
96fec24603c408f4 kvm10 | ||
9600c24600c40814 kvm11 | ||
960dc24600c47d20 kvm12 | ||
960dc24600c47d28 kvm13 | ||
96fec24600c40808 kvm14 | ||
96fac24603c46bfc kvm15 | ||
96fec24603c408c8 kvm16 | ||
96fbc24600c4a740 kvm17 | ||
96fcc24603c4a7fc kvm18 | ||
96fcc24603c4a7ec kvm19 | ||
); | ||
|
||
my $action = $ENV{ACTION} || 'missing action'; | ||
my $id = 'missing environment variable'; | ||
if (defined $ENV{ID_SERIAL_SHORT}) { | ||
$id = substr $ENV{ID_SERIAL_SHORT}, 0, 16; | ||
} | ||
|
||
my $name = sprintf "Unknown KVM with ID '%s'", $id; | ||
$name = $serial_to_name{$id} if exists $serial_to_name{$id}; | ||
|
||
my $msg = 'kvm-event: ' . $name; | ||
if ($action eq 'add') { | ||
$msg .= ' was attached.'; | ||
} elsif ($action eq 'remove') { | ||
$msg .= ' was removed.'; | ||
} else { | ||
$msg .= ", and an unknown event has occurred ($action)"; | ||
} | ||
|
||
system('/usr/bin/logger', $msg); | ||
|
||
exit; | ||
|
||
=head2 | ||
The environment seen (kvm13) | ||
ACTION=add | ||
ACTION=remove | ||
==== event ==== | ||
Thu May 26 13:08:33 CEST 2016 | ||
ACTION=add | ||
BUSNUM=002 | ||
DEVLINKS=/dev/char/189:136 | ||
DEVNAME=bus/usb/002/009 | ||
DEVNUM=009 | ||
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3 | ||
DEVTYPE=usb_device | ||
ID_BUS=usb | ||
ID_MODEL=Multidevice | ||
ID_MODEL_ENC=Multidevice | ||
ID_MODEL_ID=0002 | ||
ID_REVISION=0001 | ||
ID_SERIAL=Peppercon_AG_Multidevice_960dc24600c47d282641C894DA0F1B6A | ||
ID_SERIAL_SHORT=960dc24600c47d282641C894DA0F1B6A | ||
ID_USB_INTERFACES=:030101:030102: | ||
ID_VENDOR=Peppercon_AG | ||
ID_VENDOR_ENC=Peppercon\x20AG | ||
ID_VENDOR_ID=14dd | ||
MAJOR=189 | ||
MINOR=136 | ||
PRODUCT=14dd/2/1 | ||
PWD=/ | ||
SEQNUM=3362 | ||
SHLVL=1 | ||
SUBSYSTEM=usb | ||
TYPE=0/0/0 | ||
UDEV_LOG=3 | ||
_=/usr/bin/env | ||
=cut | ||
|