Thursday, December 29, 2011

watercolors









Some polish artist... Have to find his name.

Sunday, December 11, 2011

Friday, December 9, 2011

openvpn ip tuples

 [  1,  2]   [  5,  6]   [  9, 10]   [ 13, 14]   [ 17, 18]   [ 21, 22]   [ 25, 26]   [ 29, 30]   [ 33, 34]   [ 37, 38]
[ 41, 42]   [ 45, 46]   [ 49, 50]   [ 53, 54]   [ 57, 58]   [ 61, 62]   [ 65, 66]   [ 69, 70]   [ 73, 74]   [ 77, 78]
[ 81, 82]   [ 85, 86]   [ 89, 90]   [ 93, 94]   [ 97, 98]   [101,102]   [105,106]   [109,110]   [113,114]   [117,118]
[121,122]   [125,126]   [129,130]   [133,134]   [137,138]   [141,142]   [145,146]   [149,150]   [153,154]   [157,158]
[161,162]   [165,166]   [169,170]   [173,174]   [177,178]   [181,182]   [185,186]   [189,190]   [193,194]   [197,198]
[201,202]   [205,206]   [209,210]   [213,214]   [217,218]   [221,222]   [225,226]   [229,230]   [233,234]   [237,238]
[241,242]   [245,246]   [249,250]   [253,254]

Monday, December 5, 2011

fraud during russian elections 2011

This night votes on election in "Russian Parliament" ("Duma") are counted. There is one of many interesting articles which was written by journalist who participated in fraud. It was almost uncovered advertisement with proposal to vote several times in several districts. This is a short quotation from the article:
 "Each of as have to vote on seven districts. Thus, on the 4th of December only in Horoshevo-Mnevnoki district for United Russia was unduly inserted 3080 votes: (40 people x 11 votes x 7 districts)"

http://www.lenta.ru/articles/2011/12/04/carousel/


Tuesday, November 22, 2011

ssl redirect

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

Sunday, October 16, 2011

dpkg arch i486->i686

/usr/share/dpkg/cputable

In the second column, change GNU name to be "i686" instead of "i486".

(instead of: dpkg-architecture -f -ti686-linux-gnu)

Saturday, October 15, 2011

опросник от нгс, вопросы для админов от нгс

У нас в городе появилась практика попросить у друга-админа вопросы, чтобы собеседовать админа. Поскольку меня задолбало видеть на собеседованиях одни и те же вопросы от людей, которые не в состоянии самостоятельно провести собеседование, не способны сами понять, насколько админ компетентен, не способны отличить вопросы для админа начального уровня от вопросов для начальника отдела и т.д., а также потому что сам список этих вопросов содержит дибильные вопросы, я выкладываю опросник от нгса с приблизительными ответами. Давайте уже, придумайте что-нибудь посвежее.


I. Сеть.
1. Чем отличается свич от хаба?
A: Хаб ретранслирует пакет на все порты, switch - только на нужные. 
[Старый вопрос и потому ненужный вопрос. Хабы уже стали историей.]

2. Что такое коммутатор и концентратор?
А: Свитч и хаб.

3. Чем отличаются 802.1q, 802.2, 802.11b и 802.11g ? Что это вообще такое и
что это из себя представляет?
A: Это номера RFC для VLAN, LLC, wi-fi по стандарту b и g. [ Как часто, коллеги, вам приходится штудировать RFC по LLC? Также часто как и 802.13...23? Зачем это здесь? ]

4. Что такое full-duplex? Какой еще duplex бывает?
А: Двусторонняя передача данных. Есть еще half-duplex.

5. Что такое 568A/B ?
А: Варианты разводки витой пары. 
[Этим вопросом мы открываем конкурс дибильных вопросов данного опросника! Каждый день в моей повседневной практике мне приходится отличать вариант обжима 568A от 568B! ]

6. Чем отличаются 10Base-T, 100Base-TX и 1000Base-T?
А: 10Base-T и 1000Base-T - стандарты на 10 и 1000 мбс. 100Base-TX - Fast
Ethernet по 2-ум парам.

7. Сколько уровней в модели OSI?
А: 7

8. Какие из них находятся на 3х нижних позициях?
А: Физический, Канальный, Сетевой
[Не проще ли было сразу попросить перечислить уровни OSI?]

9. В чем отличия TCP и UDP ?
А: TCP - это протокол с гарантированной доставкой и контролем передачи.
UDP нет.

10. Что является для них транспортом?
A: IPv4/IPv6/IPSec

11. Какие IP-протоколы вы знаете?
A: ... [IP - это в стеке TCP/IP или все протоколы, которые используют IP???]

12. Что необходимо, чтобы заработал pptp VPN?
A: открыть tcp 1723 port.
[или о чем вобще думал чел, который задавал этот вопрос?]
13. Что такое firewall?
A: Это технология, позволяющая фильтровать сетевой трафик.
[Браво! Вопрос на 5 баллов! Автор, ты подбирал вопросы в соответствии со своим уровнем? ]
14. Что такое маршрутизация?
А: Это базовая технология для определения источника и приемника передачи
данных.

