#! /usr/bin/perl
use DBI;
use POSIX;
+use lib '../include';
+use nms;
use strict;
use warnings;
my $date = $year . "-" . $months{$1} . "-" . $2 . " " . $3;
if (!defined($dbh) || !$dbh->ping) {
- $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+ $dbh = nms::db_connect();
$q = $dbh->prepare("UPDATE dhcp SET last_ack=? WHERE inet ? << network AND ( last_ack < ? OR last_ack IS NULL )")
or die "Couldn't prepare query";
}
use Net::Telnet;
use DBI;
use POSIX;
+use lib '../include';
+use nms;
# Tweak and check
my $password = 'removed';
my $delaytime = 30;
my $poll_frequency = 60;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org",
- "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = db_connect();
$dbh->{AutoCommit} = 0;
my $spoll = $dbh->prepare("
use DBI;
use Getopt::Long;
use LWP::UserAgent;
+use lib '../include';
+use nms;
+
{
package RequestAgent;
our @ISA = qw(LWP::UserAgent);
# ACTION
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org",
- "snmpfetch", "removed")
- or die "Couldn't connect to database";
-
+my $dbh = nms::db_connect();
my $sth = $dbh->prepare("SELECT sysname,ip FROM switches WHERE sysname LIKE ? ORDER BY ip");
$sth->execute($target_mask);
use CGI;
use GD;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
my $greentimeout = 900;
my $maxtimeout = $greentimeout*9;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
GD::Image->trueColor(1);
$img = GD::Image->new('snmp-bg.png');
#! /usr/bin/perl
use CGI;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
print $cgi->header(-type=>'text/html', -refresh=>'45; http://nms.tg05.gathering.org/nettkart-telnet.pl');
print <<"EOF";
#! /usr/bin/perl
use CGI;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
print $cgi->header(-type=>'text/html', -refresh=>'10; http://nms.tg05.gathering.org/nettkart-text.pl');
print <<"EOF";
#! /usr/bin/perl
use CGI;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
print $cgi->header(-type=>'text/html', -refresh=>'45; http://nms.tg05.gathering.org/nettkart-web.pl');
print <<"EOF";
use CGI;
use GD;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
GD::Image->trueColor(1);
$img = GD::Image->new('snmp-bg.png');
use LWP::Simple;
use CGI;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
-or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
my $cam = $cgi->param('cam');
if (!defined($cam) || ($cam ne "1" && $cam ne "2")) {
use CGI;
use GD;
use DBI;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
GD::Image->trueColor(1);
$img = GD::Image->new('snmp-bg.png');
use POSIX ":sys_wait_h";
use strict;
use warnings;
+use lib '../include';
+use nms;
my $cgi = CGI->new;
my $switch = $cgi->param('id');
my $width = $cgi->param('width');
require './mygraph.pl';
my $start = [Time::HiRes::gettimeofday];
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
# Fetch the name
my $ref = $dbh->selectrow_hashref('SELECT sysname FROM switches WHERE switch=?', undef, $switch);
#!/usr/bin/perl
+use lib '../include';
+use nms;
#
#
# Grab from .htaccess-authentication
my $user = $ENV{'REMOTE_USER'};
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org",
- "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
$dbh->{AutoCommit} = 0;
# Ugly casting, found not other way
#!/usr/bin/perl
+use lib '../include';
+use nms;
#
#
# Grab from .htaccess-authentication
my $user = $ENV{'REMOTE_USER'};
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org",
- "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
$dbh->{AutoCommit} = 0;
my $sgetdone = $dbh->prepare(
#!/usr/bin/perl
+use lib '../include';
+use nms;
#
#
my $img = GD::Image->new('stemp-bg5.png');
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
my $black = $img->colorAllocate(0,0,0);
my $white = $img->colorAllocate(255,255,255);
use CGI;
use GD;
use DBI;
+use lib '../include';
+use nms;
use strict;
use warnings;
#my $img = GD::Image->new(100,100);
my $cgi = CGI->new;
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
my $sgetpoll = $dbh->prepare('select switch,(select temp from temppoll where switches.switch=temppoll.switch AND temp != 0 order by id desc limit 1) AS temp,placement from switches natural join placements');
use Net::Telnet;
use POSIX;
use Time::HiRes;
+use lib '../include';
+use nms;
use strict;
use warnings;
#require 'SNMP_Session.pm';
my $timeout = 25;
my $location = 'skipet';
-my $dbh = DBI->connect("dbi:Pg:dbname=snmpfetch;host=violet.tg05.gathering.org", "snmpfetch", "removed")
- or die "Couldn't connect to database";
+my $dbh = nms::db_connect();
$dbh->{AutoCommit} = 0;
my $qswitch = $dbh->prepare(<<"EOF")