Reference for Command Numbers

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tantczak
Posts: 3
Joined: Thu Mar 19, 2015 11:35 am

Reference for Command Numbers

Post by tantczak »

Hi,
We've recently stated writing into our deploy scripts for various products a call to curl that disables Nagios alerts on the machine for the services being deployed. It's a really cool and useful thing to add to the scripts, and saves us a bunch of false positive e-mail and text messages. I am aware that most any command you can issue through the website can be issued in this way, but I have been unable to find an resource that lists the command numbers (EG Disable notifications is "cmd_typ=29") that correspond to various actions. In particular, recently, I've wanted to enable and disable an event handler as part of a script and also disable a check all together. While I could probably figure this out by clicking buttons and seeing what the URLs are, it would be really cool to just have a quick reference available for this. Is anyone aware of such a thing?

Trevor
cmerchant
Posts: 546
Joined: Wed Sep 24, 2014 11:19 am

Re: Reference for Command Numbers

Post by cmerchant »

Here is the documentation on the external commands:

http://nagios.sourceforge.net/docs/nagi ... mands.html

More specifically, I did not see a cross-reference to the cmd id's. But you could look at the this of external commands here:

http://old.nagios.org/developerinfo/ext ... ndlist.php

and look at the source of that web page.
tantczak
Posts: 3
Joined: Thu Mar 19, 2015 11:35 am

Re: Reference for Command Numbers

Post by tantczak »

Thanks for the reply. I've seen this and it isn't quite what I want. I possibly should have mentioned thing's that I've hunted up. These "external commands" actually work by sending them through named pipe called nagios.cmd on the Nagios server. Whilst it would not be impossible to have my scripts ssh into the Nagios server and push data through that pipe, it's not ideal at all. For one thing I'd have to either give the nagios user a shell or setup some elaborate sudo scheme to allow access. What I'm talking about is using curl to essentially give commands to the Nagios webserver as through it were just a user who clicked a link. For example, the full text of the command I posted above would be:

curl -d "cmd_typ=29&cmd_mod=2&host=hostname&btnSubmit=Commit" "http://mynagiosserver/thruk/cgi-bin/cmd.cgi" -u "user:Password"

This command would disable all notifications for the host "hostname" on the Nagios server "mynagiosserver". Issuing the same command with cmd_typ=28 turns notifications back on. I pipe the output of this to a file, check for success, then proceed with my deploy. This is fine for some servers. Others we only disable notifications on the specific service we are deploying to. I'd like to be able to turn off event handlers and service checks the same way. Having a reference for all the commands might also give us ideas for other uses
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Reference for Command Numbers

Post by tgriep »

Is this what you are looking for?

Code: Select all

/***************************** COMMANDS *********************************/

#define CMD_NONE			0

#define CMD_ADD_HOST_COMMENT		1
#define CMD_DEL_HOST_COMMENT		2

#define CMD_ADD_SVC_COMMENT		3
#define CMD_DEL_SVC_COMMENT		4

#define CMD_ENABLE_SVC_CHECK		5
#define CMD_DISABLE_SVC_CHECK		6

#define CMD_SCHEDULE_SVC_CHECK		7

#define CMD_DELAY_SVC_NOTIFICATION	9

#define CMD_DELAY_HOST_NOTIFICATION	10

#define CMD_DISABLE_NOTIFICATIONS	11
#define CMD_ENABLE_NOTIFICATIONS	12

#define CMD_RESTART_PROCESS		13
#define CMD_SHUTDOWN_PROCESS		14

#define CMD_ENABLE_HOST_SVC_CHECKS              15
#define CMD_DISABLE_HOST_SVC_CHECKS             16

#define CMD_SCHEDULE_HOST_SVC_CHECKS            17

#define CMD_DELAY_HOST_SVC_NOTIFICATIONS        19  /* currently unimplemented */

#define CMD_DEL_ALL_HOST_COMMENTS               20
#define CMD_DEL_ALL_SVC_COMMENTS                21

#define CMD_ENABLE_SVC_NOTIFICATIONS                    22
#define CMD_DISABLE_SVC_NOTIFICATIONS                   23
#define CMD_ENABLE_HOST_NOTIFICATIONS                   24
#define CMD_DISABLE_HOST_NOTIFICATIONS                  25
#define CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST        26
#define CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST       27
#define CMD_ENABLE_HOST_SVC_NOTIFICATIONS		28
#define CMD_DISABLE_HOST_SVC_NOTIFICATIONS		29

