aboutsummaryrefslogtreecommitdiff
path: root/contrib/aix/check_failed
blob: 50cdf7e1a4af87294766ec1b0c994f38acc7b97b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
#======================
# Created May 25, 2000
#======================

# This scripts is for checking for failed root login attempts on
# any machine running AIX which has a failedlogin file in /etc/security
# The purpose is to thwart (good word) any unauthorised people from
# even trying to log in as root. This plugin has been developed for Nagios
# running on AIX.  
# Lonny Selinger SpEnTBoY lonny@abyss.za.org
# May


my $server = $ARGV[0];

if (!$ARGV[0]) {
	print "You must specify a server to check\n";
	print "usage: ./check_failed <Server Name>\n";
	exit (-1);
	} else {
		open (DATE, "/bin/date '+%b %d' |");
 		while (<DATE>) {
			$dline = $_;
			@dresults = $dline;
			chop $dresults[0];
		}	
		open (SULOG, "rsh $server -l root who /etc/security/failedlogin | grep root |");
 		while (<SULOG>) {
			$line = $_;
			@results = split (/\s+/,$line);
			if ($line =~ /^root/) {
			if (join(' ', @results[2,3]) eq $dresults[0]) {	
				print "FAILED root login on $dresults[0], node: $ARGV[0] from $results[5]\n";
				exit(2);
			}
		}
	}
}	
if (join(' ', @results[2,3]) ne $dresults[0]) {
	print "No Failed Root Logins on This Node\n";
	exit(0);
}
exit(0);
close(SULOG);
close(DATE);