Hi everybody,

I've been bashing my head against the wall for 3 days already and I 
can't seem to be able to understand what's going on.

As I've already googled about this until my fingers bled I decided to 
ask you guys, maybe you're in a better position on this:

Here's the issue

Icinga (classic) install: 1.10.2

OS:
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.3 LTS
Release:        12.04
Codename:       precise

Completely random 2 commands end up with the error in $subj.

Here's the script (command):

#!/usr/bin/php
<?php
$HOSTNAME=$argv[1];

$lines=snmprealwalk($HOSTNAME,'public','.1.3.6.1.4.1.2021.9.1');
foreach($lines as $key=>$value) {
     if (!empty($value)) {
         $second=explode('iso.3.6.1.4.1.2021.9.1.',$key);
         $third=explode('.',$second[1]);
         $index=trim($third[1]);
         $diskInfo[$index][$third[0]]=$value;
     }
}
$infoLine='';
$status=0;
foreach ($diskInfo as $diskKey=>$diskValues) {
     if (!strpos($diskValues[3],'/dev')) {
         unset($diskInfo[$diskKey]);
     } else {
         $diskName=trim(clean($diskValues[2]));
         if($diskName=='/') {
             $diskName='root';
         }
         $diskInfo[$diskKey][2]=$diskName;
         $infoLine.= 
$diskName.'('.trim(clean($diskValues[3])).'):'.trim(clean($diskValues[9])).'% 
used; ';
         $percentUsed=(int)trim(clean($diskValues[9]));
         if($percentUsed >= 90 ) $status=1;
         if($percentUsed >= 99 ) $status=2;
     }
}
fwrite(STDOUT, $infoLine."\n");
exit($status);
function clean($data){
     $dataArray = explode(':',$data);
     $dataOutput = trim($dataArray[1]);
     $dataOutput = str_replace('"','',$dataOutput);
     return $dataOutput;
}


Running this from command line (shell) outputs the correct answer 
including the exit code:
root@louie:~# sudo -u icinga /usr/local/icinga/libexec/check_disk_snmp 
172.20.1.21 2>/dev/null ; echo $?
root(/dev/sda1):19% used; /boot(/dev/sda2):18% used;
0
and as the user itself:
/usr/local/icinga/libexec/check_disk_snmp 172.20.1.21 2>/dev/null ; echo $?
root(/dev/sda1):19% used; /boot(/dev/sda2):18% used;
0

so everything seems to be correct (as far as i can tell)

Here's the service definition

define service {
                 service_description check_disk_snmp
                 check_command check_disk_snmp
                 host_name                             telefonix
                 check_period                          24x7
                 notification_period                   24x7
                 register                              1
                 max_check_attempts                    3
                 check_interval                        5
                 retry_interval                        5
                 first_notification_delay              5
                 notification_interval                 5
                 active_checks_enabled                 1
                 notifications_enabled                 1
                 event_handler_enabled                 0
                 contact_groups                        +C1
}


Any ideas ?

Thx in adavnce:
Radu Dragomir

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
icinga-users mailing list
icinga-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/icinga-users

Reply via email to