+ New plugin for solaris local with many modes.

A plugin for solaris 10 (net-snmp) is coming soon.
This commit is contained in:
garnier-quentin 2014-01-06 23:33:39 +01:00
parent 16510e0a30
commit 9832382ec9
14 changed files with 3204 additions and 2 deletions

View File

@ -67,7 +67,8 @@ sub execute {
command => $cmd,
arguments => [@$args, $sub_cmd],
timeout => $options{options}->{timeout},
wait_exit => 1
wait_exit => 1,
redirect_stderr => 1
);
} else {
$cmd = 'sudo ' if (defined($options{sudo}));
@ -78,7 +79,8 @@ sub execute {
($lerror, $stdout, $exit_code) = backtick(
command => $cmd,
timeout => $options{options}->{timeout},
wait_exit => 1
wait_exit => 1,
redirect_stderr => 1
);
}

View File

@ -0,0 +1,630 @@
# OK Merethis
[SunFire E4500/E5500]
system.match = ^System Configuration:.*Sun Enterprise E4500/E5500
system.checks = Memory,Leds,Fans,Temperatures,PSU
checks.Memory.description = memory banks status
checks.Memory.begin_match = ^=+ Memory
checks.Memory.end_match = ^=
checks.Memory.data_match = ^\s*(\d+)\s+(\d+)\s+\S+\s+(.*?)\s+(.*?)\s+
checks.Memory.data_labels = Board,Bank,Status,Condition
checks.Memory.ok_condition = "%Condition%" eq "OK"
checks.Memory.output_string = Memory Board '%Board%' on bank '%Bank%' status is '%Condition%'
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:
checks.Leds.end_match = :$
checks.Leds.data_match = ^\S+\s+(\S+)\s+(\S+)\s+(\S+)
checks.Leds.data_labels = Power,Failure,Running
checks.Leds.ok_condition = "%Failure%" ne "ON"
checks.Leds.output_string = System failure led status is '%Failure%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fans:
checks.Fans.end_match = ^$
checks.Fans.skip_match = ^(-+|Unit)
checks.Fans.data_match = ^(\S+)\s+(\S+)
checks.Fans.data_labels = Unit,Status
checks.Fans.ok_condition = "%Status%" eq "OK"
checks.Fans.output_string = Fan '%Unit%' status is '%Status%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^System Temperatures
checks.Temperatures.end_match = :$
checks.Temperatures.skip_match = ^(Brd|-+)
checks.Temperatures.data_match = ^\s*(\S+)\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(.*?)$
checks.Temperatures.data_labels = Location,State,Temperature,Trend
checks.Temperatures.ok_condition = ( "%Trend%" eq "stable" )
checks.Temperatures.output_string = Trend status '%Trend%' for temperature sensor '%Location%' (temp.: %Temperature% deg.)
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^$
checks.PSU.data_match = ^\s*(.*?)\s{2}\s+(.*?)$
checks.PSU.skip_match = ^(Supply|-+)
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "OK"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
# OK Merethis (v1280)
[Netra-T12]
system.match = ^System Configuration:.*Sun Fire V1280
system.checks = Memory,Fans,Temperatures,Voltages,FRU
checks.Memory.description = memory module
checks.Memory.begin_match = ^Memory Module Groups:
checks.Memory.end_match = ^$
checks.Memory.skip_match = ^(-+|ControllerID)
checks.Memory.data_match = ^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)
checks.Memory.data_labels = ControllerID,GroupID,Labels,Status
checks.Memory.ok_condition = "%Status%" eq "okay"
checks.Memory.output_string = Memory Module '%ControllerID%' '%Labels%' status is '%Status%'
checks.Fans.description = fan status
checks.Fans.begin_match = ^Fan Status:
checks.Fans.end_match = ^$
checks.Fans.skip_match = ^(-+|Location)
checks.Fans.data_match = ^(\S+)\s+(\S+)\s+(\S+)
checks.Fans.data_labels = Location,Sensor,Status
checks.Fans.ok_condition = "%Status%" =~ m/self-regulating|okay/i
checks.Fans.output_string = Fan '%Location%' status is '%Status%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^Temperature sensors:
checks.Temperatures.end_match = :$
checks.Temperatures.skip_match = ^(-+|Location)
checks.Temperatures.data_match = ^(\S+)\s+(\S+)\s+(\S+)
checks.Temperatures.data_labels = Location,Sensor,Status
checks.Temperatures.ok_condition = "%Status%" eq "okay"
checks.Temperatures.output_string = Temperature sensor '%Location%' status is '%Status%'
checks.Voltages.description = voltages sensors
checks.Voltages.begin_match = ^Voltage sensors:
checks.Voltages.end_match = :$
checks.Voltages.skip_match = ^(-+|Location)
checks.Voltages.data_match = ^(\S+)\s+(\S+)\s+(\S+)
checks.Voltages.data_labels = Location,Sensor,Status
checks.Voltages.ok_condition = "%Status%" eq "okay"
checks.Voltages.output_string = Voltage sensor '%Location%' status is '%Status%'
checks.FRU.description = FRU operational status
checks.FRU.begin_match = ^Fru Operational Status:
checks.FRU.end_match = ^$
checks.FRU.skip_match = ^(-+|Location)
checks.FRU.data_match = ^(\S+)\s+(\S+)
checks.FRU.data_labels = Location,Status
checks.FRU.ok_condition = "%Status%" eq "okay"
checks.FRU.output_string = FRU '%Location%' operationnal status is '%Status%'
[SunFire 280R]
system.match = ^System Configuration:.*Sun Fire 280R
system.checks = Leds,Fans,Disks,PSU
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:\s+
checks.Leds.end_match = ^$
checks.Leds.fetch_mode = linear
checks.Leds.data_match = ((?:\S+\s)*\S+),\[\s*(.*?)\s*\]
checks.Leds.data_labels = Location,Status
checks.Leds.ok_condition = not( ( "%Location%" =~ m/FAULT/i ) and ("%Status%" eq "ON") )
checks.Leds.output_string = System LED '%Location%' status is '%Status%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Bank :
checks.Fans.end_match = ^=
checks.Fans.data_match = ^(\S+)\s+\[\s*(\S+)\s*\]
checks.Fans.data_labels = Bank,Status
checks.Fans.ok_condition = "%Status%" eq "NO_FAULT"
checks.Fans.output_string = Fan '%Bank%' status is '%Status%'
checks.Disks.description = disks status
checks.Disks.begin_match = ^Disk Status:
checks.Disks.end_match = ^=
checks.Disks.data_match = ^(.*?\d+)(?:.*?)\[\s*(\S+)\s*\]\s*$
checks.Disks.data_labels = Disk,Status
checks.Disks.ok_condition = "%Status%" eq "NO_FAULT"
checks.Disks.output_string = Disk '%Disk%' status is '%Status%'
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^=
checks.PSU.data_match = ^(.*?\d+)\s+\[\s*(\S+)\s*\]
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "OK"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
[Enterprise 150]
system.match = ^System Configuration:.*Sun Ultra 1 SBus
system.checks = Boards
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^(No) /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
[Enterprise 250]
system.match = ^System Configuration:.*Sun \(TM\) Enterprise 250
system.checks = Memory,Leds,Disks,Fans,PSU,Boards
checks.Memory.description = memory banks status
checks.Memory.begin_match = ^=+ Memory
checks.Memory.end_match = ^=
checks.Memory.data_match = ^\s*(\d+)\s+\S+\s+(.*?)\s+.*?(\S+)$
checks.Memory.data_labels = Bank,Socket,Status
checks.Memory.ok_condition = "%Status%" eq "OK"
checks.Memory.output_string = Memory unit '%Socket%' on bank '%Bank%' status is '%Status%'
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:\s+
checks.Leds.end_match = ^$
checks.Leds.fetch_mode = linear
checks.Leds.data_match = ((?:\S+\s)*\S+),\[\s*(.*?)\s*\]
checks.Leds.data_labels = Location,Status
checks.Leds.ok_condition = not( ( "%Location%" =~ m/ERROR/i ) and ("%Status%" eq "ON") )
checks.Leds.output_string = System LED '%Location%' status is '%Status%'
checks.Disks.description = disks status
checks.Disks.begin_match = ^Disk LED Status:
checks.Disks.end_match = ^=
checks.Disks.data_match = (DISK\s+\d+):\s+\[\s*(.*?)\s*\]
checks.Disks.data_labels = Disk,Status
checks.Disks.ok_condition = "%Status%" =~ m/^(OK|EMPTY)$/
checks.Disks.output_string = Disk '%Disk%' status is '%Status%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Bank :
checks.Fans.end_match = ^=
checks.Fans.data_match = ^(\S+)\s+\d+\s+(\S+)
checks.Fans.data_labels = Bank,Status
checks.Fans.ok_condition = "%Status%" eq "OK"
checks.Fans.output_string = Fan '%Bank%' status is '%Status%'
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^=
checks.PSU.data_match = ^\s*(\d+).*?(\S+)$
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "OK"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
[Enterprise 450]
system.match = ^System Configuration:.*Sun Enterprise 450
system.checks = Memory,Leds,Disks,Fans,PSU,Boards
checks.Memory.description = memory banks status
checks.Memory.begin_match = ^=+ Memory
checks.Memory.end_match = ^=
checks.Memory.data_match = ^\s*(\d+)\s+\S+\s+(.*?)\s+.*?(\S+)$
checks.Memory.data_labels = Bank,Socket,Status
checks.Memory.ok_condition = "%Status%" eq "OK"
checks.Memory.output_string = Memory unit '%Socket%' on bank '%Bank%' status is '%Status%'
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:\s+
checks.Leds.end_match = ^$
checks.Leds.fetch_mode = linear
checks.Leds.data_match = ((?:\S+\s)*\S+),\[\s*(.*?)\s*\]
checks.Leds.data_labels = Location,Status
checks.Leds.ok_condition = not( ( "%Location%" =~ m/ERROR/i ) and ("%Status%" eq "ON") )
checks.Leds.output_string = System LED '%Location%' status is '%Status%'
checks.Disks.description = disks status
checks.Disks.begin_match = ^Disk LED Status:
checks.Disks.end_match = ^=
checks.Disks.data_match = (DISK\s+\d+):\s+\[\s*(.*?)\s*\]
checks.Disks.data_labels = Disk,Status
checks.Disks.ok_condition = "%Status%" =~ m/^(OK|EMPTY)$/
checks.Disks.output_string = Disk '%Disk%' status is '%Status%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fans:
checks.Fans.end_match = ^$
checks.Fans.data_match = ^(\S+)\s+\d+\s+(\S+)
checks.Fans.data_labels = Bank,Status
checks.Fans.ok_condition = "%Status%" eq "OK"
checks.Fans.output_string = Fan '%Bank%' status is '%Status%'
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^=
checks.PSU.data_match = ^\s*(\d+).*?(\S+)$
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "OK"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
[Enterprise 3000]
system.match = Sun Enterprise 3000$
system.checks = Leds,Fans,Temperatures,PSU,Boards
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:
checks.Leds.end_match = :$
checks.Leds.data_match = ^\S+\s+(\S+)\s+(\S+)\s+(\S+)
checks.Leds.data_labels = Power,Failure,Running
checks.Leds.ok_condition = "%Failure%" ne "ON"
checks.Leds.output_string = System failure led status is '%Failure%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fans:
checks.Fans.end_match = ^$
checks.Fans.skip_match = ^(-+|Unit)
checks.Fans.data_match = ^(\S+)\s+(\S+)
checks.Fans.data_labels = Unit,Status
checks.Fans.ok_condition = "%Status%" eq "OK"
checks.Fans.output_string = Fan '%Unit%' status is '%Status%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^System Temperatures
checks.Temperatures.end_match = :$
checks.Temperatures.skip_match = ^Location
checks.Temperatures.data_match = ^(\S+\s+\d+):\s+(.*?)\s+(\S+)
checks.Temperatures.data_labels = Location,Temperature,Trend
checks.Temperatures.ok_condition = ( "%Trend%" eq "stable" )
checks.Temperatures.output_string = Trend status '%Trend%' for temperature sensor '%Location%' (temp.: %Temperature% deg.)
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^$
checks.PSU.data_match = ^((?:\S+\s)*\S+)\s+(\S+)
checks.PSU.skip_match = ^(Supply|-+)
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "OK"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+(\sIO Cards|Cartes ES)
checks.Boards.end_match = ^=+\s\S+
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
[Ultra 10]
system.match = ^System Configuration:.*Sun Ultra 5\/10 UPA\/PCI
system.checks = Boards
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
[SunFire V120]
system.match = ^System Configuration:.*Sun Fire V120
system.checks = Boards
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
# OK Merethis
[UltraSPARCengine_CP-40]
system.match = ^System Configuration:.*sun4u SPARCengine CP2000
system.checks = Boards
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
[SunFire V240]
system.match = ^System Configuration:.*Sun Fire V240
system.checks = Fans,Leds,Temperatures,Voltages,Current,FRU
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Status:
checks.Fans.end_match = :$
checks.Fans.data_match = ^(.*?\d+)\s+(\S+)\s+(\S+)
checks.Fans.data_labels = Location,Sensor,Status
checks.Fans.ok_condition = "%Status%" eq "okay"
checks.Fans.output_string = Fan '%Location%/%Sensor%' status is '%Status%'
checks.Leds.description = system leds status
checks.Leds.begin_match = ^Led State:
checks.Leds.end_match = :$
checks.Leds.data_match = ^(\S+)\s+(?:SERVICE)\s+(\S+)
checks.Leds.data_labels = Location,State
checks.Leds.ok_condition = "%State%" eq "off"
checks.Leds.output_string = Service indicator '%Location%' state is '%State%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^Temperature sensors:
checks.Temperatures.end_match = :$
checks.Temperatures.skip_match = ^Location
checks.Temperatures.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Temperatures.data_labels = Location,Sensor,Status
checks.Temperatures.ok_condition = ( "%Status%" eq "okay" )
checks.Temperatures.output_string = Temperature sensor '%Location%/%Sensor%' status is '%Status%'
checks.Voltages.description = voltage sensors
checks.Voltages.begin_match = ^Voltage sensors:
checks.Voltages.end_match = :$
checks.Voltages.skip_match = ^Location
checks.Voltages.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Voltages.data_labels = Location,Sensor,Status
checks.Voltages.ok_condition = "%Status%" eq "okay"
checks.Voltages.output_string = Voltage sensor '%Location%/%Sensor%' status is '%Status%'
checks.Current.description = current sensors
checks.Current.begin_match = ^Current sensors:
checks.Current.end_match = ^$
checks.Current.skip_match = ^Location
checks.Current.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Current.data_labels = Location,Sensor,Status
checks.Current.ok_condition = "%Status%" eq "okay"
checks.Current.output_string = Current sensor '%Location%/%Sensor%' status is '%Status%'
checks.FRU.description = FRU operational status
checks.FRU.begin_match = ^Fru Operational Status:
checks.FRU.end_match = ^$
checks.FRU.skip_match = ^Location
checks.FRU.data_match = ^(\S+)\s+(\S+)
checks.FRU.data_labels = Location,Status
checks.FRU.ok_condition = "%Status%" =~ m/present|okay/
checks.FRU.output_string = FRU '%Location%' status is '%Status%'
# OK Merethis
[SunFire V440]
system.match = ^System Configuration:.*Sun Fire V440
system.checks = Fans,Leds,Temperatures,Voltages,Current,FRU
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Speeds:
checks.Fans.end_match = :$
checks.Fans.data_match = ^(.*?\d+)\s+(\S+)\s+(\S+)
checks.Fans.data_labels = Location,Sensor,Status
checks.Fans.ok_condition = "%Status%" eq "okay"
checks.Fans.output_string = Fan '%Location%/%Sensor%' status is '%Status%'
checks.Leds.description = system leds status
checks.Leds.begin_match = ^Led State:
checks.Leds.end_match = :$
checks.Leds.data_match = ^(\S+)\s+(?:SERVICE)\s+(\S+)
checks.Leds.data_labels = Location,State
checks.Leds.ok_condition = "%State%" eq "off"
checks.Leds.output_string = Service indicator '%Location%' state is '%State%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^Temperature sensors:
checks.Temperatures.end_match = :$
checks.Temperatures.skip_match = ^Location
checks.Temperatures.data_match = ^(\S+)\s+(\S+)\s+(.*)$
checks.Temperatures.data_labels = Location,Sensor,Status
checks.Temperatures.ok_condition = ( "%Status%" eq "okay" )
checks.Temperatures.output_string = Temperature sensor '%Location%/%Sensor%' status is '%Status%'
checks.Voltages.description = voltage sensors
checks.Voltages.begin_match = ^Voltage sensors:
checks.Voltages.end_match = :$
checks.Voltages.skip_match = ^Location
checks.Voltages.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Voltages.data_labels = Location,Sensor,Status
checks.Voltages.ok_condition = "%Status%" eq "okay"
checks.Voltages.output_string = Voltage sensor '%Location%/%Sensor%' status is '%Status%'
checks.Current.description = current sensors
checks.Current.begin_match = ^Current sensors:
checks.Current.end_match = ^$
checks.Current.skip_match = ^Location
checks.Current.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Current.data_labels = Location,Sensor,Status
checks.Current.ok_condition = "%Status%" eq "okay"
checks.Current.output_string = Current sensor '%Location%/%Sensor%' status is '%Status%'
checks.FRU.description = FRU operational status
checks.FRU.begin_match = ^Fru Operational Status:
checks.FRU.end_match = ^$
checks.FRU.skip_match = ^Location
checks.FRU.data_match = ^(\S+)\s+(\S+)$
checks.FRU.data_labels = Location,Status
checks.FRU.ok_condition = "%Status%" =~ m/present|okay/
checks.FRU.output_string = FRU '%Location%' status is '%Status%'
[SunFire V490]
system.match = ^System Configuration:.*Sun Fire V490
system.checks = Temperatures,Leds,Disks,Fans,PSU
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^System Temperatures.*:
checks.Temperatures.end_match = ^$
checks.Temperatures.skip_match = ^Device
checks.Temperatures.data_match = ^(\S+)\s+(\S+)\s+(\S+)$
checks.Temperatures.data_labels = Sensor,Temperature,Status
checks.Temperatures.ok_condition = ( "%Status%" eq "OK" )
checks.Temperatures.output_string = Temperature sensor '%Sensor%' status is '%Status%' (temp.: %Temperature% deg.)
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:
checks.Leds.end_match = ^=
checks.Leds.fetch_mode = linear
checks.Leds.skip_match = ^-+
checks.Leds.data_match = ((?:\S+\s)*\S+),\[\s*(.*?)\s*\]
checks.Leds.data_labels = Location,Status
checks.Leds.ok_condition = not( ( "%Location%" eq "FAULT" ) and ("%Status%" eq "ON") )
checks.Leds.output_string = System LED '%Location%' status is '%Status%'
checks.Disks.description = disks status
checks.Disks.begin_match = ^Disk Status:
checks.Disks.end_match = ^$
checks.Disks.data_match = ^(.*?\d+)(?:.*?)\[\s*(\S+)\s*\]\s*$
checks.Disks.data_labels = Disk,Status
checks.Disks.ok_condition = "%Status%" eq "NO_FAULT"
checks.Disks.output_string = Disk '%Disk%' status is '%Status%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Status:
checks.Fans.end_match = ^=
checks.Fans.data_match = ^(\S+)\s+(\S+)\s+(.*?)\s+\[\s*(\S+)\s*\]
checks.Fans.data_labels = Tray,Fan,Speed,Status
checks.Fans.ok_condition = "%Status%" eq "NO_FAULT"
checks.Fans.output_string = Fan '%Tray%/%Fan%' status is '%Status%' (speed: %Speed% rpm)
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^=
checks.PSU.data_match = ^(.*?)\s+\[\s*(\S+)\s*\]
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "NO_FAULT"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
[SunFire 880]
system.match = ^System Configuration:.*Sun Fire 880
system.checks = Boards,Temperatures,Leds,Disks,Fans,PSU
checks.Boards.description = IO cards status
checks.Boards.begin_match = ^=+\sIO Cards
checks.Boards.end_match = ^=
checks.Boards.data_match = ^(No failures found in System|(?:No|Detected) System Faults)
checks.Boards.data_labels = Diagnosis
checks.Boards.ok_condition = "%Diagnosis%" =~ m/^No /
checks.Boards.output_string = System diagnosis for IO cards is '%Diagnosis%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^System Temperatures
checks.Temperatures.end_match = ^$
checks.Temperatures.skip_match = ^Device
checks.Temperatures.data_match = ^(\S+)\s+(.*?)\s+(\S+)
checks.Temperatures.data_labels = Device,Temperature,Status
checks.Temperatures.ok_condition = ( "%Status%" eq "OK" )
checks.Temperatures.output_string = Temperature sensor '%Device%' status is '%Status%' (temp.: %Temperature% deg.)
checks.Leds.description = system leds status
checks.Leds.begin_match = ^System LED Status:
checks.Leds.end_match = ^=
checks.Leds.skip_match = ^$
checks.Leds.fetch_mode = linear
checks.Leds.data_match = ((?:\S+\s)*\S+),\[\s*(.*?)\s*\]
checks.Leds.data_labels = Location,Status
checks.Leds.ok_condition = not( ( "%Location%" eq "FAULT" ) and ("%Status%" eq "ON") )
checks.Leds.output_string = System LED '%Location%' status is '%Status%'
checks.Disks.description = disks status
checks.Disks.begin_match = ^Disk Status:
checks.Disks.end_match = ^$
checks.Disks.data_match = ^(.*?\d+)(?:.*?)\[PRESENT\]\s+\[\s*(\S+)\s*\]
checks.Disks.data_labels = Disk,Fault
checks.Disks.ok_condition = "%Fault%" eq "OFF"
checks.Disks.output_string = Fault LED status '%Fault%' for disk '%Disk%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Bank :
checks.Fans.end_match = ^=
checks.Fans.data_match = ^(\S+)\s+(\d+)\s+\[ENABLED\]\s+(\S+)
checks.Fans.data_labels = Fan,Speed,Status
checks.Fans.ok_condition = "%Status%" eq "OK"
checks.Fans.output_string = Fan '%Fan%' status is '%Status%' (speed: %Speed% rpm)
checks.PSU.description = power supplies status
checks.PSU.begin_match = ^Power Supplies:
checks.PSU.end_match = ^=
checks.PSU.data_match = ^(\S+\d+)\s+(\S+)
checks.PSU.data_labels = Supply,Status
checks.PSU.ok_condition = "%Status%" eq "GOOD"
checks.PSU.output_string = Power supply '%Supply%' status is '%Status%'
[SunFire V210]
system.match = ^System Configuration:.*Sun Fire V210
system.checks = CPU,Fans,Temperatures,Current,Voltages,Leds,FRU
checks.CPU.description = CPU status
checks.CPU.begin_match = ^=+ CPUs =
checks.CPU.end_match = ^$
checks.CPU.data_match = ^\s*(\d+)\s+(?:.*?)\s+(\S+)\s+(\S+)\s*$
checks.CPU.data_labels = CPU,Status,Location
checks.CPU.ok_condition = "%Status%" eq "on-line"
checks.CPU.output_string = CPU%CPU% ('%Location%') status is '%Status%'
checks.Fans.description = fans status
checks.Fans.begin_match = ^Fan Status:
checks.Fans.end_match = :$
checks.Fans.skip_match = ^Location
checks.Fans.data_match = ^(\S+)\s+(\S+)\s+(\S+)
checks.Fans.data_labels = Location,Sensor,Status
checks.Fans.ok_condition = "%Status%" eq "okay"
checks.Fans.output_string = Fan '%Location%/%Sensor%' status is '%Status%'
checks.Leds.description = system leds status
checks.Leds.begin_match = ^Led State:
checks.Leds.end_match = :$
checks.Leds.data_match = ^(\S+)\s+(?:SERVICE)\s+(\S+)
checks.Leds.data_labels = Location,State
checks.Leds.ok_condition = "%State%" eq "off"
checks.Leds.output_string = Service indicator '%Location%' state is '%State%'
checks.Temperatures.description = temperature sensors
checks.Temperatures.begin_match = ^Temperature sensors:
checks.Temperatures.end_match = :$
checks.Temperatures.skip_match = ^Location
checks.Temperatures.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Temperatures.data_labels = Location,Sensor,Status
checks.Temperatures.ok_condition = ( "%Status%" eq "okay" )
checks.Temperatures.output_string = Temperature sensor '%Location%/%Sensor%' status is '%Status%'
checks.Voltages.description = voltage sensors
checks.Voltages.begin_match = ^Voltage sensors:
checks.Voltages.end_match = :$
checks.Voltages.skip_match = ^Location
checks.Voltages.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Voltages.data_labels = Location,Sensor,Status
checks.Voltages.ok_condition = "%Status%" eq "okay"
checks.Voltages.output_string = Voltage sensor '%Location%/%Sensor%' status is '%Status%'
checks.Current.description = current sensors
checks.Current.begin_match = ^Current sensors:
checks.Current.end_match = :$
checks.Current.skip_match = ^Location
checks.Current.data_match = ^(\S+)\s+(\S+).*?(\S+)$
checks.Current.data_labels = Location,Sensor,Status
checks.Current.ok_condition = "%Status%" eq "okay"
checks.Current.output_string = Current sensor '%Location%/%Sensor%' status is '%Status%'
checks.FRU.description = FRU operational status
checks.FRU.begin_match = ^Fru Operational Status:
checks.FRU.end_match = ^$
checks.FRU.skip_match = ^Location
checks.FRU.data_match = ^(\S+)\s+(\S+)
checks.FRU.data_labels = Location,Status
checks.FRU.ok_condition = "%Status%" =~ m/present|okay/
checks.FRU.output_string = FRU '%Location%' status is '%Status%'

