Monitor Your Business V2

3,135 views

Published on

The most important thing happening in your website is the business process. So why should you monitor your database and your webserver only when your business is failing? Monitoring is not only about hardware and databases - it's also about the internals of your application. Learn how to monitor your business using PHP and how to create nice, good looking management compatible graphs.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,135
On SlideShare
0
From Embeds
0
Number of Embeds
707
Actions
Shares
0
Downloads
63
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Monitor Your Business V2

  1. 1. Monitor your Business Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  2. 2. PHPCon Italia 2009 Who is talking? Monitor your Business Lars Jankowfsky • CTO swoodoo.com • php since php/fi • developing since 15 years Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  3. 3. PHPCon Italia 2009 Preface Monitor your Business • No rocket science today • using existing tools for business monitoring • nagios • cacti Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  4. 4. PHPCon Italia 2009 What can you expect? Monitor your Business Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  5. 5. PHPCon Italia 2009 What can you expect? Monitor your Business Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  6. 6. PHPCon Italia 2009 What can you expect? Monitor your Business Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  7. 7. PHPCon Italia 2009 nagios Monitor your Business nagios Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  8. 8. PHPCon Italia 2009 nagios Monitor your Business • popular open source network monitoring software • usually used mostly for networking/service monitoring (load,ping,mysql...) • http://www.nagios.org • http://nagios.sourceforge.net/docs/3_0/quickstart- ubuntu.html Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  9. 9. PHPCon Italia 2009 nagios Monitor your Business • orders (eCommerce) • imported data (webservices) • customer activity (web 2.0) •... Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  10. 10. PHPCon Italia 2009 nagios Monitor your Business e.g. Order tracking • we use OXID CE • http://www.oxid-esales.com/download • could be any other shopping cart (osc,magento...) shop zeigen phpmyadmin zeigen Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  11. 11. PHPCon Italia 2009 nagios Monitor your Business the script • /usr/local/nagios/libexec • php-cli • nagios active mode diff types - we use active (nagios calls) passive checks write into nagios command file, and later nagios reads. Asynchronous Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  12. 12. PHPCon Italia 2009 nagios Monitor your Business Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  13. 13. PHPCon Italia 2009 nagios Monitor your Business #!/usr/bin/php <?php $link = mysql_connect('localhost', 'root', 'root'); mysql_select_db('oxid', $link); $result = mysql_query(quot;SELECT count(*) FROM `oxorder` WHERE date(oxorderdate) = curdate()quot;); $row = mysql_fetch_array($result, MYSQL_NUM); $todayordercount = $row[0]; mysql_close($link); if ($todayordercount < 1) { echo(quot;VALUE ERROR - we got $todayordercount|v=$todayordercountquot;); exit(2); } elseif ($todayordercount < 5) { echo(quot;VALUE WARNING - we got $todayordercount|v=$todayordercountquot;); exit(1); } else { echo(quot;VALUE OK - we got $todayordercount|v=$todayordercountquot;); exit(0); } Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  14. 14. PHPCon Italia 2009 nagios Monitor your Business Plugin Return Code: • 0=OK • 1=WARNING • 2=CRITICAL • 3=UNKNOWN Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  15. 15. PHPCon Italia 2009 nagios Monitor your Business ../etc/objects/commands.cfg Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  16. 16. PHPCon Italia 2009 nagios Monitor your Business ../etc/objects/commands.cfg #Shop Orders define command{ command_name check-oxid-orders command_line $USER1$/check_oxid_orders } Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  17. 17. PHPCon Italia 2009 nagios Monitor your Business ../etc/objects/localhost.cfg Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  18. 18. PHPCon Italia 2009 nagios Monitor your Business ../etc/objects/localhost.cfg define service{ use local-service host_name localhost service_description SHOP_ORDERS check_command check-oxid-orders } Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  19. 19. PHPCon Italia 2009 nagios Monitor your Business Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  20. 20. PHPCon Italia 2009 nagios Monitor your Business Why nagios ? • automatic alerts like SMS or eMail • nearly every provider uses it • can use SNMP for remote testing • easy to setup and to configure Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  21. 21. PHPCon Italia 2009 cacti Monitor your Business cacti Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  22. 22. PHPCon Italia 2009 cacti Monitor your Business • popular open source RRD graphing tool • RRD == Round Robin Database • http://www.cacti.net • apt-get install cacti Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  23. 23. PHPCon Italia 2009 cacti Monitor your Business • graphs for management like: • orders, sales • conversion rates • booking/visitor rate • import/sec. rate • ... Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  24. 24. PHPCon Italia 2009 cacti Monitor your Business e.g. Page Impression tracking • again OXID CE • take source from table ,oxlogs‘ shop zeigen phpmyadmin zeigen Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  25. 25. PHPCon Italia 2009 cacti Monitor your Business /usr/local/share/cacti/scripts/test.php Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  26. 26. PHPCon Italia 2009 cacti Monitor your Business /usr/local/share/cacti/scripts/test.php #!/usr/bin/php <?php $link = mysql_connect('localhost', 'root', 'root'); mysql_select_db('oxid', $link); $result = mysql_query(quot;SELECT count(*) FROM `oxlogs` WHERE UNIX_TIMESTAMP(oxtime) > (UNIX_TIMESTAMP() - 300)quot;); $row = mysql_fetch_array($result, MYSQL_NUM); $hitsPerFiveMinutes = $row[0]; mysql_close($link); // something else $b = rand(0,10); echo(quot;OK:$hitsPerFiveMinutes ERR:$bquot;); Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  27. 27. PHPCon Italia 2009 cacti Monitor your Business is the script ok ? • amount of data... • RRD advantages Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  28. 28. PHPCon Italia 2009 cacti Monitor your Business #1 - create data input method Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  29. 29. PHPCon Italia 2009 cacti Monitor your Business #2 - add data input method fields Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  30. 30. PHPCon Italia 2009 cacti Monitor your Business #3 - create data template Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  31. 31. PHPCon Italia 2009 cacti Monitor your Business #3 - create data template Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  32. 32. PHPCon Italia 2009 cacti Monitor your Business #4 - add data template fields Maximum value 0 has special meaning. It means that threshold for maximum value. be sure that everything is correct. No changes possible later! Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  33. 33. PHPCon Italia 2009 cacti Monitor your Business #5 - create graph template... #6 - create graph template items after that add type „legend“ Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  34. 34. PHPCon Italia 2009 cacti Monitor your Business #6 - create graph template items Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  35. 35. PHPCon Italia 2009 cacti Monitor your Business #7 - create graph Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  36. 36. PHPCon Italia 2009 cacti Monitor your Business #7 - add into tree Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  37. 37. PHPCon Italia 2009 cacti Monitor your Business et voila.... Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  38. 38. PHPCon Italia 2009 TDD! Monitor your Business Talking about the php.... • no reason to hack! • use same source for cacti and nagios! • don‘t forget the tests... Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  39. 39. PHPCon Italia 2009 TDD! Monitor your Business Talking about the php.... Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  40. 40. PHPCon Italia 2009 That‘s it... Monitor your Business Questions ? Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009
  41. 41. PHPCon Italia 2009 That‘s it... Monitor your Business Thank you for your interest! http://joind.in/talk/view/237 Lars Jankowfsky, swoodoo.com Freitag, 20. März 2009

×