Thanks so much for the great ideas on this! Here is my updated promise:
bundle agent check_breakin_attempts
{
vars:
"current_day" string => execresult("/bin/date +%d", "useshell");
"current_month" string => execresult("/bin/date +%b", "useshell");
"breakin_failed_passwd" string => execresult("/bin/grep '$(current_month) $(current_day)' /var/log/messages* | \
/bin/grep 'Failed' | \
/bin/grep 'password' | \
/bin/awk '{ print $11 }'", "useshell");
classes:
"no_results" not => regcmp(".+","$breakin_failed_passwd"),
comment => "This checks to see if the string is empty..";
reports:
linux::
!no_results::
"Command failed! Results: $(breakin_failed_passwd)";
no_results::
"Command succeeded! $(breakin_failed_passwd)";
}
For some reason, I can execute the command to grep the log on the command line, but when I try to run it with this policy, it doesn't return anything for me. I think I need to look into the 'useshell' option, maybe that isn't set correctly. Thanks a bunch for your help!
Pam