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