View File

@ -0,0 +1,185 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::analyzedisks;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'format' },
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
"command-options:s" => { name => 'command_options', default => '2>&1 << EOF
0
quit
EOF' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $num_errors = 0;
my $disks_name = '';
foreach (split /\n/, $stdout) {
if (/\s+([^\s]+)\s+<(drive type unknown|drive not available)/i ) {
$num_errors++;
$disks_name .= ' [' . $1 . ']';
}
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($num_errors > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Disks$disks_name are on errors."));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on disks.");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check disk status (need 'format' command).
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'format').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/sbin').
=item B<--command-options>
Command options (Default: '2>&1 << EOF
0
quit
EOF').
=back
=cut

View File

@ -0,0 +1,225 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::cpu;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
use centreon::plugins::statefile;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'kstat' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-n sys 2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{hostname} = undef;
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{statefile_cache}->check_options(%options);
$self->{hostname} = $self->{option_results}->{hostname};
if (!defined($self->{hostname})) {
$self->{hostname} = 'me';
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{statefile_cache}->read(statefile => 'cache_solaris_local_' . $self->{hostname} . '_' . $self->{mode});
my $old_timestamp = $self->{statefile_cache}->get(name => 'last_timestamp');
my $datas = {};
$datas->{last_timestamp} = time();
$self->{output}->output_add(severity => 'OK',
short_msg => "CPUs usages are ok.");
my @output_cpu_instance = split("instance", $stdout);
shift @output_cpu_instance;
foreach (@output_cpu_instance) {
/:\s.*?(\d+)/;
my $cpu_number = $1;
/.*?cpu_ticks_idle\s.*?(\d+).*?cpu_ticks_kernel\s.*?(\d+).*?cpu_ticks_user\s.*?(\d+)/ms;
$datas->{'cpu_idle_' . $cpu_number} = $1;
$datas->{'cpu_system_' . $cpu_number} = $2;
$datas->{'cpu_user_' . $cpu_number} = $3;
if (!defined($old_timestamp)) {
next;
}
my $old_cpu_idle = $self->{statefile_cache}->get(name => 'cpu_idle_' . $cpu_number);
my $old_cpu_system = $self->{statefile_cache}->get(name => 'cpu_system_' . $cpu_number);
my $old_cpu_user = $self->{statefile_cache}->get(name => 'cpu_user_' . $cpu_number);
if (!defined($old_cpu_system) || !defined($old_cpu_idle) || !defined($old_cpu_user)) {
next;
}
if ($datas->{'cpu_idle_' . $cpu_number} < $old_cpu_idle) {
# We set 0. Has reboot.
$old_cpu_user = 0;
$old_cpu_idle = 0;
$old_cpu_system = 0;
}
my $total_elapsed = ($datas->{'cpu_idle_' . $cpu_number} + $datas->{'cpu_user_' . $cpu_number} + $datas->{'cpu_system_' . $cpu_number}) - ($old_cpu_user + $old_cpu_idle + $old_cpu_system);
my $idle_elapsed = $datas->{'cpu_idle_' . $cpu_number} - $old_cpu_idle;
my $cpu_ratio_usetime = 100 * $idle_elapsed / $total_elapsed;
$cpu_ratio_usetime = 100 - $cpu_ratio_usetime;
my $exit_code = $self->{perfdata}->threshold_check(value => $cpu_ratio_usetime,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(long_msg => sprintf("CPU %d %.2f%%", $cpu_number, $cpu_ratio_usetime));
if ($exit_code ne 'OK') {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("CPU %d %.2f%%", $cpu_number, $cpu_ratio_usetime));
}
$self->{output}->perfdata_add(label => 'cpu_' . $cpu_number, unit => '%',
value => sprintf("%.2f", $cpu_ratio_usetime),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0, max => 100);
}
$self->{statefile_cache}->write(data => $datas);
if (!defined($old_timestamp)) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation...");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check system CPUs (need 'kstat' command).
=over 8
=item B<--warning>
Threshold warning in percent.
=item B<--critical>
Threshold critical in percent.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'kstat').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: '-n sys 2>&1').
=back
=cut

View File

@ -0,0 +1,174 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::fcconnected;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'luxadm' },
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
"command-options:s" => { name => 'command_options', default => '-e port 2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{output}->output_add(severity => 'OK',
short_msg => "Fc connections are ok.");
my $num_connected = 0;
foreach (split /\n/, $stdout) {
$self->{output}->output_add(long_msg => $_);
if ($_ !~ /NOT CONNECTED/i) {
$num_connected++;
}
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_connected,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($exit_code ne 'OK') {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Some cards are not connected (see additionnal info for more details)"));
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check number of fiber channel connected (need sun/oracle driver and not Emulex/Qlogic).
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'luxadm').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/sbin').
=item B<--command-options>
Command options (Default: '-e port 2>&1').
=back
=cut

View File

@ -0,0 +1,172 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::fmadm;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'luxadm' },
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
"command-options:s" => { name => 'command_options', default => '-e port 2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my $num_errors = 0;
foreach (split /\n/, $stdout) {
$self->{output}->output_add(long_msg => $_);
$num_errors++;
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($num_errors > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("The Fault Manager reports some hardware problems (see additionnal info for more details)"));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "The Fault Manager does not report any hardware problem.");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Hardware Faults (need at least Solaris 10 and 'fmadm' command).
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'fmadm').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/sbin').
=item B<--command-options>
Command options (Default: 'faulty -r 2>&1').
=back
=cut

