Name

nstfruity — NST Script To Setup Fruity Package For Nagios Management.

Synopsis

nstfruity [ -m TEXT | --mode TEXT ] [ --dbimport FILENAME ] [ --passwd TEXT ] [ --pkg-dir DIRECTORY ] [ -h [true]|false | --help [true]|false ] [ -H [true]|false | --help-long [true]|false ] [ -v [true]|false | --verbose [true]|false ] [ --version [true]|false ]

Description

The nstfruity script is used to manage the fruity package (which in turn is used to manage the nagios package).

There are several things to consider when using nstfruity:

  • You must have the MySQL server up and running first (the setup_mysql script can help with this).

  • Using this script will not directly affect nagios. One will need to use the fruity interface, review and/or edit the configuration information maintained by fruity, export the information maintained by fruity (to make it accessible to nagios) and finally, restart the nagios service to load in the new configuration tables.

  • Removing the fruity setup does NOT affect nagios.

  • Once fruity has been setup, you access it by pointing a web browser at https://127.0.0.1/fruity/ (you may subsitute the external IP address of the system for "127.0.0.1" if you are accessing it remotely).

  • A simplified interface to this script is provided in the NST WUI (its located on the "Nagios Setup" page).

Here is a example of using nstfruity (include the "--verbose" option to get additional output):

[root@probe ~]# nstfruity --mode setup
New password for 'fruity' database: 
Retype new password:
[root@probe ~]# if nstfruity --mode status; then echo "OK"; fi
OK
[root@probe ~]# nstfruity --mode remove
[root@probe ~]# 

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

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

--mode setup

This mode of operation is used to initialize fruity and make it accessible via a web browser. 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.

--dbimport minimal|FILE

By default, we only create the fruity database - providing a "clean slate" to work with. If you specify "--dbimport minimal", we will initialize fruity with data (to save you some tedious setup). Alternatively, if you have a copy of fruity tables you'd like initialize the database with, you may specify the fully qualified file name (like: "--dbimport /tmp/myfruity.sql"). The file must contain valid SQL statements and may optionally be compressed via bzip2 or gzip.

--passwd PROMPT|RANDOM|value

If you don't want to be prompted to provide the fruity 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/fruity/config.inc").

--pkg-dir DIRECTORY

This option is intended for NST developers (it allows us to download and try out newer versions of fruity).

--mode status

This mode of operation is used to tell whether fruity 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 fruity is setup 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):

--verbose (-v)

Provides verbose diagnostic output about what the script is doing.

--mode remove

This mode of operation is used to remove the fruity setup from the system. This will remove the entire fruity 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):

--verbose (-v)

Provides verbose diagnostic output about what the script is doing.

--mode dbexport

This mode of operation is used to dump a copy of the SQL database used by fruity. 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 fruity setup, and then set up fruity and initialize it with the previously exported database:

[root@probe ~]# nstfruity --mode dbexport | bzip2 -c >| /tmp/fruity.sql.bz2
[root@probe ~]# nstfruity --mode remove
[root@probe ~]# nstfruity --mode setup --dbimport /tmp/fruity.sql.bz2
New password for 'fruity' database: 
Retype new password:
[root@probe ~]# 

Options

The following command line options are available:

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

This option controls what nstfruity will do. If you specify "status" (the default), it will indicate whether Fruity has been setup yet or not. If you specify "setup" it will remove any previous setup information and set up Fruity on your NST system. If you specify "remove" it will remove the Fruity setup. If you specify "dbexport", the SQL database will be dumped in a form usable for the "--dbimport FILE" option.

[--dbimport FILENAME]

By default, the Fruity management system starts with a clean slate (nothing configured). One would then need to import the current Nagios configuration (which is often desirable) or spend a lot of time with the initial setup of the Fruity 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 (see "/usr/local/share/nstfruity/minimal.sql.bz2" for an example). 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. Alternatively, you may specify "--dbimport minimal" and we will load the minimal configuration found in the "/usr/local/share/nstfruity" directory.

[--passwd TEXT]

This option allows one to set the password used for access to the "fruity" 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.

[--pkg-dir DIRECTORY]

Typically you will never need to change this parameter from its default value of "/usr/local/fruity". However, if you've downloaded and installed a newer version of Fruity, you can use this option to instruct the script to use your new installation (we can't guarantee it will work as this option allows the NST developers to experiment with newer versions of Fruity).

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

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

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

This option will attempt to pull up additional nstfruity 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, nstfruity 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.