Révision c098ee86
update the ossec plugin
- harmonize the coding style of the three scripts
- harmonize the label names and file names with other popular plugins
- fix active_response script to use correct date format
| plugins/ossec/ossec-active-response | ||
|---|---|---|
| 1 |
|
|
| 2 |
# /bin/ sh |
|
| 3 |
# |
|
| 4 |
if [ "$1" = "autoconf" ] ; then |
|
| 5 |
|
|
| 6 |
echo "yes" |
|
| 7 |
# |
|
| 8 |
exit 0 |
|
| 9 |
# |
|
| 10 |
fi |
|
| 11 |
# |
|
| 12 |
# |
|
| 13 |
logdir="/var/ossec/logs/" |
|
| 14 |
if [ "$1" = "config" ] ; then |
|
| 15 |
# |
|
| 16 |
echo "graph_title Active Response" |
|
| 17 |
# |
|
| 18 |
echo "graph_args --base 1000 -l 0 " |
|
| 19 |
# |
|
| 20 |
echo "graph_vlabel Number of active response" |
|
| 21 |
# |
|
| 22 |
echo "graph_category Ossec" |
|
| 23 |
# |
|
| 24 |
echo "graph_scale no" |
|
| 25 |
# |
|
| 26 |
echo "c_add_actions.label Number of Rules added" |
|
| 27 |
# |
|
| 28 |
echo "c_add_actions.draw LINE2" |
|
| 29 |
# |
|
| 30 |
echo 'c_add_actions.min 0' |
|
| 31 |
# |
|
| 32 |
echo "c_del_actions.label Number of Rules deleted" |
|
| 33 |
# |
|
| 34 |
echo "c_del_actions.draw LINE2" |
|
| 35 |
# |
|
| 36 |
echo 'c_del_actions.min 0' |
|
| 37 |
# |
|
| 38 |
exit 0 |
|
| 39 |
# |
|
| 40 |
fi |
|
| 41 |
# |
|
| 42 |
# |
|
| 43 |
|
|
| 44 |
|
|
| 45 |
####Deleting the temporary logs files ########## |
|
| 46 |
rm -fr /tmp/ossecactive* |
|
| 47 |
|
|
| 48 |
|
|
| 49 |
###For Loop for grepping the last 5 mins logs and moving it to the /tmp |
|
| 50 |
|
|
| 51 |
month="$(date "+%b")"; time="$(date "+%d")";year="$(date "+%Y")"; |
|
| 52 |
if [ "$time" -le "9" ]; then |
|
| 53 |
search1="$month $time" |
|
| 54 |
else |
|
| 55 |
search1="$month $time" |
|
| 56 |
fi |
|
| 57 |
|
|
| 58 |
#search1="$month $time" |
|
| 59 |
#echo "$search1" |
|
| 60 |
for (( i = 5; i>=0; i-- )) ; do grep $(date "+%R" -d "-$i min") /var/ossec/logs/active-responses.log | grep "$search1" | grep "$year" >> /tmp/ossecactive.log;done |
|
| 61 |
|
|
| 62 |
|
|
| 63 |
#############Fore Loop Ends########## |
|
| 64 |
|
|
| 65 |
####Grepping the Hosts Blocked in last 5 mins########### |
|
| 66 |
NB_ADD=`cat /tmp/ossecactive.log| grep add | wc -l` |
|
| 67 |
|
|
| 68 |
###########Grepping the Hosts Removed from the blocked list in last 5 mins############ |
|
| 69 |
|
|
| 70 |
NB_DEL=`cat /tmp/ossecactive.log | grep del | wc -l` |
|
| 71 |
# |
|
| 72 |
# |
|
| 73 |
|
|
| 74 |
############Displaying the VALUES############# |
|
| 75 |
echo "c_add_actions.value ${NB_ADD}"
|
|
| 76 |
# |
|
| 77 |
echo "c_del_actions.value ${NB_DEL}" #
|
|
| 78 |
# |
|
| 79 |
exit 0 |
|
| plugins/ossec/ossec-agents | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
|
|
| 3 |
if [ "$1" = "autoconf" ]; then |
|
| 4 |
echo "yes" |
|
| 5 |
exit 0 |
|
| 6 |
fi |
|
| 7 |
|
|
| 8 |
if [ "$1" = "config" ]; then |
|
| 9 |
echo "graph_title Ossec Agents Status" |
|
| 10 |
echo "graph_args --base 1000 -l 0" |
|
| 11 |
echo "graph_vlabel Number of Ossec Agents" |
|
| 12 |
echo "graph_category Ossec" |
|
| 13 |
echo "graph_scale no" |
|
| 14 |
echo "active.label ACTIVE" |
|
| 15 |
echo "active.draw LINE2" |
|
| 16 |
echo 'active.min 0' |
|
| 17 |
echo "inactive.label INACTIVE" |
|
| 18 |
echo "inactive.draw LINE2" |
|
| 19 |
echo 'inactive.min 0' |
|
| 20 |
exit 0 |
|
| 21 |
fi |
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
ACTIVE=`/var/ossec/bin/list_agents -c | grep -wv "** No agent available" | wc -l` |
|
| 27 |
INACTIVE=`/var/ossec/bin/list_agents -n | grep -wv "** No agent available" | wc -l` |
|
| 28 |
|
|
| 29 |
echo "active.value ${ACTIVE}"
|
|
| 30 |
echo "inactive.value ${INACTIVE}"
|
|
| 31 |
exit 0 |
|
| plugins/ossec/ossec-alerts | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
|
|
| 3 |
if [ "$1" = "autoconf" ]; then |
|
| 4 |
echo "yes" |
|
| 5 |
exit 0 |
|
| 6 |
fi |
|
| 7 |
|
|
| 8 |
if [ "$1" = "config" ]; then |
|
| 9 |
echo "graph_title Ossec Alerts per service" |
|
| 10 |
echo "graph_args --base 1000 -l 0" |
|
| 11 |
echo "graph_vlabel Number of Alerts per service" |
|
| 12 |
echo "graph_category Ossec" |
|
| 13 |
echo "graph_scale no" |
|
| 14 |
echo "apache.label APACHE" |
|
| 15 |
echo "apache.draw LINE2" |
|
| 16 |
echo 'apache.min 0' |
|
| 17 |
echo "ssh.label SSH" |
|
| 18 |
echo "ssh.draw LINE2" |
|
| 19 |
echo 'ssh.min 0' |
|
| 20 |
echo "sudo.label SUDO" |
|
| 21 |
echo "sudo.draw LINE2" |
|
| 22 |
echo 'sudo.min 0' |
|
| 23 |
echo "total.label TOTAL" |
|
| 24 |
echo "total.draw LINE2" |
|
| 25 |
echo 'total.min 0' |
|
| 26 |
exit 0 |
|
| 27 |
fi |
|
| 28 |
|
|
| 29 |
rm -fr /tmp/ossecalerts* |
|
| 30 |
logdir="/var/ossec/logs/alerts" |
|
| 31 |
|
|
| 32 |
###For Loop for grepping the last 5 mins logs |
|
| 33 |
for (( i = 5; i >=0; i-- )) ; do |
|
| 34 |
grep $(date +%R -d "-$i min") $logdir/alerts.log >> /tmp/ossecalerts.log |
|
| 35 |
done |
|
| 36 |
|
|
| 37 |
APACHE=`cat /tmp/ossecalerts.log | grep -i 'apache\|http' | wc -l` |
|
| 38 |
SSH=`cat /tmp/ossecalerts.log | grep ssh | wc -l` |
|
| 39 |
SUDO=`cat /tmp/ossecalerts.log | grep sudo | wc -l` |
|
| 40 |
TOTAL=`cat /tmp/ossecalerts.log | grep -v ">"| wc -l` |
|
| 41 |
|
|
| 42 |
echo "apache.value ${APACHE}"
|
|
| 43 |
echo "ssh.value ${SSH}"
|
|
| 44 |
echo "sudo.value ${SUDO}"
|
|
| 45 |
echo "total.value ${TOTAL}"
|
|
| 46 |
exit 0 |
|
| plugins/ossec/ossec_active_response | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
|
|
| 3 |
if [ "$1" = "autoconf" ]; then |
|
| 4 |
echo "yes" |
|
| 5 |
exit 0 |
|
| 6 |
fi |
|
| 7 |
|
|
| 8 |
if [ "$1" = "config" ]; then |
|
| 9 |
echo "graph_title OSSEC Active Response" |
|
| 10 |
echo "graph_args --base 1000 -l 0" |
|
| 11 |
echo "graph_vlabel Number of responses" |
|
| 12 |
echo "graph_category ossec" |
|
| 13 |
echo "graph_scale no" |
|
| 14 |
echo "c_add_actions.label rules added" |
|
| 15 |
echo "c_add_actions.draw LINE2" |
|
| 16 |
echo 'c_add_actions.min 0' |
|
| 17 |
echo "c_del_actions.label rules deleted" |
|
| 18 |
echo "c_del_actions.draw LINE2" |
|
| 19 |
echo 'c_del_actions.min 0' |
|
| 20 |
exit 0 |
|
| 21 |
fi |
|
| 22 |
|
|
| 23 |
### Deleting temporary log files from last run |
|
| 24 |
rm -f /tmp/ossecactive.log |
|
| 25 |
logdir="/var/ossec/logs" |
|
| 26 |
|
|
| 27 |
|
|
| 28 |
### day of moth needs to be space padded |
|
| 29 |
month="$(date "+%b")"; day="$(date "+%e")";year="$(date "+%Y")"; |
|
| 30 |
search1="$month $day" |
|
| 31 |
|
|
| 32 |
### for loop for grepping the last 5 min of logs and copy it to /tmp |
|
| 33 |
for (( i = 5; i >=0; i-- )) ; do |
|
| 34 |
grep $(date "+%R" -d "-$i min") $logdir/active-responses.log | grep "$search1" | grep "$year" >> /tmp/ossecactive.log |
|
| 35 |
done |
|
| 36 |
### End for loop |
|
| 37 |
|
|
| 38 |
### count the lines for each action in the temporary log file |
|
| 39 |
NB_ADD=`cat /tmp/ossecactive.log | grep add | wc -l` |
|
| 40 |
NB_DEL=`cat /tmp/ossecactive.log | grep del | wc -l` |
|
| 41 |
|
|
| 42 |
echo "c_add_actions.value ${NB_ADD}"
|
|
| 43 |
echo "c_del_actions.value ${NB_DEL}"
|
|
| 44 |
|
|
| 45 |
exit 0 |
|
| plugins/ossec/ossec_agents | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
|
|
| 3 |
if [ "$1" = "autoconf" ]; then |
|
| 4 |
echo "yes" |
|
| 5 |
exit 0 |
|
| 6 |
fi |
|
| 7 |
|
|
| 8 |
if [ "$1" = "config" ]; then |
|
| 9 |
echo "graph_title Ossec agents status" |
|
| 10 |
echo "graph_args --base 1000 -l 0" |
|
| 11 |
echo "graph_vlabel Number of ossec agents" |
|
| 12 |
echo "graph_category ossec" |
|
| 13 |
echo "graph_scale no" |
|
| 14 |
echo "active.label active" |
|
| 15 |
echo "active.draw LINE2" |
|
| 16 |
echo 'active.min 0' |
|
| 17 |
echo "inactive.label inactive" |
|
| 18 |
echo "inactive.draw LINE2" |
|
| 19 |
echo 'inactive.min 0' |
|
| 20 |
exit 0 |
|
| 21 |
fi |
|
| 22 |
|
|
| 23 |
### where to find the ossec tools |
|
| 24 |
ossecdir="/var/ossec/bin" |
|
| 25 |
|
|
| 26 |
### count the lines from the output of the list_agents tool |
|
| 27 |
ACTIVE=`$ossecdir/list_agents -c | grep -wv "** No agent available" | wc -l` |
|
| 28 |
INACTIVE=`$ossecdir/list_agents -n | grep -wv "** No agent available" | wc -l` |
|
| 29 |
|
|
| 30 |
echo "active.value ${ACTIVE}"
|
|
| 31 |
echo "inactive.value ${INACTIVE}"
|
|
| 32 |
exit 0 |
|
| plugins/ossec/ossec_alerts | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
|
|
| 3 |
if [ "$1" = "autoconf" ]; then |
|
| 4 |
echo "yes" |
|
| 5 |
exit 0 |
|
| 6 |
fi |
|
| 7 |
|
|
| 8 |
if [ "$1" = "config" ]; then |
|
| 9 |
echo "graph_title Ossec alerts per service" |
|
| 10 |
echo "graph_args --base 1000 -l 0" |
|
| 11 |
echo "graph_vlabel Number of alerts per service" |
|
| 12 |
echo "graph_category ossec" |
|
| 13 |
echo "graph_scale no" |
|
| 14 |
echo "apache.label httpd" |
|
| 15 |
echo "apache.draw LINE2" |
|
| 16 |
echo 'apache.min 0' |
|
| 17 |
echo "ssh.label ssh" |
|
| 18 |
echo "ssh.draw LINE2" |
|
| 19 |
echo 'ssh.min 0' |
|
| 20 |
echo "sudo.label sudo" |
|
| 21 |
echo "sudo.draw LINE2" |
|
| 22 |
echo 'sudo.min 0' |
|
| 23 |
echo "total.label total" |
|
| 24 |
echo "total.draw LINE2" |
|
| 25 |
echo 'total.min 0' |
|
| 26 |
exit 0 |
|
| 27 |
fi |
|
| 28 |
|
|
| 29 |
### Deleting temporary log files from last run |
|
| 30 |
rm -f /tmp/ossecalerts.log |
|
| 31 |
logdir="/var/ossec/logs/alerts" |
|
| 32 |
|
|
| 33 |
###For Loop for grepping the last 5 mins logs |
|
| 34 |
for (( i = 5; i >=0; i-- )) ; do |
|
| 35 |
grep $(date +%R -d "-$i min") $logdir/alerts.log >> /tmp/ossecalerts.log |
|
| 36 |
done |
|
| 37 |
### End for loop |
|
| 38 |
|
|
| 39 |
### count the lines for each service in the temporary log file |
|
| 40 |
APACHE=`cat /tmp/ossecalerts.log | grep -i 'apache\|http' | wc -l` |
|
| 41 |
SSH=`cat /tmp/ossecalerts.log | grep ssh | wc -l` |
|
| 42 |
SUDO=`cat /tmp/ossecalerts.log | grep sudo | wc -l` |
|
| 43 |
TOTAL=`cat /tmp/ossecalerts.log | grep -v ">"| wc -l` |
|
| 44 |
|
|
| 45 |
echo "apache.value ${APACHE}"
|
|
| 46 |
echo "ssh.value ${SSH}"
|
|
| 47 |
echo "sudo.value ${SUDO}"
|
|
| 48 |
echo "total.value ${TOTAL}"
|
|
| 49 |
exit 0 |
|
Formats disponibles : Unified diff