Ad Widget

Collapse

Is there a way to collect any IPMI sensor data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blind_oracle
    Junior Member
    • Feb 2009
    • 23

    #16
    It works fine for me in 2.0.5

    Does ExternalScripts variable in zabbix config points to where the script is?

    My template's item are like:
    ipmi_sensors.pl['FAN 1', numeric, {$IPMI_HOSTNAME}]

    So, it's much like yours.
    Try to run this script as a zabbix user, maybe there's some permission issue.
    Does zabbix user have rights to write to a directory where the cache files are?
    In my case it's /var/tmp, but maybe you've changed it.

    Comment

    • mikesjn
      Junior Member
      • Jan 2009
      • 11

      #17
      Hi Blind_Oracle
      Definitely works if I su zabbix or su - zabbix, which is my zabbix usr account, and run ipmi_sensors.pl, I did change the temp directory, but the file is being written to:
      *********************************
      Output from running as zabbix user:

      zabbix@zabbixsvr:/usr/local/share/zabbix/externalscripts> ./ipmi_sensors.pl 'Fan1 RPM' numeric 192.168.128.175
      2760.00
      *********************************
      But the zabbix shows log shows [] as the output.

      Many thanks for your help
      Mike

      Comment

      • blind_oracle
        Junior Member
        • Feb 2009
        • 23

        #18
        So, the cache file is being created? Does it contain the right data?

        Comment

        • mikesjn
          Junior Member
          • Jan 2009
          • 11

          #19
          It is permissions

          Hi,
          It is permissions. I had the permissions set as user root grp zabbix rwr-xr-x ipmi-sensrs.pl and on temp dir when working.
          If I change the owner to zabbix on both script and tmp dir and output file I get no return. not sure what permissions to use?
          Thanks, I am in tghe right area now.
          Regards
          Mike

          Comment

          • blind_oracle
            Junior Member
            • Feb 2009
            • 23

            #20
            I have the script as zabbix:zabbix and 0550 chmod.

            The temp dir is usual /var/tmp which is root:root and 41777 (sticky bit)

            Comment

            • mikesjn
              Junior Member
              • Jan 2009
              • 11

              #21
              Hi,
              Still getting "became not supported: Received value [] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]"

              In the zabbix server log, setup the same as you suggested in the last post and get correct response if I run the query as zabbix user from the command line.
              Regards
              Mike

              Comment

              • blind_oracle
                Junior Member
                • Feb 2009
                • 23

                #22
                Sorry, i have no more ideas.
                The fact that script works from shell indicates that there's some problem with your OS or zabbix setup.

                Here's the latest version of the script (don't remember if it's any different from the one i've already posted), just in case:
                Code:
                # cat ipmi_sensors.pl
                #!/usr/bin/perl -w
                
                use strict;
                use warnings;
                use Fcntl ':flock';
                
                my $sensor = $ARGV[0];
                my $type = $ARGV[1];
                my $server = $ARGV[2];
                
                $type = 'numeric' if not defined $type;
                exit(1) if not defined $server or not defined $sensor;
                
                $sensor =~ s/\'//g;
                
                my $expires = 60;
                
                my $user = 'zabbix';
                my $pass = 'xxxxxxxx';
                
                my $ipmi_cmd = '';
                my $cache_file = '/var/tmp/ipmi_sensors_'.$server;
                $ipmi_cmd = '/opt/freeipmi/sbin/ipmi-sensors -D LAN2_0 -h '.$server.' -u '.$user.' -p '.$pass.' -l USER -W discretereading --no-header-output --comma-separated-output 2>/dev/null';
                
                my @rows = ();
                if(not -e $cache_file) {
                    open(CACHE, '>>', $cache_file);
                    if(flock(CACHE, LOCK_EX | LOCK_NB)) {
                        my $results = results();
                        if(defined $results) {
                            truncate(CACHE, 0);
                            print CACHE $results;
                            close(CACHE);
                        } else {
                            close(CACHE);
                            unlink($cache_file);
                            exit(1);
                        }
                    }
                } else {
                    open(CACHE, '>>', $cache_file);
                    if(flock(CACHE, LOCK_EX | LOCK_NB)) {
                        my @stat = stat($cache_file);
                        my $delta = time() - $stat[9];
                        if($delta > $expires or $delta < 0) {
                            my $results = results();
                            if(defined $results) {
                                truncate(CACHE, 0);
                                print CACHE $results;
                                close(CACHE);
                            } else {
                                close(CACHE);
                                unlink($cache_file);
                                exit(1);
                            }
                        }
                    }
                }
                
                open(CACHE, '<' . $cache_file);
                flock(CACHE, LOCK_EX);
                @rows = <CACHE>;
                close(CACHE);
                
                foreach my $row (@rows) {
                    my @cols = split(',', $row);
                    
                    if($cols[1] eq $sensor) {
                        if($type eq 'discrete') {
                            my $r = $cols[5];
                            $r =~ s/\'//g;
                            chop($r);
                            print $r;
                        } elsif($type eq 'numeric') {
                            if($cols[3] eq '' or $cols[3] eq 'N/A') {
                                print "0";
                            } else {
                                print $cols[3];
                            }
                        }
                    }
                }
                
                sub results {
                    my $results = `$ipmi_cmd`;
                    if($? == 0) {
                        return $results;
                    } else {
                        return undef;
                    }
                }

                Comment

                • mikesjn
                  Junior Member
                  • Jan 2009
                  • 11

                  #23
                  You are a star!

                  That is it. I can see what is was now, but it wasn't obvious - I had tried outputting to a text file and I couldn't see it then - there was an extra control character. New script works a treat. Thanks for all your help.
                  M

                  Comment

                  • blind_oracle
                    Junior Member
                    • Feb 2009
                    • 23

                    #24
                    Yes, i see that there was a newline in the end.
                    Looks like that i've dealt with the same issue and removed it, but have forgotten about it

                    Comment

                    • aigars
                      Member
                      • Apr 2010
                      • 55

                      #25
                      Maybe someone can help? Created script in zabbix external scripts directory and added chmod +x rights. When I run this script no output is provided.

                      Code:
                       ./ipmi_sensors.pl 'Temp 1' numeric x.x.x.x
                      When runing from command line like this I can get data
                      Code:
                       ipmi-sensors -D LAN2_0 -h hostname -u user -p pass  -l USER -W discretereading
                      Code:
                      0: UID Light (OEM Reserved): [OEM State = 0000h]
                      1: Sys. Health LED (OEM Reserved): [OEM State = 0000h]
                      2: Power Supply 1 (Power Supply): [Presence detected]
                      3: Power Supply 2 (Power Supply): [Presence detected]
                      4: Power Supplies (Power Supply): [Fully Redundant]
                      6: Fan 1 (Fan): [transition to Running]
                      7: Fan 2 (Fan): [transition to Running]
                      8: Fan 3 (Fan): [transition to Running]
                      9: Fan 4 (Fan): [transition to Running]
                      10: Fan 5 (Fan): [transition to Running]
                      11: Fan 6 (Fan): [transition to Running]
                      12: Fans (Fan): [Fully Redundant]
                      14: Temp 1 (Temperature): 19.00 C (NA/41.00): [OK]
                      15: Temp 2 (Temperature): 40.00 C (NA/82.00): [OK]
                      16: Temp 3 (Temperature): 40.00 C (NA/82.00): [OK]
                      17: Temp 4 (Temperature): 30.00 C (NA/87.00): [OK]
                      18: Temp 5 (Temperature): 29.00 C (NA/87.00): [OK]
                      19: Temp 6 (Temperature): 35.00 C (NA/87.00): [OK]
                      20: Temp 7 (Temperature): 36.00 C (NA/87.00): [OK]
                      21: Temp 8 (Temperature): 42.00 C (NA/90.00): [OK]
                      22: Temp 9 (Temperature): 34.00 C (NA/65.00): [OK]
                      23: Temp 10 (Temperature): 44.00 C (NA/90.00): [OK]
                      24: Temp 11 (Temperature): 34.00 C (NA/70.00): [OK]
                      25: Temp 12 (Temperature): 40.00 C (NA/90.00): [OK]
                      26: Temp 13 (Temperature): 34.00 C (NA/70.00): [OK]
                      27: Temp 14 (Temperature): 35.00 C (NA/70.00): [OK]
                      28: Temp 15 (Temperature): 34.00 C (NA/70.00): [OK]
                      29: Temp 16 (Temperature): NA (NA/70.00): [NA]
                      30: Temp 17 (Temperature): NA (NA/70.00): [NA]
                      31: Temp 18 (Temperature): NA (NA/70.00): [NA]
                      32: Temp 19 (Temperature): 24.00 C (NA/70.00): [OK]
                      33: Temp 20 (Temperature): 27.00 C (NA/70.00): [OK]
                      34: Temp 21 (Temperature): 31.00 C (NA/80.00): [OK]
                      35: Temp 22 (Temperature): 31.00 C (NA/80.00): [OK]
                      36: Temp 23 (Temperature): 37.00 C (NA/77.00): [OK]
                      37: Temp 24 (Temperature): 32.00 C (NA/70.00): [OK]
                      38: Temp 25 (Temperature): 32.00 C (NA/70.00): [OK]
                      39: Temp 26 (Temperature): 32.00 C (NA/70.00): [OK]
                      40: Temp 27 (Temperature): NA (NA/70.00): [NA]
                      41: Temp 28 (Temperature): NA (NA/70.00): [NA]
                      42: Temp 29 (Temperature): 35.00 C (NA/60.00): [OK]
                      43: Temp 30 (Temperature): 64.00 C (NA/110.00): [OK]
                      44: Memory (Memory): [Presence detected]
                      45: Power Meter (Current): [Device Enabled]
                      What I missed? Thanks!

                      Comment

                      • richlv
                        Senior Member
                        Zabbix Certified Trainer
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Oct 2005
                        • 3112

                        #26
                        necroposting with old news... but if somebody missed it, zabbix supports discrete ipmi sensors since 2.2

                        Zabbix 3.0 Network Monitoring book

                        Comment

                        Working...