#!/usr/local/bin/perl
#check_oracle#
use strict;
use DBI;
use Net::SMTP;
$ENV{'ORACLE_HOME'} = '/app/oracle/product/9.2';
my $errors;
my $total = 0;
check_oracle();
if($total > 0) {
my $mailer = Net::SMTP->new("142.1.0.1");
$mailer->mail('dpr-prod@repl1.newport.net');
$mailer->to('root');
$mailer->data();
$mailer->datasend("Subject: DPR database");
$mailer->datasend("\n");
$mailer->datasend($errors);
$mailer->dataend();
}
sub check_oracle {
my $username = '######_@@@@';
my $password = '@@@@';
my $tnsalias = 'DPR';
my $dbh = DBI->connect('dbi:Oracle:'.$tnsalias, $username, $password, { PrintError => 0 });
unless($dbh) {
$errors .= "DPR database may be unavailable.\n";
$total++;
};
}
sunil_kumar 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.