Showing posts with label notification. Show all posts
Showing posts with label notification. Show all posts

Tuesday, 12 June 2012

Check_file with date for HP UX

today just able to get the solution for checking file for HP-UX.

Issue: I need to check file certain file everyday using GWOS and nagios as a base.
Becoz the hp-ux used perl scripting, so for me its really challenging.
If using bash scripting its should be no problem.

GWOS server = Redhat 5.6
Target = HP-UX server.
example file : /tmp/test_20120920.csv


========================================================================
create file end with .pl (for plugin)
example : vi check_ftpget.pl


add below details on GWOS server:


#!/usr/local/groundwork/perl/bin/perl
## Written 12/5/00 Jeremy Hanmer
# $Id: check_ftpget2.pl,v 1.1.1.1 2005/02/07 19:33:32 hmann Exp $
use POSIX qw/strftime/;
use strict;
use Net::FTP;
use Getopt::Std;

use vars qw($opt_H $opt_u $opt_p $opt_f $opt_date);
getopts("H:u:p:f:date");

my $date = strftime "%Y%m%d", localtime;

my $host = $opt_H ||
    die "usage: check_ftp.pl -H host [<-u user> <-p pass> <-f file>]\n";

my $username = $opt_u || 'anonymous';
my $pass = $opt_p || "$ENV{'LOGNAME'}\@$ENV{'HOSTNAME'}" ;

my $file ="$opt_f$date.csv";

my $status = 0;
my $problem;
my $output = "ftp ok $file";

my $ftp = Net::FTP->new("$host") ||
    &crit("connect");

$ftp->login("$username", "$pass") ||
    &crit("login");

$ftp->get($file) ||
    &crit("get") if $file;

sub crit()
{
    $problem = $_[0];
    $status = 2;
    if ( $problem eq 'connect' ) {
        $output = "can't connect";
    } elsif ( $problem eq 'login' ) {
        $output = "can't log in";
    } elsif ( $problem eq 'get' ) {
        $output = "cant get $file";
    }
}

print "$output\n";
exit $status;


========================================================================


test the scripting at GWOS server.
check-ftpget3.pl -H XXXXX -u nagios2 -p XXXXXX-f /tmp/test_
ftp ok /tmp/test_20120612.csv




ok done..can sleep..hahahaha


Wednesday, 9 May 2012

GWOS: checking SWAP_hpux

edit the plugin from previous post.

to something like

swapinfo | grep dev

settle.!!!!

Tuesday, 8 May 2012

GWOS: checking memory HPUX

What is GWOS:  http://www.gwos.com/
Note: GWOS (Groundwork Open source) running on RHEL 5.6


 dem it, i spent almost 2 days to settle this up.

so finally i solved it by download the plugin from http://exchange.nagios.org/directory/Plugins/Operating-Systems/HP-2DUX/Hp-2Dux-check_memory/details

1: Login to HPUX as nagios user, (please make sure password-less.)
2:  edit the .profile, like this
           # Set up the search paths:
           PATH=$PATH:/usr/sbin/.

3: Copy the plugin into the libexec folder  (please make sure the permission correct)

done for HPUX server.

For part at GWOS

1: Login GWOS > Configuration tab > Command tab >
2: Please make sure below setting for macro and value
      USER1=/usr/local/groundwork/nagios/libexec
      USER17=nagios    
      USER22=libexec

3: click New > choose User1 > and upload the check_by_ssh command
4: add below command , and now the checking memory DONE!! wohooo

      $USER1$/check_by_ssh -H $HOSTADDRESS$ -t 60 -l "$USER17$" -C     "$USER22$/check_memhpux -u -w $ARG1$ -c $ARG2$"



example output:

/usr/local/groundwork/nagios/libexec/check_by_ssh -H xxxx.xxxx.xxxx.xxxx -t 60 -l "nagios" -C "libexec/check_memhpux -u -w 80 -c 90"
Memory OK - 32.4% (5155720 kB) used