#!/usr/bin/perl
use Net::OpenSSH;
use Getopt::Long;
use Switch;
Getopt::Long::Configure('bundling');
$status=GetOptions
(
"H=s" => \$dname, "DeviceName=s" => \$dname,
"u=s" => \$uname, "UserName=s" => \$uname,
"p=s" => \$password, "Password=s" => \$password,
"w=s" => \$warn, "Warning=i" => \$warn,
"c=s" => \$crit, "Critical=i" => \$crit,
"m=s" => \$mount, "Mount=s" => \$mount,
"s=s" => \$switch, "Switch=s" => \$switch,
"C=s" => \$command, "Command=s" => \$command
);
if ( $status == 0 ) {
print_usage();
}
#-- set up a new connection
# my $ssh = Net::OpenSSH->new('$uname:$password@$dname');
my $ssh = Net::OpenSSH->new($dname,user => $uname,password => $password);
$ssh->error and die "Connection error" . $ssh->error;
switch($switch)
{
case "command" {
$ssh->system("$command");
$ret = $ssh->error;
$ret =~ s/\D//g;
exit $ret;
}
}
sub print_usage {
print <
Version:1.0
Usage: check_openssh.pl -H host -u username -p password -w warn -c crit -m mode
-H STRING or IPADDRESS
Check interface on the indicated host.
-u STRING VALUE
Logon name of the remote UNIX server
-p STRING VALUE
Password to access the remote UNIX server
-w INTEGER VALUE
Warning condition depending on the Plug-in's used at remote server or Switch mode used
-c INTEGER VALUE
Critical condition depending on the Plug-in's used at remote server or Switch mode used
-s STRING VALUE
Switch mode is a string used to run the remote command or script
memory : memory usage
check_load: Server Load
check_disk: Disk Utilization on Server(provide mount point). e.g. -s check_disk -m /
db_status : Check the health of Oracle DB server
command : For running command at remote host. E.g. -s command -C "ls"
EOU
exit 3;
}
use Net::OpenSSH;
use Getopt::Long;
use Switch;
Getopt::Long::Configure('bundling');
$status=GetOptions
(
"H=s" => \$dname, "DeviceName=s" => \$dname,
"u=s" => \$uname, "UserName=s" => \$uname,
"p=s" => \$password, "Password=s" => \$password,
"w=s" => \$warn, "Warning=i" => \$warn,
"c=s" => \$crit, "Critical=i" => \$crit,
"m=s" => \$mount, "Mount=s" => \$mount,
"s=s" => \$switch, "Switch=s" => \$switch,
"C=s" => \$command, "Command=s" => \$command
);
if ( $status == 0 ) {
print_usage();
}
#-- set up a new connection
# my $ssh = Net::OpenSSH->new('$uname:$password@$dname');
my $ssh = Net::OpenSSH->new($dname,user => $uname,password => $password);
$ssh->error and die "Connection error" . $ssh->error;
switch($switch)
{
case "command" {
$ssh->system("$command");
$ret = $ssh->error;
$ret =~ s/\D//g;
exit $ret;
}
}
sub print_usage {
print <
Version:1.0
Usage: check_openssh.pl -H host -u username -p password -w warn -c crit -m mode
-H STRING or IPADDRESS
Check interface on the indicated host.
-u STRING VALUE
Logon name of the remote UNIX server
-p STRING VALUE
Password to access the remote UNIX server
-w INTEGER VALUE
Warning condition depending on the Plug-in's used at remote server or Switch mode used
-c INTEGER VALUE
Critical condition depending on the Plug-in's used at remote server or Switch mode used
-s STRING VALUE
Switch mode is a string used to run the remote command or script
memory : memory usage
check_load: Server Load
check_disk: Disk Utilization on Server(provide mount point). e.g. -s check_disk -m /
db_status : Check the health of Oracle DB server
command : For running command at remote host. E.g. -s command -C "ls"
EOU
exit 3;
}
No comments:
Post a Comment