From 487d64a4e4122ca7b389b5e26b6cdf156c877c04 Mon Sep 17 00:00:00 2001 From: Elan Ruusamäe Date: Thu, 3 Mar 2016 21:23:49 +0200 Subject: allow checking 0-sized resource (ex. IPC$) patch by Marek Marczykowski --- plugins-scripts/check_disk_smb.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 98992268..4e46397d 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl @@ -212,7 +212,8 @@ if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) { my ($total_bytes) = $1 * $2; my ($occupied_bytes) = $1 * $2 - $avail_bytes; my ($avail) = $avail_bytes/1024; - my ($capper) = int(($3/$1)*100); + my ($capper); + if ($1!=0) { $capper = int(($3/$1)*100) } else { $capper=100 }; my ($mountpt) = "\\\\$host\\$share"; # TODO : why is the kB the standard unit for args ? -- cgit v1.2.3-74-g34f1 From c2f20fdd94feb06e815a891b22f25fac10c2cc13 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Fri, 27 Jan 2017 12:56:11 +0000 Subject: use pack_sockaddr_in rather than hand-rolled On some OS, sockaddr structs include a length field. Perl's pack_sockaddr_in takes this into account; the hand-rolled "pack('S n a4 x8'..." doesn't do so, resulting in connection failures. --- plugins-scripts/check_ircd.pl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 84f20229..4822fe68 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl @@ -146,7 +146,6 @@ sub bindRemote ($$) { my ($in_remotehost, $in_remoteport) = @_; my $proto = getprotobyname('tcp'); - my $sockaddr; my $that; my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); @@ -154,8 +153,7 @@ sub bindRemote ($$) print "IRCD UNKNOWN: Could not start socket ($!)\n"; exit $ERRORS{"UNKNOWN"}; } - $sockaddr = 'S n a4 x8'; - $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); + $that = pack_sockaddr_in ($in_remoteport, $thataddr); if (!connect(ClientSocket, $that)) { print "IRCD UNKNOWN: Could not connect socket ($!)\n"; exit $ERRORS{"UNKNOWN"}; -- cgit v1.2.3-74-g34f1