Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Nagios 4

You're reading from   Learning Nagios 4 For system administrators who want a fast, easily understood introduction to Nagios 4, this is the perfect book. Get to grips with the latest version of this powerful monitoring tool and transform the stability of your whole system.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783288649
Length 400 pages
Edition Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Wojciech Kocjan Wojciech Kocjan
Author Profile Icon Wojciech Kocjan
Wojciech Kocjan
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Learning Nagios 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introducing Nagios 2. Installing Nagios 4 FREE CHAPTER 3. Using the Nagios Web Interface 4. Using the Nagios Plugins 5. Advanced Configuration 6. Notifications and Events 7. Passive Checks and NSCA 8. Monitoring Remote Hosts 9. Monitoring using SNMP 10. Advanced Monitoring 11. Programming Nagios 12. Using the Query Handler Index

Using the core service


The Nagios query handler provides the @core service, which can be used to get and set information about the Nagios process.

For all commands handled by the @core service, the result is a text that ends with the \0 character—to read a response, all we need to do is continue reading until we receive \0, which indicates the end of the response.

It allows you to query information about the queue of scheduled jobs, such as the next active check or background operation to be performed. The command name is squeuestats and the full command to be sent is as follows:

@core squeuestats\0

The result is a string with multiple statistics information in the form of name=value, separated by semicolons—name1=value1;name2=value2;....

For example, to print all information, we can simply use the following code:

#!/usr/bin/env python

import socket, sys, os

nagios_qh = "/var/nagios/rw/nagios.qh"

s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(nagios_qh)

s.sendall("@core...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image