ZABBIX Forums  
  #21  
Old 16-12-2014, 08:26
mirddin mirddin is offline
Junior Member
 
Join Date: Nov 2013
Location: Kyiv, Ukraine
Posts: 21
Default Ilo_user+ilo_pass

At first, thanks topicstarter for the great script! =)

Here's a small update, just to be able to use different user/pass

Two additional variables {$ILO_USER} and {$ILO_PASS}.
Attached Files
File Type: gz ipmi_script_ilo_discovery.tar.gz (5.0 KB, 811 views)
Reply With Quote
  #22  
Old 22-12-2014, 14:59
mirddin mirddin is offline
Junior Member
 
Join Date: Nov 2013
Location: Kyiv, Ukraine
Posts: 21
Default

hi all!
does anybody know, is it possible to add macro {$ILO} to the template with smth like:

{$ILO}={$HOST.IP} (...or $HOST.NAME or anything else)

Just not to enter separate {$ILO} with ip address to every iLO host.

thanks beforehand!
Reply With Quote
  #23  
Old 31-12-2014, 04:23
netfun2000 netfun2000 is offline
Junior Member
 
Join Date: Dec 2014
Posts: 1
Default

Quote:
Originally Posted by Smersh View Post
In zabbix log periodically appears the following strings:
Code:
flock() on closed filehandle CACHE at /usr/local/etc/zabbix22/zabbix/externalscripts/ipmi_proliant.pl line 75.
readline() on closed filehandle CACHE at /usr/local/etc/zabbix22/zabbix/externalscripts/ipmi_proliant.pl line 76.
I have a suspicion that because of this zabbix at times receives no data...
have same errors.
Reply With Quote
  #24  
Old 08-02-2015, 19:43
JasperE JasperE is offline
Junior Member
 
Join Date: Feb 2015
Posts: 4
Default

This is how to fix the error:
Code:
ilo:ipmi_proliant.pl['System Board 3 Fan 3',sensor,'{$ILO}',numeric]] became not supported: Received value [] is not suitable for value type [Numeric (float)]"
(This error has as a result that bits of iformation are missing from the graphs.)

Cause:
Cache files in /var/tmp get created twice for each host. Once with quotes, once without. Seems like about one in two ipmi-sensor cmd's is mistakenly fired, because it doesn't use a perfectly valid cached hit.

That's a problem, if you dig deeper and remove the "2>/dev/null" bits from the cmd's, then the following error appears:
Code:
ipmi_ctx_open_outofband_2_0: BMC busy
(Leave the error redirecting in there, removing that is *not* the fix)

This is how the script can be fixed. In both .pl perl files, add just below the line
Code:
my $server
the following two lines
Code:
$server =~ tr/"//d;
$server =~ tr/'//d;
That fixed it for me.
Reply With Quote
  #25  
Old 11-02-2015, 06:11
mmcpherson mmcpherson is offline
Junior Member
 
Join Date: Feb 2014
Posts: 3
Default

Quote:
Originally Posted by JasperE View Post
Code:
$server =~ tr/"//d;
$server =~ tr/'//d;
That fixed it for me.
Hey thanks for posting this! - I was interested in solving this problem. Unfortunately for me after applying fix I still have been getting many of these errors still in the log:

"became not supported: Received value [] is not suitable"... etc

But still happy as it handles the cache files better.

I'm not sure but this issue may be occurring for me still as I'm actually using this on Cisco UCS hardware. But actually, the script successfully discovers disks, fans, memory, temps, power supplies and info on this hardware and triggers don't need modification! I'll still need to come back and tweak some stuff specific to this hardware, but a really good result.

Anyway, I've determined that the errors are in my case caused by the flock operation locking the cache file for writing and the script handles this by returning an empty value. External checks happily ignore empty return values for strings, but empty numeric return values cause the item to become unsupported. I've made some changes to implement a fix for this. The solution involves creating and reading from a secondary temp cache file (the second filename is appended with _tmp), while the flock operation is in progress on the primary cache file.

I've attached my modified version of the ipmi_proliant.pl script.

Also, here is a diff of the changes I made:

