V7R30


Nagios for IBM i


 


Vous devez avoir Installé "Nagios Core" sur un serveur

(Ubuntu dans une partition Power8 pour notre cas)


Voici ce que dit le fichier Nagios-Plugin-for-IBM-i-Install-and-Configure-Guidelines.txt

 

==========================================================
=============Install the Nagios plugin for i==============
==========================================================

----------------------------------------------------------
1. Extract the Nagios for i plugin to the directory: /usr/local/nagios/
----------------------------------------------------------
# tar xzf nagios-plugin-for-IBM-i.tar.gz /usr/local/nagios/
----------------------------------------------------------
2. Execute the below command:
----------------------------------------------------------
# /bin/bash /usr/local/nagios/libexec/ibmi_init.sh.
It will initialize the IBM i related commands, services and templates into the configuration files
----------------------------------------------------------
3. Issue below command to add the user name and password of the system
that you would like to monitor (you can use -h option to see the help):
----------------------------------------------------------
# /bin/bash /usr/local/nagios/libexec/host_config.sh -i [host | sst]
----------------------------------------------------------
4. Start the server of plugin for i and restart the nagios service
----------------------------------------------------------
# /bin/bash /usr/local/nagios/libexec/server_start.sh # service nagios restart

Quelques remarques pour une installation non standard

(en effet l'installation part du principe que nagios est dans /usr/local/nagios , or sur Ubuntu c'est dans /etc/nagios3)

Après avoir restauré le fichier .tar

  1. passez ibmi_init.sh -p /etc/nagios3/objects.

  2. passez les commandes
    1. host_config.sh -i host.
      pour enregistrer un profil(et son mot de passe) pour accèder à votre IBM i.
    2. host_config.sh -i sst
      pour enregistrer un profil SST (et son mot de passe) pour accèder aux informations disques de votre IBM i.


      les informations sont enregistrées cryptées dans /user/local/nagios/Nagios.host.java.config.ser

      Vérifiez que /usr/local/nagios existe et que vous avez le droit d'écriture.


    3. host_config.sh -d
      permet de supprimer un poste
    4. host_config.sh -a
      permet de les voir

Vérifiez le contenu des fichiers de config. (.cfg)

 

nagios.cfg contient la liste des fichiers de config à charger

# Debian uses by default a configuration directory where nagios3-common,
# other packages and the local admin can dump or link configuration
# files into.
cfg_dir=/etc/nagios3/conf.d

# OBJECT CONFIGURATION FILE(S)
# These are the object configuration files in which you define hosts,
# host groups, contacts, contact groups, services, etc.
# You can split your object definitions across several config files
# if you wish (as shown below), or keep them all in a single config file.

# You can specify individual object config files as shown below:
cfg_file=/etc/nagios3/objects/commands.cfg
cfg_file=/etc/nagios3/objects/templates.cfg
cfg_file=/etc/nagios3/objects/services.cfg
cfg_file=/etc/nagios3/objects/localhost.cfg
#cfg_file=/etc/nagios3/objects/contacts.cfg
#cfg_file=/etc/nagios3/objects/timeperiods.cfg

# Definitions for monitoring a IBMi machine
cfg_file=/etc/nagios3/objects/as400.cfg

as400.cfg (dans notre exemple) : liste des machines IBM i

define host{
  use generic-host
  host_name AS400
  alias ibmi
  address 10.3.1.1
}
define hostgroup{
  hostgroup_name as400group1
  alias group1
  members AS400
}

services.cfg : liste des services à surveiller (font références à des commandes)

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description CPU utilization
  check_command check-ibmi-cpu-utilization!CPU!60!80
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Active job number
  check_command check-ibmi-active-job-num!ActiveJobs
}

define service{
  use generic-service
  hostgroup_name as400group1
  service_description Disk configuration
  check_command check-ibmi-disk-config!DiskConfig
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Disk usage
  check_command check-ibmi-disk-usage!DiskUsage!60!80
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Asp usage
  check_command check-ibmi-asp-usage!ASPUsage!60!80
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Disk utilization
  check_command check-ibmi-disk-utilization!DiskUtiliz!0!80
}

define service{
  use generic-service
  hostgroup_name as400group1
  service_description Message
  check_command check-ibmi-message!Message!QSYS!QSYSOPR
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Page faults
  check_command check-ibmi-page-faults!PageFaults!2!5
}

define service{
  use generic-service
  hostgroup_name as400group1
  service_description Subsystem jobs
  check_command check-ibmi-subsystem-jobs!SubsystemJobs!QHTTPSVR
}

define service{
  use generic-service
  hostgroup_name as400group1
  service_description Temporary storage top N jobs
  check_command check-ibmi-temp-storage-jobs!TempStorageJobs!10
}

define service{
  use generic-service
  hostgroup_name as400group1
  service_description Long run sql
  check_command check-ibmi-long-run-sql!LongRunSQL!10!20
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Current log on user number
  check_command check-ibmi-cur-logon-users!CurSignOnUsers
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Specific job CPU
  check_command check-ibmi-specific-job-cpu!SpecificJobCPU!ADMIN2!60!80
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description CPU overload jobs num
  check_command check-ibmi-cpu-overload-jobs-num!CPUOverloadJobs!60!80
}

define service{
  use generic-service
  hostgroup_name as400group1
  service_description Specific message
  check_command check-ibmi-specific-message!SpecificMessage!CPA*
}

