$SIG{'URG'} = sub { # # Update the current status of Host from Database A.> my $curStatus = $host->fetchResyncStatus(); B.> $host->setResyncStatus($curStatus); print "\n Received CLD in :: ". $host->getIP(); } ; #### sub fetchResyncStatus { my $self = shift; my $hostname = $self->getIP(); my $status; # # Connect to database, If unable to do so, log # an error and return my $dbh = DBI->connect( "dbi:Oracle:", "", "" ) || do { $self->error(__LINE__.":". DBI::errstr."\n"); return 0; }; # # Sql query to retrieve host status from the database my $sql_query = "SELECT STATUS FROM NMS_CONFIG WHERE IPADDRESS='".$hostname. "'"; # # Prepare SQL query, If unable to do so, log an error and # return my $sth = $dbh->prepare($sql_query) || do { $self->error(__LINE__.": Could not prepare statement: ".$dbh->errstr. "\n"); return 0; }; # # Execute the SQL query. If unable to o so, log an error and # return $sth->execute() || do { $self->error(__LINE__.": Could not execute statement ".$sth->errstr."\n"); }; # # sql_query returns a reference to a hash with NMS_CONFIG # column name as keys and the column entries as their # corresponding values. while (my $hash_ref = $sth->fetchrow_hashref() ) { $status = $hash_ref->{'STATUS'}; } # # Disconnect from the database. $dbh->disconnect(); # # Return the value of the recieved status #return $status; print "\n\nStatus in DB :: " .$status."\n"; return 'NORMAL';