Code:
11d10
< use File::Copy qw(copy);
16,19d14
< # -- Start patch -- fix issue with redundant temp file with quotes - see https://www.zabbix.com/forum/showthread.php?t=44968&page=3 for info
< $server =~ tr/"//d;
< $server =~ tr/'//d;
< # -- End patch --
59d53
<                 copy $cache_file, $cache_file.'_tmp';
64a59
>     my $results = results();
67d61
<       my $results = results();
75c69
<             $cache_file = $cache_file.'_tmp';
---
>             exit(1);
80,87c74,77
< if (-e $cache_file) {
<     open(CACHE, '<' . $cache_file);
<     flock(CACHE, LOCK_EX);
<     @rows = <CACHE>;
<     close(CACHE);
< } else {
<     exit(1);
< }
---
> open(CACHE, '<' . $cache_file);
> flock(CACHE, LOCK_EX);
> @rows = <CACHE>;
> close(CACHE);
97,101c87
<                   if ($r eq '' or $r eq 'N/A') {
<                       exit(0);
<                   } else {
<                         print $r;
<                   }
---
>                     print $r;
Attached Files
File Type: zip ipmi_proliant-updated_by_mmcpherson.zip (1.3 KB, 440 views)
Reply With Quote
  #26  
Old 11-02-2015, 11:28
JasperE JasperE is offline
Junior Member
 
Join Date: Feb 2015
Posts: 4
Default

Quote:
Originally Posted by mmcpherson View Post
I've made some changes to implement a fix for this. The solution involves creating and reading from a secondary temp cache file (the second filename is appended with _tmp), while the flock operation is in progress on the primary cache file.
Hi there mmcpherson, that's indeed another bug you discovered. I think it occurs when two threads are refreshing the cache at the same time. Your fix however seems to output the previously cached value from the tmp file, rather than waiting for an acquired lock and outputting the current sensor values, only after the lock was acquired and the cache file was refreshed.

Being new to perl and file locking, I dug a little deeper in the documentation and the ipmi script. I think I found a proper fix for the locking issues the causing race condition errors.

The script I have attached below is supposed to:
1 - First determine if no cache file exists, or if it is outdated
2 - If that's the case, -first- acquire a lock, in a blocking mode. Meaning it waits for a lock if another thread has it locked.
3 - After the lock is acquired. Check again if another thread hasn't refreshed the cache file while the current thread was waiting for the lock.
4 - Only if the now locked cache file is outdated, and only then, truncate cache, issue $ipmi_cmd, and write outputs to cache.
5 - Release exclusive lock for write mode
6 - Acquire shared lock for reading the newly refreshed cache file.

See attachment.
Note that this is a version of the script which requires ILO username and password to be passed on from macros in the template as posted by Mirddin here: https://www.zabbix.com/forum/showpos...5&postcount=21
Attached Files
File Type: zip ipmi_proliant_v2.zip (2.0 KB, 817 views)

Last edited by JasperE; 12-02-2015 at 10:35. Reason: Fixed an issue where the script wouldn't properly create new cache files if the cache file didn't already exist
Reply With Quote
  #27  
Old 12-02-2015, 10:38
JasperE JasperE is offline
Junior Member
 
Join Date: Feb 2015
Posts: 4
Default

I updated the attachment of my previous post.
The script wouldn't handle creation of cache files for new IPMI hosts properly.
(I had only tested with existing hosts for which cache files were already created)

I also added a debugmode with debug messages for cache file handling, the debugmode can be enabled by changing $debug = 0 to 1.
Reply With Quote
  #28  
Old 12-02-2015, 10:52
karzer karzer is offline
Member
 
Join Date: Mar 2010
Posts: 53
Default

Thanks JasperE, it is running.
Reply With Quote
  #29  
Old 13-02-2015, 03:24
mmcpherson mmcpherson is offline
Junior Member
 
Join Date: Feb 2014
Posts: 3
Default

Thanks JasperE, very nicely crafted!

Works perfect for me, and much appreciated that you included comments. I can't say I know anything about perl, and seldom code so it's a good opportunity for me to learn.

Cheers!
Reply With Quote
  #30  
Old 03-03-2015, 23:31
dkmudrechenko dkmudrechenko is offline
Junior Member
 
Join Date: Mar 2015
Posts: 1
Smile Zabbix couldn't get values

Had a problem when Zabbix ran script but never got any data, the problem was with ilo_discovery.pl. Perl produced "experimental feature" warnings that broke JSON format of the output (since zabbix uses stderr + stdout). So I had to include the following line to stop perl acting funky and make it working -
"no if ($] >= 5.01, 'warnings' => 'experimental';"

Hope it will help someone!

Thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:37.