define service{
  use generic-service,srv-pnp
  hostgroup_name as400group1
  service_description Basic information
  check_command check-ibmi-basic-info!BasicInfo
}

commands.cfg (liste des commandes, utilisées par les services))

################################################################################
#
# IBM i STATUS CHECK COMMANDS
#
################################################################################
# 'check-cpu-utilization' command definition
define command{
  command_name check-ibmi-cpu-utilization
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-active-job' command definition
define command{
  command_name check-ibmi-active-job-num
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$
}
#'check-disk-config' command definition
define command{
  command_name check-ibmi-disk-config
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$
}
#'check-disk-usage' command definition
define command{
command_name check-ibmi-disk-usage
command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-asp-usage' command definition
define command{
  command_name check-ibmi-asp-usage
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-iasp-usage' command definition
define command{
  command_name check-ibmi-iasp-usage
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-disk-utilization' command definition
define command{
  command_name check-ibmi-disk-utilization
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-message' command definition
define command{
  command_name check-ibmi-message
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -lib $ARG2$ -name $ARG3$ -ty $ARG4$
}
#'check-page-faults' command definition
define command{
  command_name check-ibmi-page-faults
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-subsystem-jobs' command definition
define command{
  command_name check-ibmi-subsystem-jobs
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -s $ARG2$
}
#'check-temp-storage-jobs' command definition
define command{
  command_name check-ibmi-temp-storage-jobs
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -n $ARG2$
}
#'check-long-run-sql' command definition
define command{
  command_name check-ibmi-long-run-sql
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-current-logon-users' command definition
define command{
  command_name check-ibmi-cur-logon-users
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$
}
#'check-specific-job-cpu' command definition
define command{
  command_name check-ibmi-specific-job-cpu
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -j $ARG2$ -w $ARG3$ -c $ARG4$
}
#'check-cpu-overload-jobs-num' command definition
define command{
  command_name check-ibmi-cpu-overload-jobs-num
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
}
#'check-specific-message' command definition
define command{
  command_name check-ibmi-specific-message
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$ -I $ARG2$
}
#'check-basic-information' command definition
define command{
  command_name check-ibmi-basic-info
  command_line /bin/bash $USER1$/check_ibmi_status.sh -m $ARG1$ -H $HOSTADDRESS$
}
#'check-daemon-server' command definition
define command{
  command_name check-nagios-daemon-server
  command_line /bin/bash $USER1$/check_daemon_status.sh -m $ARG1$
}

les commandes font référence à $USER1$ qui est défini dans resource.cfg

# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/lib/nagios/plugins

     .../...

Nous avons donc copié check_ibmi_status.sh et check_daemon_status.sh dans /usr/lib/nagios/plugins
et nous les avons modifié pour qu'ils fassent référence à notre répertoire nagios (pour nous /etc/nagios3)

 

#!/bin/bash
java -cp /etc/nagios3/libexec/jt400.jar:/etc/nagios3/libexec/server.jar:/etc/nagios3/libexec/ CheckIBMiStatus $*


il faut ensuite (re)démarrer Nagios et le démon spécifique à IBM i
 dans notre cas nous avons remplacé :

 

dans les fichiers situés ici

 

server_start.sh

#!/bin/bash
pid=$(ps -ef | grep java | grep "name=nagios" | awk '{print $2}')
if [ "" = "$pid" ] ; then
  echo "Starting Nagios Server"
  nohup java -cp /etc/nagios3/libexec/jt400.jar:/etc/nagios3/libexec/server.jar com.ibm.nagios.Server -dname=nagios > /usr/local/nagios/server.log &
  /etc/init.d/nagios3 start
  echo "Nagios Service Started"
else
  echo "The server is already started"
fi

server_stop.sh

#!/bin/bash
ps -ef | grep java | grep "name=nagios" | awk '{print $2}' | xargs kill -9
/etc/init.d/nagios3 stop
echo "Nagios Server stopped"


server_restart.sh

#!/bin/bash
ps -ef | grep java | grep "name=nagios" | awk '{print $2}' | xargs kill -9
/etc/init.d/nagios3 stop
echo "Nagios Server stopped"

pid=$(ps -ef | grep java | grep "name=nagios" | awk '{print $2}')
if [ "" = "$pid" ] ; then
  echo "Starting Nagios Server"
  nohup java -cp /etc/nagios3/libexec/jt400.jar:/etc/nagios3/libexec/server.jar com.ibm.nagios.Server -dname=nagios > /usr/local/nagios/server.log &
  /etc/init.d/nagios3 start
  echo "Nagios Service Started"
else
  echo "The server is already started"
fi



cela doit lancer un démon server.jar parallèlement à nagios.


C'est lui qui va se connecter à l'iBMi pour passer des requêtes (SQL as a service)



Quelques exemples de requêtes capturées par un STRDBMON.




Vérifiez qu'il s'exécute

ce que fait ce service dans localhost.cfg

#Define a service to check Nagios Daemon server on the local machine.
#Disable natifications for this service by default, as not all users may have HTTP enabled.

define service{
  use daemon-server-service
  host_name localhost
  service_description Daemon Server
  check_command check-nagios-daemon-server!DaemonServer
  notifications_enabled 0
}




et voilà



Détail pour notre IBM i



2020, IBM a ajouté un nouveau service

 

CustomSQL         The user could leverage SQL services to create self-defined matrix

il faut modifier le fichier CustomSQL.xml

ET les dernières versions sont disponibles ici : https://github.com/IBM/nagios-for-i

 

©AF400