From ed9283b4dcc16d521c2c86046d8d7e3565843f51 Mon Sep 17 00:00:00 2001 From: Lasse Haugen Date: Wed, 29 Jun 2016 11:54:37 +0200 Subject: Update collector for dx --- collectors/dhcptail.pl | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/collectors/dhcptail.pl b/collectors/dhcptail.pl index e5d7d4a..857bf5e 100755 --- a/collectors/dhcptail.pl +++ b/collectors/dhcptail.pl @@ -1,17 +1,13 @@ #! /usr/bin/perl use DBI; use POSIX; -use lib '../include'; +use lib '/opt/gondul/include'; use nms; use strict; use Data::Dumper; use warnings; -BEGIN { - require "../include/config.pm"; -} - -my (undef,undef,undef,undef,undef,$year,undef,undef,undef) = gmtime(time); +my $year = 2016; my %months = ( Jan => 1, @@ -31,10 +27,10 @@ my %months = ( my $realtime = 0; my ($dbh, $q,$check); $dbh = nms::db_connect(); -$q = $dbh->prepare("INSERT INTO dhcp (switch,time,ip,mac) VALUES((SELECT switch FROM switches WHERE ?::inet << subnet4 ORDER BY sysname LIMIT 1),?,?,?)"); -$check = $dbh->prepare("SELECT max(time)::timestamp - ?::timestamp < '0s'::interval as doit FROM dhcp;"); +$q = $dbh->prepare("INSERT INTO dhcp (dhcp_server,switch,time,ip,mac) VALUES($nms::config::dhcp_id,(SELECT switch FROM switches WHERE ?::inet << subnet4 ORDER BY sysname LIMIT 1),?,?,?)"); +$check = $dbh->prepare("SELECT max(time)::timestamp - ?::timestamp < '0s'::interval as doit FROM dhcp where dhcp_server = $nms::config::dhcp_id;"); -open(SYSLOG, "tail -n 9999999 -F /var/log/syslog |") or die "Unable to tail syslog: $!"; +open(SYSLOG, "tail -n 9999999 -F /var/log/messages |") or die "Unable to tail syslog: $!"; while () { /(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(\d+)\s+(\d+:\d+:\d+).*DHCPACK on (\d+\.\d+\.\d+\.\d+) to (\S+) / or next; my $date = $year . "-" . $months{$1} . "-" . $2 . " " . $3 . " Europe/Oslo"; -- cgit v1.2.3