# Nagios: How to write properly the service command?

**URL:** <https://forums.percona.com/t/nagios-how-to-write-properly-the-service-command/3572>\
**Category:** Percona Monitoring Plugins\
**Created:** [June 26, 2014, 3:49am UTC](https://forums.percona.com/t/nagios-how-to-write-properly-the-service-command/3572 "2014-06-26T03:49:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![camelel](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@camelel](https://forums.percona.com/u/camelel)\
**Post date:** [June 26, 2014, 3:49am UTC](https://forums.percona.com/t/nagios-how-to-write-properly-the-service-command/3572/1 "2014-06-26T03:49:19Z")

</div>

Hi there,

I’ve downloaded Percona’s Nagios monitoring tools and started setting them up, but I have some problem with one of the checks (the only one I’ve tried so far).  
I have this command in /etc/nagios/commands.cfg:

define command{  
command\_name check-mysql-connections  
command\_line $USER1$/pmp-check-mysql-status -l $USER3$ -p $USER4$ -H $HOSTADDRESS$ -x Threads\_connected -o / -y max\_connections -T pct -w 80 -c 95  
}

This is the service check I’ve built in reference:

define service{  
servicegroups Database Functionality  
host\_name server.hostname  
service\_description MySQL check status  
check\_command check-mysql-connections!nagios!nagios-passwd!IPADDRESS!Threads\_connected!/!max\_connections!pct!80!95! #(tried with “!” and without).  
use generic-service  
}

In both cases, the notification in Nagios looks like this: [TABLE=“class: status”]  
[TR]  
[TD=“class: statusBGUNKNOWN, bgcolor: #E2ABDC”] [TABLE]  
[TR]  
[TD=“align: left”] [TABLE]  
[TR]  
[TD=“class: statusBGUNKNOWN, align: left”][MySQL check status](http://nagios/nagios/cgi-bin//extinfo.cgi?type=2&host=bdb-com-2-56.nl.adsmarket.com&service=MySQL+check+status)[/TD]  
[/TR]  
[/TABLE]  
[/TD]  
[TD=“class: statusBGUNKNOWN”] [TABLE]  
[TR]  
[TD=“align: center”][/TD]  
[/TR]  
[/TABLE]  
[/TD]  
[/TR]  
[/TABLE]  
[/TD]  
[TD=“class: statusUNKNOWN, bgcolor: #BF44B2”]UNKNOWN[/TD]  
[TD=“class: statusBGUNKNOWN, bgcolor: #E2ABDC”]06-26-2014 11:14:56[/TD]  
[TD=“class: statusBGUNKNOWN, bgcolor: #E2ABDC”]0d 0h 29m 59s[/TD]  
[TD=“class: statusBGUNKNOWN, bgcolor: #E2ABDC”]4/4[/TD]  
[TD=“class: statusBGUNKNOWN, bgcolor: #E2ABDC, align: center”]Error: -o must be one of: / \* + -. Try --help. [/TD]  
[/TR]  
[/TABLE]

What am I doing wrong?

Thanks alot

Itai

---

<div class="post-metadata">

**Author:** ![weber](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@weber](https://forums.percona.com/u/weber)\
**Post date:** [June 30, 2014, 1:18pm UTC](https://forums.percona.com/t/nagios-how-to-write-properly-the-service-command/3572/2 "2014-06-30T13:18:18Z")

</div>

Your don’t need “!nagios!nagios-passwd!IPADDRESS!Threads\_connected!/!max\_connections!pct!80!95! #(tried with “!” and without).”  
The way you have written this, it’s the arguments to check-mysql-connections command but the actual command has no $ARG1$, $ARG2$ etc. vars.

Change  
check\_command check-mysql-connections!nagios!nagios-passwd!IPADDRESS!Threads\_connected!/!max\_connections!pct!80!95! #(tried with “!” and without).  
to  
check\_command check-mysql-connections

---

<div class="post-metadata">

**Author:** ![camelel](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@camelel](https://forums.percona.com/u/camelel)\
**Post date:** [July 1, 2014, 5:29am UTC](https://forums.percona.com/t/nagios-how-to-write-properly-the-service-command/3572/3 "2014-07-01T05:29:33Z")

</div>

Thanks, found it myself, it works like a charm!