#define CMD_PROCESS_SERVICE_CHECK_RESULT		30

#define CMD_SAVE_STATE_INFORMATION			31
#define CMD_READ_STATE_INFORMATION			32

#define CMD_ACKNOWLEDGE_HOST_PROBLEM			33
#define CMD_ACKNOWLEDGE_SVC_PROBLEM			34

#define CMD_START_EXECUTING_SVC_CHECKS			35
#define CMD_STOP_EXECUTING_SVC_CHECKS			36

#define CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS		37
#define CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS		38

#define CMD_ENABLE_PASSIVE_SVC_CHECKS			39
#define CMD_DISABLE_PASSIVE_SVC_CHECKS			40

#define CMD_ENABLE_EVENT_HANDLERS			41
#define CMD_DISABLE_EVENT_HANDLERS			42

#define CMD_ENABLE_HOST_EVENT_HANDLER			43
#define CMD_DISABLE_HOST_EVENT_HANDLER			44

#define CMD_ENABLE_SVC_EVENT_HANDLER			45
#define CMD_DISABLE_SVC_EVENT_HANDLER			46

#define CMD_ENABLE_HOST_CHECK				47
#define CMD_DISABLE_HOST_CHECK				48

#define CMD_START_OBSESSING_OVER_SVC_CHECKS		49
#define CMD_STOP_OBSESSING_OVER_SVC_CHECKS		50

#define CMD_REMOVE_HOST_ACKNOWLEDGEMENT			51
#define CMD_REMOVE_SVC_ACKNOWLEDGEMENT			52

#define CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS             53
#define CMD_SCHEDULE_FORCED_SVC_CHECK                   54

#define CMD_SCHEDULE_HOST_DOWNTIME                      55
#define CMD_SCHEDULE_SVC_DOWNTIME                       56

#define CMD_ENABLE_HOST_FLAP_DETECTION                  57
#define CMD_DISABLE_HOST_FLAP_DETECTION                 58

#define CMD_ENABLE_SVC_FLAP_DETECTION                   59
#define CMD_DISABLE_SVC_FLAP_DETECTION                  60

#define CMD_ENABLE_FLAP_DETECTION                       61
#define CMD_DISABLE_FLAP_DETECTION                      62

#define CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS          63
#define CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS         64

#define CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS         65
#define CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS        66

#define CMD_ENABLE_HOSTGROUP_SVC_CHECKS                 67
#define CMD_DISABLE_HOSTGROUP_SVC_CHECKS                68

/* commands 69-77 are unimplemented */
#define CMD_UNIMPLEMENTED_69                            69
#define CMD_UNIMPLEMENTED_70                            70
#define CMD_UNIMPLEMENTED_71                            71
#define CMD_UNIMPLEMENTED_72                            72
#define CMD_UNIMPLEMENTED_73                            73
#define CMD_UNIMPLEMENTED_74                            74
#define CMD_UNIMPLEMENTED_75                            75
#define CMD_UNIMPLEMENTED_76                            76
#define CMD_UNIMPLEMENTED_77                            77

#define CMD_DEL_HOST_DOWNTIME                           78
#define CMD_DEL_SVC_DOWNTIME                            79

#define CMD_ENABLE_PERFORMANCE_DATA                     82
#define CMD_DISABLE_PERFORMANCE_DATA                    83

#define CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME            84
#define CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME             85
#define CMD_SCHEDULE_HOST_SVC_DOWNTIME                  86

/* new commands in Nagios 2.x found below... */
#define CMD_PROCESS_HOST_CHECK_RESULT		        87

#define CMD_START_EXECUTING_HOST_CHECKS			88
#define CMD_STOP_EXECUTING_HOST_CHECKS			89

#define CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS		90
#define CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS		91

#define CMD_ENABLE_PASSIVE_HOST_CHECKS			92
#define CMD_DISABLE_PASSIVE_HOST_CHECKS			93

#define CMD_START_OBSESSING_OVER_HOST_CHECKS		94
#define CMD_STOP_OBSESSING_OVER_HOST_CHECKS		95

#define CMD_SCHEDULE_HOST_CHECK		                96
#define CMD_SCHEDULE_FORCED_HOST_CHECK                  98

#define CMD_START_OBSESSING_OVER_SVC		        99
#define CMD_STOP_OBSESSING_OVER_SVC		        100