15. Какие виды маршрутизации вы знаете?
A: Статическая и динамическая.

16. Что такое OSPF, BGP и RIP?
А: Протоколы динамической маршрутизации.

17. Из каких частей состоит IP-адрес?
А: Из адреса сети и хоста.

18. Какие виды/типы VPN вы знаете?
А: IPSec, OpenVPN, PPTP

19. Напишите необходимые ключи iptables, которые реализуют проброс трафика с
интерфейса eth0 на IP-адрес 192.168.2.1 для порта 22
А: iptables -t nat -A PREROUTING -i eth0 -p TCP --dport 22 -j DNAT --to-destination
192.168.2.1


II. Почта.
1. Что такое SMTP, POP3, IMAP что в них общего и чем они отличаются?
А: Это текстовые почтовые протоколы. SMTP - протокол MTA, POP3, IMAP -
протоколы MUA.

2. Из каких частей состоит письмо и что в них содержится?
A: smtp envelope - headers для MTA, message headers - для LDA, body. 

3. Что такое спам?
A: Несанкционированная рассылка.
[Кого призван отфилтровать этот вопрос? Особенно после вопроса про SMTP.]
4. Какие методы фильтрации спама вы знаете?
А: а) Основанные на свойствах SMTP и DNS. б) Внешние базы. в) Контентный
анализ.

5. С какими почтовыми продуктами вы работали?
А: ...

6. Какую служебную информацию можно извлечь из письма?
A: Согласно заголовкам.

7. Какие стандарты описывают формат сообщения, процесс передачи сообщения,
процесс приема сообщения?
А: gg://smtp rfc [Чувак, ну зачем этот вопрос вообще?!]

8. Что такое greylisting?
A: Временная задержка. Предполагается, что спаммер не сможет перепослать
письмо. [На самом деле они уже давно (лет 10?) научились.]

9. Что такое dnsbl?
А: Общая база по спамерам.

III. Unix
1. Как посмотреть какую версию ядра мы сейчас используем?
А: uname -a

2. Как посмотреть какую ОС мы сейчас используем?
A: uname -a

3. Чем отличается Linux и FreeBSD?
A: Проще будет сказать, чем они похожи: обе относятся к
posix-совместимым системам. [Этому вопросу мы присуждаем первое место в списке дибильных.]

4. Как посмотреть список процессов?
А: В какой ОС? [Дибильный вопрос номер 2. Чувак, прочти FAQ как правильно задавать вопросы.]

5. Как посмотреть список сетевых соединений?
А: netstat

6. Как в Linux посмотреть список слушающих сокетов?
A: netstat -nl [О! Вот здесь вопрос задан правильно. Молодец.]

7. Как посмотреть список файлов открытых процессом?
A: lsof -p PID

9. Какие средства мониторинга состояния системы вы знаете?
A: iostat, vmstat, netstat, top ...

10. Как посмотреть чем именно сейчас занят процесс?
A: ps aux, колонка STAT

11. Как удалить каталог рекурсивно?
A: rm -Rf [Глупый вопрос. Можно заодно спросить, как включить компьютер. У админа. ]

12. Что такое конвеер и как им пользоваться?
A: Перенаправление ввода-вывода. foo | bar [Их никто ща не называет конвеерами, если что. Pipe. Просто pipe.]

13. Приведите пример использования grep? Например, поиск и вывод только
IPv4-адреса.
A: egrep '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'

14. Приведите пример использования awk? Например, вывод 3-его от конца поля,
если 2-е поле равно "OK" (поля разделены табуляцией).
A: awk '{if ($2=="OK" ) print $(NF-2) }'

15. Приведите пример использования sed? Например, замена всех почтовых
адресов на "<skipped>"
A: sed -ir 's/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}/<skipped>/g'
filename

16. Ваш любимый коммандный интерпретатор? Почему?
A: bash, т.к. универсальный

17. Какие скриптовые языки Вы знаете?
А: ...
V. Инфраструктура
1. Что такое DHCP, как оно работает, вкратце?
A: Это сервис автоматической конфигурации хостов. Работает с
использованием бродкастов.

2. Что такое DNS и как оно устроено, вкратце?
А: Служба для связи ip c именами и обратно.

3. Что такое такое "система управления версиями"?
А: CVS, SVN, git ["Это система управления версиями". Как иначе-то сказать?]

4. Что такое SNMP?
A: Simple Network Managment Protocol

5. Какие системы управления пакетами вы знаете? Что такое "пакет" ПО,
вкратце?
A: deb, rpm, source based, примитивная пакетная система в Solaris и FreeBSD

VI. Аппаратные средства
1. За какие ресурсы сервера "дерутся" программы?
A: cpu, io, mem

