Hi List,

I was adding a few checks for oracle processes using check_snmp_runningproc
and noticed a few problems.  It seems that when the check returns a list of
processes from a remote host it lowercases them all and attempts to strips
out .e .ex and .exe extensions.

The extensions used in the regular expression weren't escaping the dot which
resulted them in stripping out any character followed by an e, ex or exe.
 In my case this meant it was matching against "orac" instead of oracle.

I also noticed that the user input wasn't undergoing the same translations
as the returned processes (both the conversion to lower case and the
stripping of extensions).  I fixed this by cleaning up the regexp and adding
in a lc() function and the same regexp for user input.  Below is a diff that
can be used to patch the issue.

If theres a different format that should be used for diff's please let me
know.  The below was done with 'diff -ur'.

Thanks,

Killian


--- check_snmp_runningproc      2010-06-28 12:12:25.000000000 +0100
+++ check_snmp_runningproc-new  2010-06-25 16:36:54.000000000 +0100
@@ -76,7 +76,10 @@
     # print "Using community $community\n";
 }
 if ($opt_p) {
-    $processes = $opt_p;
+    $processes = lc($opt_p);
+    $processes =~ s/\.exe//g;    # removes .exe file extentions
+    $processes =~ s/\.ex//g;     # removes .ex file extentions
+    $processes =~ s/\.e//g;      # removes .e file extentions
 }
 else {
     print "No processes specified\n";
@@ -149,11 +152,10 @@
             $returnedprocess = $s->var_bind_list()->{$oid};

             $returnedprocess = lc($returnedprocess);
-            $returnedprocess =~ s/.exe//g;    # removes .exe file
extentions
-            $returnedprocess =~ s/.ex//g;     # removes .ex file extentions
-            $returnedprocess =~ s/.e//g;      # removes .e file extentions
+            $returnedprocess =~ s/\.exe//g;    # removes .exe file
extentions
+            $returnedprocess =~ s/\.ex//g;     # removes .ex file
extentions
+            $returnedprocess =~ s/\.e//g;      # removes .e file extentions
             $counter = 0;
-
             foreach $line (@processes) {
                 if ( $returnedprocess =~ m/$line/ ) {
                     @matches[$counter] = @matches[$counter] + 1;
_______________________________________________
Opsview-users mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-users

Reply via email to