Site Monitor
polski
Ogólnie
Zestaw skryptów służący do prostego monitorowania zmian na stronach WWW oraz zawartości serwerów FTP. Skrypty napisane są w Bashu.
Możliwości
Monitoring stron lub czegokolwiek innego, co potrafi odczytać wget
- przede wszystkim po protokole
HTTP
i HTTPS
.
Specjalnie są traktowane adresy, do których dostęp uzyskiwany jest protokołem FTP
- porównywane są sumy
listingów katalogów. Oprócz tego rozpoznawane są adresy zawierające pseudo-protokoły: ftp+grep:
oraz
ftp+igrep
. Pozawalają one na porównywanie sum z fragmentów, które pasują do wyrażenia regularnego
określanego dodatkowo w adresie.
Przykładowe linki
Przykładowa zawartość pliku z linkami:
ftp+grep://ftp.icm.edu.pl/pub/mozilla/firefox/releases/3\.0\.10
ftp+igrep://ftp.icm.edu.pl/pub/mozilla/FiReFoX
ftp://ftp.icm.edu.pl/pub/mozilla/thunderbird/releases/
http://wodny.org/
https://poczta.onet.pl/
Pierwsza linijka sprawdza, czy w katalogu releases
jest jakiś plik/katalog pasujący do wyrażenia
regularnego "3\.0\.10". Należy zauważyć, że używane jest tu narzędzie grep
i należy stosować
zasady zapisu wyrażeń zgodne z tym narzędziem.
Druga linijka w katalogu mozilla
każe szukać elementów pasujących do wzorca "firefox" bez brania
pod uwagę wielkości liter.
Trzecia linijka wylicza sumę z listingu katalogu.
Czwarta i piąta linijka wyliczają sumę z zawartości strony.
Format linków
wyrażenie regularne z zachowaniem wielkości liter: ftp+grep://<serwer+katalog>/<wyrażenie regularne>wyrażenie regularne bez zachowana wielkości liter: ftp+igrep://<serwer+katalog>/<wyrażenie regularne>
suma z listingu katalogu: ftp://<serwer+katalog>
suma z treści strony: http://<adres>
suma z treści strony: https://<adres>
Przykład użycia
- Generowanie aktualnych sum z jednoczesnym podglądem dzięki
tee
:
$ ./genhashes.sh data/links | tee data/links_and_sums
wynik:
LINK: ftp+grep://ftp.icm.edu.pl/pub/mozilla/firefox/releases/3.0.11
RETURNED : 0
LINK: ftp+igrep://ftp.icm.edu.pl/pub/mozilla/FiReFoX
ftp+grep://ftp.icm.edu.pl/pub/mozilla/firefox/releases/3.0.11
d41d8cd98f00b204e9800998ecf8427e
RETURNED : 0
LINK: ftp://ftp.icm.edu.pl/pub/mozilla/thunderbird/releases/
ftp+igrep://ftp.icm.edu.pl/pub/mozilla/FiReFoX
38144139eb6ab85bb6e881ba8e4bbb9b
RETURNED : 0
LINK: http://wodny.org/
ftp://ftp.icm.edu.pl/pub/mozilla/thunderbird/releases/
87246f27c4264a1436bd75290e137060
RETURNED : 0
LINK: https://poczta.onet.pl/
http://wodny.org/
490c28b8e77c8b22bfde03277012bbe1
RETURNED : 0
https://poczta.onet.pl/
6b50a51b41b25ce851aa24ae336777c0
Linki wraz sumami znalazły się w plikudata/links_and_sums
, w kosoli pojawiło się też parę dodatkowych informacji. Widać, że wszystkie połączenia się udały (RETURNED : 0
) oraz np. nie udało się znaleźć nic pasującego do wzorca3.0.11
w katalogureleases
(suma MD5 d41d8cd98f00b204e9800998ecf8427e tożsama z sumą pustego wejścia -$ echo -n | md5sum
). - Uruchomienie monitoringu:
Można odpalić po prostu w konsoli:
$ ./monitor.sh data/links_and_sums
,
ale jeśli włączone jest powiadomieniem mailem o zmianach, dużo zabawniej jest odpalić program z użyciem narzędziascreen
na jakimś serwerze i pozostawić go samemu sobie:
$ screen ./monitor.sh data/links_and_sums
.
Uwagi końcowe
By włączyć:
powiadamianie mailem - należy w pliku monitor.sh
ustawić zmienną MAILNOTIFY
na 1.
szyfrowanie powiadomienia - w pliku monitor.sh
ustawić zmienną MAILENCRYPT
na 1.
Do wysłania maila używany jest program mutt
. Raport jest doklejany do listu jako załącznik. Dane służące do
tworzenia maila, w tym nagłówki z adresem nadawcy i odbiorcy, znajdują się w pliku data/message
.
Przed pierwszym uruchomieniem należy wejść do pliku monitor.sh
i ustawić wg potrzeb zmienne:
- MAILNOTIFY
- MAILENCRYPT
- GNUPGHOME (jeśli
MAILENCRYPT == 1)
- KEYID (jeśli
MAILENCRYPT == 1)
- KEYID (jeśli
data/message
(jeśli MAILNOTIFY == 1).
Download
Repozytorium SVN
Archiwum tar.gz
English
Summary
A set of simple scripts used for WWW and FTP sites monitoring. They are written in Bash.
Features
Observation of sites or any other thing that wget
can download - primarily HTTP
and
HTTPS
.
Access to FTP
proceeds in a special way - directory listings are compared. There are also some
pseudo-protocols supported by these scripts: ftp+grep:
and ftp+igrep
. They allow you to
compare sums of fragments matched by a regular expression appended to the address past the last slash.
Examples
Example of a file with a list of links:
ftp+grep://ftp.icm.edu.pl/pub/mozilla/firefox/releases/3\.0\.10
ftp+igrep://ftp.icm.edu.pl/pub/mozilla/FiReFoX
ftp://ftp.icm.edu.pl/pub/mozilla/thunderbird/releases/
http://wodny.org/
https://poczta.onet.pl/
The first line checks if there is a file/directory matched by the "3\.0\.10" regular expresion inside the
releases
directory. grep
is used for matching so please use the format of regexps of that
tool.
The second line checks if there is anything matched by "firefox" regexp in the mozilla
directory
without considering character case.
The third line calculates the sum of the directory listing.
Links format
regular expression (case must match): ftp+grep://<server+directory>/<regexp>regular expression (ignore case): ftp+igrep://<server+directory>/<regexp>
sum of the directory listing: ftp://<server+directory>
site content's sum: http://<address>
site content's sum: https://<address>
How to use
- Generating original sums with debug via
tee
:
$ ./genhashes.sh data/links | tee data/links_and_sums
result:
LINK: ftp+grep://ftp.icm.edu.pl/pub/mozilla/firefox/releases/3.0.11
RETURNED : 0
LINK: ftp+igrep://ftp.icm.edu.pl/pub/mozilla/FiReFoX
ftp+grep://ftp.icm.edu.pl/pub/mozilla/firefox/releases/3.0.11
d41d8cd98f00b204e9800998ecf8427e
RETURNED : 0
LINK: ftp://ftp.icm.edu.pl/pub/mozilla/thunderbird/releases/
ftp+igrep://ftp.icm.edu.pl/pub/mozilla/FiReFoX
38144139eb6ab85bb6e881ba8e4bbb9b
RETURNED : 0
LINK: http://wodny.org/
ftp://ftp.icm.edu.pl/pub/mozilla/thunderbird/releases/
87246f27c4264a1436bd75290e137060
RETURNED : 0
LINK: https://poczta.onet.pl/
http://wodny.org/
490c28b8e77c8b22bfde03277012bbe1
RETURNED : 0
https://poczta.onet.pl/
6b50a51b41b25ce851aa24ae336777c0
Links with sums are now indata/links_and_sums
, there is some additional information on the console. All the connections completed successfully (RETURNED : 0
) and the3.0.11
regexp didn't match anything inside thereleases
directory (MD5 sum d41d8cd98f00b204e9800998ecf8427e of an empty input -$ echo -n | md5sum
). - Observation:
You can just run it on the cosole:
$ ./monitor.sh data/links_and_sums
,
If mail notification is enabled it's a much better idea to use thescreen
tool:
$ screen ./monitor.sh data/links_and_sums
.
Final notice
To enable:
mail notification - inside the monitor.sh
file set the MAILNOTIFY
variable to 1.
notification encryption - inside the monitor.sh
file set the MAILENCRYPT
variable to 1.
mutt
is used as a tool to send mails. The report is sent as an attachment. Data used for generating mail
including From and To headers are stored in the data/message
file.
Before the first run, please edit the monitor.sh
file and set variables' values:
- MAILNOTIFY
- MAILENCRYPT
- GNUPGHOME (if
MAILENCRYPT == 1)
- KEYID (if
MAILENCRYPT == 1)
- KEYID (if
data/message
file (if MAILNOTIFY == 1).