Unix Technical Forum

ops.monitor

This is a discussion on ops.monitor within the HP-UX Operating System forums, part of the Unix Operating Systems category; --> Regards, Cordialement, Cyrille Lefevre. -- mailto:Cyrille.Lefevre-news%nospam@laposte.net.invalid supprimer "%nospam% et ".invalid" pour me repondre. remove "%nospam" and ".invalid" to answer ...


Go Back   Unix Technical Forum > Unix Operating Systems > HP-UX Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-17-2008, 06:02 AM
Cyrille Lefevre
 
Posts: n/a
Default ops.monitor


Regards, Cordialement,

Cyrille Lefevre.
--
mailto:Cyrille.Lefevre-news%nospam@laposte.net.invalid
supprimer "%nospam% et ".invalid" pour me repondre.
remove "%nospam" and ".invalid" to answer me.

#!/bin/ksh
#
# Monitor ops service
#
tmout=30
prog=/usr/local/bin/unicli
if [ ! -x "$prog" ]; then
echo ops.monitor error, could not find unicli
exit 1
fi

if [ "$#" = 0 ]; then
echo ops.monitor: no hosts found
exit 1
fi

failed=""
sep=""

trap rc1=1 2

for host in "$@"; do
$prog << EOF > /dev/null 2>&1 &
NODE "$host"
PORT "10510"
LOGIN "syssopra"
PASSWORD "syssopra"

TRANSACTION "GET_TIMER_INFO"
VECTOR { # Vector content
LAST
}
EOF
pid1=$!
(sleep $tmout; kill -2 $$) &
pid2=$!
rc1=0
wait $pid1
rc2=$?
if [ "$rc1" != 0 ]; then
kill $pid1
wait $pid1
rc2=$?
else
kill $pid2
fi
if [ "$rc2" != 0 ]; then
failed="$failed$sep$host"
sep=" "
fi
done

if [ "$failed" != "" ]; then
echo "$failed"
exit 1
fi

exit 0

#!/usr/bin/perl
#================================================= ===========================
# opsinstance.monitor --- check ops instance
#
# $Locker$
# $Log$
# Author : Gilles Hamel
# Created On : Mon Jun 20 10:33:26 2005
# Last Modified By: Gilles Hamel
# Last Modified On: Wed Jun 22 09:56:58 2005
# Update Count : 92
# Status : Unknown, Use with caution!
# ================================================== =========================

#
# HISTORY

use Getopt::Std;
use English;
use Time::Period;

sub Usage {

print "$_[0]\n" if defined $_[0];

print
qq{
$0 [-e exclude:exclude ...] [-i include:include ...] [-T] statefile instance1 instance2 ...
check ops instance
-e exclude:exclude ... Jobs/Apps to exclude from monitoring, can be regexps
-i include:include ... Monitor only these Jobs/Apps, can be regexps
-T Check timestamp object (__\@Time::Period)
statefile Get states from this file
instance1 instance2 Instance to monitor, can be regexp
};

exit 1;
}

my %Args;

getopts('i:e:T', \%Args) || &Usage('Invalid parameter');
&Usage('Invalid parameter') if (@ARGV < 2);

open F, shift @ARGV or die "$!";

while (<F>) {

chomp;

# GRAPH;INSTANCE;APPLICATION;JOB;AGENT;STATUS;WAIT_H OUR?;WAIT_LINK?;WAIT_RES?;WAIT_ASK?;PID;OAC;ETQ_CU R
# 0 1 2 3 4 5 6 7 8 9 10 11 12
my @A = split /;/;
my $found = 0;

foreach (@ARGV) {
$found = 1 if ($A[1] =~ /$_/);
}

next unless $found;

$Instance{$A[1]}->{$A[2]}->{$A[3]} = \@A;
}


my %failed;
my $t = time;

