extended_parse error

28 views
Skip to first unread message

bin li

unread,
Jun 26, 2013, 11:40:56 AM6/26/13
to pynag-...@googlegroups.com
Got the following errro when tried to remove a host with remove_host.py https://github.com/pynag/pynag/blob/master/examples/Parsers/remove_host.py
 
# remove_host.py  nefdev2                                              
Traceback (most recent call last):
  File "/home/bli4/nagios/bin/remove_host.py", line 16, in <module>
    nc.extended_parse()
  File "/usr/lib/python2.6/site-packages/pynag/Parsers/__init__.py", line 1217, in extended_parse
    if host['host_name'] in self._get_active_hosts(service):
  File "/usr/lib/python2.6/site-packages/pynag/Parsers/__init__.py", line 1272, in _get_active_hosts
    if host_name[0] == "!":
IndexError: string index out of range

What could be the issue?

Thanks

Páll Sigurðsson

unread,
Jun 26, 2013, 5:53:15 PM6/26/13
to pynag-...@googlegroups.com
Hmm i see that there are a lot of old and not maintained examples under Parser/ that need to be cleaned up.

If you need example on how to remove a host in python code:
#!/usr/bin/env python
import pynag.Model

my_host = pynag.Model.Host.objects.get_by_shortname('host.example.com')
my_host.delete()


If you simply want to remove a host you can use the pynag command line:

# Remove a host
pynag delete where host_name=host.example.com and object_type=host

# Remove all its services
pynag delete where host_name=host.example.com and object_type=service




--
You received this message because you are subscribed to the Google Groups "pynag-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynag-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

bin li

unread,
Jun 28, 2013, 12:59:41 PM6/28/13
to pynag-...@googlegroups.com
Does this remove the host from all services and hostgroups? I am looking for a a way to remove all references of the host.

Thanks

Páll Sigurðsson

unread,
Jun 28, 2013, 4:11:59 PM6/28/13
to pynag-...@googlegroups.com
Yes. Yes it should.

The python code you see there is a parameter called cleanup_related_items and the default is set to True.

bin li

unread,
Jun 28, 2013, 4:46:53 PM6/28/13
to pynag-...@googlegroups.com
It works great. Thanks
Reply all
Reply to author
Forward
0 new messages