Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nagios-plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
nagios-plugin
Commits
026fc7e6
Commit
026fc7e6
authored
4 years ago
by
Rémi - Le Filament
Browse files
Options
Downloads
Patches
Plain Diff
Delete obsolete check_fail2ban.sh
Use
https://github.com/n1tr0-5urf3r/icinga2-scripts/blob/master/plugins/check_fail2ban
instead
parent
aa88b775
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_fail2ban.sh
+0
-143
0 additions, 143 deletions
check_fail2ban.sh
with
0 additions
and
143 deletions
check_fail2ban.sh
deleted
100755 → 0
+
0
−
143
View file @
aa88b775
#!/bin/bash
#########################################################
# Written by Andor Westphal andor.westphal@gmail.com #
# Created: 2013-02-22 (version 1.0) #
# Modified:2013-03-12 (version 1.1) #
# -fix wrong count for output #
# -implement status check #
# #
#checks the count of active jails #
#checks for banned IP's #
#integrated performance data for banned IPs #
#shows banned IP since the last logrotate in long output#
# #
# Modified by Le Filament htpps://le-filament.com : #
# Modified: 2018-10-24 (version 1.2fil) #
# - change reporting to get it in French #
# - display usage with -h option #
# - change fail2ban.sock to fail2ban-server #
# - add AGPL3 license #
# Copyright © 2019 Le Filament #
# License AGPL-3.0 or later #
# (http://www.gnu.org/licenses/agpl.html). #
#########################################################
STATUS_OK
=
"0"
STATUS_WARNING
=
"1"
STATUS_CRITICAL
=
"2"
STATUS_UNKNOWN
=
"3"
ps_state
=
$(
ps aux |grep
"fail2ban-server"
|grep
-v
grep
|
wc
-l
)
PROGPATH
=
`
dirname
$0
`
fail2ban_client
=
$(
which fail2ban-client
)
jail_count
=
$(
$fail2ban_client
status|grep
"Number"
|cut
-f
2
)
print_usage
()
{
echo
"
Usage:
$PROGPATH
/check_fail2ban -h for help (this messeage)
-l </path/to/logfile>
-p </path/to/conffile>
-w <your warnlevel>
-c <your critlevel>
example :
$PROGPATH
/check_fail2ban -l /var/log/fail2ban.log -p /etc/fail2ban/jail.conf -w 10 -c 20
"
}
wrong_cpath
()
{
echo
"Is your path to conffile right?"
echo
"There is no entry for the bantime"
echo
"Normaly its in the jail.conf"
}
if
[
"
$ps_state
"
-lt
"1"
]
;
then
echo
" ++++ Process is not running ++++"
exit
$STATUS_CRITICAL
fi
if
[
-z
"
$1
"
]
;
then
echo
" ++++ No arguments found ++++"
exit
$STATUS_UNKNOWN
fi
while
test
-n
"
$1
"
;
do
case
"
$1
"
in
-c
)
crit
=
$2
shift
;;
-h
)
print_usage
exit
$STATUS_UNKNOWN
;;
-l
)
lpath
=
$2
shift
;;
-p
)
cpath
=
$2
shift
;;
-w
)
warn
=
$2
shift
;;
*
)
echo
"Unknown argument:
$1
"
print_usage
exit
$STATUS_UNKNOWN
;;
esac
shift
done
if
[
-z
${
crit
}
]
||
[
-z
${
lpath
}
]
||
[
-z
${
cpath
}
]
||
[
-z
${
warn
}
]
;
then
echo
" ++++ Missing arguments ++++"
print_usage
exit
$STATUS_UNKNOWN
fi
ban
=
$(
grep
"Ban "
${
lpath
}
|grep
-v
Fail|
awk
-F
[
\ \:
]
'{print $10,$8}'
)
bcount
=
$(
echo
"
$ban
"
|grep
-v
^
\#
|
grep
-v
^
$|
wc
-l
)
if
[
"
$bcount
"
-ge
${
warn
}
]
&&
[
"
$bcount
"
-lt
${
crit
}
]
;
then
State
=
"Warning"
elif
[
"
$bcount
"
-ge
${
crit
}
]
;
then
State
=
"Critical"
else
State
=
"Ok"
fi
ban_time
=
$(
cat
${
cpath
}
|grep
"bantime"
|cut
-d
" "
-f4
)
#ban_time=$(echo The bantime are ${ban_time} seconds)
long_out
=
$(
cat
/var/log/fail2ban.log |grep
"Ban "
|cut
-d
" "
-f
7,5,2|sed
-e
's/$/\\n/g'
|grep
-v
Fail
)
OUTPUT
=
$(
echo
"Etat :
${
State
}
-- IP Bannies=
${
bcount
}
-- Warning :
${
warn
}
-- Critical :
${
crit
}
\n
${
jail_count
}
Services surveillés"
)
echo
$OUTPUT
if
[
${
State
}
==
"Warning"
]
;
then
exit
${
STATUS_WARNING
}
elif
[
${
State
}
==
"Critical"
]
;
then
exit
${
STATUS_CRITICAL
}
elif
[
${
State
}
==
"Unknown"
]
;
then
exit
${
STATUS_UNKNOWN
}
else
exit
${
STATUS_OK
}
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment