-
Notifications
You must be signed in to change notification settings - Fork 8
Nagios checks for pureftpd symlink root folders #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| This is a set of simple nagios plugins written in perl, python, shell-script & powershell | ||
| for testing pureftpd-related parameters | ||
|
|
||
| # Usage | ||
|
|
||
| ## check_symlink_log.sh: | ||
|
|
||
| This script checks is there are FTP accounts with root folcers set to paths that are symlinks. It relies on check_symlink_accounts.sh to fill in the logs first, and based on the log output check_symlink_log.sh will report OK or CRITICAL | ||
|
|
||
| ```sh | ||
| ./check_symlink_log.sh | ||
| ``` | ||
|
|
||
| ### Exit codes | ||
| ``` | ||
| 0 - OK | ||
| 2 - CRITICAL | ||
| ``` | ||
|
|
||
| ### Examples | ||
| Example call when there are users with symlink root directories | ||
| ```sh | ||
| ./check_symlink_log.sh | ||
| ``` | ||
| Returns: | ||
| ```sh | ||
| CRITICAL - Number of ftp accounts with symlinks as root is 4. The full list can be seen in the /var/log/symlink.log | ||
| ``` | ||
|
|
||
| Example call when there are no users with symlink root directories | ||
| ```sh | ||
| ./check_symlink_log.sh | ||
| ``` | ||
| Returns: | ||
| ```sh | ||
| OK - Number of ftp accounts with symlinks as root is 0 | ||
| ``` | ||
| ### Nagios client setup | ||
|
|
||
| Assuming you are using nrpe client on Linux, the check scripts should be put into: `/usr/lib/nagios/plugins/atomia/` | ||
|
|
||
| #### cron.d | ||
| New file in cron.d should be added with the content line this: | ||
|
|
||
| ```sh | ||
| */5 * * * * root /usr/lib/nagios/plugins/atomia/check_symlink_accounts.sh | ||
| ``` | ||
|
|
||
| #### nrpe.cfg | ||
|
|
||
| Configuratoin should be as follwong: | ||
|
|
||
| ```sh | ||
| command[check_pureftpd_symlinks] = /usr/lib/nagios/plugins/atomia/check_symlink_log.sh | ||
| ``` | ||
|
|
||
| ### Nagios server sertup | ||
|
|
||
| Since the script is a shell script that is triggered with `check_nrpe` example call for domain admins would be: | ||
|
|
||
| ```sh | ||
| /usr/lib/nagios/plugins/check_nrpe -H ftp01.atomia.hostcenter.com -t 150 -c check_pureftpd_symlinks | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #! /bin/bash | ||
| MYSQL=/usr/bin/mysql | ||
| LOGFILE=/var/log/symlink.log | ||
| TS=`date '+%Y-%m-%d %H:%M:%S'` | ||
| sylinks=0 | ||
| $MYSQL --defaults-file=/etc/mysql/debian.cnf -N -e "use pureftpd; select Dir from users;" | \ | ||
| (while read dir; do | ||
| dir1=`echo "$dir" | sed 's/\/$//'` | ||
| if [ -L "${dir1}" ] && [ -e ${dir1} ] ; then | ||
| TS=`date '+%Y-%m-%d %H:%M:%S'` | ||
| echo "$TS $dir1 is symlink" >> $LOGFILE | ||
| ((sylinks++)) | ||
| fi | ||
| done | ||
|
|
||
| if [[ $sylinks -gt 0 ]] | ||
| then | ||
| echo "CRITICAL - Number of ftp accounts with symlinks as root is $sylinks" >> $LOGFILE | ||
| fi | ||
|
Comment on lines
+11
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case you had CRITICAL state in the log file I suggest having two files:
On line 18, you could log CRITICAL only to the lock file with Issue with this would be if, an attacker was fast enough and Nagios does not alert for 1 CRITICAL. It can be configured differently in Nagios. |
||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #! /bin/bash | ||
| LOGFILE=/var/log/symlink.log | ||
| TS=`date '+%Y-%m-%d %H:%M:%S'` | ||
|
|
||
| OUTPUT=`grep CRITICAL $LOGFILE | tail -1` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check here maybe in the lock file instead of the log. |
||
|
|
||
| if [[ -n $OUTPUT ]] | ||
| then | ||
| echo "$OUTPUT. The full list can be seen in the $LOGFILE " | ||
| exit 2 | ||
| else | ||
| echo "OK - Number of ftp accounts with symlinks as root is 0" | ||
| exit 0 | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work on RHEL based systems. You don't need the
--defaults-file=/etc/mysql/debian.cnfspecified. By default on our systems you can login without password if the script is running asroot. This is not that secure but is the way that we are using it at the moment.