Cloud Deployment und (Auto)Scaling am Beispiel von Angrybird
check_sap_health
1. Seite
Monitoring von SAP mit
check_sap_health
Gerhard Laußer
ConSol Software GmbH
Monitoring-Workshop 2016
2. Seite
Runterladen, bauen, installieren
$ git clone http://github.com/lausser/check_sap_health
$ cd check_sap_health
$ autoreconf
$ ./configure
$ make
$ cp plugins-scripts/check_sap_health
$OMD_ROOT/local/lib/nagios/plugins
13.09.2016 www.consol.de2
3. Seite
Perl-Modul sapnwrfc
$ cd /tmp
$ SAPCAR -xf NWRFC_20-20004565-Linux-x86_64.SAR
--> erzeugt /tmp/nwrfcsdk
$ perl -MCPAN -e "install sapnwrfc"
…
No libsapnwrfc installation found, usually in /usr/sap/nwrfcsdk
Which libsapnwrfc build path do you want to link against? /tmp/nwrfcsdk
$ cp libicudata.so.34 libicudecnumber.so libicui18n.so.34 libicuuc.so.34
libsapnwrfc.so libsapucum.so $OMD_ROOT/local/lib
13.09.2016 www.consol.de3
5. Seite
Klopf, Klopf
13.09.2016 www.consol.de5
$ check_sap_health
--ashost 172.24.0.195
--sysnr 42
--username NAGIOS
--password soigan
--mode connection-time
OK - 0.06 seconds to connect as NAGIOS@NPL|'connection_time'=0.06;1;5;;
$ check_sap_health
--ashost 172.24.0.195
--sysnr 42
--username NAGIOS
--password soigan
--mode connection-time
--warning 0.05
--critical 1
WARNING - 0.07 seconds to connect as NAGIOS@NPL |
'connection_time'=0.07;0.05;1;;
6. Seite
Klopf, Klopf – keiner daheim
13.09.2016 www.consol.de6
$ check_sap_health
--ashost 172.24.0.195
--sysnr 42
--username NAGIOS
--password soigan
--mode connection-time
CRITICAL - cannot create rfc connection: RFC connection open failed: 1 /
RFC_COMMUNICATION_FAILURE /
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '172.24.0.195:3342' not reached
TIME Tue May 13 13:22:30 2014
RELEASE 720
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3285
DETAIL NiPConnect2: 172.24.0.195:3342
SYSTEM CALL connect
ERRNO 111
ERRNO TEXT Connection refused
COUNTER 1
7. Seite
Klopf, Klopf – keiner daheim - Aufräumen
13.09.2016 www.consol.de7
$ check_sap_health
--ashost 172.24.0.195
--sysnr 42
--username NAGIOS
--password soigan
--mode connection-time
CRITICAL - cannot create rfc connection: RFC connection open failed: 1 /
RFC_COMMUNICATION_FAILURE /
$ ls /tmp
… rfc03337_2240837376.trc rfc11683_456742656.trc rfc03384_3936470784.trc
rfc15772_808535808.trc rfc03386_4080981760.trc rfc15774_2616141568.trc
…
hinterlässt /tmp/dev_rfc.trc (wächst und wächst…) oder rfc<pid>.trc (müllt
$RFC_TRACE_DIR zu)
check_sap_health löscht selbständig Files, die älter als 5 Minuten sind.
8. Seite
CCMS-Baum auflisten – zuerst die Monitor Sets
13.09.2016 www.consol.de8
$ check_sap_health … --mode list-ccms-monitor-sets
FlowLogicAccess
Klaus
SAP (CEN) B2B Procurement - Monitors
SAP (CEN) EBP Procurement Internal Monitors
SAP (CEN) EnterpriseBuyer Monitors
SAP APO Monitor
SAP BI Monitors
SAP Business Communication
SAP Business Workflow
SAP CCMS Admin Workplace
SAP CCMS Monitor Templates
SAP CCMS Monitors for Optional Components
SAP CCMS Technical Expert Monitors
SAP CCMS Technical Operations Templates
SAP CCMS Web Admin Monitor Templates
SAP CRM Monitor Templates
SAP CRM Monitor Templates for Release 6.20
SAP E-Sourcing Monitor Template
SAP EM Monitor Templates
SAP ERP Monitor Templates
SAP EWM Monitor Templates
SAP GBT Monitor Templates
SAP GDS Monitor Set
SAP GRC Global Trade Services Monitors
SAP IW - Monitors
SAP J2EE Monitor Templates
SAP LPO Lean Production and Operations Monitor Templates
SAP Mobile Infrastructure Monitor Templates
SAP NetWeaver Enterprise Search Monitor Templates
SAP OperatorWorkplace
SAP Portfolio and Project Management Monitor Templates
SAP Process Monitoring Infrastructure
SAP RRR Monitor
SAP SCM Basis Monitor Templates
SAP SCM Monitor Templates
SAP SNC Monitor Templates
9. Seite
CCMS-Baum auflisten – dann die Monitore
13.09.2016 www.consol.de9
$ check_sap_health … --mode list-ccms-monitors
--name "SAP CCMS Monitor Templates"
SAP CCMS Monitor Templates
Availability and Performance Overview
Background Processing
Buffers
Change & Transport System
Communications
Data Archiving
Database
Dialog Overview
Dialog per Application Server
Enqueue
Entire System
Exchange Infrastructure
Filesystems
J2EE Applications
J2EE Engine
Operating System
Performance Overview
Remote Databases
Security
Spool System
Syslog
System Configuration
System Errors
VM Container
Workload Collector
liveCache
OK - have fun
10. Seite
CCMS-Baum auflisten – dann die MTEs
13.09.2016 www.consol.de10
• MT_CLASS_PERFORMANCE
$ check_sap_health … --mode list-ccms-mtes --name "SAP CCMS Monitor
Templates" --name2 "Enqueue"
NPLEnqueueEnqueue 50
NPLEnqueueEnqueue Server 70
NPLEnqueueEnqueue ServerBackup Requests 100
NPLEnqueueEnqueue ServerCleanUp Requests 100
…
NPLEnqueueEnqueue ServerEnqueue Requests 100
NPLEnqueueEnqueue ServerGranule Arguments 111
NPLEnqueueEnqueue ServerGranule Arguments Actual Utilisation 100
NPLEnqueueEnqueue ServerGranule Arguments Peak Utilisation 111
NPLEnqueueEnqueue ServerGranule Entries 111
…
NPLEnqueueEnqueue ServerOwner Names Actual Utilisation 100
NPLEnqueueEnqueue ServerOwner Names Peak Utilisation 111
NPLEnqueueEnqueue ServerRecent Lock Time (per minute) 100
NPLEnqueueEnqueue ServerRecent Lock Wait Time (per minute) 100
NPLEnqueueEnqueue ServerRecent Server Time (per minute) 100
…
NPLEnqueueEnqueue ServerRuntime of Data Collector 100
NPLEnqueueEnqueue ServerTotal Lock Time 111
NPLEnqueueEnqueue ServerTotal Lock Wait Time 111
NPLEnqueueEnqueue ServerUpdate Queue Peak 111
NPLnplhost_NPL_42EnqueueClient 70
…
NPLnplhost_NPL_42EnqueueServerUtilisation Granule Arguments 100
NPLnplhost_NPL_42EnqueueServerUtilisation Granule Entries 100
NPLnplhost_NPL_42EnqueueServerUtilisation Owner Names 100
Connection to Standalone Enqueue 199
Enqueue 199
Enqueue Clients 199
OK
100 = MT_CLASS_PERFORMANCE
111 = MT_CLASS_SHORTTEXT
11. Seite
CCMS-MTE herausgreifen
13.09.2016 www.consol.de11
• MT_CLASS_PERFORMANCE
$ check_sap_health … --mode ccms-mte-check
--name "SAP CCMS Monitor Templates"
--name2 "Enqueue"
--name3 "NPLEnqueueEnqueue ServerTotal Lock Time"
OK - Total Lock Time = 0.188 s | 'Enqueue Server_Total Lock Time'=0.18s;;;;
12. Seite
Nochmal, aber ohne hässliche Backslashes
13.09.2016 www.consol.de12
• MT_CLASS_PERFORMANCE
$ check_sap_health … --mode ccms-mte-check
--name "SAP CCMS Monitor Templates"
--name2 "Enqueue"
--name3 "NPL#Enqueue#Enqueue Server#Total Lock Time"
--separator "#"
OK - Total Lock Time = 0.188 s | 'Enqueue Server_Total Lock Time'=0.18s;;;;
13. Seite
Mit regulären Ausdrücken
13.09.2016 www.consol.de13
$ check_sap_health … --mode ccms-mte-check
--name "SAP CCMS Monitor Templates"
--name2 "Enqueue"
--name3 "Lock Time" --regexp
OK - Enqueue Server Recent Lock Time (per minute) = 0s, Total Lock Time = 0.195 s | 'Enqueue Server_Recent
Lock Time (per minute)'=0s;0:;0:;; 'Enqueue Server_Total Lock Time'=0.20s;;;;
$ check_sap_health … --mode ccms-mte-check
--name "SAP CCMS Monitor Templates"
--name2 "Enqueue"
--name3 "Lock.*Time" --regexp
OK - Enqueue Server Recent Lock Time (per minute) = 0s, Enqueue Server Recent Lock Wait Time (per minute)
= 0s, Total Lock Time = 0.195 s, Total Lock Wait Time = 0.031 s | 'Enqueue Server_Recent Lock Time (per
minute)'=0s;0:;0:;; 'Enqueue Server_Recent Lock Wait Time (per minute)'=0s;0:;0:;; 'Enqueue Server_Total
Lock Time'=0.20s;;;; 'Enqueue Server_Total Lock Wait Time'=0.03s;;;;
17. Seite
CCMS am Solution Manager auslesen
13.09.2016 www.consol.de17
Im Solution Manager beinhalten die MTE-Namen zusätzlich die SID der
angeschlossenen Systeme
$ check_sap_health … --mode ccms-mte-check
--name "SAP CCMS Monitor Templates"
--name2 "Enqueue"
--name3 "$_SERVICESID$.*(Enqueue Request Errors)|(Enqu…."
--regexp --multiline
OK - Enqueue Server Enqueue Request Errors = 0/sec
Enqueue Server Enqueue Request Rejects = 0/sec | 'Enqueue
Server_Enqueue Request Errors'=0;0:;0:;; 'Enqueue Server_Enqueue
Request Rejects'=0;0:;0:;;
18. Seite
CCMS Beispiele
13.09.2016 www.consol.de18
define service {
service_description app_sap_NPL_default_check_datafile_offline
host_name WAWIS12
use generic-service
check_command check_sap_health_ccms!60!
$HOSTADDRESS$!42!001!NAGIOS!soigan!
SAP CCMS Monitor Templates!Database!#Database file offline
}
define service {
service_description app_sap_NPL_default_check_tablespace_usage
host_name WAWIS12
use generic-service
check_command check_sap_health_ccms!60!
$HOSTADDRESS$!42!001!NAGIOS!soigan!
SAP CCMS Monitor Templates!Database!#Used space
}
define service {
service_description app_sap_NPL_default_check_last_backup
host_name WAWIS12
use generic-service
check_command check_sap_health_ccms!60!
$HOSTADDRESS$!42!001!NAGIOS!soigan!
SAP CCMS Monitor Templates!Database!#Last succ. complete database
backup
}
define service {
service_description app_sap_NPL_default_check_last_log_backup
host_name WAWIS12
use generic-service
check_command check_sap_health_ccms!60!
$HOSTADDRESS$!42!001!NAGIOS!soigan!
SAP CCMS Monitor Templates!Database!#Archiving#Last succ. archive
log backup
}
define service {
service_description app_sap_NPL_default_check_spool_used
host_name WAWIS12
use generic-service
check_command check_sap_health_ccms!60!
$HOSTADDRESS$!42!001!NAGIOS!soigan!
SAP CCMS Monitor Templates!Spool
System!#Spool#SpoolNumbers#UsedNumbers
}
define service {
service_description app_sap_NPL_default_check_connect
host_name WAWIS12
use generic-service,srv-pnp
check_command check_sap_health!60!
$HOSTADDRESS$!42!001!NAGIOS!soigan!
connection-time!--warning 10 --critical 20
}
define servicedependency {
name dependency_app_sap_NPL_default_check_connect
host_name WAWIS12
service_description app_sap_NPL_default_check_connect
execution_failure_criteria u,c
notification_failure_criteria u,c
dependent_service_description
app_sap_NPL_default_check_datafile_offline,
app_sap_NPL_default_check_tablespace_usage,
app_sap_NPL_default_check_last_backup,
app_sap_NPL_default_check_last_log_backup,
app_sap_NPL_default_check_spool_used,
!app_sap_NPL_default_check_connect
}
……
Last Optimizer Run, Enqueue system, Shortdumps, Caches, Response
Times, Optimizer Statistics, Deadlocks, Memory Management,
R3Rollpaging, Aborted Jobs, uvm.
19. Seite
CCMS ist nicht alles
SAP-Admins benutzen Solution Manager (d.h. CCMS mit Bordmitteln).
SAP-Admins sind gutmütig und haben kein Problem mit Nagios-Usern.
Nagios-Notification ist praktisch für Umbrella-Monitoring.
In SAP-Systemen stecken teure Anpassungen, core business critical
enterprise key customer blablubb. Monitoring als Qualitätssicherung.
Fremdsysteme kommunizieren mit SAP (RFC-enabled functions).
Verfügbarkeit der Schnittstellen (und Antwortzeiten) .
In SAP steckt viel Business-Logik. Der Zugriff von Aussen (Nagios) ist
kein Hexenwerk.
Störungen im Materialfluss/Bestellwesen/Anlieferung/… erregen mehr
Aufmerksamkeit als schlechte Dialog-Response-Zeiten.
13.09.2016 www.consol.de19
20. Seite
Erweiterungen schreiben
13.09.2016 www.consol.de20
$OMD_ROOT/etc/check_sap_health/CheckSapHealthTest.pm
package MyTest;
our @ISA = qw(Classes::SAP);
use Time::HiRes;
sub init {
my $self = shift;
my $bapi_tic = Time::HiRes::time();
if ($self->mode =~ /my::test::rfcping/) {
my $ping = $self->session->function_lookup("RFC_PING");
my $fc = $ping->create_function_call;
my $frc = $fc->invoke();
$self->add_ok("pong");
# $fc kann jetzt weiter ausgewertet werden
}
my $bapi_tac = Time::HiRes::time();
my $bapi_duration = $bapi_tac - $bapi_tic;
$self->set_thresholds(warning => 5, critical => 10);
$self->add_message($self->check_thresholds($bapi_duration),
sprintf "runtime was %.2fs", $bapi_duration);
$self->add_perfdata(
label => 'runtime',
value => $bapi_duration,
);
}
21. Seite
Erweiterungen schreiben – einfacher Demo-Ping
13.09.2016 www.consol.de21
package MyTest;
…
sub init {
…
if ($self->mode =~ /my::test::rfcping/) {
$ check_sap_health
--with-mymodules-dyn-dir $USER4/check_sap_health
--mode my-test-rfcping
OK - pong, runtime was 0.02s | 'runtime'=0.02;5;10;;
MyTest
my::test::rfcping
my-test-rfcping
22. Seite
API für selbstgeschriebene Erweiterungen
Man braucht
sub init { my $self = shift;
$self->mode ist der Kommandozeilenparameter --mode in der internen
Repräsentation. (Doppeldoppelpunkt statt Bindestrich)
$self->opts->para ist der Wert des Kommandozeilenparameter para
$self->session ist das Handle für die RFC-Verbindung
$self->add_ok(text), $self->add_warning(text), …
$self->set_thresholds(warning => defwarn, critical => defcrit)
$self->check_thresholds(value)
$self->add_perfdata(label => label, value => value, [uom => uom])
13.09.2016 www.consol.de22
23. Seite
Beispiel 2: BAPI_BUPA_CENTRAL_GETLIST
13.09.2016 www.consol.de23
$ check_sap_health --with-mymodules-dyn-dir $USER4/etc/check_sap_health
--mode my-bapi-bpgetlist --name A000000001
OK - BAPI_BUPA_CENTRAL_GETDETAIL is OK, found partner ConSol* Software
GmbH, runtime was 0.14s | 'runtime'=0.14;5;10;;
25. Seite13.09.2016 www.consol.de25
etc/check_sap_health/CheckSapHealthBapi.pm
package MyBapi;
our @ISA = qw(Classes::SAP);
use Time::HiRes;
sub init {
my $self = shift;
my $bapi_tic = Time::HiRes::time();
if ($self->mode eq "my::bapi::bpgetlist") {
eval {
my $fl =
$self->session->function_lookup("BAPI_BUPA_CENTRAL_GETLIST");
my $fc = $fl->create_function_call;
$fc->BUSINESSPARTNER($self->opts->name); # A000000001
$fc->VALIDFROM("01010001");
$fc->VALIDTO("31129999");
$fc->invoke;
my @rows = @{$fc->RETURN};
if (scalar(@rows) == 0) {
# leere Tabelle RETURN ist OK
$self->add_ok("BAPI_BUPA_CENTRAL_GETDETAIL is OK");
$fc->CENTRALDATAORGANIZATION->[0]->{NAME1}
=~ s/s+$//;
$self->add_ok(sprintf "found partner %s",
$fc->CENTRALDATAORGANIZATION->[0]->{NAME1});
} elsif (scalar(@rows) == 1) {
if ($rows[0]->{TYPE} =~ /^(E|A)/) {
$self->add_unknown($rows[0]->{MESSAGE});
} else {
$self->add_ok("BAPI_BUPA_CENTRAL_GETDETAIL is OK");
}
} else {
foreach my $row (@rows) {
$errors++ if $row->{TYPE} =~ /^(E|A)/
&& $rownum > 0;
$rownum++;
}
$self->add_message($errors ? 2 : 0,
sprintf "BAPI_BUPA_CENTRAL_GETDETAIL returned %d
errors (in %d rows)",
$errors, $rownum);
}
};
if ($@) {
$self->add_unknown($@);
}
} elsif ($self->mode =~ /my::bapi::weiterefunktionen/) {
} else {
$self->add_unknown("unknown mode");
}
my $bapi_tac = Time::HiRes::time();
my $bapi_duration = $bapi_tac - $bapi_tic;
$self->set_thresholds(warning => 5, critical => 10);
$self->add_message($self->check_thresholds($bapi_duration),
sprintf "runtime was %.2fs", $bapi_duration);
$self->add_perfdata(
label => 'runtime',
value => $bapi_duration,
);
}
26. Seite
Job- und SLA-Monitoring
End-of-Day-Jobs und insbes. nächtliche Batches (bei Banken üblich)
werden in Tabellen in SAP protokolliert, incl. Startzeit, Endezeit, Status.
Mit check_sap_health kann man überwachen, ob Jobs erfolgreich und
innerhalb eines SLA-Fensters abgeschlossen wurden.
(Oder man verwendet check_sap_health, um solche Daten aus SAP zu
holen und in eine generische Job-Tabelle zu schreiben)
Bsp.: Job muss um 07:45 fertig sein, ab 10 Min. Verspätung gibt‘s Ärger.
check_sap_health --mode my-eod-sla
--name FI_LOAN_CALC
--name2 07:45
--warning 0 --critical 600
13.09.2016 www.consol.de26
28. Seite
Kurzdumps monitoren
Intern stehen die Shortdumps in der Tabelle SNAP.
Mit RFC kann man die Tabelle auslesen und prüfen, ob seit dem letzten
Lauf des Plugins neue Dumps hinzugekommen sind.
$ check_sap_health …
--mode shortdumps-count
OK - no new shortdumps
$
$ check_sap_health …
--mode shortdumps-count
CRITICAL - 2 new shortdumps appeared between 20160822 120339 and
20160822 120840
$ check_sap_health …
--mode shortdumps-count
--name username --name2 program
13.09.2016 www.consol.de28
29. Seite
Verbuchungen monitoren
Verbuchungen werden in der Tabelle VBHDR protokolliert.
Mit RFC kann man die Tabelle auslesen und prüfen, ob seit dem letzten
Lauf des Plugins (oder einem beliebigen lookback-Zeitraum)
Verbuchungsfehler auftraten.
$ check_sap_health …
--mode failed-updates
CRITICAL – 8 new failed update records appeared between 20160905 165301
and 20160905 165801
$ check_sap_health …
--mode failed-updates
--lookback 3600
CRITICAL – 29 new failed update records appeared between 20160905 165612
and 20160905 155612
13.09.2016 www.consol.de29
30. Seite
Jobabbrüche monitoren
Background-Jobs werden in der Tabelle TBTCO protokolliert.
Mit RFC kann man die Tabelle auslesen und prüfen, ob seit dem letzten
Lauf des Plugins (oder einem beliebigen lookback-Zeitraum) Abbrüche
auftraten.
$ check_sap_health …
--mode list-jobs
SAP* CROSSIT 24.08.2016 19:32:37 4 25 F
SAP* CROSSIT 24.08.2016 19:42:37 32 25 F
SAP* CROSSIT 24.08.2016 19:52:37 31 25 F
SAP* CROSSIT 24.08.2016 20:02:37 9 25 F
SAP* CROSSIT 24.08.2016 20:12:37 7 25 F
SAP* CROSSIT 24.08.2016 20:22:37 26 25 F
OK
(User, Jobname, Enddate+Endtime, Runtime, Delay, Status)
13.09.2016 www.consol.de30
31. Seite
Jobabbrüche monitoren
Background-Jobs werden in der Tabelle TBTCO protokolliert.
Mit RFC kann man die Tabelle auslesen und prüfen, ob seit dem letzten
Lauf des Plugins (oder einem beliebigen lookback-Zeitraum) Abbrüche
auftraten.
$ check_sap_health …
--mode exceeded-failed-jobs
--lookback 3600
WARNING - job CROSSIT of user SAP* ran for 26s |
'SAP*_CROSSIT_runtime'=26s;20;300;;
$ check_sap_health …
--mode failed-jobs
--lookback 3600
OK - all jobs finished in time with status ok
13.09.2016 www.consol.de31
32. Seite
Prozesse monitoren
Anzahl der einzelnen Prozesstypen.
$ check_sap_health
--mode list-processes
DIA 22136 Running
DIA 22137 Waiting
DIA 22138 Waiting
DIA 22139 Waiting
UPD 22140 Waiting
ENQ 22141 Waiting
BGD 22142 Waiting
BGD 24011 Waiting
SPO 22144 Waiting
UP2 22145 Waiting
OK - have fun
13.09.2016 www.consol.de32
33. Seite
Prozesse monitoren
Anzahl der einzelnen Prozesstypen. Mit criticalx/warningx und dem
perfdata-Label können Schwellwerte ganz gezielt gesetzt werden.
$ check_sap_health
--mode count-processes
--warningx num_dia=10: --criticalx num_dia=:3
WARNING - 4 DIA processes, 1 UPD process, 1 UP2 process, 2 BGD
processes, 1 ENQ process, 1 SPO process | 'num_dia'=4;10:;:3;;
'num_upd'=1;1:;1:;; 'num_up2'=1;1:;1:;; 'num_bgd'=2;1:;1:;;
'num_enq'=1;1:;1:;; 'num_spo'=1;1:;1:;;
13.09.2016 www.consol.de33