© Shariff Che'Lah, 123RF.com

© Shariff Che'Lah, 123RF.com

Monitoring daemons with shell tools

Watching the Daemons

Article from ADMIN 01/2010
By
Administrators often write custom monitoring programs to make sure their daemons are providing the intended functionality. But simple shell tools are just as well suited to this task, and not just for systems that are low on resources.

Unix daemons typically go about their work discreetly in the background. The process table, which is output with the ps command, only shows you that these willing helpers have been launched, although in the worst case they could just be hanging around as zombies. Whether or not a daemon is actually working is not something that the process table will tell you. In other words, you need more granular diagnostics. The underlying idea is to write a "sensor" script for each service that performs a tangible check of its individual functionality.

Because almost every program outputs standardized exit codes when it terminates, you can use Unix conventions. 0 stands for error-free processing, whereas 1 indicates some problems were encountered. This value is stored in the $? shell variable, which a shell script evaluates immediately after launching the sensor.

Various programs are suitable for automated, "unmanned" access to the service provided by a given daemon; all of them will run in the shell without a GUI. These programs often provide an option (typically -q) that suppresses output, and this is fine for accessing the exit code. Error logs are obtainable by redirecting the error output to a file or, if available, by setting the corresponding program option.

The only thing left to do is to find the matching client program test the functionality of each service.

Web Servers

To check a web server, you could use wget. The shell script command line for this would be:

wget --spider -q ip-address

The --spider option tells wget to check that the page exists but not to load it. Defining the IP address instead of the hostname avoids a false positive if DNS-based name resolution fails for some reason.

Almost

...
Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • How Upstart boots Ubuntu-based systems
    As a replacement for the legacy System V init, Upstart has abandoned many concepts: Instead of runlevels, Upstart has jobs and events, and its ability to start services in parallel considerably accelerates the boot process. Yet, configuration is almost child's play.
  • Free backup tool for data centers
    Everybody needs backups; if you are looking for an open source program that will back up heterogeneous networks, you should check out Bacula.
  • Dockerizing Legacy Applications
    Sooner or later, you'll want to convert your legacy application to a containerized environment. Docker offers the tools for a smooth and efficient transition.
  • Apache Storm
    We take you through the installation of a Storm cluster and discuss how to create your own topologies.
  • Service Management Facility (SMF) in OpenSolaris
    Linux and OpenSolaris have a number of differences. For example, OpenSolaris uses a version of the legacy System V Init to start and stop system services automatically.
comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=