View File

@ -0,0 +1,204 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::hwraidctl;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'raidctl' },
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
"command-options:s" => { name => 'command_options', default => '-S 2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $volumes_errors = 0;
my $disks_errors = 0;
my $volumes = '';
my $disks = '';
foreach (split(/\n/, $stdout)) {
#1 "LSI_1030"
#c1t2d0 2 0.2.0 0.3.0 1 OPTIMAL
#0.0.0 GOOD
#0.1.0 GOOD
#0.2.0 GOOD
#0.3.0 GOOD
#4 "LSI_1030"
# For Disk
if (/^\s*(\S+)\s+(FAILED)$/i ) {
my $disk = $1;
$disks_errors++;
$disks .= ' [' . $disk . '/FAILED' . ']';
} elsif (/^\s*(\S+).*?(DEGRADED|FAILED)$/i) {
$volumes_errors++;
$volumes .= ' [' . $1 . '/' . $2 . ']';
}
}
my ($exit_code) = check_threshold($volumes_errors, $OPTION{warning}, $OPTION{critical});
if ($volumes_errors > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Some volumes problems:" . $volumes));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on volumes");
}
($exit_code) = $self->{perfdata}->threshold_check(value => $disks_errors,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($disks_errors > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Some disks problems:" . $disks));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on disks");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Hardware Raid Status (use 'raidctl' command).
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'raidctl').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/sbin').
=item B<--command-options>
Command options (Default: '-S 2>&1').
=back
=cut

