Page 1 of 1

list the comments of a service to remove them

PostPosted: Mon Oct 21, 2019 11:02 am
by gba
Hello,

I'm looking for a bash command to list the comments of a service to list old comments of more than 30 days.
This would allow me to delete them with the following command --> /bin/printf "[%lu] DEL_SVC_COMMENT;1\n" $now > $commandfile


thank you in advance.

(excuse me for my English because I am French)

Gba

Re: list the comments of a service to remove them

PostPosted: Mon Oct 21, 2019 11:51 am
by scottwilkerson
You can get them in JSON with the API
Help -> Objects Reference -> objects/comment

Code: Select all
/nagiosxi/api/v1/objects/comment?apikey=APIKEY&pretty=1&comment_time=gt:2019-09-21

Re: list the comments of a service to remove them

PostPosted: Mon Oct 21, 2019 12:02 pm
by lmiltchev

Re: list the comments of a service to remove them

PostPosted: Tue Oct 22, 2019 2:52 am
by gba
Hello,

I can not exploit this command ; /nagiosxi/api/v1/objects/comment?apikey=APIKEY&pretty=1&comment_time=gt:2019-09-21

For info I use Thruk.

I looked at your lmiltchev link but it does not work at home.

I would like to list the comments from more than 30 days or the last comments based on a service and delete them with the command printf "[% lu] DEL_SVC_COMMENT; 1 \ n" $now > $commandfile

I really can not ..

Thank you

Re: list the comments of a service to remove them

PostPosted: Tue Oct 22, 2019 6:23 am
by scottwilkerson
gba wrote:I can not exploit this command ; /nagiosxi/api/v1/objects/comment?apikey=APIKEY&pretty=1&comment_time=gt:2019-09-21

For info I use Thruk.

You had posted on the NAgios XI group... I moved it to Nagios Core.

If you are using Core you should have the Core JSON CGI and you can get them with a query like the fillowing
Code: Select all
http://xxx.xxx.xxx.xxx/nagios/cgi-bin/statusjson.cgi?query=commentlist&commenttimefield=entrytime&starttime=1569151359&endtime=1571742401


the starttime & endtime are unix timestamps

Re: list the comments of a service to remove them

PostPosted: Tue Oct 22, 2019 10:25 am
by gba
You had posted on the NAgios XI group... I moved it to Nagios Core.


Sorry I made a mistake ! :roll:

statusjson.cgi shows me a page not found


I found the page containing all comments. By cons I can not sorted them with variables in the URL. Maybe that is not possible.



TY !

Re: list the comments of a service to remove them

PostPosted: Tue Oct 22, 2019 10:33 am
by scottwilkerson
Sorry we do not provide support for thruk, just nagios.

The link I posted exists in a nagios installation.

gba wrote:I found the page containing all comments. By cons I can not sorted them with variables in the URL. Maybe that is not possible.

Code: Select all
http://xx.xx.xx.xxx/thruk/#cgi-bin/extinfo.cgi?type=3#SERVICECOMMENTS


Again, not sure as we have no knowledge of Thruk as we are not the authors

Re: list the comments of a service to remove them

PostPosted: Wed Oct 23, 2019 3:39 am
by gba
thanks anyway

Re: list the comments of a service to remove them

PostPosted: Wed Oct 23, 2019 7:35 am
by scottwilkerson
gba wrote:thanks anyway

good luck!