2. Какие уровни RAID вы знаете? Укажите их ключевые особенности.
A: 0, 1, 5, 6, 10

3. Что такое кэш? В каких местах железа и операционной системы используется
кэш? Чем хорошо и чем плохо использование кэша?
A: Временная память. Дисковый контроллер -> raid контроллер -> кеш ОС
(несколько) -> CPU cache
[Осторожно, ща опять будет дибильный вопрос!]

4. Что такое KVM? Какие виды KVM вы знаете?
A: Это либо KVM-переключатель, либо система виртуализации. [Видимо, Автор был не в теме, вот и оставил вопрос неоднозначным.]

5. Какую информацию можно получить от систем аппаратного мониторинга?
А: Температуру, состояние здоровья, скорости и проч. [аппаратного мониторинга чего??! Там миллионы разных вещей мониторятся в зависимости от.]

6. Что показывает метрика load average? Какие цифры - "нормальные" для этой
метрики?
А: Кол-во процессов желающих использовать CPU. Нормальным будет la/cpu
number

7. Какие подходы, виды виртуализации Вы знаете? Чем они лучше/хуже между
собой ? С какими системами Вы работали?
A: Тяжелая (XEN), легкая (OpenVZ) и проч. [см. google]

VII. Web
1. Напишите команды получения главной страницы НГС (http://www.ngs.ru) из
командной строки интерпретатора (без программ-клиентов типа wget/curl/etc).
A: telnet www.ngs.ru 80
GET /index.html HTTP/1.0
Host: www.ngs.ru
\n\r\n\r

2. Напишите необходимые ключи ngrep, чтобы "поймать" запрос с URL
"http://host.tld/admin/page.php" от хоста с IP-адресом 192.168.2.1 на
локальном
интерфейсе eth0.
Дибильный вопрос. Ну шо ты пристал со своим ngrep?! Кроме тебя его никто не использует!
3. Что такое "сериализация"?
A: Упаковка данных.

4. Что такое AJAX?
А: Асинхронный javascript [ Лишний вопрос! Если это опросник для админа, то ему не обязательно знать все веб-технологии. Автор, на свете тысячи веб-фреймворков и веб-технологий! Нужно будет - разберемся с любой. ]

5. Чем плоха и хороша Java?
А: Хороша тем, что распространена и стандарт. Плоха потреблением
ресурсов и лицензией. [Слишком пространный и неоднозначный вопрос - плохой вопрос. Может, лучше обсудим вопросы управления памятью в JAVA VM? ]

VIII. БД
1. Напишите SQL-запрос, меняющий пароль локальному пользователю root в MySQL
5.x на '123'
А: update user set password=PASSWORD("123") where User='root'; flush
privileges;

2. Что такое триггер?
A: Хранимая процедура, выполняемая по условию.

3. Что такое хранимая процедура?
А: Набор инструкций, хранимый внутри базы.

4. Опишите, что делает данный SQL-запрос (MySQL 5.x, поле id - PRIMARY KEY,
с автоинкрементом): INSERT INTO table (id,val) VALUES (1,2) ON DUPLICATE
KEY UPDATE id=LAST_INSERT_ID(id), val=2;
А: Добавляет val=2 с уникальным id, начиная с 1. [ Привет php кодерам! ]

Friday, August 26, 2011

XEN 4.1.1 on Ubuntu Lucid 10.04 LTS (easy and efficient with debs)

 How to build debs with XEN 4.1.1 for Lucid in 7 steps:

Assumptions:
  • Build environment is up and running
Steps:
  1. Temporary change sources in /etc/apt/sources.list from lucid to oneiric.
  2. apt-get source apt-get source xen-hypervisor-4.1-amd64 ipxe
  3. install ipxe via executing dpkg-buildpackage -b -rfakeroot && dpkg -i ./../ipxe*deb
  4. go to xen-4.1.1 and edit debian/rules.real: change dh_python2 to simply dh_python
  5. edit debian/control and change XS-Python-Version: 2.7 to XS-Python-Version: 2.6
  6. edit debian/changelog appropriately
  7. dpkg-buildpackage -b -rfakeroot and you are done.

Thursday, July 28, 2011

Linux in school (Russian way)

 Russia needs National Operating System! How long has Russian government been doing buzz around it? For two, thee years? New names appeared to fight for a tender for "National" OS. Even french company Mandriva is now making Russian Linux.
  Recently my old teacher asked me to visit school because starting January this year Linux comes to school. Russian Alt Linux is unusable nightmare so two classes will be equipped with Ubuntu 11.04. (Can't wait to build centralized control with cfengine or something). Notice there is no ready educational programs and no educational software, no photoshop. Only pascal, openoffice and web. All this is just for the change itself.
 But this is not the end of a story. Interactive smart boards (http://shittech.com) was also supplied to the school. You know, this is a white board with a projector and cameras and it's like interactive screen. A part of them, to be more precise model v280 doesn't work under Ubuntu 10.04 LTS, despite the fact smart tech claims to support it.
Here are the IDs of build in cameras:

Bus 001 Device 011: ID 0b8c:b000 SMART Technologies Inc.
Bus 001 Device 010: ID 0b8c:b000 SMART Technologies Inc.
Bus 001 Device 009: ID 0b8c:000e SMART Technologies Inc.
Bus 001 Device 008: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Even more funny the open source camera app Cheese successfully get the picture from them!
Smart tech control center stayed blind. No, it found the devices, but was unable to communicate with them. A SMART tech software deb package looks shitty from perspective of experienced Linux user. All the binaries are like this  .HardwareTroubleShooter_elf

Needless to say there is no reseller support of this Sh*t in Russia and official support washes it's hand out of it. How sweet! Then again nobody is responsible and no sign of

The last but not the least. A big fat warning in Russian for others who will be googling for a solution.

~~~~~~~~~~~~~~~~~~~~

SMART board v280 не завелась под Ubuntu 10.04 LTS, 2.6.32-25-generic с использованием Notebook software v 10.2 sp2
! Тех. поддержка поддержку не оказывает, даже англоязычная на info@smarttech.com. На support@smarttech.com они вобще мой тикет "потеряли", хотя пришло автоматическое подтверждение! Другие модели досок могут работать, но прекомпелированные модули ядер есть только для Ubuntu 10.04 и Suse 11.3. Короче, будете связываться, связывайтесь на свой страх и риск.

Thursday, June 23, 2011

zabbix agent 1.4 on debian lenny fails constantly

what a shame.

 14197:20110623:063623 zbx_on_exit() called.
 14197:20110623:063623 One child process died. Exiting ...
 14197:20110623:063623 zbx_on_exit() called.
 14197:20110623:063623 Cannot remove PID file [/var/run/zabbix-agent/zabbix_agentd.pid] [No such file or directory]
zabbix_agentd [1986]: Warning: ZABBIX semaphores already exist, trying to recreate.
  1986:20110623:063623 zabbix_agentd started. ZABBIX 1.4.6.
  1986:20110623:063623 Listener failed with error: Cannot bind to port 10050 for server 0.0.0.0. Error [Address already in use]. Another zabbix_agentd already running ?.
 14197:20110623:063625 ZABBIX Agent stopped


Great! Just Great.

Friday, June 10, 2011

Wednesday, June 8, 2011

why to hate summer in Russia

Summer has just started, but cold water has been already cut off for maintenance.
 - So what? - one of my fellow-country man would ask. - They do it every summer and this is just a beginning.
 - Year, you are right. But why those dicks glued warning after they did it? Humidity is like in Japan.
 - Because it's Russia. Say you are lucky because it's only for tree days.
 - Right... One thing to love winter in Siberia for is that nobody digs anything.

Wednesday, May 11, 2011

Old jokes (Today Microsoft bought Skype)

 Today Microsoft bought Skype, this is a good occasion to remember what people say.

MICROSOFT JOKES

MICROSOFT JOKES



Tech Support: "Do you have any windows open right now?"
Customer: "Are you crazy woman, it's twenty below outside ..."

--------------------------------------------------------------------------------
They say when you play that Microsoft CD backward you can hear satanic messages ... but that's nothing. If you play it forward it will install Windows.

--------------------------------------------------------------------------------
No, Windows is not a virus. Here's what viruses do:
1. They replicate quickly. ... Okay, Windows does that.
2. Viruses use up valuable system resources, slowing down the system as they do so. ... Okay, Windows does that.
3. Viruses will, from time to time, trash your hard disk. ... Okay, Windows does that too.
4. Viruses are usually carried, unknown to the user, along with valuable programs and systems. ... Sigh.. Windows does that, too.
5. Viruses will occasionally make the user suspect their system is too slow (see 2) and the user will buy new hardware. ... Yup, Windows does that, too.
Until now it seems Windows is a virus but there are fundamental differences: Viruses are well supported by their authors, are running on most systems, their program code is fast, compact and efficient and they tend to become more sophisticated as they mature.
So Windows is not a virus. ... It's a bug.

--------------------------------------------------------------------------------
Customer: "How much do Windows cost?"
Tech Support: "Windows costs about $100."
Customer: "Oh, that's kind of expensive. Can I buy just one window?"

--------------------------------------------------------------------------------
At a recent computer expo (COMDEX), Bill Gates reportedly compared the computer industry with the auto industry and stated:
"If GM had kept up with technology like the computer industry has, we would all be driving twenty-five dollar cars that got 1,000 miles to the gallon."
In response to Bill's comments, General Motors issued a press release stating (by Mr. Welch himself):
"If GM had developed technology like Microsoft, we would all be driving cars with the following characteristics:
1) For no reason whatsoever your car would crash twice a day.
2) Every time they painted new lines on the road you would have to buy a new car.
3) Occasionally your car would die on the freeway for no reason, and you would just accept this, restart and drive on.
4) Occasionally, executing a manoeuvre such as a left turn, would cause your car to shut down and refuse to restart, in which case you would have to reinstall the engine.
5) Only one person at a time could use the car, unless you bought "Car95" or "CarNT". But then you would have to buy more seats.
6) Macintosh would make a car that was powered by the sun, reliable, five times as fast, and twice as easy to drive, but would only run on five percent of the roads.
7) The oil, water temperature and alternator warning lights would be replaced by a single "general car default" warning light.
8) New seats would force everyone to have the same size butt.
9) The airbag system would say "Are you sure?" before going off.
10) Occasionally for no reason whatsoever, your car would lock you out and refuse to let you in until you simultaneously lifted the door handle, turned the key, and grab hold of the radio antenna.
11) GM would also require all car buyers to also purchase a deluxe set of Rand McNally road maps (now a GM subsidiary), even though they neither need them nor want them. Attempting to delete this option would immediately cause the car's performance to diminish by 50% or more. Moreover, GM would become a target for investigation by the Justice Department.
12) Every time GM introduced a new model car buyers would have to learn how to drive all over again because none of the controls would operate in the same manner as the old car.
13) You'd press the "start" button to shut off the engine.

--------------------------------------------------------------------------------
This is Linux land. In silent nights you can hear the Windows machines rebooting.

--------------------------------------------------------------------------------
If Windows is the solution, can we please have the problem back?

--------------------------------------------------------------------------------
Computers are like air conditioners, they stop working properly if you open Windows.

--------------------------------------------------------------------------------
Macs are for those who don't want to know why their computer works.
Linux is for those who want to know why their computer works.
DOS is for those who want to know why their computer doesn't work.
Windows is for those who don't want to know why their computer doesn't work.

--------------------------------------------------------------------------------

If Windows is the solution, can we please have the problem back?
 
--------------------------------------------------------------------------------
There was once a young man who, in his youth, professed his desire to become a great writer.
When asked to define "great" he said, "I want to write stuff that the whole world will read, stuff that people will react to on a truly emotional level, stuff that will make them scream, cry, howl in pain and anger!"
He now works for Microsoft, writing error messages.

--------------------------------------------------------------------------------
They say when you play that Microsoft CD backward you can hear satanic messages ... but that's nothing. If you play it forward it will install Windows.

--------------------------------------------------------------------------------
In Computer Heaven:
The management is from Intel,
The design and construction is done by Apple,
The marketing is done by Microsoft,
IBM provides the support,
Gateway determines the pricing.

