Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 170 lines (134 sloc) 9.48 KB
-- generates nagios_xi services generation file
function trace(Message, ...)
io.stdout:write( string.format(Message, unpack({...})))
function ctrace(C, Message, ...)
C:write( string.format(Message, unpack({...})))
DeviceTarget = nil -- which fmad system to generate for
Host = nil -- monitoring hostname
local Help = function()
trace(" --help : show help info\n")
trace(" --host <ipaddress> : set the host IP address\n")
trace(" --fmad20-1u-16t : generate for fmad20 1U 16TB system\n")
local a = 1
while a <= #arg do
local b = arg[a]
if (b == "--fmad20-1u-16t") then DeviceTarget = "fmadio20" end
if (b == "--host") then Host = arg[a+1]; a = a + 1; end
if (b == "--help") then Help(); return end
a = a + 1
if (DeviceTarget == nil) then
trace("ERROR: Invalid Device (e.g. specify --fmadio20-16t)\n");
if (Host == nil) then
trace("ERROR: Invalid Host(e.g. specify --host\n");
trace("Generating for [%s] at host [%s]\n", DeviceTarget, Host)
local Config =".cfg", "w")
assert(Config ~= nil)
ctrace(Config, "# Generated on "" by nagios_xi_service_gen.lua\n")
local DeviceServiceGen = function(Desc, Use, CheckCmd)
ctrace(Config, "define service {\n")
ctrace(Config, " host_name "..Host.."\n")
ctrace(Config, " service_description "..Desc.."\n")
ctrace(Config, " use "..Use.."\n")
ctrace(Config, " check_command "..CheckCmd.."\n")
ctrace(Config, " max_check_attempts 5\n")
ctrace(Config, " check_interval 1\n")
ctrace(Config, " retry_interval 1\n")
ctrace(Config, " check_period xi_timeperiod_24x7\n")
ctrace(Config, " notification_interval 60\n")
ctrace(Config, " notification_period xi_timeperiod_24x7\n")
ctrace(Config, " contacts nagiosadmin\n")
ctrace(Config, " _xiwizard linuxsnmp\n")
ctrace(Config, " register 1\n")
ctrace(Config, "}\n")
-- common stats
DeviceServiceGen("System CPU Usage", "xiwizard_linuxsnmp_load", "check_xi_service_snmp_linux_load! -C public --v2c -w 80 -c 90 -f")
DeviceServiceGen("System Ping", "xiwizard_switch_ping_service", "check-host-alive")
DeviceServiceGen("System Uptime", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Name", "xiwizard_linuxsnmp_load", "check_xi_service_snmp! -o . -C public -P 2c")
-- port status
DeviceServiceGen("System Bandwidth Management 1G", "xiwizard_switch_port_bandwidth_service", "check_xi_service_mrtgtraf!!500.00,500.00!800.00,800.00!M")
DeviceServiceGen("System Link Management 1G", "xiwizard_switch_port_status_service", "check_xi_service_ifoperstatus!public!5!-v 2 -p 161")
DeviceServiceGen("System Bandwidth Management 10G", "xiwizard_switch_port_bandwidth_service", "check_xi_service_mrtgtraf!!5.00,5.00!8.00,8.00!G")
DeviceServiceGen("System Link Management 10G", "xiwizard_switch_port_status_service", "check_xi_service_ifoperstatus!public!17!-v 2 -p 161")
DeviceServiceGen("System Bandwidth Aux 10G", "xiwizard_switch_port_bandwidth_service", "check_xi_service_mrtgtraf!!5.00,5.00!8.00,8.00!G")
DeviceServiceGen("System Link Aux 10G", "xiwizard_switch_port_status_service", "check_xi_service_ifoperstatus!public!17!-v 2 -p 161")
-- capture status
DeviceServiceGen("Total Packets Recevied", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total Packets Dropped", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total Packets Errors", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total Packets Captured", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Bytes Cached", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total Bytes to RAID", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total Bytes Captured", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total Bytes Overflow", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Total SMART Errors", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("RAID Status", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Capture Status", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Capture Name", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Capture Bps", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Capture Pps", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Capture TCP Bps", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("Capture UDP Bps", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
-- macro for drive stats. note it gets sorted alphabetically by name
-- want it list order to be all drives for a single attribute (e.g. temperature)
-- makes viewing the graphs easier
local DiskService = function(DriveNo, Index)
DeviceServiceGen("Drive SerialNo " ..DriveNo, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..Index.." -C public -P 2c")
DeviceServiceGen("Drive Temperature " ..DriveNo, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..Index.." -C public -P 2c")
DeviceServiceGen("Drive SMART Errors " ..DriveNo, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..Index.." -C public -P 2c")
DeviceServiceGen("Drive SMART Read Errors " ..DriveNo, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..Index.." -C public -P 2c")
DeviceServiceGen("Drive SMART DMA Errors " ..DriveNo, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..Index.." -C public -P 2c")
DeviceServiceGen("Drive SMART Realloc Errors "..DriveNo, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..Index.." -C public -P 2c")
if (DeviceTarget == "fmadio20") then
-- temp monitoring
DeviceServiceGen("System Temperature CPU0", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Temperature PCH", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Temperature Ambient", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Temperature HBA", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Temperature NIC", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
-- fan monitoring
DeviceServiceGen("System Fan RPM CPU0", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Fan RPM SYS0", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Fan RPM SYS1", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
DeviceServiceGen("System Fan RPM SYS2", "xiwizard_snmp_service", "check_xi_service_snmp! -o . -C public -P 2c")
-- capture port info
for p=0,1 do
DeviceServiceGen("Capture Link Port "..p, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..p.." -C public -P 2c")
DeviceServiceGen("Capture SFP Mode Port "..p, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..p.." -C public -P 2c")
DeviceServiceGen("Capture SFP Vendor Port "..p, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..p.." -C public -P 2c")
DeviceServiceGen("Capture SFP PartNo Port "..p, "xiwizard_snmp_service", "check_xi_service_snmp! -o ."..p.." -C public -P 2c")
DiskService("OS", 0)
DiskService("HDD0", 1)
DiskService("HDD1", 2)
DiskService("HDD2", 3)
DiskService("HDD3", 4)
DiskService("SSD0", 5)
DiskService("SSD1", 6)
DiskService("SSD2", 7)
DiskService("SSD3", 8)
DiskService("SSD4", 9)
DiskService("SSD5", 10)
DiskService("SSD6", 11)
DiskService("SSD7", 12)
ctrace(Config, "# configuration end\n")