list the comments of a service to remove them

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
gba
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

list the comments of a service to remove them

Post 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
Last edited by gba on Wed Oct 23, 2019 3:40 am, edited 1 time in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: list the comments of a service to remove them

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: list the comments of a service to remove them

Post by lmiltchev »

You can also try this plugin:

https://exchange.nagios.org/directory/A ... ld/details

Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
gba
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: list the comments of a service to remove them

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gba
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Post 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 !
Last edited by gba on Wed Oct 23, 2019 3:39 am, edited 1 time in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: list the comments of a service to remove them

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
gba
Posts: 4
Joined: Mon Oct 21, 2019 9:30 am

Re: list the comments of a service to remove them

Post by gba »

thanks anyway
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: list the comments of a service to remove them

Post by scottwilkerson »

gba wrote:thanks anyway
good luck!
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked