Re: [Nagios-users] Mass delete of host/service downtimes.

2013-02-21 Thread Páll Guðjón Sigurðsson
The posts inspired me to write downtime support in pynag command-line utility. 
Works both via livestatus or more traditional writing directly to nagios 
command pipe.

I dont mean to make this mailing list a pynag announcement one, but considering 
the questions brought i thought others might enjoy the script as well :)


Example usage:

# List downtimes
pynag downtime --list [where host_name='example.com']

# Schedule new downtimes, works for hosts,services,hostgroups,servicegroups
pynag downtime where host_name=localhost 
pynag downtime where hostgroup_name=webservers --comment Scheduled 
maintainance on everything in hostgroup
pynag downtime where service_description__contains='vmware' --comment 'Downtime 
on everything that is vmware'

# Remove a single downtime:
pynag downtime --remove where id=100

# Remove all downtimes matching search filter
pynag downtime --remove where comment=Scheduled Maintainance




- Original Message -
From: Rafał Radecki radecki.ra...@gmail.com
To: Paul Dubuc w...@paul.dubuc.org
Cc: Nagios Users List nagios-users@lists.sourceforge.net
Sent: Thursday, February 21, 2013 2:46:11 PM
Subject: Re: [Nagios-users] Mass delete of host/service downtimes.

Thank you very much. It works very well :)

Best regards,
Rafal Radecki.

2013/2/20 Paul Dubuc w...@paul.dubuc.org:
 � wrote:

 Hi All.

 I currently try to remove many host/service downtimes. I can do this
 one by one but it would be time consuming. Is there a way to remove
 all downtimes at once? Or maybe I should use a special url with some
 variables?
 I've noticed that in  /var/log/nagios/status.dat there are all
 downtimes written but it is generated on nagios start and I think that
 deleting appropriate sections from this file can be dangerous.
 I've tried curl
 'https://server/nagios/cgi-bin/cmd.cgi?cmd_typ=79down_id=2139' but
 with no luck ;)
 Any tips?


 If you have Nagios 3.3.1 or newer there are some undocumented external
 commands that can do this easily. See my previous message here for details:

 https://sourceforge.net/mailarchive/message.php?msg_id=30453206



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Re: [Nagios-users] Mass delete of host/service downtimes.

2013-02-21 Thread Andreas Ericsson
On 02/21/2013 12:16 PM, Páll Guðjón Sigurðsson wrote:
 The posts inspired me to write downtime support in pynag command-line
 utility. Works both via livestatus or more traditional writing
 directly to nagios command pipe.
 

You should avoid writing external commands to livestatus. They get
passed to Nagios from a separate thread and are susceptible to races.
This is true both in Nagios 3 and Nagios 4.

-- 
Andreas Ericsson   andreas.erics...@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null


[Nagios-users] Mass delete of host/service downtimes.

2013-02-20 Thread Rafał Radecki
Hi All.

I currently try to remove many host/service downtimes. I can do this
one by one but it would be time consuming. Is there a way to remove
all downtimes at once? Or maybe I should use a special url with some
variables?
I've noticed that in  /var/log/nagios/status.dat there are all
downtimes written but it is generated on nagios start and I think that
deleting appropriate sections from this file can be dangerous.
I've tried curl
'https://server/nagios/cgi-bin/cmd.cgi?cmd_typ=79down_id=2139' but
with no luck ;)
Any tips?


Best regards,
Rafal Radecki.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null


Re: [Nagios-users] Mass delete of host/service downtimes.

2013-02-20 Thread Páll Guðjón Sigurðsson

If you have pynag installed this script might help you along. It will clear all 
downtimes unless you uncomment some of the filters:

#!/usr/bin/python
 
import pynag.Parsers
import pynag.Control.Command
 
livestatus = pynag.Parsers.mk_livestatus()
 
downtimes = livestatus.query('GET downtimes')
 
for downtime in downtimes:
# Only remove downtime for a specific host
#if downtime['host_name'] != 'nagios.example.com': continue
 
# Only remove downtimes if check belongs to a specific hostgroup
#if 'my_hostgroup' not in downtime['hostgroups']: continue
 
host_name = downtime['host_name']
service_description = downtime['service_description']
downtime_id = downtime['id']
downtime_type = downtime['type']
print Removing downtime for: %-30s %s % ( host_name, 
service_description )
if downtime_type == 1:
# This is a service downtime
pynag.Control.Command.del_svc_downtime(downtime_id)
elif downtime_type == 0:
pynag.Control.Command.del_host_downtime(downtime_id)


Also if you have a recent version of adagios installed you can do more easily 
via web interface. 

Kind regards,
Pall Sigurdsson

- Original Message -
From: Rafał Radecki radecki.ra...@gmail.com
To: nagios-users@lists.sourceforge.net
Sent: Wednesday, February 20, 2013 3:00:39 PM
Subject: [Nagios-users] Mass delete of host/service downtimes.

Hi All.

I currently try to remove many host/service downtimes. I can do this
one by one but it would be time consuming. Is there a way to remove
all downtimes at once? Or maybe I should use a special url with some
variables?
I've noticed that in  /var/log/nagios/status.dat there are all
downtimes written but it is generated on nagios start and I think that
deleting appropriate sections from this file can be dangerous.
I've tried curl
'https://server/nagios/cgi-bin/cmd.cgi?cmd_typ=79down_id=2139' but
with no luck ;)
Any tips?


Best regards,
Rafal Radecki.

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Re: [Nagios-users] Mass delete of host/service downtimes.

2013-02-20 Thread Paul Dubuc
� wrote:
 Hi All.

 I currently try to remove many host/service downtimes. I can do this
 one by one but it would be time consuming. Is there a way to remove
 all downtimes at once? Or maybe I should use a special url with some
 variables?
 I've noticed that in  /var/log/nagios/status.dat there are all
 downtimes written but it is generated on nagios start and I think that
 deleting appropriate sections from this file can be dangerous.
 I've tried curl
 'https://server/nagios/cgi-bin/cmd.cgi?cmd_typ=79down_id=2139' but
 with no luck ;)
 Any tips?

If you have Nagios 3.3.1 or newer there are some undocumented external 
commands that can do this easily. See my previous message here for details:

https://sourceforge.net/mailarchive/message.php?msg_id=30453206



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Re: [Nagios-users] Mass delete of host/service downtimes.

2013-02-20 Thread Rafał Radecki
Thank you very much. It works very well :)

Best regards,
Rafal Radecki.

2013/2/20 Paul Dubuc w...@paul.dubuc.org:
 � wrote:

 Hi All.

 I currently try to remove many host/service downtimes. I can do this
 one by one but it would be time consuming. Is there a way to remove
 all downtimes at once? Or maybe I should use a special url with some
 variables?
 I've noticed that in  /var/log/nagios/status.dat there are all
 downtimes written but it is generated on nagios start and I think that
 deleting appropriate sections from this file can be dangerous.
 I've tried curl
 'https://server/nagios/cgi-bin/cmd.cgi?cmd_typ=79down_id=2139' but
 with no luck ;)
 Any tips?


 If you have Nagios 3.3.1 or newer there are some undocumented external
 commands that can do this easily. See my previous message here for details:

 https://sourceforge.net/mailarchive/message.php?msg_id=30453206



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null