#define CMD_START_OBSESSING_OVER_HOST		        101
#define CMD_STOP_OBSESSING_OVER_HOST		        102

#define CMD_ENABLE_HOSTGROUP_HOST_CHECKS                103
#define CMD_DISABLE_HOSTGROUP_HOST_CHECKS               104

#define CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS         105
#define CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS        106

#define CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS        107
#define CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS       108

#define CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS       109
#define CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS      110

#define CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS      111
#define CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS     112

#define CMD_ENABLE_SERVICEGROUP_SVC_CHECKS              113
#define CMD_DISABLE_SERVICEGROUP_SVC_CHECKS             114

#define CMD_ENABLE_SERVICEGROUP_HOST_CHECKS             115
#define CMD_DISABLE_SERVICEGROUP_HOST_CHECKS            116

#define CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS      117
#define CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS     118

#define CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS     119
#define CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS    120

#define CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME         121
#define CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME          122

#define CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER            123
#define CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER             124

#define CMD_CHANGE_HOST_EVENT_HANDLER                   125
#define CMD_CHANGE_SVC_EVENT_HANDLER                    126

#define CMD_CHANGE_HOST_CHECK_COMMAND                   127
#define CMD_CHANGE_SVC_CHECK_COMMAND                    128

#define CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL           129
#define CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL            130
#define CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL             131

#define CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS              132
#define CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS               133

#define CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 134

#define CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS         135
#define CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS        136

#define CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME        137

#define CMD_ENABLE_SERVICE_FRESHNESS_CHECKS             138
#define CMD_DISABLE_SERVICE_FRESHNESS_CHECKS            139

#define CMD_ENABLE_HOST_FRESHNESS_CHECKS                140
#define CMD_DISABLE_HOST_FRESHNESS_CHECKS               141

#define CMD_SET_HOST_NOTIFICATION_NUMBER                142
#define CMD_SET_SVC_NOTIFICATION_NUMBER                 143

/* new commands in Nagios 3.x found below... */
#define CMD_CHANGE_HOST_CHECK_TIMEPERIOD                144
#define CMD_CHANGE_SVC_CHECK_TIMEPERIOD                 145

#define CMD_PROCESS_FILE                                146

#define CMD_CHANGE_CUSTOM_HOST_VAR                      147
#define CMD_CHANGE_CUSTOM_SVC_VAR                       148
#define CMD_CHANGE_CUSTOM_CONTACT_VAR                   149

#define CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS           150
#define CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS          151
#define CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS            152
#define CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS           153

#define CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS      154
#define CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS     155
#define CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS       156
#define CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS      157

#define CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL            158

#define CMD_SEND_CUSTOM_HOST_NOTIFICATION               159
#define CMD_SEND_CUSTOM_SVC_NOTIFICATION                160

#define CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD         161
#define CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD          162
#define CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD 163
#define CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD  164

#define CMD_CHANGE_HOST_MODATTR                         165
#define CMD_CHANGE_SVC_MODATTR                          166
#define CMD_CHANGE_CONTACT_MODATTR                      167
#define CMD_CHANGE_CONTACT_MODHATTR                     168
#define CMD_CHANGE_CONTACT_MODSATTR                     169

#define CMD_DEL_DOWNTIME_BY_HOST_NAME                   170
#define CMD_DEL_DOWNTIME_BY_HOSTGROUP_NAME              171
#define CMD_DEL_DOWNTIME_BY_START_TIME_COMMENT          172

/* custom command introduced in Nagios 3.x */
#define CMD_CUSTOM_COMMAND                              999

/**************************** COMMAND ERRORS *****************************/
#define CMD_ERROR_OK 0 /* No errors encountered */
#define CMD_ERROR_UNKNOWN_COMMAND 1 /* Unknown/unsupported command */
#define CMD_ERROR_MALFORMED_COMMAND 2 /* Command malformed/missing timestamp? */
#define CMD_ERROR_INTERNAL_ERROR 3 /* Internal error */
#define CMD_ERROR_FAILURE 4 /* Command routine failed */

Be sure to check out our Knowledgebase for helpful articles and solutions!
tantczak
Posts: 3
Joined: Thu Mar 19, 2015 11:35 am

Re: Reference for Command Numbers

Post by tantczak »

I think that's exactly what I wanted. Thanks!
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Reference for Command Numbers

Post by jdalrymple »

Sounds like your deployment process is pretty cool!

I'm going to go ahead and mark this thread solved and lock it. Please come back if we can help further.
Locked