View File

@ -0,0 +1,220 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::hwsas2ircu;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo1" => { name => 'sudo1' },
"command1:s" => { name => 'command1', default => 'metastat' },
"command1-path:s" => { name => 'command1_path', default => '/usr/sbin' },
"command1-options:s" => { name => 'command1_options', default => '-c 2>&1' },
"sudo2" => { name => 'sudo2' },
"command2:s" => { name => 'command2', default => 'metadb' },
"command2-path:s" => { name => 'command2_path', default => '/usr/sbin' },
"command2-options:s" => { name => 'command2_options', default => '2>&1' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo1},
command => $self->{option_results}->{command1},
command_path => $self->{option_results}->{command1_path},
command_options => $self->{option_results}->{command1_options});
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on volumes");
while (($stdout =~ /^\s*Index.*?\n.*?\n\s+(\d+)\s+/imsg)) {
# Index Type ID ID Pci Address Ven ID Dev ID
# ----- ------------ ------ ------ ----------------- ------ ------
# 0 SAS2008 1000h 72h 00h:04h:00h:00h 1000h 0072h
#
# Adapter Vendor Device SubSys SubSys
# Index Type ID ID Pci Address Ven ID Dev ID
# ----- ------------ ------ ------ ----------------- ------ ------
# 1 SAS2008 1000h 72h 00h:0bh:00h:00h 1000h 0072h
#SAS2IRCU: Utility Completed Successfully.
my $index = $1;
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo2},
command => $self->{option_results}->{command2},
command_path => $self->{option_results}->{command2_path},
command_options => sprintf($self->{option_results}->{command2_options}, $index));
#IR Volume information
#------------------------------------------------------------------------
#IR volume 1
# Volume ID : 905
# Volume Name : test
# Status of volume : Okay (OKY)
# RAID level : RAID1
# Size (in MB) : 68664
# Physical hard disks :
# PHY[0] Enclosure#/Slot# : 1:2
# PHY[1] Enclosure#/Slot# : 1:3
#------------------------------------------------------------------------
#Physical device information
if ($stdout2 =~ /^IR Volume information(.*)Physical device information/ims) {
my @content = split(/\n/, $1);
shift @content;
my $volume_name = '';
foreach my $line (@content) {
next if ($line =~ /^---/);
if ($line =~ /Volume Name\s+:\s+(.*)/i) {
$volume_name = $1;
$volume_name = centreon::plugins::misc::trim($volume_name);
next;
}
if ($line =~ /Status of volume\s+:\s+(.*)(\n|\()/i) {
my $status_volume = $1;
$status_volume = centreon::plugins::misc::trim($status_volume);
if ($status_volume !~ /Okay/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Volume 'volume_name' status is '$status_volume'");
}
}
}
}
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Hardware Raid Status (use 'sas2ircu' command).
=over 8
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo1>
Use 'sudo' to execute the command.
=item B<--command1>
Command to get information (Default: 'sas2ircu').
Can be changed if you have output in a file.
=item B<--command1-path>
Command path (Default: '/usr/bin').
=item B<--command1-options>
Command options (Default: 'LIST 2>&1').
=item B<--sudo2>
Use 'sudo' to execute the command.
=item B<--command2>
Command to get information (Default: 'sas2ircu').
Can be changed if you have output in a file.
=item B<--command2-path>
Command path (Default: '/usr/bin').
=item B<--command2-options>
Command options (Default: '%s DISPLAY 2>&1').
!!! Modify it if you know what you do ;) !!!
=back
=cut

