关于使用Nagios远程提取Informix信息及监控Oracle、Informix数据库的技术咨询
Hey there! I’ve got you covered on your Nagios monitoring questions for your school project—let’s dive right in.
Absolutely! Nagios has solid support for Oracle monitoring, mostly through community-maintained plugins like check_oracle_health. Here’s the gist:
- You’ll need the Oracle Instant Client installed on either the Nagios server or the remote CentOS VM (depending on whether you run checks locally or via NRPE).
- The plugin can monitor key metrics like database connectivity, tablespace usage, active sessions, and listener status.
- Just configure the plugin with your Oracle credentials, set up a service definition in Nagios, and you’re good to go.
Yes, it can—this is totally doable, even if documentation is a bit harder to find than for Oracle. Here are your best solutions:
1. Use the Community-Maintained check_informix Plugin
There’s a custom plugin called check_informix built specifically for this. Here’s how to set it up:
- First, install the Informix Client SDK on your remote CentOS VM. Make sure to set environment variables like
INFORMIXDIRandINFORMIXSERVERcorrectly so the plugin can talk to the database. - Grab the
check_informixscript (available in Nagios community repositories) and place it in your Nagios plugins directory (usually/usr/local/nagios/libexec/). - Give it execute permissions:
chmod +x check_informix. - Configure NRPE (Nagios Remote Plugin Executor) on the remote VM to run this plugin. Add a line like this to
nrpe.cfg:command[check_informix_status]=/usr/local/nagios/libexec/check_informix -d YOUR_DBNAME -u DB_USER -p DB_PASSWORD - Restart the NRPE service:
systemctl restart nrpe.
2. Write Your Own Custom Script
If you can’t find the pre-built plugin, writing a simple shell or Python script works too. Use Informix’s built-in command-line tools like dbaccess or onstat to pull metrics:
- For example, a shell script to check if the database is responsive might look like this:
#!/bin/bash export INFORMIXDIR=/opt/informix export INFORMIXSERVER=your_informix_server # Test database connectivity dbaccess YOUR_DBNAME - <<EOF SELECT COUNT(*) FROM systables WHERE tabname='systables'; EOF # Parse the output to return Nagios-compatible status codes (0=OK, 1=WARNING, 2=CRITICAL) if [ $? -eq 0 ]; then echo "OK: Informix database is responsive" exit 0 else echo "CRITICAL: Could not connect to Informix database" exit 2 fi - Save this script, make it executable, and add it to your NRPE config just like the pre-built plugin.
3. Key Informix Metrics to Monitor
Don’t forget to track these critical stats:
- Database instance status (use
onstat -to check if the server is up) - Dbspace usage (to avoid running out of storage for your database)
- Active sessions and lock contention (with
onstat -uandonstat -l) - Logical log usage (to prevent log full errors)
The standard way to pull remote Informix data into Nagios is using NRPE—here’s the step-by-step:
- Install NRPE and Nagios plugins on your remote CentOS VM (most distros have packages for this, like
nagios-nrpe-serverandnagios-plugins). - Edit
nrpe.cfgto allow your Nagios server’s IP address to connect (look for theallowed_hostsdirective). - Deploy your Informix monitoring plugin/script to the VM’s plugin directory and configure the NRPE command as shown earlier.
- On your Nagios server, define a service that uses the
check_nrpeplugin to call the remote command. Example service definition:define service { host_name remote-centos-vm service_description Informix Database Status check_command check_nrpe!check_informix_status max_check_attempts 3 check_interval 5 retry_interval 1 check_period 24x7 notification_interval 60 notification_period 24x7 } - Test it out! Run this command on your Nagios server to verify:
You should get a status message telling you if the Informix database is OK or has issues./usr/local/nagios/libexec/check_nrpe -H REMOTE_VM_IP -c check_informix_status
内容的提问来源于stack exchange,提问作者kadar

