- API over IBMi Web Service
- No additional IBMi user is needed
- Security
- API access only from specified IP addresses
- API access only with valid authorisation key
- Read only
- As SQL statement only SELECT is allowed
- IFS access is allowed only for objects to which the user QTMHHTP1 has rights
- The Nagios check command is the script ibminagios.sh, this script calls the IBMi Web Service (IBMi program ibminagios) with authorisation key, command and command parameters and processes the output of the API.
- IBMi objects
- /etc/ibminagios.conf
- rights (only the user QTMHHTP1 should able to read and write the file):
-rw------- QTMHHTP1 0
- content:
AUTHKEY=halala
- Authorisation key to use the API.
- rights (only the user QTMHHTP1 should able to read and write the file):
- IBMNAGIOS/IBMNAGIOS *PGM
- /etc/ibminagios.conf
- Nagios objects
- the tool wget must be installed
- /etc/ibminagios.conf
- rights (only the user nagios should able to read and write the file):
-rw------- nagios nobody
- content:
<host>:AUTHKEY=halala <host>:HTTPPORT=81
- Authorisation key and API port fpr each monitored hosts.
- rights (only the user nagios should able to read and write the file):
- <nagios path>/etc/checkcommands.conf
define command { command_name ibminagios command_line $USER1$/ibminagios.sh $HOSTADDRESS$ "$ARG1$" "$ARG2$" "$ARG3$" "$ARG4$" "$ARG5$" "$ARG6$" "$ARG7$" "$ARG8$" "$ARG9$" }
- <nagios path>/libexec/ibminagios.sh
- IBMi Web Service
- httpd.conf
ScriptAlias /ibminagios /QSYS.LIB/IBMINAGIOS.LIB/IBMINAGIOS.PGM <Directory /QSYS.LIB/IBMINAGIOS.LIB/> Order Deny,Allow Allow From 10.43.85.172 Deny From all SetHandler cgi-script Options +ExecCGI SetEnv IBMI_NAGIOS_CONF_FILE /etc/ibminagios.conf </Directory>
- you should change the IP address to the address of the nagios (only nagios will be able use this API).
- you may use the SetEnv IBMI_NAGIOS_CONF_FILE to define the path of the ibminagios.conf file on the IBMi. The default path is /etc/ibminagios.conf.
- httpd.conf
ibminagios.sh <host> <command>
command: [ syssts aspused <warning_condition> <critical_condition> ] |
[ job [ msgw <warning_condition> <critical_condition> <exception_of_job_names> ] |
[ act <warning_condition> <critical_condition> <job_name> ] ] |
[ outq splfcount <warning_condition> <critical_condition> <outq_name> ] |
[ sql - <warning_condition> <critical_condition> <sql_statement> ] |
[ sbs [ act <warning_condition> <critical_condition> <sbs_name> ] |
[ jobcount <warning_condition> <critical_condition> <sbs_name> ] ] |
[ msgq [ inq <warning_condition> <critical_condition> <msgq_name> <msgid | *ALL> <minutes> ] |
[ search <warning_condition> <critical_condition> <msgq_name> <msgid | *ALL> <minutes> [ <exception_of_message_ids> ] ] ] |
[ ifs [ filecount <warning_condition> <critical_condition> <dir_name> ] |
[ dircount <warning_condition> <critical_condition> <dir_name> ] |
[ filesize <warning_condition> <critical_condition> <dir_name> <file_name> ] |
[ oldestfile <warning_condition> <critical_condition> <dir_name> ] ]
warning_condition and critical_condition:
format: [ <condition><value> | - ]
- : no condition processing
conditions:
lt : less than
le : less equal
eq : equal
ne : not equal
ge : greater equal
gt : greater than
values (per command and subcommand):
syssts aspused : percent of usage
job msgw : number of jobs
job act : number of jobs
outq splfcount : number of spool files
sql : return value of the sql statement
sbs act : status of the subsystem
sbs jobcount : number of jobs
msgq inq : number of messages
msgq search : number of messages
ifs filecount : number of files
ifs dircount : number of directories
ifs filesize : size of the file in bytes
ifs oldestfile : age of the file in seconds
special value: <NULL>
exception_of_job_names: Job names separated with comma
exception_of_message_ids: Message ids separated with comma
- Usage
https://<host>:<port>/ibminagios?authkey=<auth_key>&cmd=<command>
- Commands
- 001
- Required param: -
- Optional param: -
- Output: Info=|AspUsed=<x>|
- 002
- Required param: OUTQNAME
- Optional param: OUTQLIB
- Output: Info=|NumberOfFiles=<x>|
- 003
- Required param: -
- Optional param: STATUS, JOBNAME
- Output: Info=|JobName=<x>|JobUser=<x>|JobNumber=<x>|Status=<x>|Type=<x>|SubType=<x>|ActiveJobStatus=<x>|SubsystemName=<x>|
- 004
- Required param: SQL
- Optional param: -
- Output: Info=|Value=<x>|
- 005
- Required param: -
- Optional param: SBSNAME
- Output: Info=|SubsystemName=<x>|SubsystemLibraryName=<x>|Status=<x>|ActiveJobs=<x>|
- 006
- Required param: MSGQNAME, MINUTES
- Optional param: MSGID
- Output: Info=|MessageId=<x>|Date=<x>|Time=<x>|Severity=<x>|Type=<x>|
- 007
- Required param: DIR
- Optional param: FILE
- Output: Info=|Name=<x>|Type=<x>|Size=<x>|ChangedDateTime=<x>|ModifiedDateTime=<x>|AccessedDateTime=<x>|CodePage=<x>|
- 001
- System ASP used
Warning from 75%, critical from 90%.
check_command ibminagios!syssts!aspused!ge75!ge90
- Number of spool files in output queue QEZDEBUG
Warning if there is at least 1 spool file in the queue, no critical check.
check_command ibminagios!outq!splfcount!ge1!-!QEZDEBUG
- Number of jobs with active status MSGW (with two exceptions)
Warning if there is at least 1 job has active status MSGW, nor critical check. The job names USVJOB and RH_STRZX60 are exceptions (they have always active status MSGW).
check_command ibminagios!job!msgw!ge1!-!USVJOB,RH_STRZX60
- Number of active jobs with name USVJOB
No warning check, critical if the number of of jobs is 0 (the job is not active).
check_command ibminagios!job!act!-!eq0!USVJOB
- Number of not active iCluster nodes
Warning if the number of not active nodes greater equal 1, no critical check.
check_command ibminagios!sql!-!ge1!-!SELECT count(*) AS satz FROM icluster.dmnodes WHERE status <> '*ACTIVE'
- Number of jobs in the subsystem ZEITSBSD
Warning if the number of jobs is less than 7, no critical check.
check_command ibminagios!sbs!jobcount!lt7!-!ZEITSBSD
- Status of the OMK subsystem
No warning check, critical if the status of the subsystem is not *ACTIVE
check_command ibminagios!sbs!act!-!ne*ACTIVE!OMK
- Number of messages in the message QSECOFR in the last 15 minutes
Warning if the number of messages in the last 15 minutes is greater than 0, no critical check.
check_command ibminagios!msgq!search!gt0!-!QSECOFR!*ALL!15
- Number of files in the IFS directory /home/transfer
Warning if the number of files is greater than 100, no critical check.
check_command ibminagios!ifs!filecount!gt100!-!/home/transfer
- Oldest file in the IFS directory /home/transfer
Warning of the age of the oldest file is greater than 32000000 (aproximately 1 year), no critical check.
check_command ibminagios!ifs!oldestfile!gt32000000!-!/home/transfer/archive
- Size of the IFS file /tmp/sendmail.log
Warning if the size of the file is greater than 4000000 (aproximately 4 MB), no critical check.
check_command ibminagios!ifs!filesize!gt4000000!-!/tmp!sendmail.log