<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki-ext.aps.anl.gov/epics/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MauroGiacchini</id>
	<title>EPICSWIKI - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki-ext.aps.anl.gov/epics/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MauroGiacchini"/>
	<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=Special:Contributions/MauroGiacchini"/>
	<updated>2026-07-12T07:22:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=2841</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=2841"/>
		<updated>2011-12-02T15:02:42Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Save the original Nagios setup and replace it */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on RedHat Enterprise 5 x86 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
Nagios application is provided by rpmforge repository, so you have to install it to configure yum properly. &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install the package, you have to install DAG's GPG key:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional) Verify the package you have downloaded&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NB''' (Security warning): The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the md5sum of the key injection package, and trust Dag, et al., then it should be as safe as your trust of them extends.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point it is possible to install the Nagios application. For the &amp;quot;server side&amp;quot;, you need these following packages:&lt;br /&gt;
::1) '''nagios''': the main application package&lt;br /&gt;
::2) '''nagios-plugins''': provides all the command scripts used by users to define nagios services. In some cases there is also nagios-plugins-all (that's better)&lt;br /&gt;
::3) '''nagios-plugins-nrpe''': provides the check_nrpe script used to communicate with nagios clients and run remote services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins-nrpe''&lt;br /&gt;
&lt;br /&gt;
With that I've installed Nagios 3.2.3 version.&lt;br /&gt;
&lt;br /&gt;
== Nagios: configuration ==&lt;br /&gt;
&lt;br /&gt;
When you install Nagios by yum, all the apache configuration are done by default.&lt;br /&gt;
&lt;br /&gt;
To check the web interface you must define the password for '''nagiosadmin''' user (default nagios administrator). This passsword must be encrypted. you can use '''htpasswd''' command to set that an save in &lt;br /&gt;
&lt;br /&gt;
          ''/etc/nagios/htpasswd.users''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the apache and nagios services &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' service httpd start'' (restart)&lt;br /&gt;
     root&amp;gt;'' service nagios start''&lt;br /&gt;
&lt;br /&gt;
and check the nagios webpage at '''http://localhost.localdomain/nagios''' . If it is all correct, you have to see the authentication popup. When you are in the main page, you can monitor the localhost machine (nagios provides some information about hosts and services); all the services should be OK, but in some case you have to check some permissions/configurations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main configuration file is '''/etc/nagios/nagios.cfg'''&lt;br /&gt;
&lt;br /&gt;
in this file you can configure every feature of nagios. We use most of the default options, the only parameters enabled are:&lt;br /&gt;
&lt;br /&gt;
* enable servers directory: you can define all the servers' cfg files into this directory (cleaner job)&lt;br /&gt;
&lt;br /&gt;
  '''cfg_dir=/etc/nagios/servers'''&lt;br /&gt;
&lt;br /&gt;
:and create the folder:&lt;br /&gt;
&lt;br /&gt;
  # mkdir /etc/nagios/servers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the servers folder you have to define all the hosts you want to monitor. For a correct management, you have to define 2 different files:&lt;br /&gt;
&lt;br /&gt;
* '''HOST.cfg''': define the specifics that nagios uses to monitor the host desired. You must define one file per host!&lt;br /&gt;
* '''groups.cfg''': indicate all the different groups of hosts. It is very useful to manage and monitor a large number of machines&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* File '''''servers/example.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define host{&lt;br /&gt;
        use                     linux-server            &lt;br /&gt;
        host_name               '''example'''&lt;br /&gt;
        alias                   '''example display in web interface'''&lt;br /&gt;
        address                 '''10.6.0.1'''&lt;br /&gt;
        notification_period     '''24x7'''&lt;br /&gt;
        icon_image              '''example.jpg'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''PING'''&lt;br /&gt;
        check_command                   '''check_ping!100.0,20%!500.0,60%'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''SSH'''&lt;br /&gt;
        check_command                   '''check_ssh'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
:in this code:&lt;br /&gt;
::1) '''notification_period''' is defined in /etc/nagios/objects/timeperiods.cfg  --&amp;gt; you can edit this file to add/set different time periods&lt;br /&gt;
::2) '''icon_image''' is situated in '''/usr/share/nagios/images/logos/'''. if you want to add new images you must save them in this place&lt;br /&gt;
::3) '''service_description''' is the service name displayed in the web interface&lt;br /&gt;
::4) '''check_command''' define the command desired and situated in '''/usr/lib/nagios/plugins'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* File '''''servers/groups.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define hostgroup{&lt;br /&gt;
        hostgroup_name  example ; The name of the hostgroup&lt;br /&gt;
        alias           example @ MyLab ; Long name of the group&lt;br /&gt;
        members         localhost, '''example'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You have to define the '''host_name''' used before in '''members''' variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After these changes, verify the configuration files through &lt;br /&gt;
&lt;br /&gt;
 # nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
and then, if there aren't any error, restart the service&lt;br /&gt;
&lt;br /&gt;
 # service nagios restart&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/nagios.log - Nagios log &lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/nagios.conf - Nagios Apache folder files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What you did in the chapters above was a generic Nagios installation/setup.&lt;br /&gt;
&lt;br /&gt;
Going to [http://www.lnl.infn.it/~epics/NAL/LNL/ here]. You will find the nagios plugin to EPICS _and_ a complete tra ball of a nagios configuration. Download the pkugin and save into the&lt;br /&gt;
&lt;br /&gt;
''/usr/lib/nagios/plugins/''&lt;br /&gt;
&lt;br /&gt;
Change the permission to check_caget.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to broadcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
Download the epics.gif image available from the same [http://www.lnl.infn.it/~epics/NAL/LNL/ place] &lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''mv epics,gif /usr/share/nagios/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same [http://www.lnl.infn.it/~epics/NAL/LNL/ place]&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind. Acknowledgments to Maurizio Montis, who made a kickstart script to deploy a RHEL5 box equipped with Nagios ready to use, and, adjust and fix the old notes on FC7 to the new OS: RHEL5.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 15.54, 2 Dec 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1932</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1932"/>
		<updated>2011-12-02T15:02:18Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Now install the EPICS logos images */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on RedHat Enterprise 5 x86 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
Nagios application is provided by rpmforge repository, so you have to install it to configure yum properly. &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install the package, you have to install DAG's GPG key:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional) Verify the package you have downloaded&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NB''' (Security warning): The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the md5sum of the key injection package, and trust Dag, et al., then it should be as safe as your trust of them extends.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point it is possible to install the Nagios application. For the &amp;quot;server side&amp;quot;, you need these following packages:&lt;br /&gt;
::1) '''nagios''': the main application package&lt;br /&gt;
::2) '''nagios-plugins''': provides all the command scripts used by users to define nagios services. In some cases there is also nagios-plugins-all (that's better)&lt;br /&gt;
::3) '''nagios-plugins-nrpe''': provides the check_nrpe script used to communicate with nagios clients and run remote services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins-nrpe''&lt;br /&gt;
&lt;br /&gt;
With that I've installed Nagios 3.2.3 version.&lt;br /&gt;
&lt;br /&gt;
== Nagios: configuration ==&lt;br /&gt;
&lt;br /&gt;
When you install Nagios by yum, all the apache configuration are done by default.&lt;br /&gt;
&lt;br /&gt;
To check the web interface you must define the password for '''nagiosadmin''' user (default nagios administrator). This passsword must be encrypted. you can use '''htpasswd''' command to set that an save in &lt;br /&gt;
&lt;br /&gt;
          ''/etc/nagios/htpasswd.users''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the apache and nagios services &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' service httpd start'' (restart)&lt;br /&gt;
     root&amp;gt;'' service nagios start''&lt;br /&gt;
&lt;br /&gt;
and check the nagios webpage at '''http://localhost.localdomain/nagios''' . If it is all correct, you have to see the authentication popup. When you are in the main page, you can monitor the localhost machine (nagios provides some information about hosts and services); all the services should be OK, but in some case you have to check some permissions/configurations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main configuration file is '''/etc/nagios/nagios.cfg'''&lt;br /&gt;
&lt;br /&gt;
in this file you can configure every feature of nagios. We use most of the default options, the only parameters enabled are:&lt;br /&gt;
&lt;br /&gt;
* enable servers directory: you can define all the servers' cfg files into this directory (cleaner job)&lt;br /&gt;
&lt;br /&gt;
  '''cfg_dir=/etc/nagios/servers'''&lt;br /&gt;
&lt;br /&gt;
:and create the folder:&lt;br /&gt;
&lt;br /&gt;
  # mkdir /etc/nagios/servers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the servers folder you have to define all the hosts you want to monitor. For a correct management, you have to define 2 different files:&lt;br /&gt;
&lt;br /&gt;
* '''HOST.cfg''': define the specifics that nagios uses to monitor the host desired. You must define one file per host!&lt;br /&gt;
* '''groups.cfg''': indicate all the different groups of hosts. It is very useful to manage and monitor a large number of machines&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* File '''''servers/example.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define host{&lt;br /&gt;
        use                     linux-server            &lt;br /&gt;
        host_name               '''example'''&lt;br /&gt;
        alias                   '''example display in web interface'''&lt;br /&gt;
        address                 '''10.6.0.1'''&lt;br /&gt;
        notification_period     '''24x7'''&lt;br /&gt;
        icon_image              '''example.jpg'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''PING'''&lt;br /&gt;
        check_command                   '''check_ping!100.0,20%!500.0,60%'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''SSH'''&lt;br /&gt;
        check_command                   '''check_ssh'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
:in this code:&lt;br /&gt;
::1) '''notification_period''' is defined in /etc/nagios/objects/timeperiods.cfg  --&amp;gt; you can edit this file to add/set different time periods&lt;br /&gt;
::2) '''icon_image''' is situated in '''/usr/share/nagios/images/logos/'''. if you want to add new images you must save them in this place&lt;br /&gt;
::3) '''service_description''' is the service name displayed in the web interface&lt;br /&gt;
::4) '''check_command''' define the command desired and situated in '''/usr/lib/nagios/plugins'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* File '''''servers/groups.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define hostgroup{&lt;br /&gt;
        hostgroup_name  example ; The name of the hostgroup&lt;br /&gt;
        alias           example @ MyLab ; Long name of the group&lt;br /&gt;
        members         localhost, '''example'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You have to define the '''host_name''' used before in '''members''' variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After these changes, verify the configuration files through &lt;br /&gt;
&lt;br /&gt;
 # nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
and then, if there aren't any error, restart the service&lt;br /&gt;
&lt;br /&gt;
 # service nagios restart&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/nagios.log - Nagios log &lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/nagios.conf - Nagios Apache folder files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What you did in the chapters above was a generic Nagios installation/setup.&lt;br /&gt;
&lt;br /&gt;
Going to [http://www.lnl.infn.it/~epics/NAL/LNL/ here]. You will find the nagios plugin to EPICS _and_ a complete tra ball of a nagios configuration. Download the pkugin and save into the&lt;br /&gt;
&lt;br /&gt;
''/usr/lib/nagios/plugins/''&lt;br /&gt;
&lt;br /&gt;
Change the permission to check_caget.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to broadcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
Download the epics.gif image available from the same [http://www.lnl.infn.it/~epics/NAL/LNL/ place] &lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''mv epics,gif /usr/share/nagios/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same [place http://www.lnl.infn.it/~epics/NAL/LNL/]&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind. Acknowledgments to Maurizio Montis, who made a kickstart script to deploy a RHEL5 box equipped with Nagios ready to use, and, adjust and fix the old notes on FC7 to the new OS: RHEL5.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 15.54, 2 Dec 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1931</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1931"/>
		<updated>2011-12-02T15:01:53Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Insert the EPICS Nagios Plugins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on RedHat Enterprise 5 x86 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
Nagios application is provided by rpmforge repository, so you have to install it to configure yum properly. &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install the package, you have to install DAG's GPG key:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional) Verify the package you have downloaded&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NB''' (Security warning): The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the md5sum of the key injection package, and trust Dag, et al., then it should be as safe as your trust of them extends.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point it is possible to install the Nagios application. For the &amp;quot;server side&amp;quot;, you need these following packages:&lt;br /&gt;
::1) '''nagios''': the main application package&lt;br /&gt;
::2) '''nagios-plugins''': provides all the command scripts used by users to define nagios services. In some cases there is also nagios-plugins-all (that's better)&lt;br /&gt;
::3) '''nagios-plugins-nrpe''': provides the check_nrpe script used to communicate with nagios clients and run remote services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins-nrpe''&lt;br /&gt;
&lt;br /&gt;
With that I've installed Nagios 3.2.3 version.&lt;br /&gt;
&lt;br /&gt;
== Nagios: configuration ==&lt;br /&gt;
&lt;br /&gt;
When you install Nagios by yum, all the apache configuration are done by default.&lt;br /&gt;
&lt;br /&gt;
To check the web interface you must define the password for '''nagiosadmin''' user (default nagios administrator). This passsword must be encrypted. you can use '''htpasswd''' command to set that an save in &lt;br /&gt;
&lt;br /&gt;
          ''/etc/nagios/htpasswd.users''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the apache and nagios services &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' service httpd start'' (restart)&lt;br /&gt;
     root&amp;gt;'' service nagios start''&lt;br /&gt;
