bitmuncher
Foren Gott
Ich hab hier ein Nagios mit Nagiosgrapher auf einem lenny laufen. Prinzipiell funktioniert auch alles, aber Nagiosgrapher erstellt für einige Werte keine Grafiken, obwohl entsprechende Konfigurationen vorliegen. Dies betrifft z.B. den Wert, der ausgibt wieviele Sockets eine Tomcat-Instanz offen hat. Ermittelt wird dies mit folgendem Skript/Plugin:
Die Graphen-Definition im Nagios-Grapher sieht dafür so aus:
Diese Definition existiert für jede Tomcat-Instanz (p0 bis p6) auf den Servern. Nagiosgrapher meint dazu aber nur
Ich hatte als graph_log_regex auch schon '(\d+) sockets' versucht, aber das bringt das gleiche Ergebnis. Seltsamerweise funktionieren ähnliche Graphen aber problemlos. Das Problem tritt scheinbar zumeist dann auf, wenn der zu verarbeitende Wert am Anfang des Plugin-Outputs steht. Allerdings auch nicht immer, denn ich habe z.B. ein Plugin, das ausgibt wieviele neue Log-Einträge es in einem Tomcat gibt und dessen graph_log_regex '(\d+) new entries' funktioniert problemlos. Das gleiche Problem existiert aber auch noch bei einigen anderen Graphen (z.B. zum Heap Memory u.a.).
Hat irgendwer eine Idee wie das Problem zu lösen ist?
Code:
#!/usr/bin/perl
use Getopt::Std;
my $OK_STATE = 0;
my $WARNING_STATE = 1;
my $CRITICAL_STATE = 2;
getopts('i:w:c:') or die "Usage: $0 -i <instance> -w <warnlevel> -c <critlevel>";
if(!$opt_w || !$opt_c || !$opt_i) {
print "Usage: $0 -i <instance> -w <warnlevel> -c <critlevel>";
exit $WARNING_STATE;
}
my $warn_level = $opt_w;
my $crit_level = $opt_c;
my $instance = $opt_i;
$cmd = "ps ax | grep catalina | grep ".$instance." | grep -v 'ps ax' | awk '{print \$1}'";
my $tmp = `$cmd`;
chomp($tmp);
$cmd = "sudo /bin/netstat -lntpa | awk '{print \$7}' | grep ".$tmp." | wc -l";
$tmp = `$cmd`;
my $count = $tmp + 0;
if($crit_level <= $count) {
print "CRITICAL - ".$count." sockets.\n";
exit $CRITICAL_STATE;
} elsif($warn_level <= $count) {
print "WARNING - ".$count." sockets.\n";
exit $WARNING_STATE;
} else {
print "OK - ".$count." sockets.\n";
exit $OK_STATE;
}
Die Graphen-Definition im Nagios-Grapher sieht dafür so aus:
Code:
define ngraph{
service_name Tomcat open sockets p0
graph_log_regex ([0-9]+)\s+sockets
graph_value sockets
graph_units sockets
graph_legend open sockets
rrd_plottype AREA
rrd_color ff0000
}
Diese Definition existiert für jede Tomcat-Instanz (p0 bis p6) auf den Servern. Nagiosgrapher meint dazu aber nur
Code:
2010-01-12 12:08:46 REGEX: 2 blocks for 'Tomcat open sockets p0' found.
2010-01-12 12:08:46 REGEX: graph_value=sockets
2010-01-12 12:08:46 REGEX: perfdata=ok - 23 sockets.
2010-01-12 12:08:46 VALUES: [de05.domain.tld][Tomcat open sockets p0]:No matching output values found...
Ich hatte als graph_log_regex auch schon '(\d+) sockets' versucht, aber das bringt das gleiche Ergebnis. Seltsamerweise funktionieren ähnliche Graphen aber problemlos. Das Problem tritt scheinbar zumeist dann auf, wenn der zu verarbeitende Wert am Anfang des Plugin-Outputs steht. Allerdings auch nicht immer, denn ich habe z.B. ein Plugin, das ausgibt wieviele neue Log-Einträge es in einem Tomcat gibt und dessen graph_log_regex '(\d+) new entries' funktioniert problemlos. Das gleiche Problem existiert aber auch noch bei einigen anderen Graphen (z.B. zum Heap Memory u.a.).
Hat irgendwer eine Idee wie das Problem zu lösen ist?