In Computer Hell:
The management is from Apple,
Microsoft does design and construction,
IBM handles the marketing,
The support is from Gateway,
Intel sets the price.

--------------------------------------------------------------------------------
A pilot is flying a small, single-engine, charter plane with a couple of really important executives on board into Seattle airport. There is fog so thick that visibility is 40 feet, and his instruments are out. He circles looking for a landmark and after an hour, he is low on fuel and his passengers are very nervous. At last, through a small opening in the fog he sees a tall building with one guy working alone on the fifth floor. Circling, the pilot banks and shouts through his open window: "Hey, where am I?". The solitary office worker replies: "You're in an airplane.". The pilot immediately executes a swift 275 degree turn and executes a perfect blind landing on the airport's runway five miles away. Just as the plane stops, the engines cough and die from lack of fuel. The stunned passengers ask the pilot how he did it. "Elementary," replies the pilot, "I asked the guy in that building a simple question. The answer he gave me was 100% correct but absolutely useless; therefore, I knew that must be Microsoft's support office and from there the airport is three minutes away on a course of 87 degrees."

--------------------------------------------------------------------------------
The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners.
 
--------------------------------------------------------------------------------
At a recent computer expo (COMDEX), Bill Gates reportedly compared the computer industry with the auto industry and stated:
"If GM had kept up with technology like the computer industry has, we would all be driving twenty-five dollar cars that got 1,000 miles to the gallon."
In response to Bill's comments, General Motors issued a press release stating (by Mr. Welch himself):
"If GM had developed technology like Microsoft, we would all be driving cars with the following characteristics:
1) For no reason whatsoever your car would crash twice a day.
2) Every time they painted new lines on the road you would have to buy a new car.
3) Occasionally your car would die on the freeway for no reason, and you would just accept this, restart and drive on.
4) Occasionally, executing a manoeuvre such as a left turn, would cause your car to shut down and refuse to restart, in which case you would have to reinstall the engine.
5) Only one person at a time could use the car, unless you bought "Car95" or "CarNT". But then you would have to buy more seats.
6) Macintosh would make a car that was powered by the sun, reliable, five times as fast, and twice as easy to drive, but would only run on five percent of the roads.
7) The oil, water temperature and alternator warning lights would be replaced by a single "general car default" warning light.
8) New seats would force everyone to have the same size butt.
9) The airbag system would say "Are you sure?" before going off.
10) Occasionally for no reason whatsoever, your car would lock you out and refuse to let you in until you simultaneously lifted the door handle, turned the key, and grab hold of the radio antenna.
11) GM would also require all car buyers to also purchase a deluxe set of Rand McNally road maps (now a GM subsidiary), even though they neither need them nor want them. Attempting to delete this option would immediately cause the car's performance to diminish by 50% or more. Moreover, GM would become a target for investigation by the Justice Department.
12) Every time GM introduced a new model car buyers would have to learn how to drive all over again because none of the controls would operate in the same manner as the old car.
13) You'd press the "start" button to shut off the engine. 

