Added aslookup and fixed a bug in watchd regarding variable naming
This commit is contained in:
parent
70cc3b54ce
commit
af7e9c4218
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
#aslookup.pl - Looks up information on a given ASN or IP address
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Net::Whois::RIPE;
|
||||||
|
|
||||||
|
my $default_as_server = "whois.radb.net";
|
||||||
|
my %whois_options = (
|
||||||
|
"hostname" => $default_as_server,
|
||||||
|
);
|
||||||
|
|
||||||
|
my $whois = Net::Whois::RIPE->new(%whois_options);
|
||||||
|
my $witerator = $whois->query('1.1.1.1');
|
||||||
|
while($witerator->isnt_exhausted()) {
|
||||||
|
my $wdata = $witerator->value()
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ Scripts
|
||||||
-------
|
-------
|
||||||
|
|
||||||
This readme contains an up to date list of all scripts in the repo + their descriptions:
|
This readme contains an up to date list of all scripts in the repo + their descriptions:
|
||||||
|
- aslookup: Perl - Script to look up ASN information for a given IP or ASN
|
||||||
- mailview: Perl - Script to parse HTML email and format it in a text-reader-friendly way.
|
- mailview: Perl - Script to parse HTML email and format it in a text-reader-friendly way.
|
||||||
- nscheck: Bash - DNS diagnosis script
|
- nscheck: Bash - DNS diagnosis script
|
||||||
- paster: Bash - Script to take standard input and 'paste' it to a pastebin site.
|
- paster: Bash - Script to take standard input and 'paste' it to a pastebin site.
|
||||||
|
|
25
watchd
25
watchd
|
@ -1,21 +1,16 @@
|
||||||
#/usr/bin/env bash
|
#!/bin/bash
|
||||||
# watchd - Bash script to check the integrity/state of a given directory. Meant to be run continuously in cron.
|
# watchd - Bash script to check the integrity/state of a given directory. Meant to be run continuously in cron.
|
||||||
# Written 9th January 2013 by Matthew Connelly <maff@maff.me.uk>
|
# Written 9th January 2013 by Matthew Connelly <maff@maff.me.uk>
|
||||||
|
|
||||||
#Internal variables
|
#Internal variables
|
||||||
HOSTNAME="$(hostname -f)"
|
HOSTNAME="$(hostname -f)"
|
||||||
HOSTNAME_SHORT="$(hostname -s)"
|
HOSTNAME_SHORT="$(hostname -s)"
|
||||||
EGREP_BIN="$(command -v egrep)"
|
EGREP_BIN="/bin/egrep"
|
||||||
if [ $? -ne 0 -o -z "$EGREP_BIN" ]; then echo "Failed to locate 'egrep'."; exit 1; fi
|
FIND_BIN="/bin/find"
|
||||||
FIND_BIN="$(command -v find)"
|
LS_BIN="/bin/ls"
|
||||||
if [ $? -ne 0 -o -z "$FIND_BIN" ]; then echo "Failed to locate 'find'."; exit 1; fi
|
|
||||||
LS_BIN="$(command -v ls)"
|
|
||||||
if [ $? -ne 0 -o -z "$LS_BIN" ]; then echo "Failed to locate 'ls'."; exit 1; fi
|
|
||||||
LS_ARGS="-lAd"
|
LS_ARGS="-lAd"
|
||||||
SENDMAIL_BIN="$(command -v sendmail)"
|
SENDMAIL_BIN="/usr/sbin/sendmail"
|
||||||
if [ $? -ne 0 -o -z "$SENDMAIL_BIN" ]; then echo "Failed to locate 'sendmail'."; exit 1; fi
|
STAT_BIN="/usr/bin/stat"
|
||||||
STAT_BIN="$(command -v stat)"
|
|
||||||
if [ $? -ne 0 -o -z "$STAT_BIN" ]; then echo "Failed to locate 'stat'."; exit 1; fi
|
|
||||||
STAT_ARGS="-c %a"
|
STAT_ARGS="-c %a"
|
||||||
|
|
||||||
#This should be the full path to your config file
|
#This should be the full path to your config file
|
||||||
|
@ -68,7 +63,7 @@ for file in $LS_OUT; do
|
||||||
RUN_CHECKS="NO"
|
RUN_CHECKS="NO"
|
||||||
F_SKIPPED_COUNT=$(($F_SKIPPED_COUNT+1))
|
F_SKIPPED_COUNT=$(($F_SKIPPED_COUNT+1))
|
||||||
else
|
else
|
||||||
if [ "$CHECK_FILES_PERMS_OWNER_CHANGED" == "YES" ]; then
|
if [ "$CHECK_FILE_PERMS_OWNER_CHANGED" == "YES" ]; then
|
||||||
FPERMS="$($STAT_BIN $STAT_ARGS "$FILENAME")"
|
FPERMS="$($STAT_BIN $STAT_ARGS "$FILENAME")"
|
||||||
FOWNER="$(echo $file|awk '{print $3 " " $4}')"
|
FOWNER="$(echo $file|awk '{print $3 " " $4}')"
|
||||||
fi
|
fi
|
||||||
|
@ -95,7 +90,7 @@ for file in $LS_OUT; do
|
||||||
fi
|
fi
|
||||||
#Then we check permissions
|
#Then we check permissions
|
||||||
PREV_PERMS="$(echo $PREV_STATE|awk '{print $2}')"
|
PREV_PERMS="$(echo $PREV_STATE|awk '{print $2}')"
|
||||||
if [ "$PREV_PERMS" != "$FPERMS" ] && [ "$RUN_CHECKS" == "YES" ] && [ "$CHECK_FILES_PERMS_OWNER_CHANGED" == "YES" ]; then
|
if [ "$PREV_PERMS" != "$FPERMS" ] && [ "$RUN_CHECKS" == "YES" ] && [ "$CHECK_FILE_PERMS_OWNER_CHANGED" == "YES" ]; then
|
||||||
#Permissions check failed, permissions were modified
|
#Permissions check failed, permissions were modified
|
||||||
CHECKOUT="$CHECKOUT$STR_PERMSCHANGED "
|
CHECKOUT="$CHECKOUT$STR_PERMSCHANGED "
|
||||||
FILESTATE="$FILESTATE EPERMSCHANGED"
|
FILESTATE="$FILESTATE EPERMSCHANGED"
|
||||||
|
@ -103,7 +98,7 @@ for file in $LS_OUT; do
|
||||||
fi
|
fi
|
||||||
#Then we check ownership
|
#Then we check ownership
|
||||||
PREV_OWNERGROUP="$(echo $PREV_STATE|awk '{print $3 " " $4}')"
|
PREV_OWNERGROUP="$(echo $PREV_STATE|awk '{print $3 " " $4}')"
|
||||||
if [ "$PREV_OWNERGROUP" != "$FOWNER" ] && [ "$RUN_CHECKS" == "YES" ] && [ "$CHECK_FILES_PERMS_OWNER_CHANGED" == "YES" ]; then
|
if [ "$PREV_OWNERGROUP" != "$FOWNER" ] && [ "$RUN_CHECKS" == "YES" ] && [ "$CHECK_FILE_PERMS_OWNER_CHANGED" == "YES" ]; then
|
||||||
#Ownership check failed, owner or group has changed
|
#Ownership check failed, owner or group has changed
|
||||||
CHECKOUT="$CHECKOUT$STR_OWNCHANGED "
|
CHECKOUT="$CHECKOUT$STR_OWNCHANGED "
|
||||||
FILESTATE="$FILESTATE EOWNERCHANGED"
|
FILESTATE="$FILESTATE EOWNERCHANGED"
|
||||||
|
@ -147,7 +142,7 @@ To: $EMAIL_TO <$EMAIL_ADDR>
|
||||||
|
|
||||||
$EMAIL_BODY_HEAD$IFSN$COUNT_OUT$IFSN$IFSN$EMAIL_BODY_DETAIL$IFSN$IFSN$HR_OUTPUT$IFSN$EMAIL_BODY_TAIL"
|
$EMAIL_BODY_HEAD$IFSN$COUNT_OUT$IFSN$IFSN$EMAIL_BODY_DETAIL$IFSN$IFSN$HR_OUTPUT$IFSN$EMAIL_BODY_TAIL"
|
||||||
#Send the email
|
#Send the email
|
||||||
if [ "$ENABLE_EMAIL" == "YES" ]; then
|
if [ "$NOTIFY_EMAIL" == "YES" ]; then
|
||||||
echo "$EMAILOUT"|$SENDMAIL_BIN $EMAIL_FROM $EMAIL_ADDR
|
echo "$EMAILOUT"|$SENDMAIL_BIN $EMAIL_FROM $EMAIL_ADDR
|
||||||
fi
|
fi
|
||||||
#Make a backup of the old statefile and write a new one
|
#Make a backup of the old statefile and write a new one
|
||||||
|
|
10
watchd.conf
10
watchd.conf
|
@ -1,7 +1,7 @@
|
||||||
#Configuration
|
#Configuration
|
||||||
#Paths
|
#Paths
|
||||||
#WATCH_DIR: This is the full path to the directory that watchd should monitor. This should not end with a backslash (/).
|
#WATCH_DIR: This is the full path to the directory that watchd should monitor. This should not end with a backslash (/).
|
||||||
WATCH_DIR="/"
|
WATCH_DIR="/home/ipxcore/public_html/order"
|
||||||
#WATCH_STATE_FILE: This should be the full path to the file watchd should use to store tracking data
|
#WATCH_STATE_FILE: This should be the full path to the file watchd should use to store tracking data
|
||||||
WATCH_STATE_FILE="/root/.watchd.prevstate"
|
WATCH_STATE_FILE="/root/.watchd.prevstate"
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@ CHECK_FILES_DESTROYED="YES"
|
||||||
#NOTIFY_EMAIL: Set this to 'YES' to enable email notifications of alerts from watchd.
|
#NOTIFY_EMAIL: Set this to 'YES' to enable email notifications of alerts from watchd.
|
||||||
NOTIFY_EMAIL="YES"
|
NOTIFY_EMAIL="YES"
|
||||||
#EMAIL_ADDR: This should be the email address notifications are sent to.
|
#EMAIL_ADDR: This should be the email address notifications are sent to.
|
||||||
EMAIL_ADDR="example@example.com"
|
EMAIL_ADDR="email@ipxcore.com"
|
||||||
|
|
||||||
#Check tracking configuration.
|
#Check tracking configuration.
|
||||||
#FILES_TO_SKIP: This is a list of all directories or files that watchd should not track.
|
#FILES_TO_SKIP: This is a list of all directories or files that watchd should not track.
|
||||||
#Variables that can be used: $WATCH_DIR - The base path.
|
#Variables that can be used: $WATCH_DIR - The base path.
|
||||||
#Make sure all paths are separated with the '|' character. Also make sure that this character is not present at the beginning or end of this value.
|
#Make sure all paths are separated with the '|' character. Also make sure that this character is not present at the beginning or end of this value.
|
||||||
#Simple regular expressions are supported, and directories can be specified using the format "/path/to/dir/.*", where the end of the directory has '/.*' appended.
|
#Simple regular expressions are supported, and directories can be specified using the format "/path/to/dir/.*", where the end of the directory has '/.*' appended.
|
||||||
FILES_TO_SKIP=""
|
FILES_TO_SKIP="$WATCH_DIR/modules/servers/Comodo_Module/error_log|$WATCH_DIR/admin/error_log|$WATCH_DIR/templates_c/.*"
|
||||||
|
|
||||||
#String and template configuration.
|
#String and template configuration.
|
||||||
#Strings: These specify what should be stated in the event that various checks are triggered. Default values should be used here unless you need to make watchd say something else about a check.
|
#Strings: These specify what should be stated in the event that various checks are triggered. Default values should be used here unless you need to make watchd say something else about a check.
|
||||||
|
@ -39,8 +39,8 @@ STR_FILEDESTROYED="File could not be found, and has been either deleted or moved
|
||||||
#Templates: These specify the base header and footer of the email that will be sent.
|
#Templates: These specify the base header and footer of the email that will be sent.
|
||||||
#Variables that can be used: $HOSTNAME - The fully-qualified domain name of the server; $HOSTNAME-SHORT - The least-qualified name of the server
|
#Variables that can be used: $HOSTNAME - The fully-qualified domain name of the server; $HOSTNAME-SHORT - The least-qualified name of the server
|
||||||
EMAIL_SUBJ="[watchd] Alert"
|
EMAIL_SUBJ="[watchd] Alert"
|
||||||
EMAIL_FROM="$HOSTNAME_SHORT@example.com"
|
EMAIL_FROM="$HOSTNAME_SHORT@ipxcore.com"
|
||||||
EMAIL_TO="Example"
|
EMAIL_TO="IPXcore"
|
||||||
EMAIL_BODY_HEAD="This is watchd on the machine $HOSTNAME.
|
EMAIL_BODY_HEAD="This is watchd on the machine $HOSTNAME.
|
||||||
I have detected one or more anomalies in $WATCH_DIR.
|
I have detected one or more anomalies in $WATCH_DIR.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue