[Nagiosplug-devel] check_mssql
Roy Sigurd Karlsbakk
roy at karlsbakk.net
Wed May 14 00:12:11 CEST 2003
the only check_mssql script I've seen was a dirty hack with sqsh. I find it
better to do this in perl
On Tuesday 13 May 2003 18:26, Jonathan Rozes wrote:
> This is the third version of a check_mssql plugin I've seen now. Why does
> everybody insist on reinventing the wheel (and poorly, at that)?
>
> jonathan
>
> > -----Original Message-----
> > From: Roy Sigurd Karlsbakk [mailto:roy at karlsbakk.net]
> > Sent: Tuesday, May 13, 2003 2:09 AM
> > To: NagiosPlug Devel
> > Subject: [Nagiosplug-devel] check_mssql
> >
> >
> > hi
> >
> > just wrote this. works fine here. any chance to get this
> > checked into cvs?
> >
> > roy
> >
> > #!/usr/bin/perl -w
> >
> > use DBI;
> > use DBD::Sybase;
> > use Getopt::Long;
> > use Date::Parse;
> > use strict;
> >
> > my (
> > $server,$database,$username,$password,$query,$help,$verbose,
> > $dbh,$sth,$lasterror,
> > $nagline,
> > $s
> > );
> > my $exitcode = 0;
> > my $lastread = 0;
> > my $data_returned = 0;
> >
> > sub syntax {
> > $s = shift or $s = 'Unknown';
> > printf("Error: ($s)\n") unless ($help);
> > printf("Syntax: %s -s <server> -d <database> -u <username> -p
> > <password> -q <query> [-v]\n", $0);
> > printf("* --database -d Database name\n");
> > printf("* --server -s Server name\n");
> > printf("* --username -u Username\n");
> > printf("* --password -p Password\n");
> > printf("* --query -q SQL query to run\n");
> > printf(" --verbose -v verbose\n");
> > exit(3);
> > }
> >
> > Getopt::Long::Configure('bundling');
> > GetOptions
> > ("p=s" => \$password, "password=s" => \$password,
> > "u=s" => \$username, "username=s" => \$username,
> > "s=s" => \$server, "server=s" => \$server,
> > "d=s" => \$database, "database=s" => \$database,
> > "q=s" => \$query, "query=s" => \$query,
> > "h" => \$help, "help" => \$help,
> > "v" => \$verbose, "verbose" => \$verbose);
> >
> > syntax("Help:") if ($help);
> > syntax("Missing username") unless (defined($username));
> > syntax("Missing password") unless (defined($password));
> > syntax("Missing server") unless (defined($server));
> > syntax("Missing database") unless (defined($database));
> > syntax("Missing query string") unless (defined($query));
> >
> > unless ($dbh = DBI->connect("dbi:Sybase:server=".uc($server),
> > "$username",
> > "$password")) {
> > printf ("Can't connect to mssql server $dbh->errstr");
> > exit(2);
> > }
> > unless ($dbh->do("use $database")) {
> > printf ("Can't 'use $database': $dbh->errstr");
> > exit(2);
> > }
> > $sth = $dbh->prepare($query);
> > unless ($lasterror = $sth->execute()) {
> > printf("Error in query: $dbh->errstr\n");
> > exit(2);
> > }
> >
> > exit($exitcode);
> >
> > --
> > Roy Sigurd Karlsbakk, Datavaktmester
> > ProntoTV AS - http://www.pronto.tv/
> > Tel: +47 9801 3356
> >
> > Computers are like air conditioners.
> > They stop working when you open Windows.
> >
> >
> >
> > -------------------------------------------------------
> > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
> > The only event dedicated to issues related to Linux
> > enterprise solutions
> > www.enterpriselinuxforum.com
> >
> > _______________________________________________
> > Nagiosplug-devel mailing list
> > Nagiosplug-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> >
> > ::: Please include plugins version (-v) and OS when reporting
> >
> > any issue.
> >
> > ::: Messages without supporting info will risk being sent to /dev/null
>
> -------------------------------------------------------
> Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
> The only event dedicated to issues related to Linux enterprise solutions
> www.enterpriselinuxforum.com
>
> _______________________________________________
> Nagiosplug-devel mailing list
> Nagiosplug-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
>
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
--
Roy Sigurd Karlsbakk, Datavaktmester
ProntoTV AS - http://www.pronto.tv/
Tel: +47 9801 3356
Computers are like air conditioners.
They stop working when you open Windows.
More information about the Devel
mailing list