Wednesday, May 4, 2011

MySQL monitoring with OpenNMS 1.8.11 and JDBC

 There are different ways to monitor MySQL using OpenNMS: mysql snmp project, with php script and agregation with OpenNMS http collector and using JDBC facility in OpenNMS. Some people say that using MySQL SNMP is more beneficial in sense of traffic usage and reporting results. JDBC is good if you don't have access on remote host to compile mysql snmp (or don't want to make rpm,deb and port:) and just want to ask DBA to add user for monitoring.
 This is a compilation of the wiki articles, which you can found here and here.

 Although OpenNMS wiki describes Capsd settings, we will ignore this and use it's replacemen, that is provisiond+detectors.


 a) OpenNMS dataflow assumes that first every service have to be detected with simple check. Detector configured in WebUI: Admin-&gt;Provisioning Groups-&gt;Edit Foreign Source-&gt;Add detector-&gt;JDBC

Here I put foreign source xml file, so that you can pick up necessary parameters:

<detector class="org.opennms.netmgt.provision.detector.jdbc.JdbcDetector" name="JDBC for MySQL">
            <parameter value="opennms" key="user"/>
            <parameter value="abc" key="password"/>
            <parameter value="com.mysql.jdbc.Driver" key="dbDriver"/>
            <parameter value="jdbc:mysql://xx.xx.xx.xx/information_schema" key="url"/>
            <parameter value="3" key="retries"/>
            <parameter value="3306" key="port"/>
</detector>




Database URL is constructed according to this.

OpenNMS needs addition Java components to make DB requests. For that reason I installed libmysql-java (deb) which provided me with
/usr/share/java/mysql-connector-java-5.1.10.jar
 This file should be included in /etc/opennms/opennms.conf like this:
ADDITIONAL_CLASSPATH="/usr/share/java/mysql-connector-java-5.1.10.jar:/usr/share/java/postgresql-jdbc3-8.4.jar"
or just copied into $OPENNMS_HOME/lib/


Otherwise OpenNMS complains about it:

INFO  [scanExecutor-9] NullDetectorMonitor: JDBC for MySQL: An undeclared throwable exception was caught contating address xx.xx.xx.xx port 3306
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver




b) After detection data may be collected via collectd. That is why we add following to the collectd-configuration.xml (xx.xx.xx.xx - may be a host name or an ip)


<package name="mysql">
    <filter>IPADDR != '0.0.0.0'</filter>
    <specific xmlns="">xx.xx.xx.xx</specific>
        <service name="MySQL" interval="300000" user-defined="false" status="on">
       <parameter key="retry" value="2"/>
       <parameter key="timeout" value="3000"/>
       <parameter key="collection" value="mysql"/>
       <parameter key="url" value="jdbc:mysql://xx.xx.xx.xx/information_schema"/>
       <parameter key="user" value="opennms"/>
       <parameter key="password" value="abc"/>
       <parameter key="driver" value="com.mysql.jdbc.Driver"/>
     </service>
 </package>



Collection service from first part should be linked with actual Java collector. Put this also in collectd-configuration.xml


<collector service="MySQL" class-name="org.opennms.netmgt.collectd.JdbcCollector"/>




c) Collection "mysql" from the above should be linked with corresponding datacollection description (snmp, http, jdbc etc). Thus place this into  jdbc-datacollection-config.xml (If my formating sux just copy from original wiki)