View File

@ -0,0 +1,229 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::lomv120;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'lom' },
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
"command-options:s" => { name => 'command_options', default => '-fpv 2>&1' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems detected.");
if ($stdout =~ /^Fans:(.*?):/ims) {
#Fans:
#1 FAULT speed 0%
#2 FAULT speed 0%
#3 OK speed 100%
#4 OK speed 100%
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
next if ($line !~ /^\s*(\S+)\s+(\S+)/);
my ($fan_num, $status) = ($1, $2);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Fan '$fan_num' status is '$status'");
}
}
}
if ($stdout =~ /^PSUs:(.*?):/ims) {
#PSUs:
#1 OK
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
next if ($line !~ /^\s*(\S+)\s+(\S+)/);
my ($psu_num, $status) = ($1, $2);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Psu '$psu_num' status is '$status'");
}
}
}
if ($stdout =~ /^Supply voltages:(.*?):/ims) {
#Supply voltages:
#1 5V status=ok
#2 3V3 status=ok
#3 +12V status=ok
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
$line = centreon::plugins::misc::trim($line);
my @fields = split(/\s+/, $line);
shift @fields;
my $field_status = pop(@fields);
$field_status =~ /status=(.*)/i;
my $status = $1;
my $name = join(' ', @fields);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Supply voltage '$name' status is '$status'");
}
}
}
if ($stdout =~ /^System status flags:(.*)/ims) {
#System status flags:
# 1 SCSI-Term status=ok
# 2 USB0 status=ok
# 3 USB1 status=ok
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
$line = centreon::plugins::misc::trim($line);
my @fields = split(/\s+/, $line);
shift @fields;
my $field_status = pop(@fields);
$field_status =~ /status=(.*)/i;
my $status = $1;
my $name = join(' ', @fields);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "System '$name' flag status is '$status'");
}
}
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Hardware Status for 'v120' (use 'lom' command).
=over 8
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'lom').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/sbin').
=item B<--command-options>
Command options (Default: '-fpv 2>&1').
=back
=cut

