nstzabbix — Script to manage Zabbix on a NST probe.
nstzabbix [
-m
TEXT
| --mode TEXT
] [ --dbimport FILENAME
] [ --dbimport-rm [true]|false
] [ --passwd TEXT
] [ --start [true]|false
] [ --agent-server HOST|IP
] [ --agent-mysql-checks [true]|false
] [ --pidfile FILENAME
] [
-h
[true]|false
| --help [true]|false
] [
-H
[true]|false
| --help-long [true]|false
] [
-v
[true]|false
| --verbose [true]|false
] [ --version [true]|false
]
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:
You must have the MySQL server up and running first (the setup_mysql script can help with this).
Zabbix is composed of three parts: a server, a web based interface, and agent components. The nstzabbix script is used to setup and configure each of these parts. However, setting up the server and its web based front end is separate from setting up the agent component. It is possible to run both the agent and the server on the same system, but you will need to invoke this script twice, once to setup the server and once to setup the agent.
Once Zabbix has been setup, you access it
by pointing a web browser at https://127.0.0.1/zabbix/
(you may subsitute the external IP address of the system for
"127.0.0.1" if you are accessing it
remotely).
After the initial setup of the
Zabbix server, one will be able to
log into the server using the "Admin"
account (leave the password field blank). One should
IMMEDIATELY set the password on the
"Admin" account and any of the other
accounts which the Zabbix server
creates. NOTE: This only applies if you omitted the
"--dbimport FILE" option at the time of
setup.
After completing the setup, one can use "service zabbix status|start|stop" and/or "service zabbix-agent status|start|stop" to query and control the state of the Zabbix daemon(s).
A simplified interface to this script is
provided in the NST WUI (it is located on the "Zabbix
Setup" page).
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 setupNew password for 'zabbix' database: Retype new password:[root@probe ~]#if nstzabbix --mode status; then echo "OK"; fi[root@probe ~]#service zabbix startStarting zabbix server: [ OK ][root@probe ~]#if nstzabbix --mode status; then echo "OK"; fiOK[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 statuszabbix_agentd (pid 22677 22676 22675 22674 22673 22669) is running...[root@probe ~]#service zabbix-agent stopShutting 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 ~]#
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):
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.
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.
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.
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.
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.
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.
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.
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.
This mode of operation is used to tell whether Zabbix
has been setup yet or not. It is written such that there is no
output unless an error occurs or the
"--verbose" option is also specified. However,
it does exit with 0 if the Zabbix server is setup running
and 1 if not (making it useful to other scripts). The following
command line option(s) may be used in "status"
mode (all are optional):
Provides verbose diagnostic output about what the script is doing.
NOTE: This does not check the status of the
Zabbix agent. Once may use the
command "service zabbix-agent status" to
determine if the Zabbix agent is
running.
This mode of operation is used to remove the Zabbix
setup from the system. This will remove the entire Zabbix
database from the SQL server. It is
written such that there is no output unless an error occurs or the
"--verbose" option is also specified. However,
it does exit with 0 if successful and 1 if not (making it useful
to other scripts). The following command line option(s) may be
used in "remove" mode (all are
optional):
Provides verbose diagnostic output about what the script is doing.
This does not affect the configuration files found under
the "/etc/zabbix" directory. It only stops
the Zabbix server and removes its
associated database.
This mode of operation is used to dump a copy of the SQL
database used by Zabbix. No other options are required in
this mode of operation. Since the SQL database is written directly
to the standard output, you can not use the
"--verbose" option in this mode.
The following demonstrates how to save a copy of the current database (in a compressed form), remove the entire Zabbix setup, and then set up Zabbix and initialize it with the previously exported database:
[root@probe ~]#nstzabbix --mode dbexport | bzip2 -c >| /tmp/zabbix.sql.bz2[root@probe ~]#nstzabbix --mode remove[root@probe ~]#nstzabbix --mode setup --dbimport /tmp/zabbix.sql.bz2New password for 'zabbix' database: Retype new password:[root@probe ~]#
This mode of operation is used to determine whether the
Zabbix already exists. This mode does
not echo any output to the console (unless the
"--verbose" option is included). The script
will exit with a return code of 0 if the
Zabbix database exists.
This mode is not typically used from the command line (it is intended to support other scripts), but the following demonstrates how it can be used:
[root@probe ~]#nstzabbix --mode dbexists -v+ NOTE + The "zabbix" database was found.[root@probe ~]#if nstzabbix --mode dbexists; then echo "Database Found"; fiDatabase Found[root@probe ~]#
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.