&lt;br /&gt;
and check the nagios webpage at '''http://localhost.localdomain/nagios''' . If it is all correct, you have to see the authentication popup. When you are in the main page, you can monitor the localhost machine (nagios provides some information about hosts and services); all the services should be OK, but in some case you have to check some permissions/configurations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main configuration file is '''/etc/nagios/nagios.cfg'''&lt;br /&gt;
&lt;br /&gt;
in this file you can configure every feature of nagios. We use most of the default options, the only parameters enabled are:&lt;br /&gt;
&lt;br /&gt;
* enable servers directory: you can define all the servers' cfg files into this directory (cleaner job)&lt;br /&gt;
&lt;br /&gt;
  '''cfg_dir=/etc/nagios/servers'''&lt;br /&gt;
&lt;br /&gt;
:and create the folder:&lt;br /&gt;
&lt;br /&gt;
  # mkdir /etc/nagios/servers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the servers folder you have to define all the hosts you want to monitor. For a correct management, you have to define 2 different files:&lt;br /&gt;
&lt;br /&gt;
* '''HOST.cfg''': define the specifics that nagios uses to monitor the host desired. You must define one file per host!&lt;br /&gt;
* '''groups.cfg''': indicate all the different groups of hosts. It is very useful to manage and monitor a large number of machines&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* File '''''servers/example.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define host{&lt;br /&gt;
        use                     linux-server            &lt;br /&gt;
        host_name               '''example'''&lt;br /&gt;
        alias                   '''example display in web interface'''&lt;br /&gt;
        address                 '''10.6.0.1'''&lt;br /&gt;
        notification_period     '''24x7'''&lt;br /&gt;
        icon_image              '''example.jpg'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''PING'''&lt;br /&gt;
        check_command                   '''check_ping!100.0,20%!500.0,60%'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''SSH'''&lt;br /&gt;
        check_command                   '''check_ssh'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
:in this code:&lt;br /&gt;
::1) '''notification_period''' is defined in /etc/nagios/objects/timeperiods.cfg  --&amp;gt; you can edit this file to add/set different time periods&lt;br /&gt;
::2) '''icon_image''' is situated in '''/usr/share/nagios/images/logos/'''. if you want to add new images you must save them in this place&lt;br /&gt;
::3) '''service_description''' is the service name displayed in the web interface&lt;br /&gt;
::4) '''check_command''' define the command desired and situated in '''/usr/lib/nagios/plugins'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* File '''''servers/groups.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define hostgroup{&lt;br /&gt;
        hostgroup_name  example ; The name of the hostgroup&lt;br /&gt;
        alias           example @ MyLab ; Long name of the group&lt;br /&gt;
        members         localhost, '''example'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You have to define the '''host_name''' used before in '''members''' variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After these changes, verify the configuration files through &lt;br /&gt;
&lt;br /&gt;
 # nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
and then, if there aren't any error, restart the service&lt;br /&gt;
&lt;br /&gt;
 # service nagios restart&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/nagios.log - Nagios log &lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/nagios.conf - Nagios Apache folder files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What you did in the chapters above was a generic Nagios installation/setup.&lt;br /&gt;
&lt;br /&gt;
Going to [http://www.lnl.infn.it/~epics/NAL/LNL/ here]. You will find the nagios plugin to EPICS _and_ a complete tra ball of a nagios configuration. Download the pkugin and save into the&lt;br /&gt;
&lt;br /&gt;
''/usr/lib/nagios/plugins/''&lt;br /&gt;
&lt;br /&gt;
Change the permission to check_caget.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to broadcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
Download the epics.gif image available from the same [place http://www.lnl.infn.it/~epics/NAL/LNL/] &lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''mv epics,gif /usr/share/nagios/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same [place http://www.lnl.infn.it/~epics/NAL/LNL/]&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind. Acknowledgments to Maurizio Montis, who made a kickstart script to deploy a RHEL5 box equipped with Nagios ready to use, and, adjust and fix the old notes on FC7 to the new OS: RHEL5.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 15.54, 2 Dec 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1930</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1930"/>
		<updated>2011-12-02T14:52:54Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Conclusions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on RedHat Enterprise 5 x86 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
Nagios application is provided by rpmforge repository, so you have to install it to configure yum properly. &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install the package, you have to install DAG's GPG key:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional) Verify the package you have downloaded&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NB''' (Security warning): The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the md5sum of the key injection package, and trust Dag, et al., then it should be as safe as your trust of them extends.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point it is possible to install the Nagios application. For the &amp;quot;server side&amp;quot;, you need these following packages:&lt;br /&gt;
::1) '''nagios''': the main application package&lt;br /&gt;
::2) '''nagios-plugins''': provides all the command scripts used by users to define nagios services. In some cases there is also nagios-plugins-all (that's better)&lt;br /&gt;
::3) '''nagios-plugins-nrpe''': provides the check_nrpe script used to communicate with nagios clients and run remote services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins-nrpe''&lt;br /&gt;
&lt;br /&gt;
With that I've installed Nagios 3.2.3 version.&lt;br /&gt;
&lt;br /&gt;
== Nagios: configuration ==&lt;br /&gt;
&lt;br /&gt;
When you install Nagios by yum, all the apache configuration are done by default.&lt;br /&gt;
&lt;br /&gt;
To check the web interface you must define the password for '''nagiosadmin''' user (default nagios administrator). This passsword must be encrypted. you can use '''htpasswd''' command to set that an save in &lt;br /&gt;
&lt;br /&gt;
          ''/etc/nagios/htpasswd.users''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the apache and nagios services &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' service httpd start'' (restart)&lt;br /&gt;
     root&amp;gt;'' service nagios start''&lt;br /&gt;
&lt;br /&gt;
and check the nagios webpage at '''http://localhost.localdomain/nagios''' . If it is all correct, you have to see the authentication popup. When you are in the main page, you can monitor the localhost machine (nagios provides some information about hosts and services); all the services should be OK, but in some case you have to check some permissions/configurations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main configuration file is '''/etc/nagios/nagios.cfg'''&lt;br /&gt;
&lt;br /&gt;
in this file you can configure every feature of nagios. We use most of the default options, the only parameters enabled are:&lt;br /&gt;
&lt;br /&gt;
* enable servers directory: you can define all the servers' cfg files into this directory (cleaner job)&lt;br /&gt;
&lt;br /&gt;
  '''cfg_dir=/etc/nagios/servers'''&lt;br /&gt;
&lt;br /&gt;
:and create the folder:&lt;br /&gt;
&lt;br /&gt;
  # mkdir /etc/nagios/servers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the servers folder you have to define all the hosts you want to monitor. For a correct management, you have to define 2 different files:&lt;br /&gt;
&lt;br /&gt;
* '''HOST.cfg''': define the specifics that nagios uses to monitor the host desired. You must define one file per host!&lt;br /&gt;
* '''groups.cfg''': indicate all the different groups of hosts. It is very useful to manage and monitor a large number of machines&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* File '''''servers/example.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define host{&lt;br /&gt;
        use                     linux-server            &lt;br /&gt;
        host_name               '''example'''&lt;br /&gt;
        alias                   '''example display in web interface'''&lt;br /&gt;
        address                 '''10.6.0.1'''&lt;br /&gt;
        notification_period     '''24x7'''&lt;br /&gt;
        icon_image              '''example.jpg'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''PING'''&lt;br /&gt;
        check_command                   '''check_ping!100.0,20%!500.0,60%'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''SSH'''&lt;br /&gt;
        check_command                   '''check_ssh'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
:in this code:&lt;br /&gt;
::1) '''notification_period''' is defined in /etc/nagios/objects/timeperiods.cfg  --&amp;gt; you can edit this file to add/set different time periods&lt;br /&gt;
::2) '''icon_image''' is situated in '''/usr/share/nagios/images/logos/'''. if you want to add new images you must save them in this place&lt;br /&gt;
::3) '''service_description''' is the service name displayed in the web interface&lt;br /&gt;
::4) '''check_command''' define the command desired and situated in '''/usr/lib/nagios/plugins'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* File '''''servers/groups.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define hostgroup{&lt;br /&gt;
        hostgroup_name  example ; The name of the hostgroup&lt;br /&gt;
        alias           example @ MyLab ; Long name of the group&lt;br /&gt;
        members         localhost, '''example'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You have to define the '''host_name''' used before in '''members''' variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After these changes, verify the configuration files through &lt;br /&gt;
&lt;br /&gt;
 # nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
and then, if there aren't any error, restart the service&lt;br /&gt;
&lt;br /&gt;
 # service nagios restart&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/nagios.log - Nagios log &lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/nagios.conf - Nagios Apache folder files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What you did in the chapters above was a generic Nagios installation/setup.&lt;br /&gt;
&lt;br /&gt;
Going to [here http://www.lnl.infn.it/~epics/NAL/LNL/]. You will find the nagios plugin to EPICS _and_ a complete tra ball of a nagios configuration. Download the pkugin and save into the&lt;br /&gt;
&lt;br /&gt;
''/usr/lib/nagios/plugins/''&lt;br /&gt;
&lt;br /&gt;
Change the permission to check_caget.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to broadcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
Download the epics.gif image available from the same [place http://www.lnl.infn.it/~epics/NAL/LNL/] &lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''mv epics,gif /usr/share/nagios/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same [place http://www.lnl.infn.it/~epics/NAL/LNL/]&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind. Acknowledgments to Maurizio Montis, who made a kickstart script to deploy a RHEL5 box equipped with Nagios ready to use, and, adjust and fix the old notes on FC7 to the new OS: RHEL5.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 15.54, 2 Dec 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1929</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1929"/>
		<updated>2011-12-02T14:48:51Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Insert the EPICS Nagios Plugins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on RedHat Enterprise 5 x86 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
Nagios application is provided by rpmforge repository, so you have to install it to configure yum properly. &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install the package, you have to install DAG's GPG key:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional) Verify the package you have downloaded&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NB''' (Security warning): The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the md5sum of the key injection package, and trust Dag, et al., then it should be as safe as your trust of them extends.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point it is possible to install the Nagios application. For the &amp;quot;server side&amp;quot;, you need these following packages:&lt;br /&gt;
::1) '''nagios''': the main application package&lt;br /&gt;
::2) '''nagios-plugins''': provides all the command scripts used by users to define nagios services. In some cases there is also nagios-plugins-all (that's better)&lt;br /&gt;
::3) '''nagios-plugins-nrpe''': provides the check_nrpe script used to communicate with nagios clients and run remote services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins-nrpe''&lt;br /&gt;
&lt;br /&gt;
With that I've installed Nagios 3.2.3 version.&lt;br /&gt;
&lt;br /&gt;
== Nagios: configuration ==&lt;br /&gt;
&lt;br /&gt;
When you install Nagios by yum, all the apache configuration are done by default.&lt;br /&gt;
&lt;br /&gt;
To check the web interface you must define the password for '''nagiosadmin''' user (default nagios administrator). This passsword must be encrypted. you can use '''htpasswd''' command to set that an save in &lt;br /&gt;
&lt;br /&gt;
          ''/etc/nagios/htpasswd.users''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the apache and nagios services &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' service httpd start'' (restart)&lt;br /&gt;
     root&amp;gt;'' service nagios start''&lt;br /&gt;
&lt;br /&gt;
and check the nagios webpage at '''http://localhost.localdomain/nagios''' . If it is all correct, you have to see the authentication popup. When you are in the main page, you can monitor the localhost machine (nagios provides some information about hosts and services); all the services should be OK, but in some case you have to check some permissions/configurations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main configuration file is '''/etc/nagios/nagios.cfg'''&lt;br /&gt;
&lt;br /&gt;
in this file you can configure every feature of nagios. We use most of the default options, the only parameters enabled are:&lt;br /&gt;
&lt;br /&gt;
* enable servers directory: you can define all the servers' cfg files into this directory (cleaner job)&lt;br /&gt;
&lt;br /&gt;
  '''cfg_dir=/etc/nagios/servers'''&lt;br /&gt;
&lt;br /&gt;
:and create the folder:&lt;br /&gt;
&lt;br /&gt;
  # mkdir /etc/nagios/servers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the servers folder you have to define all the hosts you want to monitor. For a correct management, you have to define 2 different files:&lt;br /&gt;
&lt;br /&gt;
* '''HOST.cfg''': define the specifics that nagios uses to monitor the host desired. You must define one file per host!&lt;br /&gt;
* '''groups.cfg''': indicate all the different groups of hosts. It is very useful to manage and monitor a large number of machines&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* File '''''servers/example.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define host{&lt;br /&gt;
        use                     linux-server            &lt;br /&gt;
        host_name               '''example'''&lt;br /&gt;
        alias                   '''example display in web interface'''&lt;br /&gt;
        address                 '''10.6.0.1'''&lt;br /&gt;
        notification_period     '''24x7'''&lt;br /&gt;
        icon_image              '''example.jpg'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''PING'''&lt;br /&gt;
        check_command                   '''check_ping!100.0,20%!500.0,60%'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''SSH'''&lt;br /&gt;
        check_command                   '''check_ssh'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
:in this code:&lt;br /&gt;
::1) '''notification_period''' is defined in /etc/nagios/objects/timeperiods.cfg  --&amp;gt; you can edit this file to add/set different time periods&lt;br /&gt;
::2) '''icon_image''' is situated in '''/usr/share/nagios/images/logos/'''. if you want to add new images you must save them in this place&lt;br /&gt;
::3) '''service_description''' is the service name displayed in the web interface&lt;br /&gt;
::4) '''check_command''' define the command desired and situated in '''/usr/lib/nagios/plugins'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* File '''''servers/groups.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define hostgroup{&lt;br /&gt;
        hostgroup_name  example ; The name of the hostgroup&lt;br /&gt;
        alias           example @ MyLab ; Long name of the group&lt;br /&gt;
        members         localhost, '''example'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You have to define the '''host_name''' used before in '''members''' variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After these changes, verify the configuration files through &lt;br /&gt;
&lt;br /&gt;
 # nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
and then, if there aren't any error, restart the service&lt;br /&gt;
&lt;br /&gt;
 # service nagios restart&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/nagios.log - Nagios log &lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/nagios.conf - Nagios Apache folder files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What you did in the chapters above was a generic Nagios installation/setup.&lt;br /&gt;
&lt;br /&gt;
Going to [here http://www.lnl.infn.it/~epics/NAL/LNL/]. You will find the nagios plugin to EPICS _and_ a complete tra ball of a nagios configuration. Download the pkugin and save into the&lt;br /&gt;
&lt;br /&gt;
''/usr/lib/nagios/plugins/''&lt;br /&gt;
&lt;br /&gt;
Change the permission to check_caget.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to broadcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
Download the epics.gif image available from the same [place http://www.lnl.infn.it/~epics/NAL/LNL/] &lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''mv epics,gif /usr/share/nagios/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same [place http://www.lnl.infn.it/~epics/NAL/LNL/]&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 21:34, 30 Nov 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1928</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1928"/>
		<updated>2011-12-02T14:46:09Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Here's how to install NAL using yum on RHEL 5 x86 Linux box */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on RedHat Enterprise 5 x86 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
Nagios application is provided by rpmforge repository, so you have to install it to configure yum properly. &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To install the package, you have to install DAG's GPG key:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(Optional) Verify the package you have downloaded&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;''  rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm ''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NB''' (Security warning): The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the md5sum of the key injection package, and trust Dag, et al., then it should be as safe as your trust of them extends.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install the package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point it is possible to install the Nagios application. For the &amp;quot;server side&amp;quot;, you need these following packages:&lt;br /&gt;
::1) '''nagios''': the main application package&lt;br /&gt;
::2) '''nagios-plugins''': provides all the command scripts used by users to define nagios services. In some cases there is also nagios-plugins-all (that's better)&lt;br /&gt;
::3) '''nagios-plugins-nrpe''': provides the check_nrpe script used to communicate with nagios clients and run remote services&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins''&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum install -y nagios-plugins-nrpe''&lt;br /&gt;
&lt;br /&gt;
With that I've installed Nagios 3.2.3 version.&lt;br /&gt;
&lt;br /&gt;
== Nagios: configuration ==&lt;br /&gt;
&lt;br /&gt;
When you install Nagios by yum, all the apache configuration are done by default.&lt;br /&gt;
&lt;br /&gt;
To check the web interface you must define the password for '''nagiosadmin''' user (default nagios administrator). This passsword must be encrypted. you can use '''htpasswd''' command to set that an save in &lt;br /&gt;
&lt;br /&gt;
          ''/etc/nagios/htpasswd.users''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start the apache and nagios services &lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' service httpd start'' (restart)&lt;br /&gt;
     root&amp;gt;'' service nagios start''&lt;br /&gt;
&lt;br /&gt;
and check the nagios webpage at '''http://localhost.localdomain/nagios''' . If it is all correct, you have to see the authentication popup. When you are in the main page, you can monitor the localhost machine (nagios provides some information about hosts and services); all the services should be OK, but in some case you have to check some permissions/configurations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main configuration file is '''/etc/nagios/nagios.cfg'''&lt;br /&gt;
&lt;br /&gt;
in this file you can configure every feature of nagios. We use most of the default options, the only parameters enabled are:&lt;br /&gt;
&lt;br /&gt;
* enable servers directory: you can define all the servers' cfg files into this directory (cleaner job)&lt;br /&gt;
&lt;br /&gt;
  '''cfg_dir=/etc/nagios/servers'''&lt;br /&gt;
&lt;br /&gt;
:and create the folder:&lt;br /&gt;
&lt;br /&gt;
  # mkdir /etc/nagios/servers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the servers folder you have to define all the hosts you want to monitor. For a correct management, you have to define 2 different files:&lt;br /&gt;
