Cacti Beginner's Guide(Second Edition)
上QQ阅读APP看书,第一时间看更新

Gathering the data

The following important lines within the script retrieve the relevant Cacti data by executing a sequence of operating system commands:

# Retrieve the number of lines containing a "authentication failure" or "Invalid user" string 
$data{'invalid_users'} = `egrep " authentication failure|Invalid user" $secure_log  | wc -l`; 
 
# Retrieve the number of lines containing a "New session" or "Accepted password" string 
$data{'valid_logons'} = `egrep " New session|Accepted password" $secure_log  | wc -l`; 

The first line looks for the string Invalid user within the secure log file by using the grep command. This command will print all lines containing this string. By using the special pipe character, |, we redirect the output from this command to the wc (abbreviation for word count) command. By using the -l switch, the wc command will count the number of lines. The output of this command is then stored within the $data{'invalid_users'} variable.