#!/usr/bin/perl -w use strict; use warnings; #You might need to define parameters for the input. use DBI; use Getopt::Long qw(:config no_ignore_case); my ($status, $failed, $host, $verbose, $timeout); my $VERSION = 0.1; my $HELP = 0; # Default values $failed = 0; my %STATUSCODE = ( 'OK' => '0', 'WARNING' => '1', 'CRITICAL' => '2', 'UNKNOWN' => '3'); my $usage = < \$host, "h|help" => \$HELP,); if( !$result ) { print "ERROR: Problem with cmdline args\n"; print $usage; exit($STATUSCODE{'UNKNOWN'});} if( $HELP ) { print $usage; exit($STATUSCODE{'UNKNOWN'});} if ( !($host) ){ print "ERROR: Missing required arguments\n"; print $usage; exit($STATUSCODE{'UNKNOWN'});}; my $dsn = 'DBI:Sybase:server=prime'; my $dbh = DBI->connect('DBI:Sybase:server=test;UID=sa;PWD=;'); if (!$dbh){die "Could not open connection to DSN because of [$!]";} my $query = $dbh->selectall_arrayref("SELECT COGIPF_STATUS FROM [PVP21_Audit].[dbo].[COGIPF_AGENTRUN] WHERE [COGIPF_LOCALTIMESTAMP] >= CONVERT(VarChar(20), GetDate() +1,101)", { Slice => {} } ); foreach $query (@$query) { if ($query->{COGIPF_STATUS} eq 'Failed') {$failed = 1} } unless (@$query) { $failed = 1 }; if ( $failed == 0 ) { print "Jobs Succeeded\n"; exit($STATUSCODE{'OK'}); }elsif ( $failed == 1 ){ print "Job Failure\n"; exit($STATUSCODE{'CRITICAL'}); }else{ print "Undetermined error\n"; exit($STATUSCODE{'UNKNOWN'}); }