&lt;br /&gt;
* '''HOST.cfg''': define the specifics that nagios uses to monitor the host desired. You must define one file per host!&lt;br /&gt;
* '''groups.cfg''': indicate all the different groups of hosts. It is very useful to manage and monitor a large number of machines&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
* File '''''servers/example.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define host{&lt;br /&gt;
        use                     linux-server            &lt;br /&gt;
        host_name               '''example'''&lt;br /&gt;
        alias                   '''example display in web interface'''&lt;br /&gt;
        address                 '''10.6.0.1'''&lt;br /&gt;
        notification_period     '''24x7'''&lt;br /&gt;
        icon_image              '''example.jpg'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''PING'''&lt;br /&gt;
        check_command                   '''check_ping!100.0,20%!500.0,60%'''&lt;br /&gt;
        }&lt;br /&gt;
 define service{&lt;br /&gt;
        use                             local-service   &lt;br /&gt;
        host_name                       example&lt;br /&gt;
        service_description             '''SSH'''&lt;br /&gt;
        check_command                   '''check_ssh'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
:in this code:&lt;br /&gt;
::1) '''notification_period''' is defined in /etc/nagios/objects/timeperiods.cfg  --&amp;gt; you can edit this file to add/set different time periods&lt;br /&gt;
::2) '''icon_image''' is situated in '''/usr/share/nagios/images/logos/'''. if you want to add new images you must save them in this place&lt;br /&gt;
::3) '''service_description''' is the service name displayed in the web interface&lt;br /&gt;
::4) '''check_command''' define the command desired and situated in '''/usr/lib/nagios/plugins'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* File '''''servers/groups.cfg''''':&lt;br /&gt;
&lt;br /&gt;
 define hostgroup{&lt;br /&gt;
        hostgroup_name  example ; The name of the hostgroup&lt;br /&gt;
        alias           example @ MyLab ; Long name of the group&lt;br /&gt;
        members         localhost, '''example'''&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You have to define the '''host_name''' used before in '''members''' variable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After these changes, verify the configuration files through &lt;br /&gt;
&lt;br /&gt;
 # nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
and then, if there aren't any error, restart the service&lt;br /&gt;
&lt;br /&gt;
 # service nagios restart&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/nagios.log - Nagios log &lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/nagios.conf - Nagios Apache folder files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to [here http://www.lnl.infn.it/~epics/NAL/LNL/]. You will find the nagios plugin to EPICS _and_ a complete tra ball of a nagios configuration. Download the pkugin and save into the&lt;br /&gt;
&lt;br /&gt;
''/usr/lib/nagios/plugins/''&lt;br /&gt;
&lt;br /&gt;
Change the permission to check_caget.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to broadcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
Download the epics.gif image available from the same [place http://www.lnl.infn.it/~epics/NAL/LNL/] &lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''mv epics,gif /usr/share/nagios/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same [place http://www.lnl.infn.it/~epics/NAL/LNL/]&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 21:34, 30 Nov 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1927</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1927"/>
		<updated>2011-11-30T20:42:13Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Conclusions */  site link update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found [http://www.lnl.infn.it/~epics/joomla/nal.html here].&lt;br /&gt;
A special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use [http://www.lnl.infn.it/~epics/LivEPICS/Slackware/Slax6.0/ here] .&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 21:34, 30 Nov 2011 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1926</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1926"/>
		<updated>2007-11-24T10:28:44Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Conclusions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 23 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1460</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1460"/>
		<updated>2007-11-24T09:05:35Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* NAGIOS as a Linux service */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
NB. If you are using my etc.nagios.tar the passwd to login is &amp;quot;nagiosadmin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1459</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1459"/>
		<updated>2007-11-24T09:02:56Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
===SELinux setup===&lt;br /&gt;
&lt;br /&gt;
For the first test: set it permissive by  &lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''system-config-securitylevel''&lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1458</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1458"/>
		<updated>2007-11-24T07:27:57Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* See my nagios screen shots in action: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Status Map&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosStatusMap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=File:NagiosStatusMap.jpg&amp;diff=2844</id>
		<title>File:NagiosStatusMap.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=File:NagiosStatusMap.jpg&amp;diff=2844"/>
		<updated>2007-11-24T07:26:26Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: NagiosStatusMap&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NagiosStatusMap&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1457</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1457"/>
		<updated>2007-11-17T06:07:13Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Save the original Nagios setup and replace it */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements. You will find an epicsExample.cfg which contains a pre-setted PV names, please adjust that to meet the yours.&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1456</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1456"/>
		<updated>2007-11-17T06:04:13Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Insert the EPICS Nagios Plugins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1455</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1455"/>
		<updated>2007-11-17T06:03:39Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Insert the EPICS Nagios Plugins */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Note: After the version 1.3 the plugin assume the presence of caget into the /usr/bin if that is not true to your site please fix it making a symbolic link like (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1454</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1454"/>
		<updated>2007-11-17T06:00:51Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* The Plugin Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 17-11-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# CAGET LOCATION&lt;br /&gt;
# This option determines where the caget executable is located.&lt;br /&gt;
# The default /usr/bin/caget should be made with a symbolic link&lt;br /&gt;
# made by root (i.e.): ln -s /opt/epics/base-3.14.9/bin/linux-x86/caget /usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_LOCATION=/usr/bin/caget&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget_dev_gw [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the caget presence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type $CAGET_LOCATION &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn? _or_ caget not found!)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
CAGET_REPLY=`$CAGET_LOCATION -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1453</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1453"/>
		<updated>2007-11-16T15:42:21Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
    AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
    AuthType Basic&lt;br /&gt;
    AuthUserFile /etc/nagios/passwd&lt;br /&gt;
    require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 25-08-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the EPICS_BASE variable, and caget presence.&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type caget &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn?)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1452</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1452"/>
		<updated>2007-11-16T14:39:18Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Now install the EPICS logos images */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
download the epics.logo.images.tar available from the same place in http://www.nagiosexchange.org that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
and install that:&lt;br /&gt;
&lt;br /&gt;
    root&amp;gt; ''tar -xvf epics.logo.images.tar''&lt;br /&gt;
    root&amp;gt; ''mv EPICSlogo* /usr/share/nagios/html/images/logos/''&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 25-08-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the EPICS_BASE variable, and caget presence.&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type caget &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn?)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1451</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1451"/>
		<updated>2007-11-16T14:23:11Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
Using the EPICS follows variables you should avoid to bradcast the network, for me the variblese were:&lt;br /&gt;
&lt;br /&gt;
     EPICS_CA_AUTO_ADDR_LIST=NO&lt;br /&gt;
     EPICS_CA_ADDR_LIST=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
therefore may I test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 127.0.0.1''&lt;br /&gt;
     &amp;gt; ''STATE_OK: giacchinHost:aiExample 5 2007-11-16 15:23:18.560231  ; te: 0 sec.''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar available at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 25-08-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the EPICS_BASE variable, and caget presence.&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type caget &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn?)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1450</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1450"/>
		<updated>2007-11-16T05:58:01Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This is a Wiki: Please add or correct things as you find them wrong, misleading or out-of date.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everything is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar available at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself. There is a cool Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607 which give you the possibility to continuous monitoring the PVs during the regular usage of the browser.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS version (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 25-08-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the EPICS_BASE variable, and caget presence.&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type caget &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn?)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1449</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1449"/>
		<updated>2007-11-16T05:48:55Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everything is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar available at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself (i.e. a Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607).&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 06:40, 16 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 25-08-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the EPICS_BASE variable, and caget presence.&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type caget &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn?)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1448</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1448"/>
		<updated>2007-11-16T05:45:48Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recommended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; button, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everything is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar available at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favorite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screen shots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Service Details&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nagios Alert Histogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Conclusions ==&lt;br /&gt;
&lt;br /&gt;
There are a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself (i.e. a Firefox plugin https://addons.mozilla.org/it/firefox/addon/3607).&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great acknowledgments to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be found at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someone is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 00:40, 15 Nov 2007 (CST)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== The Plugin Script ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/lib/nagios/plugins/check_caget_dev_gw.sh&amp;lt;/tt&amp;gt;   script for Nagios&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
##                           Nagios plugin to check EPICS PV Status                ##&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#####################################################################################&lt;br /&gt;
#&lt;br /&gt;
# Script to retrieve EPICS PV Name status using the &amp;quot;caget&amp;quot; command.&lt;br /&gt;
# Written by Mauro Giacchini (mauro.giacchini@lnl.infn.it)&lt;br /&gt;
# Last Modified: 25-08-2007&lt;br /&gt;
#&lt;br /&gt;
# Usage: ./check_caget.sh -pv &amp;lt;PV name&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Description:&lt;br /&gt;
#   	This script uses caget command to retrieve the PV status. &lt;br /&gt;
#&lt;br /&gt;
# Limitations:&lt;br /&gt;
# 	This script has been tested on Linux Fedora Core 6.&lt;br /&gt;
#&lt;br /&gt;
# Output:&lt;br /&gt;
# 	The output contains the &amp;quot;te&amp;quot; time elapsed calculated like a difference from PV's&lt;br /&gt;
# timestamp and the linux &amp;quot;date&amp;quot; command (suggestion: use ntp common server&lt;br /&gt;
# to IOCs and Nagios server box). The STATUS of the service (..of the PV)&lt;br /&gt;
# follow the severity rules:&lt;br /&gt;
#&lt;br /&gt;
# Severity (none) &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_OK		# OK = green&lt;br /&gt;
#&lt;br /&gt;
# Severity MINOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_WARNING	# WARNING = yellow&lt;br /&gt;
#&lt;br /&gt;
# Severity MAJOR  &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_CRITICAL	# CRITICAL = red&lt;br /&gt;
#&lt;br /&gt;
# PV not found    &amp;gt;&amp;gt;&amp;gt;&amp;gt; STATE_UNKNOWN	# UNKNOWNN = orange&lt;br /&gt;
#&lt;br /&gt;
# In case of Severity (none) it show the stdout of &amp;quot;caget -a&amp;quot; with appended the &amp;quot;te&amp;quot;.&lt;br /&gt;
#&lt;br /&gt;
# Other notes:&lt;br /&gt;
#  Firefox Plugin : A FireFox extension is avilable to monitor Nagios server.&lt;br /&gt;
#  https://addons.mozilla.org/it/firefox/addon/3607&lt;br /&gt;
#&lt;br /&gt;
# Nagios configuration setup: &lt;br /&gt;
# 	You need to add the command to commands.cfg&lt;br /&gt;
# &lt;br /&gt;
# define command{&lt;br /&gt;
# 	command_name	check_caget&lt;br /&gt;
# 	command_line	$USER1$/check_caget.sh -pv $ARG1$&lt;br /&gt;
# 	}&lt;br /&gt;
#&lt;br /&gt;
#	And, you need to add the service to services.cfg&lt;br /&gt;
#&lt;br /&gt;
# define service{&lt;br /&gt;
#        use         		generic-service	;&lt;br /&gt;
#        host_name		IOC_Example	;&lt;br /&gt;
#        service_description   	aiExample	;&lt;br /&gt;
#        is_volatile           	0		;&lt;br /&gt;
#        check_period		24x7		;&lt;br /&gt;
#        max_check_attempts    	3		;&lt;br /&gt;
#        normal_check_interval 	3		;&lt;br /&gt;
#        retry_check_interval  	1		;&lt;br /&gt;
#        contact_groups        	admins		;&lt;br /&gt;
#        notification_interval 	120		;&lt;br /&gt;
#        notification_period   	24x7		;&lt;br /&gt;
#        notification_options  	w,u,c,r		;&lt;br /&gt;
#        check_command         	check_caget!rootHost:aiExample	;&lt;br /&gt;
#        }&lt;br /&gt;
#&lt;br /&gt;
# then place this script in the /usr/lib/nagios/plugins/ on the Nagios box server.&lt;br /&gt;
# Don't forget to set the right execution permission to this file.&lt;br /&gt;
#&lt;br /&gt;
# Threshold and ranges: please, have a look at:&lt;br /&gt;
# http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT&lt;br /&gt;
#&lt;br /&gt;
# Last: This script still needs debugging and fixups (exercise for reader) :-)&lt;br /&gt;
#&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# DEBUGGING OPTION&lt;br /&gt;
# This option determines whether or not debugging messages are showed &lt;br /&gt;
# Values: 0=debugging off, 1=debugging on&lt;br /&gt;
&lt;br /&gt;
DEBUG=&amp;quot;0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Script exit status&lt;br /&gt;
&lt;br /&gt;
STATE_OK=0		# OK = green&lt;br /&gt;
&lt;br /&gt;
STATE_WARNING=1		# WARNING = yellow&lt;br /&gt;
&lt;br /&gt;
STATE_CRITICAL=2	# CRITICAL = red&lt;br /&gt;
&lt;br /&gt;
STATE_UNKNOWN=3  	# UNKNOWNN = orange&lt;br /&gt;
&lt;br /&gt;
VERSION=&amp;quot;v1.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_revision() function&lt;br /&gt;
&lt;br /&gt;
print_revision (){&lt;br /&gt;
    &lt;br /&gt;
    echo &amp;quot;Check_caget (nagios-plugins 1.4 to nagios 2.9) (EPICS base 3.14.9) $VERSION&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_usage() function&lt;br /&gt;
&lt;br /&gt;
print_usage() {&lt;br /&gt;
&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; &amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -H &amp;lt;EPICS_CA_ADDR_LIST&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -p &amp;lt;EPICS_CA_SERVER_PORT&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget -pv &amp;lt;PV name&amp;gt; -expval &amp;lt;EXPECTED VALUE&amp;gt;&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-h] [--help]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;Usage: check_caget [-V]&amp;quot;&lt;br /&gt;
    	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# print_help() function&lt;br /&gt;
&lt;br /&gt;
print_help() {&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Script to retrieve the PV status for EPICS control systems.&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;This plugin not developped by the Nagios Plugin group.&amp;quot;&lt;br /&gt;
	echo &amp;quot;Please do not e-mail them for support on this plugin, since&amp;quot;&lt;br /&gt;
	echo &amp;quot;they won't know what you're talking about :P&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;For contact info: mauro.giacchini@lnl.infn.it&amp;quot;&lt;br /&gt;
	echo &amp;quot;Download : http://www.lnl.infn.it/~epics/&amp;quot;&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Check the EPICS_BASE variable, and caget presence.&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence() {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ! type caget &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then&lt;br /&gt;
&lt;br /&gt;
	echo &amp;quot;STATUS CRITICAL: caget not found (Did you set up the rigth one Nagios USERn?)&amp;quot;&lt;br /&gt;
	exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Control caget plugin input parameters&lt;br /&gt;
&lt;br /&gt;
EXPVAL=&amp;quot;&amp;quot;&lt;br /&gt;
EPICS_CA_ADDR_LIST=&amp;quot;&amp;quot; 	# Default YES&lt;br /&gt;
EPICS_CA_SERVER_PORT=&amp;quot;&amp;quot; # Default 5064 _and_  	value &amp;gt; 5000&lt;br /&gt;
EPICS_CA_SERVER_PORT_MIN=&amp;quot;5000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
while test -n &amp;quot;$1&amp;quot;; do&lt;br /&gt;
&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in&lt;br /&gt;
&lt;br /&gt;
	--help)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-h)&lt;br /&gt;
	print_help&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-V)&lt;br /&gt;
	print_revision&lt;br /&gt;
	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-pv)&lt;br /&gt;
	PVNAME=$2&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-expval)&lt;br /&gt;
	EXPVAL=$2&lt;br /&gt;
	if [ -z $EXPVAL ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected value absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-H)&lt;br /&gt;
	EPICS_CA_ADDR_LIST=$2&lt;br /&gt;
	if [ -z $EPICS_CA_ADDR_LIST ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_ADDR_LIST absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_ADDR_LIST&lt;br /&gt;
	EPICS_CA_AUTO_ADDR_LIST=&amp;quot;NO&amp;quot;&lt;br /&gt;
	export EPICS_CA_AUTO_ADDR_LIST&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	-p)&lt;br /&gt;
	EPICS_CA_SERVER_PORT=$2&lt;br /&gt;
	if [ -z $EPICS_CA_SERVER_PORT ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT absent&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	if [ $EPICS_CA_SERVER_PORT -le $EPICS_CA_SERVER_PORT_MIN ]; then&lt;br /&gt;
  	  	echo &amp;quot;STATUS CRITICAL: Expected EPICS_CA_SERVER_PORT minor than allowed (5001)&amp;quot;&lt;br /&gt;
   	 	exit $STATE_CRITICAL&lt;br /&gt;
	fi&lt;br /&gt;
	export EPICS_CA_SERVER_PORT&lt;br /&gt;
	shift&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;&amp;quot;&lt;br /&gt;
	echo &amp;quot;Unknow argument: $1&amp;quot;&lt;br /&gt;
	print_usage&lt;br /&gt;
	exit $STATE_UNKNOWN&lt;br /&gt;
	;;&lt;br /&gt;
 &lt;br /&gt;
esac&lt;br /&gt;
shift&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
verify_caget_presence&lt;br /&gt;
&lt;br /&gt;
if [ -z $PVNAME ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATUS CRITICAL: PV Name not specified&amp;quot;&lt;br /&gt;
    exit $STATE_CRITICAL&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# FINALLY... RETRIEVING THE VALUES (caget)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CAGET_REPLY=`caget -a $PVNAME`&lt;br /&gt;
&lt;br /&gt;
IFS=&amp;quot; &amp;quot;&lt;br /&gt;
read pvname date time value status severity&amp;lt;&amp;lt;END&lt;br /&gt;
$CAGET_REPLY&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
if [ -z $pvname ]; then&lt;br /&gt;
&lt;br /&gt;
    echo &amp;quot;STATE_UNKNOWN: $PVNAME not found&amp;quot;&lt;br /&gt;
    exit $STATE_UNKNOWN&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Calculus difference between the PV timestamp and the actual time&lt;br /&gt;
&lt;br /&gt;
	SPACE=&amp;quot; &amp;quot;&lt;br /&gt;
	dte1=$(date --date &amp;quot;$date$SPACE$time&amp;quot; +%s)&lt;br /&gt;
    	dte2=$(date +%s)&lt;br /&gt;
    	diffSec=$((dte2-dte1))&lt;br /&gt;
    	if ((diffSec &amp;lt; 0)); then abs=-1; else abs=1; fi&lt;br /&gt;
	te=$((diffSec/abs))&lt;br /&gt;
#    	echo &amp;quot;Time elapsed (sec.): $te&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using an expected value&lt;br /&gt;
&lt;br /&gt;
if [ $EXPVAL ]; then&lt;br /&gt;
&lt;br /&gt;
		if  [[ $value -eq $EXPVAL ]] ;&lt;br /&gt;
			then echo &amp;quot;STATE_OK: Expected value ($EXPVAL) to $pvname match; te: $te sec.&amp;quot;&lt;br /&gt;
			exit $STATE_OK;&lt;br /&gt;
			else  echo &amp;quot;STATUS CRITICAL: Expected value ($EXPVAL) to $pvname didn't match&amp;quot;&lt;br /&gt;
			exit $STATE_CRITICAL; &lt;br /&gt;
		fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#####################################################################################&lt;br /&gt;
# Output the NAGIOS status using the Severity field&lt;br /&gt;
case $severity in&lt;br /&gt;
&lt;br /&gt;
	MAJOR)&lt;br /&gt;
    	echo &amp;quot;STATUS CRITICAL: $pvname in MAJOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_CRITICAL&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	MINOR)&lt;br /&gt;
    	echo &amp;quot;STATE_WARNING: $pvname in MINOR severity status; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_WARNING&lt;br /&gt;
	;;&lt;br /&gt;
&lt;br /&gt;
	*)&lt;br /&gt;
	echo &amp;quot;STATE_OK: $pvname $value $date $time $status ; te: $te sec.&amp;quot;&lt;br /&gt;
    	exit $STATE_OK&lt;br /&gt;
	;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1447</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1447"/>
		<updated>2007-11-15T07:18:01Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Now install the EPICS logos images===&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screenshots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be keeped at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 00:40, 15 Nov 2007 (CST)&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1446</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1446"/>
		<updated>2007-11-15T07:16:53Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios default installation===&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Nagios Default Folder Locations===&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Insert the EPICS Nagios Plugins===&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Now install the EPICS logos images'''&lt;br /&gt;
&lt;br /&gt;
     &amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save the original Nagios setup and replace it===&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===NAGIOS check configuration file===&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===HTTPD configuration===&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===NAGIOS as a Linux service===&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
     root&amp;gt; ''service httpd restart''&lt;br /&gt;
     root&amp;gt; ''service Nagios stop''&lt;br /&gt;
     root&amp;gt; ''service Nagios start''&lt;br /&gt;
     root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See my nagios screenshots in action:===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
More information about NAL could be keeped at : http://www.lnl.infn.it/~epics/NAL.html&lt;br /&gt;
You should find there a special LivEPICS (Linux Live CD EPICS fully equipped) with NAGIOS pre-setted and ready to use.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[mailto:Mauro.Giacchini_at_lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 00:40, 15 Nov 2007 (CST)&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1445</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1445"/>
		<updated>2007-11-15T06:53:12Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios default installation'''&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last &lt;br /&gt;
stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios Default Folder Locations'''&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Insert the EPICS Nagios Plugins'''&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Now install the EPICS logos images'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save the original Nagios setup and replace it'''&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NAGIOS check configuration file'''&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''HTTPD configuration'''&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into &lt;br /&gt;
/usr/lib/nagios/cgi-bin/ &lt;br /&gt;
and &lt;br /&gt;
/usr/share/nagios/html/&lt;br /&gt;
&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''NAGIOS as a Linux service'''&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''service httpd restart''&lt;br /&gt;
root&amp;gt; ''service Nagios stop''&lt;br /&gt;
root&amp;gt; ''service Nagios start''&lt;br /&gt;
root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''See my nagios screenshots in action:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 00:40, 15 Nov 2007 (CST)&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1444</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1444"/>
		<updated>2007-11-15T06:50:32Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios default installation'''&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
root&amp;gt;'' yum -y install nagios''&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios Default Folder Locations'''&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Insert the EPICS Nagios Plugins'''&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;Nagios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''./check_caget_dev_gw.sh --help''&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''camonitor giacchinHost:aiExample&lt;br /&gt;
''&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''ifconfig''&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47''&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Now install the EPICS logos images'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ''cd /usr/share/nagios/html/images/logos''&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save the original Nagios setup and replace it'''&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''tar cvf nagios.or.tar ./nagios/''&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''tar xvf  ./etc.nagios.tar''&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NAGIOS check configuration file'''&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
''&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''HTTPD configuration'''&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into /usr/lib/nagios/cgi-bin/ and /usr/share/nagios/html/&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
''&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''NAGIOS as a Linux service'''&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
root&amp;gt; ''service httpd restart''&lt;br /&gt;
root&amp;gt; ''service Nagios stop''&lt;br /&gt;
root&amp;gt; ''service Nagios start''&lt;br /&gt;
root&amp;gt; ''service Nagios status''&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''See my nagios screenshots in action:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 00:40, 15 Nov 2007 (CST)&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1443</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1443"/>
		<updated>2007-11-15T06:40:58Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Here's how to install NAL using yum on Fedora Core 7 Linux box ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios default installation'''&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
# yum -y install nagios&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
# yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios Default Folder Locations'''&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Insert the EPICS Nagios Plugins'''&lt;br /&gt;
&lt;br /&gt;
Going to http://www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;NAgios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
&amp;gt; chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh --help&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
&amp;gt; camonitor giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
#ifconfig&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Now install the EPICS logos images'''&lt;br /&gt;
&lt;br /&gt;
# cd /usr/share/nagios/html/images/logos&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save the original Nagios setup and replace it'''&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
# tar cvf nagios.or.tar ./nagios/&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
# tar xvf  ./etc.nagios.tar&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NAGIOS check configuration file'''&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
# nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''HTTPD configuration'''&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into /usr/lib/nagios/cgi-bin/ and /usr/share/nagios/html/&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
#htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NAGIOS as a Linux service'''&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
# service httpd restart&lt;br /&gt;
# service Nagios stop&lt;br /&gt;
# service Nagios start&lt;br /&gt;
# service Nagios status&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See my nagios screenshots in action:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosServicesDetail.jpg]]&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
[[Image:NagiosAlertHistogram.jpg]]&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:MauroGiacchini|MauroGiacchini]] 00:40, 15 Nov 2007 (CST)&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=File:NagiosServicesDetail.jpg&amp;diff=2843</id>
		<title>File:NagiosServicesDetail.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=File:NagiosServicesDetail.jpg&amp;diff=2843"/>
		<updated>2007-11-15T06:37:08Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: NagiosServiceDetails&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NagiosServiceDetails&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=File:NagiosAlertHistogram.jpg&amp;diff=2842</id>
		<title>File:NagiosAlertHistogram.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=File:NagiosAlertHistogram.jpg&amp;diff=2842"/>
		<updated>2007-11-15T06:31:54Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: NagiosAlertHistogram&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NagiosAlertHistogram&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1442</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1442"/>
		<updated>2007-11-15T06:23:31Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(HOWTO install and setup NAL on Fedora Core 7)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here's how to install NAL using yum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAGIOS INSTALLATION&lt;br /&gt;
'''Nagios default installation'''&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
# yum -y install nagios&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
# yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Nagios Default Folder Locations'''&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Insert the EPICS Nagios Plugins'''&lt;br /&gt;
&lt;br /&gt;
Going to www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;NAgios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
&amp;gt; chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh --help&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
&amp;gt; camonitor giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
#ifconfig&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Now install the EPICS logos images'''&lt;br /&gt;
&lt;br /&gt;
# cd /usr/share/nagios/html/images/logos&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Save the original Nagios setup and replace it'''&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
# tar cvf nagios.or.tar ./nagios/&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
# tar xvf  ./etc.nagios.tar&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NAGIOS check configuration file'''&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
# nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''HTTPD configuration'''&lt;br /&gt;
&lt;br /&gt;
====================&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into /usr/lib/nagios/cgi-bin/ and /usr/share/nagios/html/&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
#htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAGIOS as a Linux service&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
# service httpd restart&lt;br /&gt;
# service Nagios stop&lt;br /&gt;
# service Nagios start&lt;br /&gt;
# service Nagios status&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See my nagios screenshots in action:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
Mauro.&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1441</id>
		<title>How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_NAL_(Nagios_Alarm_Handler)_to_monitor_an_EPICS_network&amp;diff=1441"/>
		<updated>2007-11-15T06:19:04Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(HOWTO install and setup NAL on Fedora Core 7)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here's how to install NAL using yum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAGIOS INSTALLATION&lt;br /&gt;
====================&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
# yum -y install nagios&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
# yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
Nagios Default Folder Locations&lt;br /&gt;
================================&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insert the EPICS Nagios Plugins&lt;br /&gt;
================================&lt;br /&gt;
&lt;br /&gt;
Going to www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;NAgios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
&amp;gt; chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh --help&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
&amp;gt; camonitor giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
#ifconfig&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
Now install the EPICS logos images&lt;br /&gt;
===================================&lt;br /&gt;
&lt;br /&gt;
# cd /usr/share/nagios/html/images/logos&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save the original Nagios setup and replace it&lt;br /&gt;
==============================================&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
# tar cvf nagios.or.tar ./nagios/&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
# tar xvf  ./etc.nagios.tar&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
NAGIOS check configuration file&lt;br /&gt;
================================&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
# nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
HTTPD configuration&lt;br /&gt;
====================&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into /usr/lib/nagios/cgi-bin/ and /usr/share/nagios/html/&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
#htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAGIOS as a Linux service&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
# service httpd restart&lt;br /&gt;
# service Nagios stop&lt;br /&gt;
# service Nagios start&lt;br /&gt;
# service Nagios status&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See my nagios screenshots in action:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
Mauro.&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowTo_Documents&amp;diff=1467</id>
		<title>HowTo Documents</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowTo_Documents&amp;diff=1467"/>
		<updated>2007-11-15T05:58:54Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Infrastructure and Other Stuff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a directory of various How-To documents written by members of the EPICS collaboration.  Contributions to this page are most welcome!&lt;br /&gt;
&lt;br /&gt;
=== EPICS Base on Different Architectures and Operating Systems ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.aps.anl.gov/epics/base/RTEMS/tutorial/ Getting Started with EPICS on RTEMS]&lt;br /&gt;
* [[HowToPC104|Getting Started with R3.14.7 on a PC104 running Linux]]&lt;br /&gt;
* [[How To Port EPICS to a new OS/Architecture]]&lt;br /&gt;
&lt;br /&gt;
=== Drivers and Device Support ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.aps.anl.gov/epics/modules/soft/asyn/R4-8/tutorial.html How To Do Serial (using Asyn Driver)]&lt;br /&gt;
* [http://www.aps.anl.gov/epics/modules/soft/asyn/BeginnerGuideToASYN-VXI11.pdf Beginners Guide to using VXI-11 (with Asyn Driver)]&lt;br /&gt;
* [[How to make your EPICS driver operating system independent]]&lt;br /&gt;
* [[How To Write Device Support that uses Asyn Driver]] ''(Incomplete!)''&lt;br /&gt;
&lt;br /&gt;
=== Applications ===&lt;br /&gt;
&lt;br /&gt;
* [[How To Install Channel Archiver On Scientific Linux]]&lt;br /&gt;
* [[What PV Save and Restore Tools are available]]&lt;br /&gt;
&lt;br /&gt;
=== Infrastructure and Other Stuff ===&lt;br /&gt;
&lt;br /&gt;
* [[How To Set Up a Linux Box as an IOC Boot Server]]&lt;br /&gt;
* [[How To Set Up a Mirror of the EPICS Web Site]]&lt;br /&gt;
* [[How to Set Up a Soft IOC Framework on Linux]]&lt;br /&gt;
* [[How to Set Up Console Access and Logging for VME and Soft IOCs]]&lt;br /&gt;
* [[How to Set Up NAL (Nagios Alarm Handler) to monitor an EPICS network]]&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_Nagios_to_monitor_an_EPICS_network&amp;diff=2840</id>
		<title>How to Set Up Nagios to monitor an EPICS network</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=How_to_Set_Up_Nagios_to_monitor_an_EPICS_network&amp;diff=2840"/>
		<updated>2007-11-15T05:57:25Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;HOWTO install and setup NAL (Nagios Alarm Handler) on Fedora Core 7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here's how to install NAL using yum&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAGIOS INSTALLATION&lt;br /&gt;
===================&lt;br /&gt;
&lt;br /&gt;
The default nagios installation can be done by doing like so&lt;br /&gt;
&lt;br /&gt;
# yum -y install nagios&lt;br /&gt;
&lt;br /&gt;
With that I've installed nagios.i386 0:2.9-1.fc7 version; this is the last stable version (the 3.0 is under development).&lt;br /&gt;
&lt;br /&gt;
Optional, but recomended if you have enough disk space: install more Nagios plugins and addons.&lt;br /&gt;
&lt;br /&gt;
# yum -y install nagios-plugins nagios-plugins-all&lt;br /&gt;
&lt;br /&gt;
That is not necessary but should be useful if you use NAL like a regular NAGIOS server more than only NAL (to monitor EPICS PVs network).&lt;br /&gt;
&lt;br /&gt;
Nagios Default Folder Locations&lt;br /&gt;
================================&lt;br /&gt;
&lt;br /&gt;
By default Nagios yum installation, Nagios stores the following file location into your harddisk&lt;br /&gt;
&lt;br /&gt;
    * /etc/nagios/ - Nagios configuration folder locations&lt;br /&gt;
    * /var/log/nagios/ - Nagios log and messages folder locations&lt;br /&gt;
    * /usr/share/nagios/ - Nagios, docs, sounds, and image folder locations&lt;br /&gt;
    * /usr/lib/nagios/cgi-bin/ - Nagios CGI folder location&lt;br /&gt;
    * /usr/bin - Nagios binaries&lt;br /&gt;
    * /etc/httpd/conf.d/ - Nagios Apache folder files&lt;br /&gt;
    * /etc/logrotate.d/nagios/ - Nagios log rotation file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insert the EPICS Nagios Plugins&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
Going to www.nagiosexchange.org ; using the &amp;quot;search&amp;quot; botton, look to &amp;quot;epics&amp;quot;. You will find a project named &amp;quot;NAgios plugins for EPICS&amp;quot;. Scroll down that page, click over &amp;quot;check_caget_dev_gw.sh&amp;quot;. Download it and save into the&lt;br /&gt;
/usr/lib/nagios/plugins/&lt;br /&gt;
Change the permission to check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
&amp;gt; chmod  +x check_caget_dev_gw.sh&lt;br /&gt;
&lt;br /&gt;
now verify that is usable with:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh --help&lt;br /&gt;
&lt;br /&gt;
verfing using camonitor a PV, ie for me giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
&amp;gt; camonitor giacchinHost:aiExample&lt;br /&gt;
&lt;br /&gt;
if everithings is good, now discover which is the IP number (for me it was 192.168.0.47) of your linux box by&lt;br /&gt;
&lt;br /&gt;
#ifconfig&lt;br /&gt;
&lt;br /&gt;
and test the plugin with the follow command:&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ./check_caget_dev_gw.sh -pv giacchinHost:aiExample -H 192.168.0.47&lt;br /&gt;
&lt;br /&gt;
if that reply correctly the status of your PV you can continue the installation.&lt;br /&gt;
&lt;br /&gt;
Now install the EPICS logos images.&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
# cd /usr/share/nagios/html/images/logos&lt;br /&gt;
&lt;br /&gt;
download there the usr.share.nagios.html.images.logo.tar availabe at same place in nagiosexchange.org&lt;br /&gt;
that contains : EPICSlogo.gd2 EPICSlogo.gif EPICSlogoSmall.gif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Save the original Nagios setup and replace it.&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
Go to /etc folder and save the original setup&lt;br /&gt;
&lt;br /&gt;
# tar cvf nagios.or.tar ./nagios/&lt;br /&gt;
&lt;br /&gt;
download there the etc.nagios.tar available at same place at nagiosexchange.org&lt;br /&gt;
&lt;br /&gt;
and restore the nagios folder with that:&lt;br /&gt;
&lt;br /&gt;
# tar xvf  ./etc.nagios.tar&lt;br /&gt;
&lt;br /&gt;
Note: Now looking around the files into /etc/nagios and adjust that to meet your network setup requirements.&lt;br /&gt;
&lt;br /&gt;
NAGIOS CONFIG VERIFICATION&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For sanity checking, make sure you verify Nagios config files. This can be done like so&lt;br /&gt;
&lt;br /&gt;
# nagios -v /etc/nagios/nagios.cfg&lt;br /&gt;
&lt;br /&gt;
The above command would show you for any erroneous lines frin Nagios config file.&lt;br /&gt;
&lt;br /&gt;
HTTPD configuration&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
Check the presence of line: &amp;quot;include conf.d/*.conf&amp;quot;&lt;br /&gt;
 in /etc/httpd/conf/httpd.conf&lt;br /&gt;
&lt;br /&gt;
Check the paths into the file : /etc/httpd/conf.d/nagios.conf&lt;br /&gt;
&lt;br /&gt;
Make a file named .htaccess into /usr/lib/nagios/cgi-bin/ and /usr/share/nagios/html/&lt;br /&gt;
which will contains:&lt;br /&gt;
&lt;br /&gt;
AuthName &amp;quot;Nagios Access&amp;quot;&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthUserFile /etc/nagios/passwd&lt;br /&gt;
require valid-user&lt;br /&gt;
&lt;br /&gt;
Now create a nagios user with the following command:&lt;br /&gt;
&lt;br /&gt;
#htpasswd -c /etc/nagios/passwd nagiosadmin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NAGIOS LINUX SERVICE&lt;br /&gt;
==========================&lt;br /&gt;
&lt;br /&gt;
Basically, at this point of basic Nagios configuration, restarting Nagios should be successful.&lt;br /&gt;
&lt;br /&gt;
Reload your apache service together with your Nagios service like so&lt;br /&gt;
&lt;br /&gt;
# service httpd restart&lt;br /&gt;
# service Nagios stop&lt;br /&gt;
# service Nagios start&lt;br /&gt;
# service Nagios status&lt;br /&gt;
&lt;br /&gt;
Open your favourite web-browser on http://localhost/nagios/&lt;br /&gt;
&lt;br /&gt;
login like &amp;quot;nagiosadmin&amp;quot;, give  your password and enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See my nagios screenshots in action:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosServiceDetails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NagiosAlertHistogram&lt;br /&gt;
&lt;br /&gt;
Theare a lot of other interesting feature that comes from free using NAGIOS, looking around you should find a lot yourself.&lt;br /&gt;
&lt;br /&gt;
At this time Ralph Lange has realized a test to NAL at Bessy. A great aknowlegment to him, he has supported me since the idea of use Nagios born in my mind.&lt;br /&gt;
&lt;br /&gt;
Thank you for your attention!&lt;br /&gt;
Please, give me a your feedback, and fell free to drop me an email, I'll be happy to continue to work on this idea if someome is interested to use it.&lt;br /&gt;
&lt;br /&gt;
Mauro.&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowTo_Documents&amp;diff=1440</id>
		<title>HowTo Documents</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowTo_Documents&amp;diff=1440"/>
		<updated>2007-11-15T05:56:08Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: /* Infrastructure and Other Stuff */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a directory of various How-To documents written by members of the EPICS collaboration.  Contributions to this page are most welcome!&lt;br /&gt;
&lt;br /&gt;
=== EPICS Base on Different Architectures and Operating Systems ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.aps.anl.gov/epics/base/RTEMS/tutorial/ Getting Started with EPICS on RTEMS]&lt;br /&gt;
* [[HowToPC104|Getting Started with R3.14.7 on a PC104 running Linux]]&lt;br /&gt;
* [[How To Port EPICS to a new OS/Architecture]]&lt;br /&gt;
&lt;br /&gt;
=== Drivers and Device Support ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.aps.anl.gov/epics/modules/soft/asyn/R4-8/tutorial.html How To Do Serial (using Asyn Driver)]&lt;br /&gt;
* [http://www.aps.anl.gov/epics/modules/soft/asyn/BeginnerGuideToASYN-VXI11.pdf Beginners Guide to using VXI-11 (with Asyn Driver)]&lt;br /&gt;
* [[How to make your EPICS driver operating system independent]]&lt;br /&gt;
* [[How To Write Device Support that uses Asyn Driver]] ''(Incomplete!)''&lt;br /&gt;
&lt;br /&gt;
=== Applications ===&lt;br /&gt;
&lt;br /&gt;
* [[How To Install Channel Archiver On Scientific Linux]]&lt;br /&gt;
* [[What PV Save and Restore Tools are available]]&lt;br /&gt;
&lt;br /&gt;
=== Infrastructure and Other Stuff ===&lt;br /&gt;
&lt;br /&gt;
* [[How To Set Up a Linux Box as an IOC Boot Server]]&lt;br /&gt;
* [[How To Set Up a Mirror of the EPICS Web Site]]&lt;br /&gt;
* [[How to Set Up a Soft IOC Framework on Linux]]&lt;br /&gt;
* [[How to Set Up Console Access and Logging for VME and Soft IOCs]]&lt;br /&gt;
* [[How to Set Up Nagios to monitor an EPICS network]]&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=66</id>
		<title>HowToPC104</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=66"/>
		<updated>2005-04-13T06:20:34Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''''This is an internal note of my lab (INFN-LNL ITALY) showing results of my first experience with running EPICS on an embedded PC104 to control a Camac Crate Controller by Serial-over-Ethernet and a Rockwell Micrologix 1500 PLC by serial line. Both Devices Support was written using Asyn in collaboration with Ralph Lange.'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 1 Building R3.14.7 Base on a Linux Box =&lt;br /&gt;
# The following was performed on a workstation type Slackware 7.0  linux box (equipped with an old PentiumIII, 500Mhz, 512MB RAM). I ran into a sync problem on HD using the “BigSlack” distro, so I created the ISO image of version 7.0 and installed it using a CD-ROM.&lt;br /&gt;
# Download baseR3.14.7.tar.gz from http://www.aps.anl.gov/epics/base/R3-14/7.php&lt;br /&gt;
# Create a working directory: /usr/src/R3.14.7&lt;br /&gt;
# cd /usr/src/R3.14.7&lt;br /&gt;
# tar -zxvf baseR3.14.7.tar.gz &lt;br /&gt;
# cd base&lt;br /&gt;
# Edit configure/CONFIG_SITE, look for the following variables and change them to what is shown below:&lt;br /&gt;
#* CROSS_COMPILER_TARGET_ARCHS= &lt;br /&gt;
#* STATIC_BUILD=YES&lt;br /&gt;
# Edit startup/Site.cshrc or define EPICS_BASE in your shell:&lt;br /&gt;
#* setenv EPICS_BASE /usr/src/R3.14.7/base &lt;br /&gt;
# Source startup/Site.cshrc (or restart your shell)&lt;br /&gt;
# Type ``make'' in /usr/src/R3.14.7/base and go brew a pot of coffee.&lt;br /&gt;
# Check for binaries in bin/linux-x86&lt;br /&gt;
&lt;br /&gt;
= 2 Building the Example Application =&lt;br /&gt;
# cd /home/giacchin/ (or wherever you want to build the example)&lt;br /&gt;
# mkdir testIOC&lt;br /&gt;
# cd testIOC&lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i example &lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i -t example example &lt;br /&gt;
# make &lt;br /&gt;
# cd ../iocBoot/iocexample &lt;br /&gt;
# Start your IOC with ../../exampleApp/src/O.linux-x86/example st.cmd&lt;br /&gt;
# List the existing records using dbl&lt;br /&gt;
&lt;br /&gt;
At this point you will be in the “iocSh” (aka ioc shell). You can use the CA commandline tools from base to access your IOC through Channel Access: “caget yourHost:aiExample1” (in the same net or after you point EPICS_CA_ADDR_LIST to your linux box). The values of that example record should change between 0 and 9.&lt;br /&gt;
&lt;br /&gt;
= 3 Migrating exampleApp Code to your PC104  =&lt;br /&gt;
Once you've established working binaries on your linux box, it's time to move them to the PC104 card. I try to mimic the directory structure of the linux host on the PC104 card, so that you do not have to modify anything. The IOC boot structure should be portable without any changes, though.&lt;br /&gt;
# Log onto the pc104&lt;br /&gt;
# Create /home/giacchin (or wherever you want to put stuff) and the directory structure:&lt;br /&gt;
## mkdir /home/giacchin; cd /home/giacchin/&lt;br /&gt;
## mkdir testIOC; cd testIOC&lt;br /&gt;
## mkdir bin dbd  db iocBoot  iocBoot/iocexample&lt;br /&gt;
# Back on the host: cd /home/giacchin/testIOC/iocBoot/iocexample&lt;br /&gt;
# ftp from your linux box to your pc104 &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample; lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put st.cmd&lt;br /&gt;
# cd /home/giacchin/testIOC/db;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put dbExample1.db dbExample2.db dbsubExample.db &lt;br /&gt;
# cd /home/giacchin/testIOC/dbd ;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put example.dbd &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/linux-x86 &lt;br /&gt;
# put caRepeater example&lt;br /&gt;
&lt;br /&gt;
I used the TMZ104 (a PC104 starter kit made by [http://www.tri-m.com TRI-M ENGINEERING]). The Linux environment of the starter kit isn't equipped with all the libs necessary to use the caRepeater, therefore I copied the libraries from my host PC (with Slackware7.0) to the PC104 into the same directory. The missing libs were:&lt;br /&gt;
* libpthread&lt;br /&gt;
* libstdc++-libc6.1&lt;br /&gt;
* libreadline.so&lt;br /&gt;
&lt;br /&gt;
Now we are ready to start our application on the PC104&lt;br /&gt;
# Log onto the pc104 card &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/limux-x86&lt;br /&gt;
# chmod +x caRepeater example &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample &lt;br /&gt;
# Start the caRepeater: ../../bin/linux-x86/caRepeater &amp;amp;&lt;br /&gt;
# Start the example: ../../bin/linux-x86/example st.cmd&lt;br /&gt;
&lt;br /&gt;
At this point you can access your PC104 through Channel Access from your host or another unix machine with EPICS: camonitor giacchinHost:dbExample1&amp;lt;br&amp;gt;&lt;br /&gt;
(Don't forget to set  EPICS_CA_ADDR_LIST to the PC104 IP address if you're on a different subnet.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- [mailto:mauro.giacchini@lnl.infn.it Mauro Giacchini (INFN-LNL)] &lt;br /&gt;
7:35, 13 Apr 2005 (CDT)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Credits: This document was derived from the original version done by Arne Freyberger (JLAB), sent to me by Stephen Wood (JLAB). Thanks a lot to both of you and to Ralph Lange (BESSY) and Glen Write (CLS) for additional help.''&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=21</id>
		<title>HowToPC104</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=21"/>
		<updated>2005-04-13T06:15:31Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''''This is an internal note of my lab (INFN-LNL ITALY) showing results of my first experience with running EPICS on an embedded PC104 to control a Camac Crate Controller by Serial-over-Ethernet and a Rockwell Micrologix 1500 PLC by serial line. P.S. Both new Devices Support was written using Asyn by M.Kraimer'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 1 Building R3.14.7 Base on a Linux Box =&lt;br /&gt;
# The following was performed on a workstation type Slackware 7.0  linux box (equipped with an old PentiumIII, 500Mhz, 512MB RAM). I ran into a sync problem on HD using the “BigSlack” distro, so I created the ISO image of version 7.0 and installed it using a CD-ROM.&lt;br /&gt;
# Download baseR3.14.7.tar.gz from http://www.aps.anl.gov/epics/base/R3-14/7.php&lt;br /&gt;
# Create a working directory: /usr/src/R3.14.7&lt;br /&gt;
# cd /usr/src/R3.14.7&lt;br /&gt;
# tar -zxvf baseR3.14.7.tar.gz &lt;br /&gt;
# cd base&lt;br /&gt;
# Edit configure/CONFIG_SITE, look for the following variables and change them to what is shown below:&lt;br /&gt;
#* CROSS_COMPILER_TARGET_ARCHS= &lt;br /&gt;
#* STATIC_BUILD=YES&lt;br /&gt;
# Edit startup/Site.cshrc or define EPICS_BASE in your shell:&lt;br /&gt;
#* setenv EPICS_BASE /usr/src/R3.14.7/base &lt;br /&gt;
# Source startup/Site.cshrc (or restart your shell)&lt;br /&gt;
# Type ``make'' in /usr/src/R3.14.7/base and go brew a pot of coffee.&lt;br /&gt;
# Check for binaries in bin/linux-x86&lt;br /&gt;
&lt;br /&gt;
= 2 Building the Example Application =&lt;br /&gt;
# cd /home/giacchin/ (or wherever you want to build the example)&lt;br /&gt;
# mkdir testIOC&lt;br /&gt;
# cd testIOC&lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i example &lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i -t example example &lt;br /&gt;
# make &lt;br /&gt;
# cd ../iocBoot/iocexample &lt;br /&gt;
# Start your IOC with ../../exampleApp/src/O.linux-x86/example st.cmd&lt;br /&gt;
# List the existing records using dbl&lt;br /&gt;
&lt;br /&gt;
At this point you will be in the “iocSh” (aka ioc shell). You can use the CA commandline tools from base to access your IOC through Channel Access: “caget yourHost:aiExample1” (in the same net or after you point EPICS_CA_ADDR_LIST to your linux box). The values of that example record should change between 0 and 9.&lt;br /&gt;
&lt;br /&gt;
= 3 Migrating exampleApp Code to your PC104  =&lt;br /&gt;
Once you've established working binaries on your linux box, it's time to move them to the PC104 card. I try to mimic the directory structure of the linux host on the PC104 card, so that you do not have to modify anything. The IOC boot structure should be portable without any changes, though.&lt;br /&gt;
# Log onto the pc104&lt;br /&gt;
# Create /home/giacchin (or wherever you want to put stuff) and the directory structure:&lt;br /&gt;
## mkdir /home/giacchin; cd /home/giacchin/&lt;br /&gt;
## mkdir testIOC; cd testIOC&lt;br /&gt;
## mkdir bin dbd  db iocBoot  iocBoot/iocexample&lt;br /&gt;
# Back on the host: cd /home/giacchin/testIOC/iocBoot/iocexample&lt;br /&gt;
# ftp from your linux box to your pc104 &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample; lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put st.cmd&lt;br /&gt;
# cd /home/giacchin/testIOC/db;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put dbExample1.db dbExample2.db dbsubExample.db &lt;br /&gt;
# cd /home/giacchin/testIOC/dbd ;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put example.dbd &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/linux-x86 &lt;br /&gt;
# put caRepeater example&lt;br /&gt;
&lt;br /&gt;
I used the TMZ104 (a PC104 starter kit made by [http://www.tri-m.com TRI-M ENGINEERING]). The Linux environment of the starter kit isn't equipped with all the libs necessary to use the caRepeater, therefore I copied the libraries from my host PC (with Slackware7.0) to the PC104 into the same directory. The missing libs were:&lt;br /&gt;
* libpthread&lt;br /&gt;
* libstdc++-libc6.1&lt;br /&gt;
* libreadline.so&lt;br /&gt;
&lt;br /&gt;
Now we are ready to start our application on the PC104&lt;br /&gt;
# Log onto the pc104 card &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/limux-x86&lt;br /&gt;
# chmod +x caRepeater example &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample &lt;br /&gt;
# Start the caRepeater: ../../bin/linux-x86/caRepeater &amp;amp;&lt;br /&gt;
# Start the example: ../../bin/linux-x86/example st.cmd&lt;br /&gt;
&lt;br /&gt;
At this point you can access your PC104 through Channel Access from your host or another unix machine with EPICS: camonitor giacchinHost:dbExample1&amp;lt;br&amp;gt;&lt;br /&gt;
(Don't forget to set  EPICS_CA_ADDR_LIST to the PC104 IP address if you're on a different subnet.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- [mailto:mauro.giacchini@lnl.infn.it Mauro Giacchini (INFN-LNL)] &lt;br /&gt;
7:35, 13 Apr 2005 (CDT)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Credits: This document was derived from the original version done by Arne Freyberger (JLAB), sent to me by Stephen Wood (JLAB). Thanks a lot to both of you and to Ralph Lange (BESSY) and Glen Write (CLS) for additional help.''&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=20</id>
		<title>HowToPC104</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=20"/>
		<updated>2005-04-13T06:14:16Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''''This is an internal note of my lab (INFN-LNL ITALY) showing results of my first experience with running EPICS on an embedded PC104 to control a Camac Crate Controller by Serial-over-Ethernet and a Rockwell Micrologix 1500 PLC by serial line. P.S. Both new Devices Support was written using Asyn by M.Kraimer'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 1 Building R3.14.7 Base on a Linux Box =&lt;br /&gt;
# The following was performed on a workstation type Slackware 7.0  linux box (equipped with an old PentiumIII, 500Mhz, 512MB RAM). I ran into a sync problem on HD using the “BigSlack” distro, so I created the ISO image of version 7.0 and installed it using a CD-ROM.&lt;br /&gt;
# Download baseR3.14.7.tar.gz from http://www.aps.anl.gov/epics/base/R3-14/7.php&lt;br /&gt;
# Create a working directory: /usr/src/R3.14.7&lt;br /&gt;
# cd /usr/src/R3.14.7&lt;br /&gt;
# tar -zxvf baseR3.14.7.tar.gz &lt;br /&gt;
# cd base&lt;br /&gt;
# Edit configure/CONFIG_SITE, look for the following variables and change them to what is shown below:&lt;br /&gt;
#* CROSS_COMPILER_TARGET_ARCHS= &lt;br /&gt;
#* STATIC_BUILD=YES&lt;br /&gt;
# Edit startup/Site.cshrc or define EPICS_BASE in your shell:&lt;br /&gt;
#* setenv EPICS_BASE /usr/src/R3.14.7/base &lt;br /&gt;
# Source startup/Site.cshrc (or restart your shell)&lt;br /&gt;
# Type ``make'' in /usr/src/R3.14.7/base and go brew a pot of coffee.&lt;br /&gt;
# Check for binaries in bin/linux-x86&lt;br /&gt;
&lt;br /&gt;
= 2 Building the Example Application =&lt;br /&gt;
# cd /home/giacchin/ (or wherever you want to build the example)&lt;br /&gt;
# mkdir testIOC&lt;br /&gt;
# cd testIOC&lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i example &lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i -t example example &lt;br /&gt;
# make &lt;br /&gt;
# cd ../iocBoot/iocexample &lt;br /&gt;
# Start your IOC with ../../exampleApp/src/O.linux-x86/example st.cmd&lt;br /&gt;
# List the existing records using dbl&lt;br /&gt;
&lt;br /&gt;
At this point you will be in the “iocSh” (aka ioc shell). You can use the CA commandline tools from base to access your IOC through Channel Access: “caget yourHost:aiExample1” (in the same net or after you point EPICS_CA_ADDR_LIST to your linux box). The values of that example record should change between 0 and 9.&lt;br /&gt;
&lt;br /&gt;
= 3 Migrating exampleApp Code to your PC104  =&lt;br /&gt;
Once you've established working binaries on your linux box, it's time to move them to the PC104 card. I try to mimic the directory structure of the linux host on the PC104 card, so that you do not have to modify anything. The IOC boot structure should be portable without any changes, though.&lt;br /&gt;
# Log onto the pc104&lt;br /&gt;
# Create /home/giacchin (or wherever you want to put stuff) and the directory structure:&lt;br /&gt;
## mkdir /home/giacchin; cd /home/giacchin/&lt;br /&gt;
## mkdir testIOC; cd testIOC&lt;br /&gt;
## mkdir bin dbd  db iocBoot  iocBoot/iocexample&lt;br /&gt;
# Back on the host: cd /home/giacchin/testIOC/iocBoot/iocexample&lt;br /&gt;
# ftp from your linux box to your pc104 &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample; lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put st.cmd&lt;br /&gt;
# cd /home/giacchin/testIOC/db;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put dbExample1.db dbExample2.db dbsubExample.db &lt;br /&gt;
# cd /home/giacchin/testIOC/dbd ;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put example.dbd &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/linux-x86 &lt;br /&gt;
# put caRepeater example&lt;br /&gt;
&lt;br /&gt;
I used the TMZ104 (a PC104 starter kit made by [http://www.tri-m.com TRI-M ENGINEERING]). The Linux environment of the starter kit isn't equipped with all the libs necessary to use the caRepeater, therefore I copied the libraries from my host PC (with Slackware7.0) to the PC104 into the same directory. The missing libs were:&lt;br /&gt;
* libpthread&lt;br /&gt;
* libstdc++-libc6.1&lt;br /&gt;
* libreadline.so&lt;br /&gt;
&lt;br /&gt;
Now we are ready to start our application on the PC104&lt;br /&gt;
# Log onto the pc104 card &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/limux-x86&lt;br /&gt;
# chmod +x caRepeater example &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample &lt;br /&gt;
# Start the caRepeater: ../../bin/linux-x86/caRepeater &amp;amp;&lt;br /&gt;
# Start the example: ../../bin/linux-x86/example st.cmd&lt;br /&gt;
&lt;br /&gt;
At this point you can access your PC104 through Channel Access from your host or another unix machine with EPICS: camonitor giacchinHost:dbExample1&amp;lt;br&amp;gt;&lt;br /&gt;
(Don't forget to set  EPICS_CA_ADDR_LIST to the PC104 IP address if you're on a different subnet.)&lt;br /&gt;
&lt;br /&gt;
-- [mailto:mauro.giacchini@lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
7:35, 13 Apr 2005 (CDT)&lt;br /&gt;
&lt;br /&gt;
''Credits: This document was derived from the original version done by Arne Freyberger (JLAB), sent to me by Stephen Wood (JLAB). Thanks a lot to both of you and to Ralph Lange (BESSY) and Glen Write (CLS) for additional help.''&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=19</id>
		<title>HowToPC104</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=19"/>
		<updated>2005-04-13T06:10:54Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''''This is an internal note of my lab (INFN-LNL ITALY) showing results of my first experience with running EPICS on an embedded PC104 to control a Camac Crate Controller by Serial-over-Ethernet and a Rockwell Micrologix 1500 PLC by serial line. P.S. Both new Devices Support was written using Asyn by M.Kraimer'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 1 Building R3.14.7 Base on a Linux Box =&lt;br /&gt;
# The following was performed on a workstation type Slackware 7.0  linux box (equipped with an old PentiumIII, 500Mhz, 512MB RAM). I ran into a sync problem on HD using the “BigSlack” distro, so I created the ISO image of version 7.0 and installed it using a CD-ROM.&lt;br /&gt;
# Download baseR3.14.7.tar.gz from http://www.aps.anl.gov/epics/base/R3-14/7.php&lt;br /&gt;
# Create a working directory: /usr/src/R3.14.7&lt;br /&gt;
# cd /usr/src/R3.14.7&lt;br /&gt;
# tar -zxvf baseR3.14.7.tar.gz &lt;br /&gt;
# cd base&lt;br /&gt;
# Edit configure/CONFIG_SITE, look for the following variables and change them to what is shown below:&lt;br /&gt;
#* CROSS_COMPILER_TARGET_ARCHS= &lt;br /&gt;
#* STATIC_BUILD=YES&lt;br /&gt;
# Edit startup/Site.cshrc or define EPICS_BASE in your shell:&lt;br /&gt;
#* setenv EPICS_BASE /usr/src/R3.14.7/base &lt;br /&gt;
# Source startup/Site.cshrc (or restart your shell)&lt;br /&gt;
# Type ``make'' in /usr/src/R3.14.7/base and go brew a pot of coffee.&lt;br /&gt;
# Check for binaries in bin/linux-x86&lt;br /&gt;
&lt;br /&gt;
= 2 Building the Example Application =&lt;br /&gt;
# cd /home/giacchin/ (or wherever you want to build the example)&lt;br /&gt;
# mkdir testIOC&lt;br /&gt;
# cd testIOC&lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i example &lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i -t example example &lt;br /&gt;
# make &lt;br /&gt;
# cd ../iocBoot/iocexample &lt;br /&gt;
# Start your IOC with ../../exampleApp/src/O.linux-x86/example st.cmd&lt;br /&gt;
# List the existing records using dbl&lt;br /&gt;
&lt;br /&gt;
At this point you will be in the “iocSh” (aka ioc shell). You can use the CA commandline tools from base to access your IOC through Channel Access: “caget yourHost:aiExample1” (in the same net or after you point EPICS_CA_ADDR_LIST to your linux box). The values of that example record should change between 0 and 9.&lt;br /&gt;
&lt;br /&gt;
= 3 Migrating exampleApp Code to your PC104  =&lt;br /&gt;
Once you've established working binaries on your linux box, it's time to move them to the PC104 card. I try to mimic the directory structure of the linux host on the PC104 card, so that you do not have to modify anything. The IOC boot structure should be portable without any changes, though.&lt;br /&gt;
# Log onto the pc104&lt;br /&gt;
# Create /home/giacchin (or wherever you want to put stuff) and the directory structure:&lt;br /&gt;
## mkdir /home/giacchin; cd /home/giacchin/&lt;br /&gt;
## mkdir testIOC; cd testIOC&lt;br /&gt;
## mkdir bin dbd  db iocBoot  iocBoot/iocexample&lt;br /&gt;
# Back on the host: cd /home/giacchin/testIOC/iocBoot/iocexample&lt;br /&gt;
# ftp from your linux box to your pc104 &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample; lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put st.cmd&lt;br /&gt;
# cd /home/giacchin/testIOC/db;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put dbExample1.db dbExample2.db dbsubExample.db &lt;br /&gt;
# cd /home/giacchin/testIOC/dbd ;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put example.dbd &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/linux-x86 &lt;br /&gt;
# put caRepeater example&lt;br /&gt;
&lt;br /&gt;
I used the TMZ104 (a PC104 starter kit made by [http://www.tri-m.com TRI-M ENGINEERING]). The Linux environment of the starter kit isn't equipped with all the libs necessary to use the caRepeater, therefore I copied the libraries from my host PC (with Slackware7.0) to the PC104 into the same directory. The missing libs were:&lt;br /&gt;
* libpthread&lt;br /&gt;
* libstdc++-libc6.1&lt;br /&gt;
* libreadline.so&lt;br /&gt;
&lt;br /&gt;
Now we are ready to start our application on the PC104&lt;br /&gt;
# Log onto the pc104 card &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/limux-x86&lt;br /&gt;
# chmod +x caRepeater example &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample &lt;br /&gt;
# Start the caRepeater: ../../bin/linux-x86/caRepeater &amp;amp;&lt;br /&gt;
# Start the example: ../../bin/linux-x86/example st.cmd&lt;br /&gt;
&lt;br /&gt;
At this point you can access your PC104 through Channel Access from your host or another unix machine with EPICS: camonitor giacchinHost:dbExample1&amp;lt;br&amp;gt;&lt;br /&gt;
(Don't forget to set  EPICS_CA_ADDR_LIST to the PC104 IP address if you're on a different subnet.)&lt;br /&gt;
&lt;br /&gt;
-- [mailto:mauro.giacchini@lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
''Credits: This document was derived from the original version done by Arne Freyberger (JLAB), sent to me by Stephen Wood (JLAB). Thanks a lot to both of you and to Ralph Lange (BESSY) and Glen Write (CLS) for additional help.''&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
	<entry>
		<id>https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=18</id>
		<title>HowToPC104</title>
		<link rel="alternate" type="text/html" href="https://wiki-ext.aps.anl.gov/epics/index.php?title=HowToPC104&amp;diff=18"/>
		<updated>2005-04-13T06:09:45Z</updated>

		<summary type="html">&lt;p&gt;MauroGiacchini: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''''This is an internal note of my lab (INFN-LNL ITALY) showing results of my first experience with running EPICS on an embedded PC104 to control a Camac Crate Controller by Serial-over-Ethernet and a Rockwell Micrologix 1500 PLC by serial line. P.S. Both new Device Supports was written using Asyn by M.Kraimer'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 1 Building R3.14.7 Base on a Linux Box =&lt;br /&gt;
# The following was performed on a workstation type Slackware 7.0  linux box (equipped with an old PentiumIII, 500Mhz, 512MB RAM). I ran into a sync problem on HD using the “BigSlack” distro, so I created the ISO image of version 7.0 and installed it using a CD-ROM.&lt;br /&gt;
# Download baseR3.14.7.tar.gz from http://www.aps.anl.gov/epics/base/R3-14/7.php&lt;br /&gt;
# Create a working directory: /usr/src/R3.14.7&lt;br /&gt;
# cd /usr/src/R3.14.7&lt;br /&gt;
# tar -zxvf baseR3.14.7.tar.gz &lt;br /&gt;
# cd base&lt;br /&gt;
# Edit configure/CONFIG_SITE, look for the following variables and change them to what is shown below:&lt;br /&gt;
#* CROSS_COMPILER_TARGET_ARCHS= &lt;br /&gt;
#* STATIC_BUILD=YES&lt;br /&gt;
# Edit startup/Site.cshrc or define EPICS_BASE in your shell:&lt;br /&gt;
#* setenv EPICS_BASE /usr/src/R3.14.7/base &lt;br /&gt;
# Source startup/Site.cshrc (or restart your shell)&lt;br /&gt;
# Type ``make'' in /usr/src/R3.14.7/base and go brew a pot of coffee.&lt;br /&gt;
# Check for binaries in bin/linux-x86&lt;br /&gt;
&lt;br /&gt;
= 2 Building the Example Application =&lt;br /&gt;
# cd /home/giacchin/ (or wherever you want to build the example)&lt;br /&gt;
# mkdir testIOC&lt;br /&gt;
# cd testIOC&lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i example &lt;br /&gt;
# $EPICS_BASE/bin/linux-x86/makeBaseApp.pl -i -t example example &lt;br /&gt;
# make &lt;br /&gt;
# cd ../iocBoot/iocexample &lt;br /&gt;
# Start your IOC with ../../exampleApp/src/O.linux-x86/example st.cmd&lt;br /&gt;
# List the existing records using dbl&lt;br /&gt;
&lt;br /&gt;
At this point you will be in the “iocSh” (aka ioc shell). You can use the CA commandline tools from base to access your IOC through Channel Access: “caget yourHost:aiExample1” (in the same net or after you point EPICS_CA_ADDR_LIST to your linux box). The values of that example record should change between 0 and 9.&lt;br /&gt;
&lt;br /&gt;
= 3 Migrating exampleApp Code to your PC104  =&lt;br /&gt;
Once you've established working binaries on your linux box, it's time to move them to the PC104 card. I try to mimic the directory structure of the linux host on the PC104 card, so that you do not have to modify anything. The IOC boot structure should be portable without any changes, though.&lt;br /&gt;
# Log onto the pc104&lt;br /&gt;
# Create /home/giacchin (or wherever you want to put stuff) and the directory structure:&lt;br /&gt;
## mkdir /home/giacchin; cd /home/giacchin/&lt;br /&gt;
## mkdir testIOC; cd testIOC&lt;br /&gt;
## mkdir bin dbd  db iocBoot  iocBoot/iocexample&lt;br /&gt;
# Back on the host: cd /home/giacchin/testIOC/iocBoot/iocexample&lt;br /&gt;
# ftp from your linux box to your pc104 &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample; lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put st.cmd&lt;br /&gt;
# cd /home/giacchin/testIOC/db;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put dbExample1.db dbExample2.db dbsubExample.db &lt;br /&gt;
# cd /home/giacchin/testIOC/dbd ;  lcd &amp;lt;same directory&amp;gt;&lt;br /&gt;
# put example.dbd &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/linux-x86 &lt;br /&gt;
# put caRepeater example&lt;br /&gt;
&lt;br /&gt;
I used the TMZ104 (a PC104 starter kit made by [http://www.tri-m.com TRI-M ENGINEERING]). The Linux environment of the starter kit isn't equipped with all the libs necessary to use the caRepeater, therefore I copied the libraries from my host PC (with Slackware7.0) to the PC104 into the same directory. The missing libs were:&lt;br /&gt;
* libpthread&lt;br /&gt;
* libstdc++-libc6.1&lt;br /&gt;
* libreadline.so&lt;br /&gt;
&lt;br /&gt;
Now we are ready to start our application on the PC104&lt;br /&gt;
# Log onto the pc104 card &lt;br /&gt;
# cd /home/giacchin/testIOC/bin/limux-x86&lt;br /&gt;
# chmod +x caRepeater example &lt;br /&gt;
# cd /home/giacchin/testIOC/iocBoot/iocexample &lt;br /&gt;
# Start the caRepeater: ../../bin/linux-x86/caRepeater &amp;amp;&lt;br /&gt;
# Start the example: ../../bin/linux-x86/example st.cmd&lt;br /&gt;
&lt;br /&gt;
At this point you can access your PC104 through Channel Access from your host or another unix machine with EPICS: camonitor giacchinHost:dbExample1&amp;lt;br&amp;gt;&lt;br /&gt;
(Don't forget to set  EPICS_CA_ADDR_LIST to the PC104 IP address if you're on a different subnet.)&lt;br /&gt;
&lt;br /&gt;
-- [mailto:mauro.giacchini@lnl.infn.it Mauro Giacchini (INFN-LNL)]&lt;br /&gt;
&lt;br /&gt;
''Credits: This document was derived from the original version done by Arne Freyberger (JLAB), sent to me by Stephen Wood (JLAB). Thanks a lot to both of you and to Ralph Lange (BESSY) and Glen Write (CLS) for additional help.''&lt;/div&gt;</summary>
		<author><name>MauroGiacchini</name></author>
	</entry>
</feed>