$Id: README 75 2014-09-22 15:09:39Z abalama $ App::MBUtiny v1.09 and later This document written in Windows-1251 charset ============================================= ������� � ������� ----------------- App::MBUtiny - ������� ������� ��� ������ � ���������� ������� ����� ������, ��� ������ � ������ ������ �� ������� �����. App::MBUtiny ������ ��� ����������� �������� ���� ������ �������� - mbu � mbutiny. ����������� ----------- - ��������� ����������� ���-������ (�������) � ��������� ������/����� - ��������� ����������� ��������� ��� ������ - ������ ������� �������� � ������ ��� ������������ ���������� ����������� ���������� �� ������ - �������� ��������� ����� ������������ �� ��������� ������, ��� ��������� FTP/HTTP ���������� - ������� ��������� ����� �������� �������������� ���������������� ������ - ��������� ������� ���������� CPAN ��� � ������ ������ ����� make install - ����������� ����������� ��������� ���������� ���������� ����������� �� ��������� ����� ����������� ----------- ����� ������� ���������, ��� ���������� ��������� ������� ��������� �������, ������������� � ����� ������� ��� ����� "��������" App::MBUtiny: - gcc ��������� ������ - perl v5.10 ��� ���� (������������� �� ���� v5.12) - libwww (p5-libwww / perl-libwww) - libnet - zlib ���� �� ���������� ������������ ���������, �� ��� ������ ����������� ������� WEB ������� Apache 2.2 ��� ����. ������ ������ ���� �������� �� ���������� CGI (perl) ��������. ��������� --------- ��������� ����������� ����� ������. ������ - ������������������; ������ - ������. � ������������������ ������ ��� ��������� ���������� ��������� �������: # cpan install App::MBUtiny ��� (��� ActivePerl): # ppm install App-MBUtiny � ������ ������ ��� ����������� ��������� ��������� ����� ��������: - ������� ����������� � CPAN ��� ����������� ����� � ����� SourceForge: https://metacpan.org/pod/App::MBUtiny http://search.cpan.org/~abalama/ https://sourceforge.net/projects/app-mbutiny/ - ��������������� ���������� �����, � ������� � ����������� ����� � ������� ������� - �������� � ����������� ����� ��������� ��������������� ��������� �������: perl Makefile.PL make make test make install � �������� ��������� ������� ��������� ���������� ����������� ������ (������), ��������� ������� �� ��� ����� � ������� ����� ��� ����������� �� ����� �������. ������������� ------------- ������� ������������� ���������� ������ ���������� mbutiny (����� ������ mbutiny). ��� ���������� �������� ����������� ��������� �������� � ������������� ������ � �������������� ������������ ������ App::MBUtiny. � �������� ������������� ����� ������� ����������� ���������� � ���������������� �����. ��� ������������� ������� ��������� ��������� �������: # mbutiny config ���� �� ������� ������������� ���������������� ����� � ���� �������, �� ������� ��������� ������������� � ������ -c DIRECTORY/mbutiny.conf: # mbutiny -c /my/config/files/mbutiny.conf config ������ ���������� "���������" ���������������� ����� � �������� /my/config/files ������������ ------------ ������� �������� ������� ������� ������������. ������ ���������� ����������� ���������� ����������� ���������� ������ ����� ����������. � �������� ������������� ��� ��� ������� �� ������ ������� ����, �� �������� ������������� ���������������� �����. ���� ���������������� ������� �������� �� ��������� �����: extra/arc.conf extra/collector.conf extra/sendmail.conf hosts/host-foo.conf.sample collector.cgi.sample mbutiny.conf ������� ���������������� ������ �������� ���� mbutiny.conf. �� �������� ���������� ����������� � ���������� ����� �������������� ����� ����� ��������� � ��������������. ���� collector.cgi.sample �������� � ���� ������ ������� ���������� (� ��� ����� ������� � ������� ���������). ��� ��������� ��� ����� ������ ���������� ������������ ���������������� ���� extra/collector.conf. ���� extra/arc.conf �������� ����������� ��� ������� ������� �����������; extra/sendmail.conf �������� ����������� ��� �������� ����������� ����� �� ���������. ���� hosts/host-foo.conf.sample �������� ����� ������� �������� ����, ��� �������� ���������� ����. ���� - ��� �������� ������, ����������� ����� ������ ���������� ����������� ����������� ��������. ���� ����� ������� �� ��������� ���������� � ������ (������). ��������� ����� ����� ���� ������� � ���������� ����� ��� ����, �� ���� ����� ������� ����. mbutiny.conf ~~~~~~~~~~~~ ��� ��� ����������� ����, ���� mbutiny.conf �������� ���������� �����������. LogEnable on LogEnable off ��������� ��������� �������� ��� ��������� ����������� ��������� mbutiny. �� ��������� - off LogLevel warning ��������� ���������� ������� �������. ���������� ��������� ����� ������� �������: debug, info, notice, warning, error, crit, alert, emerg, fatal, except. �� ��������� ������������ �������� debug ��� ���������� ���������� mbutiny ���������� � ���� mbutiny.log ���������� �������� ���������� ������, ��������: /var/log/mbutiny.log � ������ ������� ��������� mbutiny � ���������� -l ������ ����� mbutiny.log ����� ������������ ���� ���������� ���� - mbutiny_debug.log. ������ ���� ����� ��� ��������� ������� ������ ��������� ����������� App::MBUtiny. BUday 3 BUday ���������� ���������� ���������� �������. ��� ���������� �������� ��������� ���������� ������� BUweek 3 BUweek ���������� ���������� ������������ �������. ��� ���������� �������� ��������� ������������ �������. ������������� �������� ��������� �� ���������� ������, ������� ���� ������� � �����������. BUmonth 3 BUmonth ���������� ���������� ����������� �������. ��� ���������� �������� ��������� ����������� �������. ������������ �������� ��������� �� ���������� ������, ������� ���� ������� ������� ����� ������� ������. SendReport yes SendReport no ��������� SendReport ���������, ��� ����� ���������� �������� ���������� ����������� � ������������ ���������� ��������� ��������� ����� �� ����� ����������� �����, ������������ � ���������������� ����� extra/sendmail.conf. �� ��������� - no SendErrorReport yes SendErrorReport no ������ ��������� ���������� ���������� ������ � ������ ������ � ������ ������������� ����� ���� ������, ��������� � ������������ ������� �������� ���������� ����������� ��� ������������. �� ��������� - no extra/sendmail.conf ~~~~~~~~~~~~~~~~~~~ ���� �������� ���� ����������� <SendMail>...</SendMail> � ������������ ��� �������� ������ �� ����������� �����. �������� �������� ������������� ����� ��������� SMTP, �� ����������� ��������� �����: TestMail test@example.com ��������� ���������� ���������� ����� �� ����� test@example.com � ������ ������� ���������� � ������ -t ErrorMail error@example.com ��������� ����������� ���������� ����� �� ������� �� ����� error@example.com � ������ ������������� ��������� SendErrorReport yes Sendmail /usr/sbin/sendmail Flags -t ��������� Sendmail ���������� �������������� SMTP ����������, ����������� ������. ������ ���������� �������� � ������ -t, ������������� ����������� Flags SMTP 192.168.0.1 SMTPuser user SMTPpass password ������ ��������� ���������� ��������� ���������� � SMTP �������� ��� �������� ���������. �������� SMTPuser � SMTPpass �������������. <Attach>...</Attach> ���� (� �� ����� ���� ������� ���������) ���������� ����, ������� ������� �������� � ����� extra/arc.conf ~~~~~~~~~~~~~~ ������ ������ � ��������. ��������� �������� ��. � ������ CTK. � ���� ������ ������������ �������� ��������� ������ � ��������, ������ �������� ������ ��������� �������������� ������ ���������� ��������� �����. ����� � ����� ����� ���� ������������ ���������: ��� ������ ���������� ������ �� �����: FILE -- ������ ��� ����� � ����� FILENAME -- ������ ��� ������ ������� DIRSRC -- ������� ������ ���� ������ DIRIN -- = DIRSRC DIRDST -- ������� ��� ����������� ����������� ������� DIROUT -- = DIRDST LIST -- ������ ������ � ������, ����� ������ ��� ������ ������ ������ ������������ ��������� ����� ������: FILE -- ������ ��� ��������� ����� ������ � ����� DIRSRC -- ������� ������ ���� ������ � ������������ ��� ������ DIRIN -- = DIRSRC LIST -- ������ ������ ��� ������, ����� ������ ��� ������� ����� ����������� ���� ������ � ����������� tar <Arc tgz> # ������ ����������� ������. ���, ��� �������, ��� ���������� ������ ������ type tar # ��� ������, ��� ������ ����� ext tgz # ���������� ������ ������ create tar -zcpf [FILE] [LIST] # ������� ��� �������� ������ extract tar -zxpf [FILE] [DIRDST] # ������� ��� ���������� ������ �� ������ list tar -ztf [FILE] # ������� ��� ��������� ������ ������ � ������ nocompress tar -cpf [FILE] # ������� ��� �������� ������ ��� ������ </Arc> extra/collector.conf ~~~~~~~~~~~~~~~~~~~~ ���� �������� ���� ����������� ��� ������� ���������� <Collector>...</Collector> ������ ���������� �������� ��������������� � ������� ���������. ���� <Collector>...</Collector> �������� ����������� ��� ���������� � �� (���� <DBI>...</DBI>) � �������������� ��������� DataDir. DataDir "/var/data/mbutiny" ��������� �������� ���� ��� �������� ������ ��������� ����� (HTTP ���������). �� ��������� - �������� ������ ������� ���������� (DOCUMENT_ROOT) hosts/host-*.conf ~~~~~~~~~~~~~~~~~ ����� � ������ host-*.conf �������� ����������� ��� ������. ������ ���� host-*.conf ������ ������������ ������ <Host name>...</Host>. ��� name - ���������� ��� �����. ��� ����� ������� �������� ����� �������, ����� ��� ������������ �� ��� ��� � ������ ��������, ������� ����������� ���������� �����������. ������ ����� ������������ ������������ ������������ ������ ����������, ���� �� ����������� ��� ��� ������. Enable yes Enable no ��������� ��� ���������� �����. �������� ������ �� ��������� �����. ���� ������� ����������, �� ��������� ����� ����������, ����� ���� ������������. �� ��������� ���� ������������. �� ������� ��������, ��� ������� � ������ <Host name>...</Host> ��������� Enable �����������! �����, �������� ������ � ��������� ������ ������. SendReport no SendErrorReport yes ��������� ��������� ��������� ������� � ������ ������� �����. ������ ��� �������� ������� �� ���������� ������ <SendMail>...</SendMail> ���, ���� �� ������� ������ ���������� ������, �� ����� extra/sendmail.conf, ���������� ����. ArcName zip ��� ������ <Arc>...</Arc> ����� extra/arc.conf. �� ��������� ���������� ������ � �������: tar, tgz, gz, zip, bz2, rar. �� ��������� ArcName ��������� �������� tar - ��������� Tape ARchive (TAR) ArcMask [HOST]-[YEAR]-[MONTH]-[DAY].[EXT] ����� ������ �������. ArcMask ��������� �� ��, �� ������ ������� (�����) ������� ����� ��������������� ������. ����� ������ ����� ����� ������� ���, �� �� ��������� ������������ ����� ����: [HOST]-[YEAR]-[MONTH]-[DAY].[EXT] ����� ����� ����� ���� ������������ ���������: DEFAULT -- �������� ��������������� ������� [HOST]-[YEAR]-[MONTH]-[DAY].[EXT] HOST -- ��� ������ ����� YEAR -- ��� �������� ������ MONTH -- ����� �������� ������ DAY -- ���� �������� ������ EXT -- ���������� ����� ������ TYPE -- ��� ������ ������������ �������� �������� ����� ����� �������, ����� ��� ��������� ��������� ���� �������� ������ ���� "���������" ������������ ���, ������������ �������. ��� �������� �������� ��������� �������� ��� �������������� ����������� ��������-��������� �������. �� ��������� � �������� ������������ ����� ����� ������������ ���� ����. ����� ��� � �������� �������� ����������� ��������� �����: [HOST].[YEAR][MONTH][DAY].[EXT] �� �������� �� ��� �� ����������� ������������ ����� �� ���������, ����: ArcMask [DEFAULT] ��������� ��������� �������� ������� BUday, BUweek � BUmonth ���� ������� � ����� ���������� ����������� mbutiny.conf. �� ��������� ������������ ��������� ����������������� ��������: BUday 3 BUweek 3 BUmonth 3 � ������, ���� ������ ��������� ����� �������, �� ��������� mbutiny ���������� �������� �� ����������� ���������� �����������. SHA1sum yes MD5sum yes �� ���������� �������� ������ �������� ���������� ������� ����������� ���� SHA1 � MD5. ������ ���� ���������� ������������ ��� �������� �������� ����������� ������� � ��������������, � ����� ��� ������ � �����������. Trigger mkdir /tmp/test Trigger echo foo > /tmp/test/foo.txt ��������. ��� �������, ������������� �� ���� ��� ����� ����������� �������� ������ �������������� ��������� (������ � �����). �������� ����������� ���� �� ������, �� ������� �� ���������� �������� �������������. ��� ���������� ���������� ������� ������� ������������ ������� ������� ��� �������� �� � ��������� ������� �������. Trigger mysqldump -f -h mysql.host.com -u user --port=3306 --password=password \ --add-drop-table --default-character-set=utf8 \ --databases databasename > /tmp/test/databasename.sql ������ ������ ������������ �� ��� ����� �������� ������ ��� ���������� ����������� � ���� ����� ��������� ���� ������. ��� � ���� ������ ���������� ����������� ��� ������. Object /tmp/test/foo.txt Object /tmp/test/databasename.sql ��� Object /tmp/test ��������� Object ���������, ����� ����� � ����� ���������� ������������ ��� �������� ��������� �����. <Exclude "exclude_sample"> # ������ ������� ���� �������� �����. ��������� ����� ���� ������ ���� Object /usr/local/etc # �����������. ���� ���������� ������� ��� ����������� ������. ��������� �� ����������� Target /tmp/test_exclude_sample # ������������� ���� ������ � ����� ������� �� ������� ������������ � ������� Target Exclude bar.txt Exclude baz.txt </Exclude> ������ ������������� ����������� ��������, �� ����� ���� ������ ���������. ������ ��������� ���������� ����� � ����� �������� ���������� � ��������� Object � ������� ������� ������������ � ������ ��������� Target. ����������� ���������� ���� ��������� ��������� �������� � ������� ������� �������� �������, ��������� �� ���������� ���������� Exclude. ������ ������ �������� �������� ������� ��������������� ���������� ����� �� �����. ������� ��������, ��� �������� ��������� Target ����� ������������� ��������� � ������ �������� ��� �� ������������ ��������. ��� ������� �������� (��. �������� ����) ����� ��������� ���� ������ � ������� ��������� Object, ��� ��� �������������� � ���������� �������. ������ � �������, ������� ����������������: ������ ����� ��������� ������� /tmp/test, ����� � ������� /tmp/test ������� ���� foo.txt � ���������� foo. ��� ����, ����� ������� ��������� ����� ����� /tmp/test/foo.txt ���������� ������� � �������� ������� ���� ��� ���� /tmp/test/foo.txt ���� ��� ����� /tmp/test. ����� ������� ���������� ������ ��������� � ���������. <Collector> URI https://user:password@collector.example.com/collector.cgi #User user # Optional. See URI #Password password # Optional. See URI #TimeOut 180 </Collector> ������ ������ ���������� ���������. ����� ������ ����� ���� ��������� � ������ ������� �����. ����� URI - ����� (URI) �� ��������� (����������). ����� � ������ HTTP ����������� ����������� ���� � ���� URI, ���� ��������, ���� ����� ������� ������������. TimeOut - �������. �� ��������� 180 ������. <Local> FixUP off Localdir C:\\Temp\\mbutimy-local1 Localdir C:\\Temp\\mbutimy-local2 #Comment Local said blah-blah-blah for collector # Optional for collector </Local> ������ <Local>...</Local> ����� ���� ������ ���� � ������ ������� �����. ������ ���������� ��������� ���������� ���������, ��� ��������� �� �������� ��������, ���� ��� ����� ������������ �� �������� ������� ������������ ������� ����������� ���������� (�������, ����������, ���������, �������������� � �.�.). ������ <Local>...</Local> �������� ��������� ���������: Localdir - ����� ���������� ���������. ������ � ��� ����� �������� �������������� ������ (��������� �����). ������ �������� Localdir ����� ���� ���������, ����� ��������� ����������� ������ � ��������� ��������� ���������. FixUP - ��������� ��������� �������� ���������� ������ �� ����������. ����� ���� �������� on ��� off Comment - ����������� ��� ����������. ������� ��� ����������� � �������. ������������ ����������� �� ��������� ������ ��������� ������. <FTP> FixUP on FTPhost ftp.example.com FTPdir mbutiny/foo FTPuser user FTPpassword password Set Passive 1 Comment FTP said blah-blah-blah for collector # Optional for collector </FTP> ������ <FTP>...</FTP> ���������� ��������� ���������� FTP-���������. <FTP> ������ ����� ���� ��������� � ������ ������� �����. � ���� ������ ���������� ������ ��� ������ �� ��������� FTP-��������. ��������� ������ - FTPhost, FTPdir, FTPuser � FTPpassword - ���������� ���������������� ������� � FTP-���������, ����� ��� ��������� FixUP � Comment ���������� �� �������� ������ <Local>...</Local>. ��������� Set ������������� �������� ���������� FTP <HTTP> FixUP on URI https://user:password@collector.example.com/collector.cgi #User user # Optional. See URI #Password password # Optional. See URI Comment HTTP said blah-blah-blah for collector # Optional for collector #TimeOut 180 </HTTP> ������ <HTTP>...</HTTP> ���������� ��������� ���������� HTTP-���������. ������ <HTTP> ����� ���� ���������. � ���� ������ ���������� ������ ��� ������ HTTP-����������. �� ������� ������ � �����������, ������ <HTTP>...</HTTP> ���������� ��������� ����� ��� "�������" ������, ����� ��� ��������� ������������ ��������� �������. ���� ��� ������� � ��������� � ��������� HTTP ��������� �� ����� ���������� �������. URI - ����� �� ��������� (��� � ����������). ����� � ������ HTTP ����������� ����������� ���� � URI ���� ��������, ���� ��� ������� ������������. FixUP - ��������� ��������� �������� ���������� ������ �� ����������. ����� ���������� FTP � Local ������� ��������� �������� on ��� off. ������� ���������, ��� ��������� ��� ���������� ������� �������� ��������� ������� ������ ����������, �.�. ����� ����� �������� �� ����� ���������� � ������ � ������� �� ������. TimeOut - �������. �� ��������� 180 ������. ������� �������� ���� ������ ������ ����������� �������, � ���� �� �������� ������ �� ��������� �������� ���������. ������ ������ ------------- ����� �������� ������ �� ���������, ������������� � ��������� - ��������� � ������� ��������� mbutiny. ��� ��������� ���������� ������ ����� ��������������� ��������: # mbutiny -h ����� ��������� ������� mbutiny �����: # mbutiny [OPTIONS] [COMMANDS [ARGS]] ���������� ��� �������� ����� �������: -D DATADIR ������ ����� (����) ���������� ��������� �����, � ������� ����� ���������� ��������� �����, ����������� ��� ������������ ��������� �����-�����, � ����� ��� ��������������� ��������� �����. �� ��������� ������������ ��������� ������� ��������� ������. -c CONFFILE --config=CONFFILE ���� ���������� ��������� ������������ � �������� ����������������� ����� CONFFILE. �� ��������� ������������ ��������� ���� � ����� mbutiny.conf. -v ���� ��������� ������ �� ������ ��������� ������ ��������� mbutiny. ��� ����� ��������� ���������� ����� ��������������� �������������� ������ -d. ������ ����� �������� ��� ������: test [HOSTs] ������� ��������� ��������� ������������ ��������� ������. ���� �������� ������ �������, �� ��������� ������������ ���� ������, ����������� � ��������������� ���������������� ������. [backup [HOSTs]] ������� ��������� ��������� ��������� ����������� ��������� ������. ���� �������� ������ �������, �� ��������� ������������ ���� ������, ����������� � ��������������� ���������������� ������. ������� ��������, ��� ������� backup �������� �������� �� ��������� ��� ��������� mbutiny. restore [HOSTs] [DATE] ������� ��������� ���������� ����������� � ���������������� ���������� ��������� ��������� ����� ��� ��������� ������ (��� ����, ���� ����� �� �������). �������� DATE ������ ����, � ������� YYYY.MM.DD ��� DD.MM.YYYY ��� ��������������. ���� ����� ��������� ����� ��� ��������� ���� ���, �� ������� �������� ��������� ����� � ���� ����, �� �� ����� ���������. �� ��������� ������ ��������� ������� �� ����� ����, �� �������� ����� ����� �������� ��������������� ������. ������ ������� �� ������������� ��������� � �������������� ������. checkup [HOSTs] [DATE] � ������� ������ ������� ����� �������� ������ ����������� �� ��������� ����� ��������� �����. �������� DATE ������ ����, � ������� YYYY.MM.DD ��� DD.MM.YYYY ��� ���������� ������� ����������. ���� ���� �� ������, �� �� ��������� ������������ ������� ����. ���������� ������������� � 0 ����� 0 ����� 0 ������ ��������� ����� �� ������� �����. ������ ������ ������ ��������� ���������� ��� ������������ ������, ������� ��� ������ ��������� ��� ����������� ������ ������������ �����������, � ����� ��� ��������������� ������� �� ������� ������ ��������� ����� ������ �� ������ �����������. �� ��������� ������������ ���� ����� ������, ��������� ���������. ������������ ������������� -------------------------- ����� ������� ������ ��������� ����� ����� ���������� � ��������� ��������� ��� ���������� � �������������� ������. ��� ����� ���������� ��������� �������� � ���� �� ������� ����������� - cron. ��� ����� ������� ����� ��������� ������ �� ���������� ���������� ����������� ���� ������: 0 2 * * * /usr/bin/mbutiny >/dev/null 2>>/var/log/mbutiny-error.log ������ �������, ��� ���������� ��������� ��������� ����������� ���� ������ ������ � 2 ���� ���� ��������� ������ ������������� ��, ��� ����� "��������" ����� �� �������: 0 2 * * * /usr/bin/mbutiny backup foo >/dev/null 2>>/var/log/mbutiny-error.log 0 3 * * * /usr/bin/mbutiny backup bar >/dev/null 2>>/var/log/mbutiny-error.log 0 4 * * * /usr/bin/mbutiny backup baz >/dev/null 2>>/var/log/mbutiny-error.log ������ ������ ����� ������� � ������ ������� �������� ������� ��������� ��������. ��� ���������� ���������� �� �������, ����� ��������� � ����� /var/log/mbutiny-error.log ��������� --------- ��������� ��� ����� App::MBUtiny. ����������� �������� CGI ��������, ������ �������� �������� � ����� collector.cgi.sample: #!/usr/bin/perl -w use strict; use WWW::MLite; my $mlite = new WWW::MLite( prefix => 'collector', name => 'Collector', module => 'App::MBUtiny::Collector', config_file => '/path/to/mbutiny/extra/collector.conf', register => ['App::MBUtiny::Collector::Root'], ); $mlite->show; ������ ������ ���������� � ����� ������ ���������� WWW::MLite, �������������� ����� ����� �������� � ������� App::MBUtiny. �������������� ���������� �� ��������� HTTP. ������ �������� CGI �������� ���������� ���������� � �������� App::MonM. App::MonM �����������, ���� ���� ������������� ������ App::MBUtiny, �� �� �������� ��������� ������������� ���� �� ������ ����������. ��������� ������������� API. API ��������������� ����� ������� ������������� � ������� XML. ��������� ���������� ���������������� ���������� �� ���������� �����, �������� extra/collector.conf ����� �������������� ����� ����������������� ����� ������������� ������ ��������������� � ���� �� ���� � CGI ������� collector.cgi ������ �������������� ������������� � ������������ �����, ��������, ������� ��������� ����, ���� ����� ������������ �� ������������ �������� Linux: /etc/mbutiny/extra/collector.conf ��������� ���������� ~~~~~~~~~~~~~~~~~~~~ ��������� ��������������� � ���� ������: 1. ��������� � ������������� App::MBUtiny �� ��������, �������������� � ��������������� �������� ������� ���������. ��. ���� 2. �������� "���� ������" � ������� mbutiny 3. ������ ����������������� ����� collector.conf 4. �������� �������� collector.cgi � ��������� ���� ������������ ����������������� ����� collector.conf 5. ��������� ���� ������� � ���������� ���� 2 ��������������� ����� ���������� ����������� ��, ��������, MySQL. ����� ������ ���� ���� ���������� ������� ��������������� "������" �� ��� ������������ ��� ���������. ������ ���������: �� ������ ������������ ��������� UTF8! ����� �������� �� ��������� ������� ������ �����we ��� ������� mbutiny. ����� ������������ � ������ ���, �� ������� ��������� ��� � ���������������� ����� collector.conf � ��������� Table ������ DBI. ��� �������� �������� ����������� DDL ����������� � ��������� �����-������� collector.conf, ������� ��� ������������ ��� ������������� App::MBUtiny. ����� ���������� ��������� �������� �� ���� 3 - ������ ��������� � ���������������� ����, ��� ����������� ���������� ��� ���������� ������ ���������� � ��������� ���������� � ��������� ����� ��. ���� 4 ��������� �� ������������� �������� �������� collector.cgi. ��� ����� ��������� ������� ��� �������������� ������� Apache � �������������� ����������� ������. � ��������� ����� �� ����� ��������� ���� ���������� � ����������� ����� ������� � ����. ����� ������� ����� ���������� ��������� ���� ������������ .htaccess, ������� ����� ��������� ��������� ����������, ������������ �������� ����������� HTTP: <Files collector.cgi> AuthName "App::MBUtiny file authorization for access to collector" AuthType Basic AuthGroupFile /var/www/mbutiny.example.com/.htgroups AuthUserFile /var/www/mbutiny.example.com/.htpasswd Require valid-user #Require username Require group collector </Files> ����� .htgroups � .htpasswd ��������� ���������� ����� � �������������, ��������������. ����� ��������� ���������� �������������� ������� ��������� ����������������� ���������� � ������ ������. ��� ����� � ������ �������� ����� ������ ���� �� ����� CGI �������� ��������� �������� check. ��������: https://mbutiny.example.com/collector.cgi?action=check ��� ���� � ���� �������� ������ ������������ XML �������� � ����� status �� ��������� 1: <status>1</status> ����� ��������� ���������� � ������� ��. � ������� API. ���� ������ �� �������� �� ��� �������� ��� ��������� � ��������� ���������� ��������� �������. ������ ���������� ����������� ������� ���������� ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ���� ������������ ������ ����, ��� � ������� mbutiny ��������� ��������� ����������� ������ ���������� �� ��������� FTP ��������� � �� ��������� ���������. ��� ������� �������������� ������������ ������� CentOS. ��� ������������ ������, ������ � ������ �����������. ���� ����� ��� host-mbutiny.example.com.conf � ���������� � �������� /etc/mbutiny/hosts <Host mbutiny.example.com> Enable yes SendReport no SendErrorReport yes ArcName tgz SHA1sum yes MD5sum yes # Triggers Trigger mysqldump -f -h localhost -u user --port=3306 --password=password \ --add-drop-table --default-character-set=utf8 \ --databases mbutiny > /home/mbutiny/mbutiny.sql # Objects Object /etc Object /home/mbutiny/mbutiny.sql # Collector definitions (Can be defined by several sections) <Collector> URI http://user:password@mbutiny.example.com/collector.cgi Comment "(LOCAL) Configuration and databases on mbutiny.example.com" #TimeOut 180 </Collector> # Local storage <Local> Localdir /home/mbutiny/local </Local> # FTP storage (Can be defined by several sections) <FTP> FixUP on FTPhost 192.168.92.88 FTPdir mbutiny/mbutiny.example.com FTPuser bu FTPpassword asdfghjkl Comment "(FTP) Configuration and databases on mbutiny.example.com" </FTP> # HTTP storage (Can be defined by several sections) <HTTP> FixUP on URI http://user:password@mbutiny.example.com/collector.cgi Comment "(HTTP) Configuration and databases on mbutiny.example.com" TimeOut 600 </HTTP> </Host> API --- ��� ��� ����������� � ������� ��������� �������������� ����� ������� (���� �������� ��������� ���������� mbutiny) � �������� ���������� (����� ���������) ����������� �� ��������� HTTP ��������� ������ ������ ������ - XML. ������ ���������� �������� �� POST ������� �������� ��������� �� ������� XML, � �������� �������� XML ����������. �� ���� ���� ����������, ����� ����� ����������� ������������ ������ � ������� � MIME ����� application/octet-stream. ���� ����������� �������� ���������� download, ������������ ��������� ���������� �������� ������ ����� ��� ������ �� ���� �� ������� ������. ����� �������� �� ���� �������������� �������� ����� ���������� � ������� download. ��� �������������� API ������ ���������� ������� POST (� ������ ������� GET) ������, ��� ������ ���������� ������ ���� ������ (��� �����������), � ������ - XML ���� �������. ����� ��� ������� �������� �������� ��������� �������: http://SITE:PORT/collector.cgi?action=���_�����������&request=XML_�������� https://SITE:PORT/collector.cgi?action=���_�����������&request=XML_�������� ���� �� ������ �� ���� ��������, �� �������������� ����� ����������� � ������ default. ����� ����� ���������� ������ ���������� ��������. ������ �������� ��������� XML, ������������� � ��������� request ����� ���: <?xml version="1.0" encoding="utf-8"?> <request> <object> ���_����������� </object> <data> ����_������ </data> </request> ����� ��� <object>...</object> �������� ��� �����������, ����������� ���������� action. ����� ��� ��� ������� ��������������� � �� ��������� ������ ������� ������. ��� <data>...</data> �������� ����� ������, ���������� ����������� �� ������. ������ ��������� ���������, ������� ���������� ������ ����������, ����� ���: <?xml version="1.0" encoding="utf-8"?> <response> <data> ����_������ </data> <debug_time>0.531</debug_time> <error> �����_������ </error> <object> ���_����������� </object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status> ������_�������� </status> </response> ��� ����� �� ��������, ���-�������� ��� ������� ����� ��� request, ����� ��� ��� ��� ������ ���������� response. ��� <object>...</object> ������� � ���, �� ����� ���������� ��� ��� �����, ��� ����� ��������������� ������������ ��� ��� �����. ��� <data>...</data> �������� ����� ������, ���������� ������ �� �����������. ��� <status>...</status> ����� ��������� ��� ��������: 0 - � ������ ��������� ������; 1 - � ������ ���� �������� ������ ������� � ���������� �������� ����������� �������� ��� ������. ���� �������� �����-���� ������, �� �� ����� ��������� � ���� <error>...</error>. �������������� ���� <debug_time>...</debug_time>, <query_string>...</query_string>, <remote_addr>...</remote_addr> �������� ���������� ����������� ��������. debug_time - ����� � ��������, ������� ������������ ��� ���������� ������ �����������. query_string - ��������� ��������� �� ����, ���� ��� ���� �������. remote_addr - IP ����� ������, ���������� ����������. default ~~~~~~~ ���������� default �������� �� ����������� ��� ���������������� �������. ������ ������ ����������� default: <?xml version="1.0" encoding="utf-8"?> <response> <data></data> <debug_time>0.056</debug_time> <error>������� ������ ����������. ������ ��������� ������������ �������� ����� �������� check</error> <object>default</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>0</status> </response> ��� ����� �� �������, ������ ��������� ������ � ������� � ������ � �������� 0. ��� ���� ������� ����� �������� �� ����. check ~~~~~ ��������� ��������� ���������� ����������. ���������� ���������� ��������� ���������� ���������� � ������ ������ ��������. ���� ���������� ������� �������� �� ���������� �����-���� �������� � �����������. ���� �������� ���������� � ���������� ���������� ������ �����������: <?xml version="1.0" encoding="utf-8"?> <request> <object>check</object> </request> <?xml version="1.0" encoding="utf-8"?> <response> <data></data> <debug_time>0.531</debug_time> <error>ERR: 2005; ERRSTR: Unknown MySQL server host 'mysql.example.com' (11001); STATE: HY000</error> <object>check</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>0</status> </response> <?xml version="1.0" encoding="utf-8"?> <request> <object>check</object> </request> <?xml version="1.0" encoding="utf-8"?> <response> <data> <action>check</action> <action>upload</action> <action>fixup</action> <action>status</action> <action>list</action> <action>info</action> <action>download</action> <action>delete</action> <dir>data</dir> <message>Ok</message> </data> <debug_time>0.125</debug_time> <error></error> <object>check</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> ��� �������� ���������� ����������� �������� ������ � ���� <data>...</data> ������ �������������� ������������. upload ~~~~~~ ���������� ������������ ����� ��������� ��� �������� ������ ��������� ����� - ��������� ������. ��� ������������ ���������� ����������� ������ � ���� ����������� ������ (MIME) multipart/form-data. ��� ��������� ������ �� ���������� multipart/form-data ��� �������� ������ ����������. <?xml version="1.0" encoding="utf-8"?> <request> <data> <comment>blah-blah-blah</comment> <file>test1-2014-09-05.zip</file> <host>test1</host> <md5>229f51f8257e5200f5942fa210b2b4c5</md5> <sha1>ecf0cc7fb25a57025a20ba42161cd215d585f3af</sha1> </data> <object>upload</object> </request> ��� <comment>...</comment> �������� ����������� ��� �������� �����������. <file>...</file> �������� ��� ����� ������������ �������. <host>...</host> �������� ��� �����, ������������ ��������. <md5>...</md5> � <sha1>...<.sha1> �������� ����������� ����� ������������� �����. ��� ��� ���� �� �������� ��������������, ��� � ��� <comment>...</comment>. ���� ������ ������� ���������� � POST ��������� � ������ data, �������������� �������� �������� ����������� multipart/form-data. <?xml version="1.0" encoding="utf-8"?> <response> <data> <id>422</id> <message>Uploading sucess</message> <path>data\test1\test1-2014-09-05.zip</path> </data> <debug_time>0.142</debug_time> <error></error> <object>upload</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> ����� �������� ����� ��������� ����� ������������ ������ ��������, ���� ������ ����� �� ������� ���������� � #ID ���������� ������ ������ � ��. ������ ����� ������������ ��������� ��� ������ � ���� <message>...</message>. fixup ~~~~~ ����� ���������� � � ������� ������������� ����������� ��������� ���������� �������� ������ ��������� ����� ��������� ����������, ������� �������� ���������� fixup, ��������� ��������� � ����������� ���� ���������. ���� ����������� � ���������� HTTP �������� ���� � ��� �� ������, �� ���������� ��� <id>...</id>, ���������� ID ������ ��� ������������ ����� (��. ���������� upload). ��� <status>...</status> ������ ��������� �������� �������: 1 - �������� ������ �������; 0 - �������� ������ � ��������. ��� <type>1</type> ������ ������������ �� �������� 1, ��� ���������� ��������� �� ��������� ����� ������ � �� � ������������ ��� ���������, ��������� ��� ��������. ������ ����� ��������� ����������� � ��������� � ��������������� �����. <?xml version="1.0" encoding="utf-8"?> <request> <data> <id>422</id> <comment>blah-blah-blah</comment> <message>Uploading sucess: test1-2014-09-05.zip ... </message> <status>1</status> <type>1</type> </data> <object>fixup</object> </request> <?xml version="1.0" encoding="utf-8"?> <response> <data> <id>422</id> <message>Fixing sucess. The data successfully inserted to table of database</message> </data> <debug_time>0.125</debug_time> <error></error> <object>fixup</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> ����� ������� ����������� ������ �������� �������, ���� = 0. <?xml version="1.0" encoding="utf-8"?> <request> <data> <comment>local said blah-blah-blah</comment> <file>test1-2014-09-05.zip</file> <host>test1</host> <md5>229f51f8257e5200f5942fa210b2b4c5</md5> <message>Files successfully stored to LOCAL directoy ... </message> <sha1>ecf0cc7fb25a57025a20ba42161cd215d585f3af</sha1> <size>131616</size> <status>1</status> <type>0</type> </data> <object>fixup</object> </request> ����� ��� <size>...</size> �������� �������� ������� ����� ��������� �����, ��������� ���� ���������� ����������� upload � fixup ��� ������ �������������� ����. list ~~~~ ���������� ��������� �������� ������ ����������� ������ ��������� ����� �� HTTP ��������� �� ����� �����. <?xml version="1.0" encoding="utf-8"?> <request> <data> <host>test1</host> </data> <object>list</object> </request> <?xml version="1.0" encoding="utf-8"?> <response> <data> <list>test1-2014-08-27.zip</list> <list>test1-2014-08-28.zip</list> <list>test1-2014-08-29.zip</list> <list>test1-2014-09-01.zip</list> <list>test1-2014-09-03.zip</list> <list>test1-2014-09-05.zip</list> <message>Spisok failov dlia khosta uspieshno poluchien</message> </data> <debug_time>0.119</debug_time> <error></error> <object>list</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> � �������� �������� ���� ��������� <host>...</host> ���������� ��� ����� ��� �������� ���������� �������� ������ ������. �� ������, � ����� <list>...</list>, ����� ������� ����� ������ ��������� �����. delete ~~~~~~ ������ ���������� ������� ������� ����� � ��������� HTTP � ����������� ������� ��������. <?xml version="1.0" encoding="utf-8"?> <request> <data> <file>test1-2014-08-27.zip</file> <host>test1</host> </data> <object>delete</object> </request> <?xml version="1.0" encoding="utf-8"?> <response> <data> <id>35</id> <message>Fail uspieshno udalien</message> </data> <debug_time>0.149</debug_time> <error></error> <object>delete</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> �� ���� ���������� ��� ����� � ��� ����� � ��������������� ����� <file>...</file> � <host>...</host> info ~~~~ ��������� ��������� ���������� � �����. <?xml version="1.0" encoding="utf-8"?> <request> <data> <file>test1-2014-09-05.zip</file> <host>test1</host> </data> <object>info</object> </request> �� ���� ���������� ��� ����� � ��� ����� � ��������������� ����� <file>...</file> � <host>...</host> <?xml version="1.0" encoding="utf-8"?> <response> <data> <id>428</id> <agent_host>mnsdesktop</agent_host> <agent_ip>127.0.0.1</agent_ip> <agent_name>test1</agent_name> <comment>blah-blah-blah</comment> <date_finish></date_finish> <date_start>2014-09-05 15:15:14</date_start> <datestamp>2014-09-05 15:15:13</datestamp> <file_md5>229f51f8257e5200f5942fa210b2b4c5</file_md5> <file_name>test1-2014-09-05.zip</file_name> <file_sha1>ecf0cc7fb25a57025a20ba42161cd215d585f3af</file_sha1> <file_size>131616</file_size> <message>Uploading sucess ... </message> <server_host>mbutiny.localhost</server_host> <server_ip>127.0.0.1</server_ip> <status>1</status> <type>1</type> </data> <debug_time>0.115</debug_time> <error></error> <object>info</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> � �������� ������������ ������ ��������� ���� ���� ������, ��������� � ������ ��������� ����������. �� ����� ����� ���� ���������. download ~~~~~~~~ ���������� ��������� ������� ���� � ����������. ������� ����� ���������� ������ XML ������, ��� ����������� ����, ��� ������������ ����������, ������������ ������ � MIME ����� �������� �� text/xml �����, ���������� �� ���������� ��������, ������� ��� ������ ���������� ��������� � ������ "AS IS". <?xml version="1.0" encoding="utf-8"?> <request> <data> <file>test1-2014-09-05.zip</file> <host>test1</host> </data> <object>download</object> </request> �� ���� ���������� ��� ����� � ��� ����� � ��������������� ����� <file>...</file> � <host>...</host> report ~~~~~~ ��������� ��������� (�����) ����������� ��� ������������� ��������� ����������� ��� ���� ������. ���� ���������� ������������ �������������� ������� ����������, ���������� ��� ��������� App::MonM. �� ��������� �������� ��������� (����) ����������� ������� �� ��������� �����, ��� �����, ��������� � ��������� ���������. ��� �������� ��������� ����������� ����� ���������� ��� �����. ���� �� ��� ����� �������, �� ���������� ������ ��������� ��������� ����� �� ���� ������ ����������. <?xml version="1.0" encoding="utf-8"?> <request> <data> <type>1</type> <host>test1</host> <date_start>01.09.2014</date_start> <date_finish>09.09.2014</date_finish> </data> <object>report</object> </request> �� ���� �������� �������������� ����: ��� �����, ��� � ���� - ������ ������� � ��������� �������. ��� ���������� ����� ��������� ����� (������� ��� ����������) ���������� �������: 0 - �������, 1 - ����������, 2 - � �� � ������. ���� ������ � ��������� ������� �������� � ������� DD.MM.YYYY. ���� �� ������� ������ �� �����, �� ��������� ������� ������ �� ������� ����� � 00:00:00 �� ������� ����� ������������. ����� ����� ���� ���������: <?xml version="1.0" encoding="utf-8"?> <response> <data> <backup> <id>460</id> <agent_host>mnsdesktop</agent_host> <agent_ip>127.0.0.1</agent_ip> <agent_name>localhost</agent_name> <comment>(HTTP) Configuration and databases on ... </comment> <date_start>2014-09-09 04:05:06</date_start> <file_md5>96e3596cff90daebd186fac5e478f0af</file_md5> <file_name>test1-2014-09-03.zip</file_name> <file_sha1>c47b0a6346f0ea3ef791a9fb579eff8b833f5d44</file_sha1> <file_size>1198023</file_size> <message>Uploading sucess ... </message> <n>1</n> <server_host>mbutiny.localhost</server_host> <server_ip>127.0.0.1</server_ip> <status>1</status> <type>1</type> </backup> <message>������ ������� �������</message> <number>1</number> </data> <debug_time>0.116</debug_time> <error></error> <object>report</object> <query_string></query_string> <remote_addr>127.0.0.1</remote_addr> <status>1</status> </response> ������ <backup>...</backup> (� �� ����� ���� ���������) �������� ������ �� ��������� �����. �������� ���� <number> ������������� ���������� ���������� �������. __END__