# Check All instances
foreach my $instance (keys %Instance) {

# Check All Appl
foreach my $appl (keys %{$Instance{$instance}}) {

# Check All Jobs
foreach my $job (keys %{$Instance{$instance}->{$appl}}) {

next if (defined $Args{i} && !($appl =~ /$Args{i}/ || $job =~ /$Args{i}/));
next if (defined $Args{e} && ($appl =~ /$Args{e}/ || $job =~ /$Args{e}/));

my $l = $Instance{$instance}->{$appl}->{$job};

if (defined $Args{T} && ($job =~ /_@(.*)$/)) {
my $p = $1;

$p =~ tr/()\'/{},/;
push(@{$failed{$instance}}, "$instance, job [$job] not reach ")
if(inPeriod($t, $p) && ($l->[5] eq 'TOBEDONE'));
next;
}

push(@{$failed{$instance}}, "$instance, appl/job [$appl/$job] ERROR") if($l->[5] eq 'FAILED');
}
}
}

exit 0 unless (%failed);

my $l = "";

foreach (keys %failed) {

print $_." ";
$l .= join "\n", @{$failed{$_}};
$l .= "\n";
}

print "\n$l\n";

exit 1;


#!/usr/bin/perl
#================================================= ===========================
# opsservice.monitor --- check ops healthness
#
# $Locker$
# $Log$
# Author : Gilles Hamel
# Created On : Mon Jun 20 10:33:26 2005
# Last Modified By: Gilles Hamel
# Last Modified On: Fri Oct 28 16:25:33 2005
# Update Count : 82
# Status : Unknown, Use with caution!
# ================================================== =========================

#
# HISTORY

use Getopt::Std;
use English;


sub Usage {

print "$_[0]\n" if defined $_[0];

print
qq{
$0 [-G graph1[:graph2 ...] | -V view] [-f statefile] [-m modserver] [prodserver ... ]
check ops services healthness and get graph state
-G graph1[:graph2 ...] Get graphs states
-V view Get graphs states from ops view
-f statefile Put states in this file
-m modserver Modelisation server to check
prodserver Production servers to check
};

exit 1;
}

my %Args;

getopts('V:G:f:m:', \%Args) || &Usage('Invalid parameter');
die "Modelisation server must be defined" if ((defined $Args{'G'}|| defined $Args{'V'}) && !defined $Args{'m'});
die "Please choose view (-V) OR graphs (-G)" if (defined $Args{'G'} && defined $Args{'V'});

my %failed;


# Check Modelisation server
if (defined $Args{'m'}) {
my $o = `opscmd transexec -trans get_srv -server $Args{'m'} 2>&1`;
push @{$failed{$Args{'m'}}},"Modelisation server : $Args{'m'}\n$o\n$!" if ($?);
}


# Check Graph/Instance
if ((defined $Args{'G'} || defined $Args{'V'}) && ! %failed) {

my $fh = *STDOUT;
my $type = '-graph';
my $arg = $Args{'G'};

if (defined $Args{'V'}) {
$arg = $Args{'V'};
$type = '-view';
}

if (defined $Args{'f'}) {
open STATFILE, ">$Args{f}$$" or die $!;
$fh = *STATFILE;
}


foreach my $e (split (/:/, $arg)) {

my $o;

$o .= "$e;$_" foreach (`opscmd snapshot $type $e -mserver $Args{'m'} 2>&1`);

if ($?) {
push @{$failed{$Args{'m'}}}, "$o\n$!" if ($?);
next;
}

print $fh "$o";

}

if (defined $Args{'f'}) {
close STATFILE or die $!;
rename "$Args{f}$$", "$Args{f}" or die $!;
}
}

# Check Production servers
foreach (@ARGV) {

my $o;

eval {
local $SIG{ALRM} = sub { die };
alarm 90;
$o = `opsadm chkthr -pserver $_ 2>&1`;
alarm 0;
};

# Timeout reach
if ($@) {
push @{$failed{$_}},"Production server : $_\nTimeout reach, opspservice not responding\n";
next;
}

push @{$failed{$_}},"Production server : $_\n$o\n" if ($?);
}

exit 0 unless (%failed);

my $l = "";

foreach (keys %failed) {

print $_." ";
$l .= join "\n", @{$failed{$_}};
}

print "\n$l\n";

exit 1;



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:46 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com