-
Notifications
You must be signed in to change notification settings - Fork 0
/
redfish-logreader
executable file
·61 lines (51 loc) · 1.37 KB
/
redfish-logreader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/ruby
############################
#
# Redshift Collector for Zabbix
#
# This script will be able to collect information previously discovered via LLD
#
# by julio.hegedus@sentia.com ## 07-08-2018
#
#
require 'net/https'
require 'uri'
require 'json'
USER =ARGV[0]
PASS =ARGV[1]
HOST =ARGV[2]
ITEM =ARGV[3]
LOGURI="/redfish/v1/Managers/iDRAC.Embedded.1/Logs/Sel"
if !USER || !PASS || !HOST || !ITEM
puts "You must gimme something man!"
puts "Try: $./redfish-lld user pass host item.to.read"
exit 1
end
base = URI.parse(["https://",HOST,LOGURI].join(''))
request = Net::HTTP::Get.new(base)
request.basic_auth(USER, PASS)
response = Net::HTTP.start(base.hostname, base.port, :timeout => 60, :use_ssl => base.scheme == "https", :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
https.request(request)
end
list = JSON.parse(response.body)
last_entry = ([" Log Entry",list['Members@odata.count']].join(' '))
list['Members'].each do |message|
if message['Name'] == last_entry
case ITEM
when "last_log"
puts message['Message']
when "date"
puts message['Created']
when "description"
puts message['Description']
when "severity"
puts message['Severity']
when "sensor"
puts message['SensorType'][0]['Member']
when "id"
puts message['Id']
else
puts list['Members@odata.count']
end
end
end