Name

nstzabbix — Script to manage Zabbix on a NST probe.

Description

The nstzabbix script is used to manage the Zabbix package (a web based system monitoring tool).

There are several things to consider when using nstzabbix:

Here is a example of using nstzabbix to setup a Zabbix server, check its status, and then remove the Zabbix server from the system (include the "--verbose" option to get additional output):

[root@probe ~]# nstzabbix -m setup
New password for 'zabbix' database: 
Retype new password:
[root@probe ~]# if nstzabbix --mode status; then echo "OK"; fi
[root@probe ~]# service zabbix start
Starting zabbix server:                                [  OK  ]
[root@probe ~]# if nstzabbix --mode status; then echo "OK"; fi
OK
[root@probe ~]# nstzabbix --mode remove
[root@probe ~]# 

Here is a example of using nstzabbix to setup the Zabbix agent on a NST probe. The NST probe will report its status information to the Zabbix server running on "192.168.1.100".

[root@probe ~]# nstzabbix -m setup --start --agent-server 192.168.1.100
[root@probe ~]# service zabbix-agent status
zabbix_agentd (pid 22677 22676 22675 22674 22673 22669) is running...
[root@probe ~]# service zabbix-agent stop
Shutting down zabbix agent:                                [  OK  ]
[root@probe ~]# 

Here is a example of using nstzabbix to export the Zabbix database to "/tmp/zabbix.sql". The exported file can serve as a back up and can be restored via: "-m setup --dbimport /tmp/zabbix.sql". Alternatively, it could be copied to a different NST probe and used to initialize the Zabbix database on that system.

[root@probe ~]# nstzabbix --mode dbexport >| /tmp/zabbix.sql
[root@probe ~]# 

--mode setup

This mode of operation can be used to initialize the Zabbix server and make it accessible via a web browser. This mode of operation is also used to configure the Zabbix agent by including "--agent-server IP" option. The following command line options may be used in "setup" mode (all are optional):

--verbose (-v)

Provides verbose diagnostic output about what the script is doing. This option can be used regardless of whether one is setting up the Zabbix server or Zabbix agent.

--start

Immediately starts the Zabbix server or agent daemon after completing the setup process. This option can be used regardless of whether one is setting up the Zabbix server or Zabbix agent.

--dbimport FILE

If you have a copy of a Zabbix database you'd like to use as your intial setup (something you saved previously via the "--mode dbexport" option), you may specify the fully qualified file name (like: "--dbimport /tmp/myzabbix.sql"). The file must contain valid SQL statements and may optionally be compressed via bzip2 or gzip. This option is only used when setting up a Zabbix server.

--dbimport-rm

Include this command line option if you want to remove the imported "FILE" (specified in the "--dbimport FILE" option) after the database is imported. This option is only used when setting up a Zabbix server.

--passwd PROMPT|RANDOM|value

If you don't want to be prompted to provide the Zabbix database password, you may specify the password on the command line. Since you seldom need to know the password, you may also specify "--passwd RANDOM" and a random password will be chosen (NOTE: The password is stored in "/etc/zabbix/db.inc.php" and "/etc/zabbix/zabbix_server.conf"). This option is only used when setting up a Zabbix server.

--pidfile FILE

Include this option if you intend to background the script and would like to have the process ID associated with the script written to a specific file. This option is only used when setting up a Zabbix server.

--agent-server IP|HOST[,IP|HOST,...]

If you want to setup the Zabbix agent component instead of the server, you must include this option. You will need to specify the IP address or resolvable host name of the Zabbix server which the agent should connect to. You may specify more than one server by using a comma to separate each address - "--agent server 127.0.0.1,192.168.1.100". NOTE: By default, this mode of operation only prepares the "/etc/zabbix/zabbix_agentd.conf" configuration file, it won't start the agent unless you include the "--start" option as well. This option is only used when setting up a Zabbix agent.

--agent-mysql-checks

Include this option to include the monitoring of the MySQL server on the system running the Zabbix agent. Adjustments will be made to the "/etc/zabbix/zabbix_agentd.conf" file to enable the monitoring of a MySQL server running on the agent system. This option is only used when setting up a Zabbix agent.

Options

The following command line options are available:

[-m TEXT] | [--mode TEXT]

This option controls what nstzabbix will do. Specify "status" (the default), to determine whether the Zabbix server has been setup and is running. Specify "setup" to set up the Zabbix server or Zabbix agent on your NST system. Specify "remove" to shutdown and remove the Zabbix server setup. Specify "dbexport", to dump the Zabbix database in a form usable for the "--dbimport FILE" option. Specify "dbexists" mode to determine whether the Zabbix database exists (mysqld must already be running).

[--dbimport FILENAME]

By default, the Zabbix management system starts with a clean slate (nothing configured). One would then need to spend a lot of time with the initial setup of the Zabbix management system. This is the default behavior maintained by this script. Alternatively, one may use the "--dbimport FILE" command line option and specify the name of a initial SQL database which they had previously exported via a previous invocation of "--mode dbexport". You may specify the fully qualified path of the initial SQL database. If the file name specified ends with ".gz" we will use the "gzip" command to uncompress it. If the file name specified ends with ".bz2" we will use the "bzip2" command to uncompress it.

[--dbimport-rm [true]|false]

This option will remove the database file after importing it (regardless of whether it was successfully loaded or not).

[--passwd TEXT]

This option allows one to set the password used for access to the "zabbix" database that will be created during setup. By default you will be prompted at the command line. If you specify a password of "RANDOM", we will generate a random password using the pwgen command.

[--start [true]|false]

When this option is combined with "--mode setup", the Zabbix server (or agent) will be immediately started after the initial setup is complete.

[--agent-server HOST|IP]

This option can be combined with "--mode setup" to setup the Zabbix agent on the NST probe (instead of the Zabbix server). You need to include the IP address (or resolvable host name) of the Zabbix server which will be monitoring this system. If you include the "--start" option as well, we will immediately start the "zabbix-agent" service for you after setup. One may alternatively use "service zabbix-agent start|stop" to control the state of the agent service after setup. NOTE: You may specify a comma separate list of IP addresses (or resolvable host names) if you have more than one Zabbix server that will be connecting to the agent.

[--agent-mysql-checks [true]|false]

This option can be combined with "--mode setup --agent-server HOST" options to permit the Zabbix agent to monitor the MySQL database on the NST probe and provide additional information to the Zabbix server. NOTE: This will result in the Zabbix agent making root access connections to your MySQL server.

[--pidfile FILENAME]

If you include "--pidfile FILENAME" on the command line, the process ID of the script will be written to the specified filename (that's all the file will contain). This option is only used when setting up the Zabbix server component (as the setup process may take a bit of time to complete).

[-h [true]|false] | [--help [true]|false]

When this option is specified, nstzabbix will display a short one line description of nstzabbix, followed by a short description of each of the supported command line options. After displaying this information nstzabbix will terminate.

[-H [true]|false] | [--help-long [true]|false]

This option will attempt to pull up additional nstzabbix documentation within a text based web browser. You can force which browser we use setting the environment variable TEXTBROWSER, otherwise, we will search for some common ones.

[-v [true]|false] | [--verbose [true]|false]

When you set this option to true, nstzabbix will produce additional output. This is typically used for diagnostic purposes to help track down when things go wrong.

[--version [true]|false]

If this option is specified, the version number of the script is displayed.