]> git.sesse.net Git - nms/commitdiff
Use nms::db_connect() everywhere.
authorSteinar H. Gunderson <sesse@samfundet.no>
Wed, 29 Mar 2006 12:44:13 +0000 (12:44 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Wed, 29 Mar 2006 12:44:13 +0000 (12:44 +0000)
16 files changed:
clients/dhcptail.pl
clients/smanagrun.pl
clients/switchfix.pl
web/dhcpkart.pl
web/nettkart-telnet.pl
web/nettkart-text.pl
web/nettkart-web.pl
web/nettkart.pl
web/overlay.pl
web/portkart.pl
web/showswitch.pl
web/smanagement.pl
web/sshow.pl
web/stempmap-ptn.pl
web/stempmap.pl
web/tempfetch.pl

index 50a51b9feef7aa3804b06ec3cee6fae0a23b0ce0..a1e1c624fa0511a11677980020bf9f2adfdf1a11 100755 (executable)
@@ -1,6 +1,8 @@
 #! /usr/bin/perl
 use DBI;
 use POSIX;
+use lib '../include';
+use nms;
 use strict;
 use warnings;
 
@@ -28,8 +30,7 @@ while (<>) {
        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";
        }
index e66cfd26469b68e3267c62cf1becc3db951a8a46..d02d731b20efe7e4302913abc3e6ae85b3012a7e 100755 (executable)
@@ -7,6 +7,8 @@ use strict;
 use Net::Telnet;
 use DBI;
 use POSIX;
+use lib '../include';
+use nms;
 
 # Tweak and check
 my $password = 'removed';
@@ -14,9 +16,7 @@ my $timeout = 15;
 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("
index 536e868bbf23b708993acd5eaf811991eed9ff3b..4329f0452057e4e87672de45266c0def1eca9753 100755 (executable)
@@ -4,6 +4,9 @@ use warnings;
 use DBI;
 use Getopt::Long;
 use LWP::UserAgent;
+use lib '../include';
+use nms;
+
 {
        package RequestAgent;
        our @ISA = qw(LWP::UserAgent);
@@ -25,10 +28,7 @@ my $target_mask = $ARGV[0] ? $ARGV[0] : 'e%-%sw';
 
 
 # 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);
 
index 2558fb99542fd118b98509758eb2904cdd43143e..e428eca776b6cc3042de3267969aede1f12f4eea 100755 (executable)
@@ -2,13 +2,14 @@
 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');
index fd320445d45c29c5c43d770b6fa22bdcc7139d58..3a8353907051aeef652e0c7ed2b2c160b51545aa 100755 (executable)
@@ -1,10 +1,11 @@
 #! /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";
index 6ac1d9f9667b7beb6a5812b8b0e64ad1e023e804..7255e581de5874a7af31ea7530be33a9b3041969 100755 (executable)
@@ -1,10 +1,11 @@
 #! /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";
index 3da5fe554ae92f9373889d5e28dd812ef6ae459a..154181f3814b977de41fc99df35187aaf3eda886 100755 (executable)
@@ -1,10 +1,11 @@
 #! /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";
index ac88162ece03f73fa2728e94fc86fc0a164d14bb..29499fb296228c1195a56b4ff5334955dd9955bc 100755 (executable)
@@ -2,10 +2,11 @@
 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');
index 21eff198badc0f7778cb3e0f0c33b75e80ed4ecd..95e91989ace2745bcc5e5bf0c37089388130705e 100755 (executable)
@@ -3,10 +3,11 @@ use GD;
 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")) {
index 24a26ecb09ab1b0f30438f83873d6a8ebe7e8f14..9150cef27b573fc404a9b0daed2229286a86d956 100755 (executable)
@@ -2,10 +2,11 @@
 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');
index 7dd716c964248ab2123d22d6f13fd08ae181adca..3be8769c34dafdd0127203a52756049fe20bf343 100755 (executable)
@@ -5,6 +5,8 @@ use Time::HiRes;
 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');
@@ -18,8 +20,7 @@ $height = 250 unless (defined($height));
 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);
index ce270c3d4f307945b0087eccbf44bba118e997b8..e6474586eb467bc45b3a248e352e0b260074f887 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+use lib '../include';
+use nms;
 #
 #
 
@@ -20,9 +22,7 @@ use Data::Dumper;
 # 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
index 32a8306ab94aed68e5fe41fc205c285595dfe719..a16da779d0285e22b17b259e40f9a6b66045734b 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+use lib '../include';
+use nms;
 #
 #
 
@@ -18,9 +20,7 @@ use DBI;
 # 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(
index 3522b514142590078ca8495dc5246b2f95da46c5..a1fc55af3b441d89b4a7502d52d66d2c7aa624a4 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+use lib '../include';
+use nms;
 #
 #
 
@@ -11,8 +13,7 @@ use warnings;
 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);
index b2df70b688461ae7f841a669fdcf2793a182df35..fcfd32cd4695755770f37ef32ff92f98862cf015 100755 (executable)
@@ -5,6 +5,8 @@
 use CGI;
 use GD;
 use DBI;
+use lib '../include';
+use nms;
 use strict;
 use warnings;
 
@@ -14,8 +16,7 @@ my $img = GD::Image->new('snmp-bg.png');
 #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');
 
index eed5417fdfbf8a712d49cac6f3becedf617397ee..3a5c84dfbc49bcb92da7e386099c0063b05eb16a 100644 (file)
@@ -5,6 +5,8 @@ use DBI;
 use Net::Telnet;
 use POSIX;
 use Time::HiRes;
+use lib '../include';
+use nms;
 use strict;
 use warnings;
 #require 'SNMP_Session.pm';
@@ -14,8 +16,7 @@ my $password = 'removed';
 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")