D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
lib
/
check_mk_agent
/
local
/
Filename :
cmk_homes_availability.pl
back
Copy
#!/usr/bin/perl use warnings; use lib "/root"; use Dreamscape::Cpanel::Home; $date=localtime(time); $args="@ARGV"; $MonitoringFlag = ".monitoring_check"; # get actual mountpoints @homes = Dreamscape::Cpanel::Home->get_homes(); sub CreateCheckpoints { open FILE, ">$home/$MonitoringFlag" or push @errors, $home; print "Creating checkpoint on $home\n"; close FILE; } sub CheckMountpoints { open FILE, "<$home/$MonitoringFlag" or push @errors, $home; close FILE; } if ( $args eq "-help") { print "Usage: cmk_homes_availability.pl [-init]\n"; print "\n"; print "Run without args to check mountpoints, use key \"-init\" to create checkpoints\n"; exit 0; } if ( $args eq "-init") { $action = \&CreateCheckpoints; } else { $action = \&CheckMountpoints; } foreach $home (@homes) { &$action } # Returning values for check_mk # 2 - Critical # 1 - Warning # 0 - OK if (@errors) { print "2 Home_check - failed to access @errors of @homes I/O error\n"; open LOG, ">>/var/log/cmk_homes_availability.log" or die "Failed to open /var/log/cmk_homes_availability.log: $!\n"; print LOG "$date Home_check - failed to access @errors of @homes I/O error\n"; close LOG; } else { print "0 Home_check - @homes is OK\n"; }