Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ commands[] = {
{ "check", nez_cmd_check },
{ "enable_notifications", nez_cmd_enable_notifications },
{ "disable_notifications", nez_cmd_disable_notifications },
{ "downtime", nez_cmd_schedule_downtime },
{ "downtime", nez_cmd_schedule_fixed_downtime },
{ "flexdowntime", nez_cmd_schedule_flex_downtime },
{ "acknowledge", nez_cmd_acknowledge },
{ "unacknowledge", nez_cmd_unacknowledge },
{ "problems", nez_cmd_problems },
Expand Down
25 changes: 18 additions & 7 deletions src/commands/downtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "downtime.h"

static int
schedule_downtime_for_obj(int sd, host* hst, service* svc, unsigned long minutes, char* comment_data)
schedule_downtime_for_obj(int sd, host* hst, service* svc, unsigned long minutes, char* comment_data, int fixed)
{
if (hst || svc) {
int typedowntime = (svc ? SERVICE_DOWNTIME : HOST_DOWNTIME);
Expand All @@ -16,8 +16,7 @@ schedule_downtime_for_obj(int sd, host* hst, service* svc, unsigned long minutes
time_t entry_time = time(NULL);
char* author = "nagioseasier";
time_t start_time = time(NULL);
time_t end_time = 0L; /* only used for fixed downtime, TODO some other time */
int fixed = 0;
time_t end_time = 0L; /* only used for fixed downtime */
unsigned long triggered_by = 0L; /* assume triggered by no obj in system? */
unsigned long duration = minutes * 60L; /* assuming duration is seconds */
unsigned long downtime_id = 0L;
Expand Down Expand Up @@ -51,7 +50,7 @@ schedule_downtime_for_obj(int sd, host* hst, service* svc, unsigned long minutes
}

int
nez_cmd_schedule_downtime(int sd, char* object, char* rest)
cmd_schedule_downtime(int sd, char* object, char* rest, int fixed)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to make this static if it's not supposed to be exported.

{
unsigned long minutes;
char* comment_data;
Expand All @@ -72,15 +71,15 @@ nez_cmd_schedule_downtime(int sd, char* object, char* rest)
nez_find_host_or_service(object, &hst, &svc);

if (svc) {
schedule_downtime_for_obj(sd, NULL, svc, minutes, comment_data);
schedule_downtime_for_obj(sd, NULL, svc, minutes, comment_data, fixed);
return 200;
}

if (hst) {
schedule_downtime_for_obj(sd, hst, NULL, minutes, comment_data);
schedule_downtime_for_obj(sd, hst, NULL, minutes, comment_data, fixed);

for (servicesmember* svcmem = hst->services; svcmem; svcmem = svcmem->next) {
schedule_downtime_for_obj(sd, NULL, svcmem->service_ptr, minutes, comment_data);
schedule_downtime_for_obj(sd, NULL, svcmem->service_ptr, minutes, comment_data, fixed);
}

return 200;
Expand All @@ -89,3 +88,15 @@ nez_cmd_schedule_downtime(int sd, char* object, char* rest)
nsock_printf_nul(sd, "NO HOST OR SERVICE FOUND FOR: %s", object);
return 404;
}

int
nez_cmd_schedule_flex_downtime(int sd, char* object, char *rest)
{
cmd_schedule_downtime(sd, object, rest, 0);
}

int
nez_cmd_schedule_fixed_downtime(int sd, char* object, char *rest)
{
cmd_schedule_downtime(sd, object, rest, 1);
}
3 changes: 2 additions & 1 deletion src/commands/downtime.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef NEZ_COMMANDS_DOWNTIME_H
#define NEZ_COMMANDS_DOWNTIME_H

int nez_cmd_schedule_downtime(int sd, char* object, char* rest);
int nez_cmd_schedule_fixed_downtime(int sd, char* object, char* rest);
int nez_cmd_schedule_flex_downtime(int sd, char* object, char* rest);

#endif