View File

@ -0,0 +1,232 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::lomv1280;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'lom' },
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
"command-options:s" => { name => 'command_options', default => '-fpv 2>&1' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems detected.");
if ($stdout =~ /^Fans:(.*?):/ims) {
#Fans:
# 1 FT0/FAN3 ft_fan3 OK speed self-regulating
# 9 IB6/FAN0 ft_fan0 OK speed 100 %
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
next if ($line !~ /^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/);
my ($fan_name, $status) = ($2, $4);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Fan '$fan_name' status is '$status'");
}
}
}
if ($stdout =~ /^PSUs:(.*?):/ims) {
#PSUs:
# PS0 OK
# PS1 OK
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
next if ($line !~ /^\s*(\S+)\s+(\S+)/);
my ($psu_num, $status) = ($1, $2);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Psu '$psu_num' status is '$status'");
}
}
}
if ($stdout =~ /^Supply voltages:(.*?):/ims) {
#Supply voltages:
# 1 SSC1 v_1.5vdc0 status=ok
# 2 SSC1 v_3.3vdc0 status=ok
# 3 SSC1 v_5vdc0 status=ok
# 4 RP0 v_1.5vdc0 status=ok
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
$line = centreon::plugins::misc::trim($line);
my @fields = split(/\s+/, $line);
shift @fields;
my $field_status = pop(@fields);
$field_status =~ /status=(.*)/i;
my $status = $1;
my $name = join(' ', @fields);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Supply voltage '$name' status is '$status'");
}
}
}
if ($stdout =~ /^System status flags:(.*)/ims) {
#System status flags:
# 1 PS0 status=okay
# 2 PS1 status=okay
# 3 PS2 status=okay
# 4 PS3 status=okay
# 5 FT0 status=okay
# 6 FT0/FAN3 status=okay
my @content = split(/\n/, $1);
shift @content;
pop @content;
foreach my $line (@content) {
$line = centreon::plugins::misc::trim($line);
my @fields = split(/\s+/, $line);
shift @fields;
my $field_status = pop(@fields);
$field_status =~ /status=(.*)/i;
my $status = $1;
my $name = join(' ', @fields);
if ($status !~ /OK/i) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "System '$name' flag status is '$status'");
}
}
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Hardware Status for 'v1280' (use 'lom' command).
=over 8
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'lom').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/sbin').
=item B<--command-options>
Command options (Default: '-fpv 2>&1').
=back
=cut

View File

