[icinga-checkins] icinga.org: icinga-core/fholzer/core: add sub for reading errors out of syslog

git at icinga.org git at icinga.org
Tue Apr 24 13:34:57 CEST 2012


Module: icinga-core
Branch: fholzer/core
Commit: c08c5cc81e1f69e653b2e616c71993e11ada5796
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=c08c5cc81e1f69e653b2e616c71993e11ada5796

Author: Franz Holzer <office at frankstar.at>
Date:   Tue Apr 24 13:35:02 2012 +0200

add sub for reading errors out of syslog
some bugfix

---

 tools/icinga_verification.pl |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/tools/icinga_verification.pl b/tools/icinga_verification.pl
index ff110d6..3bbfc4b 100644
--- a/tools/icinga_verification.pl
+++ b/tools/icinga_verification.pl
@@ -38,6 +38,7 @@ sub get_distribution;
 sub find_icinga_dir;
 sub get_icinga_version;
 sub get_ido2db_version;
+sub get_error_from_log;
 
 # preconfiguration
 my $config_ref = {
@@ -198,6 +199,9 @@ my $ido2dbversion = get_ido2db_version();
 my $selinux = which('selinuxenabled') ? qx(getenforce) : 'selinux binary not found';
 chomp($selinux);
 
+#log file test
+my $idolog = get_error_from_log("/var/log/messages", 'ido2db');
+
 ################################
 # Icinga Checks
 ################################
@@ -243,10 +247,6 @@ my $idomodssl = get_key_from_ini("$icinga_base/idomod.cfg", 'use_ssl');
 #idomod TCP port
 my $idomodtcpport = get_key_from_ini("$icinga_base/idomod.cfg", 'tcp_port');
 
-
-#ido2db - idomod socket compare
-
-
 # MySQL Checks #
 my $dbh_conn_error = '';
 my @result_icingadb  = ();
@@ -346,6 +346,7 @@ idomod Information:
  SSL Status: $idomodssl
  TCP Port: $idomodtcpport
  
+ $idolog
 ##################### Test Results: ########################
 
 Mysql Connection with ido2db.cfg:
@@ -498,4 +499,25 @@ sub get_ido2db_version {
     } else {
         return 'ido2db binary not found in PATH';
     }
-}
\ No newline at end of file
+}
+
+sub get_error_from_log ($$) {
+    my ( $file, $key ) = @_;
+
+    if ( !-f $file ) {
+        print STDERR "logfile $file does not exist\n";
+        return;
+    }
+
+    if ( open( my $fh, '<', $file ) ) {
+        while ( my $line = <$fh> ) {
+            chomp($line);
+			print "\nread error:\n $line \nfrom $file","\n", if $verbose;
+            if ( $line =~ /\$key:/ ) {
+                return $1;
+            }
+        }
+    } else {
+        print STDERR "Could not open logfile $file: $!\n";
+    }
+}





More information about the icinga-checkins mailing list