<jdbc-collection name="mysql">
        <rrd step="300">         
                  <rra>RRA:AVERAGE:0.5:1:2016</rra>
                  <rra>RRA:AVERAGE:0.5:12:1488</rra>
                  <rra>RRA:AVERAGE:0.5:288:366</rra>
                  <rra>RRA:MAX:0.5:288:366</rra>   
                  <rra>RRA:MIN:0.5:288:366</rra>   
        </rrd>                                     
      <queries>                                    
        <query name="Uptime" ifType="all" >        
          <statement>                              
            <queryString>show global status like 'Uptime'</queryString>
          </statement>                                                
          <columns>                                                   
           <column name="MyUptime" data-source-name="Value" alias="MyUptime" type="GAUGE"/>
          </columns>                                                                     
        </query>                                                                         
        <query name="Bytes_received" ifType="all" >                                      
          <statement>                                                                    
            <queryString>show global status like 'Bytes_received'</queryString>          
          </statement>                                                                   
          <columns>                                                                      
           <column name="MyBytesReceived" data-source-name="Value" alias="MyBytesReceived" type="COUNTER"/>
          </columns>                                                                                      
        </query>                                                                                          
        <query name="Bytes_sent" ifType="all" >                                                           
          <statement>                                                                                     
            <queryString>show global status like 'Bytes_sent'</queryString>                               
          </statement>                                                                                    
          <columns>                                                                                       
           <column name="MyBytesSent" data-source-name="Value" alias="MyBytesSent" type="COUNTER"/>        
          </columns>                                                                                      
        </query>                                                                                          
        <query name="Com_delete" ifType="all" >                                                           
          <statement>                                                                                     
            <queryString>show global status like 'Com_delete'</queryString>                               
          </statement>                                                                                    
          <columns>                                                                                       
           <column name="MyComDelete" data-source-name="Value" alias="MyComDelete" type="COUNTER"/>        
          </columns>                                                                                      
        </query>                                                                                          
        <query name="Com_delete_multi" ifType="all" >                                                     
          <statement>                                                                                     
            <queryString>show global status like 'Com_delete_multi'</queryString>                         
          </statement>                                                                                    
          <columns>                                                                                       
           <column name="MyComDeleteMulti" data-source-name="Value" alias="MyComDeleteMulti" type="COUNTER"/>
          </columns>                                                                                         
        </query>                                                                                             
        <query name="Com_insert" ifType="all" >                                                              
          <statement>                                                                                        
            <queryString>show global status like 'Com_insert'</queryString>                                  
          </statement>                                                                                       
          <columns>                                                                                          
           <column name="MyComInsert" data-source-name="Value" alias="MyComInsert" type="COUNTER"/>           
          </columns>                                                                                         
        </query>                                                                                             
        <query name="Com_insert_select" ifType="all" >                                                       
          <statement>                                                                                        
            <queryString>show global status like 'Com_insert_select'</queryString>                           
          </statement>                                                                                       
          <columns>                                                                                          
           <column name="MyComInsertSelect" data-source-name="Value" alias="MyComInsertSelect" type="COUNTER"/>
          </columns>                                                                                           
        </query>                                                                                               
        <query name="Com_select" ifType="all" >                                                                
          <statement>                                                                                          
            <queryString>show global status like 'Com_select'</queryString>                                    
          </statement>                                                                                         
          <columns>                                                                                            
           <column name="MyComSelect" data-source-name="Value" alias="MyComSelect" type="COUNTER"/>             
          </columns>                                                                                           
        </query>                                                                                               
        <query name="Com_stmt_execute" ifType="all" >                                                          
          <statement>                                                                                          
            <queryString>show global status like 'Com_stmt_execute'</queryString>                              
          </statement>                                                                                         
          <columns>                                                                                            
           <column name="MyComStmtExecute" data-source-name="Value" alias="MyComStmtExecute" type="COUNTER"/>  
          </columns>                                                                                           
        </query>                                                                                               
        <query name="Com_update" ifType="all" >                                                                
          <statement>                                                                                          
            <queryString>show global status like 'Com_update'</queryString>                                    
          </statement>                                                                                         
          <columns>                                                                                            
           <column name="MyComUpdate" data-source-name="Value" alias="MyComUpdate" type="COUNTER"/>             
          </columns>                                                                                           
        </query>                                                                                               
        <query name="Com_update_multi" ifType="all" >                                                          
          <statement>                                                                                          
            <queryString>show global status like 'Com_update_multi'</queryString>                              
          </statement>                                                                                         
          <columns>                                                                                            
           <column name="MyComUpdateMulti" data-source-name="Value" alias="MyComUpdateMulti" type="COUNTER"/>  
          </columns>                                                                                           
        </query>                                                                                               
        <query name="Created_tmp_disk_tables" ifType="all" >                                                   
          <statement>                                                                                          
            <queryString>show global status like 'Created_tmp_disk_tables'</queryString>                       
          </statement>                                                                                         
          <columns>                                                                                            
           <column name="MyCreatTmpDiskTbl" data-source-name="Value" alias="MyCreatTmpDiskTbl" type="COUNTER"/>
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Created_tmp_tables" ifType="all" >                                                              
          <statement>                                                                                                
            <queryString>show global status like 'Created_tmp_tables'</queryString>                                  
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyCreatTmpTables" data-source-name="Value" alias="MyCreatTmpTables" type="COUNTER"/>      
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="key_buffer_size" ifType="all" >                                                                 
          <statement>                                                                                                
            <queryString>show global variables like 'key_buffer_size'</queryString>                                  
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyKeyBufferSize" data-source-name="Value" alias="MyKeyBufferSize" type="GAUGE"/>            
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="key_cache_block_size" ifType="all" >                                                            
          <statement>                                                                                                
            <queryString>show global variables like 'key_cache_block_size'</queryString>                             
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyKeyCacheBlkSize" data-source-name="Value" alias="MyKeyCacheBlkSize" type="GAUGE"/>     
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Key_blocks_unused" ifType="all" >                                                               
          <statement>                                                                                                
            <queryString>show global status like 'Key_blocks_unused'</queryString>                                   
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyKeyBlkUnused" data-source-name="Value" alias="MyKeyBlkUnused" type="GAUGE"/>           
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Key_read_requests" ifType="all" >                                                               
          <statement>                                                                                                
            <queryString>show global status like 'Key_read_requests'</queryString>                                   
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyKeyReadReqs" data-source-name="Value" alias="MyKeyReadReqs" type="COUNTER"/>          
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Key_reads" ifType="all" >                                                                       
          <statement>                                                                                                
            <queryString>show global status like 'Key_reads'</queryString>                                           
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyKeyReads" data-source-name="Value" alias="MyKeyReads" type="COUNTER"/>                     
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Key_write_requests" ifType="all" >                                                              
          <statement>                                                                                                
            <queryString>show global status like 'Key_write_requests'</queryString>                                  
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="Value" data-source-name="Value" alias="MyKeyWriteReqs" type="COUNTER"/>        
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Key_writes" ifType="all" >                                                                      
          <statement>                                                                                                
            <queryString>show global status like 'Key_writes'</queryString>                                          
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyKeyWrites" data-source-name="Value" alias="MyKeyWrites" type="COUNTER"/>                   
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Open_files" ifType="all" >                                                                      
          <statement>                                                                                                
            <queryString>show global status like 'Open_files'</queryString>                                          
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyOpenFiles" data-source-name="Value" alias="MyOpenFiles" type="GAUGE"/>                     
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Open_tables" ifType="all" >                                                                     
          <statement>                                                                                                
            <queryString>show global status like 'Open_tables'</queryString>                                         
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyOpenTables" data-source-name="Value" alias="MyOpenTables" type="GAUGE"/>                   
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="table_cache" ifType="all" >                                                                     
          <statement>                                                                                                
            <queryString>show global variables like 'table_cache'</queryString>                                      
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyTableCache" data-source-name="Value" alias="MyTableCache" type="GAUGE"/>                   
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Questions" ifType="all" >                                                                       
          <statement>                                                                                                
            <queryString>show global status like 'Questions'</queryString>                                           
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyQuestions" data-source-name="Value" alias="MyQuestions" type="COUNTER"/>                    
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Slow_queries" ifType="all" >                                                                    
          <statement>                                                                                                
            <queryString>show global status like 'Slow_queries'</queryString>                                        
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MySlowQueries" data-source-name="Value" alias="MySlowQueries" type="COUNTER"/>               
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Connections" ifType="all" >                                                                     
          <statement>                                                                                                
            <queryString>show global status like 'Connections'</queryString>                                         
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyConnections" data-source-name="Value" alias="MyConnections" type="COUNTER"/>                
          </columns>                                                                                                 
        </query>                                                                                                     
        <query name="Threads_created" ifType="all" >                                                                 
          <statement>                                                                                                
            <queryString>show global status like 'Threads_created'</queryString>                                     
          </statement>                                                                                               
          <columns>                                                                                                  
           <column name="MyThreadsCreatd" data-source-name="Value" alias="MyThreadsCreatd" type="COUNTER"/>          
          </columns>                                                                                                 
        </query>
        <query name="Threads_cached" ifType="all" >
          <statement>
            <queryString>show global status like 'Threads_cached'</queryString>
          </statement>
          <columns>
           <column name="MyThreadsCachd" data-source-name="Value" alias="MyThreadsCachd" type="GAUGE"/>
          </columns>
        </query>
        <query name="Threads_connected" ifType="all" >
          <statement>
            <queryString>show global status like 'Threads_connected'</queryString>
          </statement>
          <columns>
           <column name="MyThreadsCnnctd" data-source-name="Value" alias="MyThreadsCnnctd" type="GAUGE"/>
          </columns>
        </query>
        <query name="Threads_running" ifType="all" >
          <statement>
            <queryString>show global status like 'Threads_running'</queryString>
          </statement>
          <columns>
           <column name="MyThreadsRunng" data-source-name="Value" alias="MyThreadsRunng" type="GAUGE"/>
          </columns>
        </query>
      </queries>

    </jdbc-collection>



d) In snmp-graph.properties (don't know why snmp) the graph description should be added. Exactly like in the official howto:


http://www.opennms.org/wiki/JDBC_Collection_configuration_for_MySQL


e) MySQL user created just to allow OpenNMS to connect and perform request on information schema.


In case you locked the user, allow access to MySQL again on the database host by:

mysqladmin flush-hosts