#48 Node Monitor supports matching on OUI
This commit is contained in:
7
Changes
7
Changes
@@ -1,3 +1,10 @@
|
|||||||
|
2.039016 - 2018-
|
||||||
|
|
||||||
|
[NEW FEATURES]
|
||||||
|
|
||||||
|
* Node Montior is now included in Admin menu
|
||||||
|
* #48 Node Monitor supports matching on OUI
|
||||||
|
|
||||||
2.039015 - 2018-03-05
|
2.039015 - 2018-03-05
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
|
|||||||
);
|
);
|
||||||
|
|
||||||
our # try to hide from kwalitee
|
our # try to hide from kwalitee
|
||||||
$VERSION = 49; # schema version used for upgrades, keep as integer
|
$VERSION = 50; # schema version used for upgrades, keep as integer
|
||||||
|
|
||||||
use Path::Class;
|
use Path::Class;
|
||||||
use File::ShareDir 'dist_dir';
|
use File::ShareDir 'dist_dir';
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ __PACKAGE__->table("node_monitor");
|
|||||||
__PACKAGE__->add_columns(
|
__PACKAGE__->add_columns(
|
||||||
"mac",
|
"mac",
|
||||||
{ data_type => "macaddr", is_nullable => 0 },
|
{ data_type => "macaddr", is_nullable => 0 },
|
||||||
|
"matchoui",
|
||||||
|
{ data_type => "boolean", is_nullable => 1 },
|
||||||
"active",
|
"active",
|
||||||
{ data_type => "boolean", is_nullable => 1 },
|
{ data_type => "boolean", is_nullable => 1 },
|
||||||
"why",
|
"why",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ SELECT nm.why, nm.cc, trim(trailing '.' from trim(trailing '0123456789' from dat
|
|||||||
d.name, d.location,
|
d.name, d.location,
|
||||||
dp.name AS portname
|
dp.name AS portname
|
||||||
FROM node_monitor nm, node n, device d, device_port dp
|
FROM node_monitor nm, node n, device d, device_port dp
|
||||||
WHERE nm.mac = n.mac
|
WHERE ((nm.mac = n.mac) OR (nm.matchoui AND (substring(nm.mac::text from 1 for 8) = n.oui)))
|
||||||
AND nm.active
|
AND nm.active
|
||||||
AND nm.cc IS NOT NULL
|
AND nm.cc IS NOT NULL
|
||||||
AND d.ip = n.switch
|
AND d.ip = n.switch
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ our %EXPORT_TAGS = (all => \@EXPORT_OK);
|
|||||||
|
|
||||||
sub _email {
|
sub _email {
|
||||||
my ($to, $subject, $body) = @_;
|
my ($to, $subject, $body) = @_;
|
||||||
|
return unless $to;
|
||||||
my $domain = setting('domain_suffix') || 'localhost';
|
my $domain = setting('domain_suffix') || 'localhost';
|
||||||
$domain =~ s/^\.//;
|
$domain =~ s/^\.//;
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ sub monitor {
|
|||||||
my $monitor = schema('netdisco')->resultset('Virtual::NodeMonitor');
|
my $monitor = schema('netdisco')->resultset('Virtual::NodeMonitor');
|
||||||
|
|
||||||
while (my $entry = $monitor->next) {
|
while (my $entry = $monitor->next) {
|
||||||
my $body = <<"end_body";
|
my $body = <<"end_body";
|
||||||
........ n e t d i s c o .........
|
........ n e t d i s c o .........
|
||||||
Node : @{[$entry->mac]} (@{[$entry->why]})
|
Node : @{[$entry->mac]} (@{[$entry->why]})
|
||||||
When : @{[$entry->date]}
|
When : @{[$entry->date]}
|
||||||
@@ -41,11 +42,13 @@ sub monitor {
|
|||||||
|
|
||||||
end_body
|
end_body
|
||||||
|
|
||||||
_email(
|
debug sprintf ' monitor - reporting on %s at %s:%s',
|
||||||
$entry->cc,
|
$entry->mac, $entry->name, $entry->port;
|
||||||
"Saw mac @{[$entry->mac]} (@{[$entry->why]}) on @{[$entry->name]} @{[$entry->port]}",
|
_email(
|
||||||
$body
|
$entry->cc,
|
||||||
);
|
"Saw mac @{[$entry->mac]} (@{[$entry->why]}) on @{[$entry->name]} @{[$entry->port]}",
|
||||||
|
$body
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ ajax '/ajax/control/admin/nodemonitor/add' => require_role admin => sub {
|
|||||||
my $monitor = schema('netdisco')->resultset('NodeMonitor')
|
my $monitor = schema('netdisco')->resultset('NodeMonitor')
|
||||||
->create({
|
->create({
|
||||||
mac => param('mac'),
|
mac => param('mac'),
|
||||||
|
matchoui => (param('matchoui') ? \'true' : \'false'),
|
||||||
active => (param('active') ? \'true' : \'false'),
|
active => (param('active') ? \'true' : \'false'),
|
||||||
why => param('why'),
|
why => param('why'),
|
||||||
cc => param('cc'),
|
cc => param('cc'),
|
||||||
@@ -54,6 +55,7 @@ ajax '/ajax/control/admin/nodemonitor/update' => require_role admin => sub {
|
|||||||
|
|
||||||
$monitor->update({
|
$monitor->update({
|
||||||
mac => param('mac'),
|
mac => param('mac'),
|
||||||
|
matchoui => (param('matchoui') ? \'true' : \'false'),
|
||||||
active => (param('active') ? \'true' : \'false'),
|
active => (param('active') ? \'true' : \'false'),
|
||||||
why => param('why'),
|
why => param('why'),
|
||||||
cc => param('cc'),
|
cc => param('cc'),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package App::Netdisco::Worker::Plugin::Monitor;
|
package App::Netdisco::Worker::Plugin::NodeMonitor;
|
||||||
|
|
||||||
use Dancer ':syntax';
|
use Dancer ':syntax';
|
||||||
use App::Netdisco::Worker::Plugin;
|
use App::Netdisco::Worker::Plugin;
|
||||||
@@ -65,6 +65,7 @@ web_plugins:
|
|||||||
- Report::SubnetUtilization
|
- Report::SubnetUtilization
|
||||||
- Report::PortLog
|
- Report::PortLog
|
||||||
- AdminTask::JobQueue
|
- AdminTask::JobQueue
|
||||||
|
- AdminTask::NodeMonitor
|
||||||
- AdminTask::Topology
|
- AdminTask::Topology
|
||||||
- AdminTask::PollerPerformance
|
- AdminTask::PollerPerformance
|
||||||
- AdminTask::PseudoDevice
|
- AdminTask::PseudoDevice
|
||||||
@@ -376,7 +377,7 @@ worker_plugins:
|
|||||||
- 'Macsuck::WirelessNodes'
|
- 'Macsuck::WirelessNodes'
|
||||||
- 'Macwalk'
|
- 'Macwalk'
|
||||||
- 'MakeRancidConf'
|
- 'MakeRancidConf'
|
||||||
- 'Monitor'
|
- 'NodeMonitor'
|
||||||
- 'Nbtstat'
|
- 'Nbtstat'
|
||||||
- 'Nbtstat::Core'
|
- 'Nbtstat::Core'
|
||||||
- 'Nbtwalk'
|
- 'Nbtwalk'
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE node_monitor ADD COLUMN "matchoui" boolean;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="nd_center-cell">Date Added</th>
|
<th class="nd_center-cell">Date Added</th>
|
||||||
<th class="nd_center-cell">MAC Address</th>
|
<th class="nd_center-cell">MAC Address</th>
|
||||||
|
<th class="nd_center-cell">Match OUI</th>
|
||||||
<th class="nd_center-cell">Enabled</th>
|
<th class="nd_center-cell">Enabled</th>
|
||||||
<th class="nd_center-cell">Reason</th>
|
<th class="nd_center-cell">Reason</th>
|
||||||
<th class="nd_center-cell">Email</th>
|
<th class="nd_center-cell">Email</th>
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="nd_center-cell"></td>
|
<td class="nd_center-cell"></td>
|
||||||
<td class="nd_center-cell"><input data-form="add" name="mac" type="text"></td>
|
<td class="nd_center-cell"><input data-form="add" name="mac" type="text"></td>
|
||||||
|
<td class="nd_center-cell"><input data-form="add" name="matchoui" type="checkbox"></td>
|
||||||
<td class="nd_center-cell"><input data-form="add" name="active" type="checkbox" checked></td>
|
<td class="nd_center-cell"><input data-form="add" name="active" type="checkbox" checked></td>
|
||||||
<td class="nd_center-cell"><input data-form="add" name="why" type="text"></td>
|
<td class="nd_center-cell"><input data-form="add" name="why" type="text"></td>
|
||||||
<td class="nd_center-cell"><input data-form="add" name="cc" type="email"></td>
|
<td class="nd_center-cell"><input data-form="add" name="cc" type="email"></td>
|
||||||
@@ -29,6 +31,9 @@
|
|||||||
<td class="nd_center-cell">
|
<td class="nd_center-cell">
|
||||||
<input data-form="update" name="mac" type="text" value="[% row.mac | html_entity %]">
|
<input data-form="update" name="mac" type="text" value="[% row.mac | html_entity %]">
|
||||||
</td>
|
</td>
|
||||||
|
<td class="nd_center-cell">
|
||||||
|
<input data-form="update" name="matchoui" type="checkbox" [% 'checked="checked"' IF row.matchoui %]>
|
||||||
|
</td>
|
||||||
<td class="nd_center-cell">
|
<td class="nd_center-cell">
|
||||||
<input data-form="update" name="active" type="checkbox" [% 'checked="checked"' IF row.active %]>
|
<input data-form="update" name="active" type="checkbox" [% 'checked="checked"' IF row.active %]>
|
||||||
</td>
|
</td>
|
||||||
@@ -73,11 +78,11 @@ $(document).ready(function() {
|
|||||||
$('#data-table').dataTable({
|
$('#data-table').dataTable({
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{
|
{
|
||||||
"targets": [ 0, 2, 5 ],
|
"targets": [ 0, 2, 3, 6 ],
|
||||||
"searchable": false
|
"searchable": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [ 0, 2, 5 ],
|
"targets": [ 0, 2, 3, 6 ],
|
||||||
"orderable": false
|
"orderable": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user