ZABBIX Forums  

Go Back   ZABBIX Forums > Zabbix Discussions and Feedback > Zabbix Cookbook

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2011, 15:06
Razique Razique is offline
Junior Member
 
Join Date: Sep 2009
Posts: 17
Default [Update !]Easy Installation But Complete MySQL Monitoring

Hi hi all,
After two days of hard work, I'm coming with a new template for MySQL monitoring.
the one provided on the wiki (http://www.zabbix.com/wiki/howto/mon...ng_replication) contains too many datas, then hard to "read", I've noticed that I was barely able to understand them.

So I've decided to create a shinny new template, which get only the critical values, (54 items) and I've created a set of nice triggers and graphs.
Here is the final result :


Here are the graphs :


Installation
1- Download the template, which replaces the current Template_App_MySQL one.
2- Download the bash script (rename it to .sh) and make it executable
3- At line 22 and 23 set the correct MySQL credentials (You should create a dedicated user)
4- Put this script on a server you want to monitor
5- Cron it! (Mine is launched every 5 minutes)


How does it work
The bash script connects one time to the MySQL server, gets all the datas, and exit
Then the values are formatted, and sent to the Zabbix Server, eg :
HOSTNAME KEY VALUE
A temporary file is generated, but deleted when the send is complete.
If you need extra values (but remember, I've tried to get only the representatives values (around 54 keys of hundreds that MySQL provides)

My triggers try to be the most representatives ones, wich "good" ratios, but I could be wrong on some triggers. When the turn to true, it mainly means that you could optimize your database.

Enjoy
Attached Files
File Type: xml zbx_templates_export.xml (89.5 KB, 1055 views)
File Type: txt monitoring_mysql.txt (5.1 KB, 1862 views)

Last edited by Razique; 07-01-2011 at 14:44. Reason: Updated Template !
Reply With Quote
  #2  
Old 07-01-2011, 14:51
Razique Razique is offline
Junior Member
 
Join Date: Sep 2009
Posts: 17
Talking Updated Template !

You will find in this update two new triggers, and two new graphs, and 4 new items !
I've also changed some graphs, and change their names (Memory VS Cache)

Here are all the triggers :


And the Graphs :



How to Update :
- Simply Update your Template, there is no need to update the bash script
Attached Files
File Type: xml UPDATE_zbx_templates_export.xml (95.6 KB, 868 views)
Reply With Quote
  #3  
Old 11-01-2011, 17:58
username_taken username_taken is offline
Junior Member
 
Join Date: Oct 2009
Posts: 10
Default

I was getting errors with the script and was finding it hard to read/debug. Knowing what it does I was able to rewrite it in perl and skip all the temp file writing etc. I'm also push the data to stdout so I can pipe the script to the zabbix_sender binary. like so

./mysql.pl | ./zabbix_sender -z zabbix-server -c /etc/zabbix/zabbix_agentd.conf -i -

perl file is attached.
Attached Files
File Type: txt mysql.txt (4.1 KB, 804 views)
Reply With Quote
  #4  
Old 12-01-2011, 20:23
Razique Razique is offline
Junior Member
 
Join Date: Sep 2009
Posts: 17
Default

Awesome
You did a nice job. How the template's working for you ?
You should implement a debug param, so the users are able to understand where it fails, when it does Too bad I don't really know how to code in Perl!
Best Regards,
Razique
Reply With Quote
  #5  
Old 03-02-2011, 21:24
lgc78 lgc78 is offline
Member
 
Join Date: Aug 2010
Posts: 35
Default

Great script. Just set it up and it seems to be working. I'm noticing that not all items are being processed though. See output below.

Info from server: "Processed 8 Failed 31 Total 39 Seconds spent 0.000443"
sent: 39; skipped: 0; total: 39
Info from server: "Processed 49 Failed 29 Total 78 Seconds spent 0.000933"
sent: 78; skipped: 0; total: 78

Also, i was wondering if there's a way to have the zabbix agent run this - instead of having to setup a cron job on each mysql server.

Thanks again for the script!
Reply With Quote
  #6  
Old 03-02-2011, 22:48
username_taken username_taken is offline
Junior Member
 
Join Date: Oct 2009
Posts: 10
Default

You can set up a custom item to run it from on the agent ... something like ...


UserParameter=custom.mysql.activate,/path/to/mysql.pl | /path/to/zabbix_sender -z zabbix-server -c /etc/zabbix/zabbix_agentd.conf -i -
Reply With Quote
  #7  
Old 04-02-2011, 02:53
lgc78 lgc78 is offline
Member
 
Join Date: Aug 2010
Posts: 35
Default

hmm doesn't seem to work. I would need to create a new item in the mysql template to match, correct? And what type should it be... zabbix_sender or zabbix agent(active) or other? Thanks for the help.
Reply With Quote
  #8  
Old 15-03-2011, 17:20
Zete Zete is offline
Junior Member
 
Join Date: Feb 2011
Posts: 4
Default

I'm kinda stuck with this.

I imported the template and linked it to mysql hsot, copied and edited mysql.pl file on the mysql host, added a line

UserParameter=custom.mysql.activate,/usr/local/sbin/mysql.pl | /usr/local/sbin/zabbix_sender -z zabbixserv -c /etc/zabbix/zabbix_agentd.conf -i -

And I see it's not working. I've just started on zabbix and have no experience on creating User parameters. I believe the "custom.mysql.activate" part is the key. Do I have to make an additional check with this key at the server side to make this work?

If i run the "/usr/local/sbin/mysql.pl | /usr/local/sbin/zabbix_sender -z zabbixserv -c /etc/zabbix/zabbix_agentd.conf -i -" command manually, I get
Code:
Info from server: "Processed 0 Failed 109 Total 109 Seconds spent 0.002408"
sent: 109; skipped: 3; total: 112
What could be the reason for that?


UPD: Resolved!!

The thing is that I have a failover solution and I needed to send the data to a host with a different name in zabbix. Slighty edited the script, so it does not provide hostname and included -s parameter in the command.

Last edited by Zete; 16-03-2011 at 18:17.
Reply With Quote
  #9  
Old 22-06-2011, 18:29
efrain02 efrain02 is offline
Member
 
Join Date: Apr 2011
Location: Around The World
Posts: 82
Default

Would you be nice and let me know if i understand right?

You put the sh file on the server you need to minitor.
On zabbix you import the template.

I don't undestad what else do you do in order to see if it's working.
Hope you could clarify this a little bit more.

Thanks!
Reply With Quote
  #10  
Old 08-07-2011, 09:05
jeannaquila jeannaquila is offline
Junior Member
 
Join Date: Jul 2011
Location: Australia
Posts: 2
Default

Thanks for this one. Looks really easy
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:47.