@ -0,0 +1,360 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
# Main code: Comes from Sebastien Phelep (seb@le-seb.org)
package os::solaris::local::mode::prtdiag;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
use File::Basename;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'prtdiag' },
"command-path:s" => { name => 'command_path', default => '/usr/platform/`/sbin/uname -i`/sbin' },
"command-options:s" => { name => 'command_options', default => '-v 2&1' },
"config-file:s" => { name => 'config_file' },
});
$self->{conf} = {};
$self->{syst} = undef;
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{config_file})) {
$self->{config_file} = $self->{option_results}->{config_file};
} else {
$self->{config_file} = dirname(__FILE__) . '/../prtdiag.conf';
}
}
sub prtdiag {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my @diag = split (/\n/, $stdout);
# Look for system type
unless( defined($self->{syst}) ) {
FSYS:
foreach my $section ( keys(%{$self->{conf}}) ) {
foreach my $param ( keys(%{ $self->{conf}->{$section} }) ) {
next unless( $param eq "system.match" );
if( grep(/$self->{conf}->{$section}->{'system.match'}/, @diag) ) {
$self->{syst} = $section;
last FSYS;
}
}
}
}
# Check for unidentified system type
unless( defined($self->{syst}) ) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Unable to identify system type !");
return ;
}
$self->{output}->output_add(long_msg => "Using system type : $self->{syst}");
# Further config checks
unless( defined($self->{conf}->{$self->{syst}}->{'system.checks'}) ) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Initialization failed - Missing 'system.checks' entry for section '$self->{syst}' in file '$self->{config_file}' !");
return ;
}
my @checks = split(/\s*,\s*/,$self->{conf}->{$self->{syst}}->{'system.checks'});
if( scalar(@checks) == 0 ) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "No check defined in 'system.checks' entry for section '$self->{syst}' in file '$self->{config_file}' !");
return ;
}
foreach my $check ( @checks ) {
foreach my $param ( "description", "begin_match", "end_match", "data_match", "data_labels", "ok_condition", "output_string" ) {
my $param_name = "checks.$check.$param";
unless( defined($self->{conf}->{$self->{syst}}->{$param_name}) ) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Initialization error - Missing '$param_name' entry for section '$self->{syst}' in file '$self->{config_file}' !");
return ;
}
}
}
# Check'em all
my @failed = ();
my @passed = ();
foreach my $check ( @checks ) {
# Get associated data
my $description = $self->{conf}->{$self->{syst}}->{"checks.$check.description"};
my @labels = split(/\s*,\s*/,$self->{conf}->{$self->{syst}}->{"checks.$check.data_labels"});
my $fetch_mode = $self->{conf}->{$self->{syst}}->{"checks.$check.fetch_mode"};
my $begin = 0;
my $dcount = 0;
my $lcount = 0;
my %data = ();
$self->{output}->output_add(long_msg => "Checking $description:");
# Parse prtdiag output
DIAG: foreach( @diag ) {
unless( $begin ) {
# Looking for begin pattern
next DIAG unless( m/$self->{conf}->{$self->{syst}}->{"checks.$check.begin_match"}/ );
s/$self->{conf}->{$self->{syst}}->{"checks.$check.begin_match"}//;
$begin = 1;
} else {
# Stop parsing if matched end pattern
last DIAG if( m/$self->{conf}->{$self->{syst}}->{"checks.$check.end_match"}/ );
}
# Skip unwanted data
if( defined($self->{conf}->{$self->{syst}}->{"checks.$check.skip_match"}) ) {
next DIAG if( m/$self->{conf}->{$self->{syst}}->{"checks.$check.skip_match"}/ );
}
# Reinit read values
my @values = ();
# === Fetching data in linear mode === #
if( defined($fetch_mode) and ($fetch_mode eq "linear") ) {
# Use specified regexp separator, or define a default one
my $regexp_separator = $self->{conf}->{$self->{syst}}->{"checks.$check.data_match_regsep"} || '\s*,\s';
# Extract regular expresssions to be used for data collection
my @dmatch = split(/\s*,\s*/,$self->{conf}->{$self->{syst}}->{"checks.$check.data_match"});
# Take care of counters
if( $lcount >= scalar(@labels) ) {
$lcount = 0;
$dcount = $dcount + scalar(@labels) + 1;
}
# Get all matching values
@values = m/$dmatch[$lcount]/g;
# Update our hash
for( my $i=0; $i < scalar(@values); $i++ ) {
$data{($dcount+$i)}->{$labels[$lcount]} = centreon::plugins::misc::trim($values[$i]);
}
$lcount++;
# Next one
next DIAG;
}
# === Fetching data otherwise (aka tabular mode) === #
else {
# Next one if this does not match
next DIAG unless( @values = m/$self->{conf}->{$self->{syst}}->{"checks.$check.data_match"}/g );
# Update our hash
for( my $i=0; $i < scalar(@values); $i++ ) {
# Take care of counters
if( $lcount >= scalar(@labels) ) {
$lcount = 0;
$dcount++;
}
$data{$dcount}->{$labels[$lcount]} = centreon::plugins::misc::trim($values[$i]);
$lcount++;
}
}
}
# Check collected data
my $errors = 0;
my $tests = 0;
foreach my $dataset ( keys(%data) ) {
my $test_result = "";
my $ok_condition = $self->{conf}->{$self->{syst}}->{"checks.$check.ok_condition"};
my $output_string = $self->{conf}->{$self->{syst}}->{"checks.$check.output_string"};
# Substitute labels in condition and output string
foreach my $label ( keys( %{ $data{$dataset} } ) ) {
$ok_condition =~ s/%$label%/$data{$dataset}->{$label}/g;
$output_string =~ s/%$label%/$data{$dataset}->{$label}/g;
}
# Test condition
if( eval($ok_condition) ) {
# Test passed
$test_result = "INF - $output_string";
push(@passed,$output_string);
} else {
# Test failed
$test_result = "ERR - $output_string";
push(@failed,$output_string);
$errors++;
}
$tests++;
$self->{output}->output_add(long_msg => " $test_result");
}
$self->{output}->output_add(long_msg => "Checked $tests component".( $tests le 1 ? "" : "s").", found ".( $errors == 0 ? "no error" : "$errors errors." ));
}
my $checked = scalar(@passed) + scalar(@failed);
if( scalar(@failed) > 0 ) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Checked $checked component" . ( $checked le 1 ? "" : "s") . ", found " . scalar(@failed) . " errors : " . join(', ',@failed));
$self->{output}->output_add(long_msg => join("\n",@passed));
} elsif( $checked == 0 ) {
$self->{output}->output_add(severity => 'WARNING',
short_msg => "Found nothing to check !");
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "Successfully checked $checked component" . ( $checked le 1 ? "" : "s"));
$self->{output}->output_add(long_msg => join("\n", @passed));
}
}
sub run {
my ($self, %options) = @_;
$self->prtdiag();
$self->{output}->display();
$self->{output}->exit();
}
sub load_prtdiag_config {
my ($self, %options) = @_;
unless( open(CONFIG,"<$self->{config_file}") ) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Initialization error - unable to open file '" . $self->{config_file} . "' : $!");
$self->{output}->display();
$self->{output}->exit();
}
my $section = undef;
while(<CONFIG>) {
chomp();
# Remove comments
s/#.*//;
# Ignore blank lines
next if( m/^\s*$/ );
if( m/^\s*\[\s*(.*?)\s*\]\s*$/ ) {
$section = $1;
next;
} elsif( m/^\s*(.*?)\s*=\s*(.*?)\s*$/ ) {
$self->{conf}->{$section}->{$1} = $2 if( defined($section) );
}
}
close (CONFIG);
}
1;
__END__
=head1 MODE
Check Sun Hardware with 'prtdiag' command.
=over 8
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'prtdiag').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: '/usr/platform/`/sbin/uname -i`/sbin').
=item B<--command-options>
Command options (Default: '-v 2>&1').
=item B<--config-file>
Config file with prtdiag output description (Default: Directory 'conf/prtdiag.conf' under absolute mode path).
=back
=cut

View File

@ -0,0 +1,262 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::svmdisks;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo1" => { name => 'sudo1' },
"command1:s" => { name => 'command1', default => 'metastat' },
"command1-path:s" => { name => 'command1_path', default => '/usr/sbin' },
"command1-options:s" => { name => 'command1_options', default => '-c 2>&1' },
"sudo2" => { name => 'sudo2' },
"command2:s" => { name => 'command2', default => 'metadb' },
"command2-path:s" => { name => 'command2_path', default => '/usr/sbin' },
"command2-options:s" => { name => 'command2_options', default => '2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo1},
command => $self->{option_results}->{command1},
command_path => $self->{option_results}->{command1_path},
command_options => $self->{option_results}->{command1_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo2},
command => $self->{option_results}->{command2},
command_path => $self->{option_results}->{command2_path},
command_options => $self->{option_results}->{command2_options});
$long_msg = $stdout2;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $num_metastat_errors = 0;
my $metastat_name = '';
foreach (split(/\n/, $stdout)) {
#d1 m 10.0GB d11 d12 (maint)
# d11 s 10.0GB /dev/dsk/c5t600A0B80002929FC0000842E5251EE71d0s6
# d12 s 10.0GB /dev/dsk/c5t600A0B800011978E000026D95251FEF1d0s6 (maint)
#d5 r 4.0GB /dev/dsk/c5t600A0B80002929FC000084305251EFADd0s6 /dev/dsk/c5t600A0B800011978E000026DC52520043d0s6 /dev/dsk/c5t600A0B800011978E000026E25252811Ad0s6
#
# Only need to check 's' (stripping) and 'r' (raid). 'm' (mirror) is (maint) because of 's' is (maint)
if (/^\s*(\S+)\s+(s|r)\s+\S+\s+(.*?)\(maint\)/i ) {
my $name = $1;
my $disks = $3;
$disks = trim($disks);
$num_metastat_errors++;
$metastat_name .= ' [' . $name . ' (' . $disks . ')]';
}
}
my $num_metadb_errors = 0;
my $metadb_name = '';
foreach (split /\n/, $stdout2) {
#flags first blk block count
# a m pc luo 16 8192 /dev/dsk/c5t600A0B80002929FC0000842E5251EE71d0s7
# a pc luo 8208 8192 /dev/dsk/c5t600A0B80002929FC0000842E5251EE71d0s7
# a pc luo 16400 8192 /dev/dsk/c5t600A0B80002929FC0000842E5251EE71d0s7
# W pc l 16 8192 /dev/dsk/c5t600A0B800011978E000026D95251FEF1d0s7
# W pc l 8208 8192 /dev/dsk/c5t600A0B800011978E000026D95251FEF1d0s7
# W pc l 16400 8192 /dev/dsk/c5t600A0B800011978E000026D95251FEF1d0s7
#
# Uppercase letters are problems:
# W - replica has device write errors
# M - replica had problem with master blocks
# D - replica had problem with data blocks
# F - replica had format problems
# S - replica is too small to hold current data base
# R - replica had device read errors
if (/^(.*?)[0-9]/i) {
my $flags = $1;
my $errors_flags = '';
while ($flags =~ /([A-Z])/g) {
$errors_flags .= $1;
}
next if ($errors_flags eq '');
/(\S+)$/;
$num_metadb_errors++;
$metadb_name .= ' [' . $1 . ' (' . $errors_flags . ')]';
}
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_metastat_errors,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($num_metastat_errors > 0) {
output_add(severity => $exit_code,
short_msg => sprintf("Some metadevices need maintenance:" . $metastat_name));
} else {
output_add(severity => 'OK',
short_msg => "No problems on metadevices");
}
($exit_code) = $self->{perfdata}->threshold_check(value => $num_metadb_errors,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($num_metadb_errors > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Some replicas have problems:" . $metadb_name));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on replicas");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check SolarisVm disk status (use 'metastat' and 'metadb' command).
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo1>
Use 'sudo' to execute the command.
=item B<--command1>
Command to get information (Default: 'metastat').
Can be changed if you have output in a file.
=item B<--command1-path>
Command path (Default: '/usr/sbin').
=item B<--command1-options>
Command options (Default: '-c 2>&1').
=item B<--sudo2>
Use 'sudo' to execute the command.
=item B<--command2>
Command to get information (Default: 'metadb').
Can be changed if you have output in a file.
=item B<--command2-path>
Command path (Default: '/usr/sbin').
=item B<--command2-options>
Command options (Default: '2>&1').
=back
=cut

View File

@ -0,0 +1,222 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::mode::vxdisks;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo1" => { name => 'sudo1' },
"command1:s" => { name => 'command1', default => 'vxdisk' },
"command1-path:s" => { name => 'command1_path', default => '/usr/sbin' },
"command1-options:s" => { name => 'command1_options', default => 'list 2>&1' },
"sudo2" => { name => 'sudo2' },
"command2:s" => { name => 'command2', default => 'vxprint' },
"command2-path:s" => { name => 'command2_path', default => '/usr/sbin' },
"command2-options:s" => { name => 'command2_options', default => '-Ath 2>&1' },
"warning:s" => { name => 'warning', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warn1} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo1},
command => $self->{option_results}->{command1},
command_path => $self->{option_results}->{command1_path},
command_options => $self->{option_results}->{command1_options});
my $long_msg = $stdout;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo2},
command => $self->{option_results}->{command2},
command_path => $self->{option_results}->{command2_path},
command_options => $self->{option_results}->{command2_options});
$long_msg = $stdout2;
$long_msg =~ s/\|/~/mg;
$self->{output}->output_add(long_msg => $long_msg);
my $num_errors = 0;
my $vxdisks_name = '';
foreach (split /\n/, $stdout) {
if (/(failed)/i ) {
my $status = $1;
next if (! /\S+\s+\S+\s+(\S+)\s+/);
$num_errors++;
$vxdisks_name .= ' [' . $1 . '/' . $status . ']';
}
}
my $vxprint_name = '';
foreach (split /\n/, $stdout2) {
if (/(NODEVICE|FAILING)/i ) {
my $status = $1;
next if (! /\S+\s+(\S+)\s+/);
$num_errors++;
$vxprint_name .= ' [' . $1 . '/' . $status . ']';
}
}
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
if ($num_errors > 0) {
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Problems on some disks:" . $vxdisks_name . $vxdisks_name));
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => "No problems on disks.");
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Veritas disk status (use 'vxdisk' and 'vxprint' command).
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine" --ssh-option='-p=52").
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo1>
Use 'sudo' to execute the command.
=item B<--command1>
Command to get information (Default: 'vxdisk').
Can be changed if you have output in a file.
=item B<--command1-path>
Command path (Default: '/usr/sbin').
=item B<--command1-options>
Command options (Default: 'list 2>&1').
=item B<--sudo2>
Use 'sudo' to execute the command.
=item B<--command2>
Command to get information (Default: 'vxprint').
Can be changed if you have output in a file.
=item B<--command2-path>
Command path (Default: '/usr/sbin').
=item B<--command2-options>
Command options (Default: '-Ath 2>&1').
=back
=cut

View File

@ -0,0 +1,85 @@
################################################################################
# Copyright 2005-2013 MERETHIS
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
# GPL Licence 2.0.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation ; either version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses>.
#
# Linking this program statically or dynamically with other modules is making a
# combined work based on this program. Thus, the terms and conditions of the GNU
# General Public License cover the whole combination.
#
# As a special exception, the copyright holders of this program give MERETHIS
# permission to link this program with independent modules to produce an executable,
# regardless of the license terms of these independent modules, and to copy and
# distribute the resulting executable under terms of MERETHIS choice, provided that
# MERETHIS also meet, for each linked independent module, the terms and conditions
# of the license of that module. An independent module is a module which is not
# derived from this program. If you modify this program, you may extend this
# exception to your version of the program, but you are not obliged to do so. If you
# do not wish to do so, delete this exception statement from your version.
#
# For more information : contact@centreon.com
# Authors : Quentin Garnier <qgarnier@merethis.com>
#
####################################################################################
package os::solaris::local::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
# $options->{options} = options object
$self->{version} = '0.1';
%{$self->{modes}} = (
'prtdiag' => 'os::solaris::local::mode::prtdiag',
'cpu' => 'os::solaris::local::mode::cpu',
'fc-connected' => 'os::solaris::local::mode::fcconnected',
'hardware-fmadm' => 'os::solaris::local::mode::fmadm',
'analyze-disks' => 'os::solaris::local::mode::analyzedisks',
'vx-disks' => 'os::solaris::local::mode::vxdisks',
'svm-disks' => 'os::solaris::local::mode::svmdisks',
'hwraidctl-status' => 'os::solaris::local::mode::hwraidctl',
'hwsas2ircu-status' => 'os::solaris::local::mode::hwsas2ircu',
'lom-v120-status' => 'os::solaris::local::mode::lomv120',
'lom-v1280-status' => 'os::solaris::local::mode::lomv1280',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Solaris through local commands (the plugin can use SSH):
- mode 'prtdiag' need 'prtdiag' command ;
- mode 'cpu': need 'kstat' command ;
- mode 'fc-connected': need sun/oracle driver and not Emulex/Qlogic ;
- mode 'hardware-fmadm': need at least Solaris 10 and fmadm command ;
- mode 'analyze-disks': need 'format' command ;
- mode 'vx-disks': need 'vxdisk' and 'vxprint' command ;
- mode 'svm-disks': need 'metastat' and 'metadb' command ;
- mode 'hwraidctl-status': need 'raidctl' command ;
- mode 'hwsas2ircu-status': need 'sas2ircu' command ;
- mode 'lom-v120-status': need 'lom' command ;
- mode 'lom-v1280-status': need 'lom' command.
=cut