Administrative Scripts

This chapter lists and describes the administrative scripts provided by PPT application.

Policy Provisioning Tool (PPT) provides various scripts. Most of these scripts perform administrative operations such as database backup, restore, and vacuuming, as well as resetting superuser password. Some scripts provide log information for troubleshooting purpose. All of these scripts, except the PPT Components Control (pptctl) Script, are located in the “scripts” folder in the PPT installation directory <ppt-install-dir>.

IMPORTANT:

The user must have PPT administrator privileges to execute these scripts.

PPT Components Control Script

PPT Components Control (pptctl) script is used to control the PPT components by performing following operations:

  • start: Starts the specified process or all processes.
  • stop: Stops the specified process or all processes.
  • restart: Restarts the specified process or all processes.
  • forcestop: Forcefully stops the specified process or all processes.
  • status: Checks current status of the specified process or all processes.

CAUTION:

If a process name is not mentioned along with the action, then the respective action is taken for all processes related to policy provisioning application.


Syntax
pptctl  [ postgres | apache | psmon | notif_server | monitor_server| scheduler ] [ start | stop | restart | forcestop | status | verbose ] | [ version ] | [ --help ]

This option describes script usage.


postgres [ start | stop | restart | forcestop | status ]:

start/ stop/ restart/ forcestop the Postgres server.


apache [ start | stop | restart | forcestop | status ]:

start/ stop/ restart/ forcestop the Apache server.


psmon [ start | stop | restart | forcestop | status ]:

start/ stop/ restart/ forcestop the Process monitor.


notif_server [ start | stop | restart | forcestop | status ]:

start/ stop/ restart/ forcestop the Notification server.


monitor_server [ start | stop | restart | forcestop | status ]:

start/ stop/ restart/ forcestop the Monitor server.


scheduler [ start | stop | restart | forcestop | status ]:

start/ stop/ restart/ forcestop the Scheduler.


Displays the version of currently installed PPT application.


Usage Description:
  • Execute the following script to start all the services associated with PPT application:
    ./pptctl start
    
    The sample output is displayed below:Starting Postgres Server ...Starting Apache Server ...Starting Notif Service ...Starting Monitor Server ...Starting Scheduler...Starting PSMon Service...
  • Execute following script to view version of installed PPT application:
    ./pptctl version
    
    The sample output is displayed below:Policy Provisioning Tool (version 14.0.93.0)
  • Execute the following script to stop the Apache Web server by force:
    ./pptctl apache forcestop
    
    The sample output is displayed below:This will stop all currently running apache requests, if any.Stopping apache...

Set Superuser Password Script

This script is used to reset the superuser password in the Policy Provisioning Tool (PPT) database.


Syntax
./set_superuser_password [ --help ]

This option describes script usage.


Usage Description:

A user with administrative privileges can execute this script without any options, as shown below:

./set_superuser_password.sh
The script prompts the user to enter a password. This password is stored in the database. The sample output is shown below:
Please enter the password
for superuser.
password:new_password
Password for superuser
changed successfully.

CAUTION:

If an existing password is specified, when prompted to enter the new superuser password, following messages are displayed:

Password update for
superuser failed.
New password cannot
be same as old password.

Database Backup and Restore Script

This script is used to perform PPT database backup and restore operations.


Syntax
backupAndRestore.sh  [ backup <backup_dir_path> ] | [ restore <backup_file> ] | [ --help ]

Takes the backup of the PPT database and configuration files including ppt.cfg and psmon.cfg and stores it in backup_dir_path location.


Restores PPT database and configuration files such as ppt.cfg and psmon.cfg. For this restore operation, this script prompts for a backup filename. Provide absolute path for the backup file that is to be restored.

CAUTION:

To restore the database no other parameters except restore are required.


This option describes script usage.


Usage Description:

Execute this script with listed options. For backup option <backup_dir_path> is mandatory. The script generates backup of PPT database and application configuration files. It creates a tar ball and compresses these files. This tar archive is created at the location specified by the user.

Backup and restore operations for the PPT application:
  • Can be performed on the same version of PPT application, i.e., if backup is generated from the version x.y of PPT application then it can be restored on version x.y only.
  • Are permitted across the platform , i.e. backup can be generated from the application on Solaris platform and this backup can be restored on the Linux platform and vice versa.
  • Upon execution this script generates complete backup, incremental backup feature is not enabled for this version of PPT application.

SNMP traps are generated to indicate un-successful backup. Details of traps can be found in Trap Details table below. For detailed information regarding SNMP traps, refer CISCO-PPT-MIB.my file located at the <ppt-install-dir>/mib directory. SNMP traps are generated for specific error conditions and success or failure messages for these operations are recorded.


Table 1. Trap Details

Trap Name and Probable Cause

Solution

starPPTDBBackupDestinationNotAccessible: Backup directory is not accessible or PPT administrator does not have enough permissions to access it.

Provide complete path of backup directory,

starPPTDBBackupNotEnoughDiskSpace: The disk on which backup is to be taken is full.

Ensure that enough space is available on the disk where backup is being generated.



For example, to generate backup of the database, execute the following command:
./backupAndRestore.sh
backup backup_dir_path.

This command generates backup of PPT database and copies configuration for PPT application and PSMon, by generating a tar archive. This tar file is created at the location backup_dir_path.

Running the Backup and Restore script via CRON:
During PPT installation a cron entry for backup script is added.Default backup time interval is configured as 1 day. This time interval can be modified using the script: <ppt-install-dir>/scripts/updateBackupInterval.sh. By default, backup is generated at midnight each day. If backup interval is modified by user, then backup operation will be performed at following time intervals:
  • hourly - start of the hour
  • daily - at midnight
  • weekly - at midnight on the weekday configured by user
  • monthly- at midnight on 1st day of month

Update Backup Interval Script

This script is used to update the database backup interval in the CRON utility. This interval is configured for the regular database backup.


Syntax
updateBackupInterval.sh [ --help ]

This option describes script usage.


Usage Description:

Execute the script without any option. For example:

./updateBackupInterval.sh
The script prompts user to specify backup interval. The valid options include: 1 - hourly, 2 - daily, 3 - weekly, and 4 - monthly. If weekly option is selected then, the script prompts for the day of week on which to generate the backup. In such case the valid options are: 0 - Sun, 1 - Mon, 2 - Tue, 3 - Wed, 4 - Thu, 5 - Fri, and 6 - Sat. Depending on the user input, backup interval in cron entry for PPT backup is modified. The sample output is shown below:
=======================================
Please select any one
of the following
options for backup
interval
1 - hourly
2 - daily
3 - weekly
4 - monthly
=======================================
Enter your option and
press [ENTER]:3
[0]Sun, [1]Mon, [2]Tue, [3]Wed, [4]Thu, [5]Fri, [6]Sat
Enter the weekday and
press [ENTER]:1
Cron updated successfully.
Crontab contents are as follows
0,5,10,15,20,25,30,35,40,45,50,55 * * * * sh /root/users/ppt//cronjobs/sessCleanup.sh
0 0 * * 1
 /root/users/ppt//scripts/backupAndRestore.sh backup /root/users/ppt/backup_dir

Database Cleanup Script

This script is used to perform the cleanup of PPT database. However the cleanup is performed for the Audit table only.


Syntax
dbcleanup [ --days number_of_days ] | [ --help ]

This option describes script usage.


Number of days for which the data is to be retained. Default is 30 days, minimum is 2 days, and maximum is 30 days. Therefore the number_of_days ranges from 2 to 30.


Usage Description:

Execute this script with the --days option followed by the number of days for which records are to be retained. For example, to delete all records older than 5 days use following command:

./dbcleanup.sh
--days 5

If the script is executed without any option, it asks for confirmation to delete data older than 30 days. To change this number of days, enter 'yes'. Enter the number of days for which the data is to be retained. Script deletes records from the database that are older than the specified number and displays success or failure message.

Sample output, generated without any option is given below:
Number of days prior
to which data is to be deleted is not specified.
Using default value:
30 days.
Do you want to change
the number of days? (yes/no):yes
Number of days:5
30 records deleted
from database, which were older than 5 days.

CAUTION:

Data purged by executing this script will not be recovered.

Database Vacuum Script

This script is used to perform the vacuuming on PPT database.


Syntax
vacuum [ --help ]

This option describes the script usage.


Usage Description:

Execute the script without any option. For example:

./vacuum.sh
It asks for confirmation. If you wish to continue then, enter ‘yes’. Script performs vacuum operation on the database and displays success or failure message. The sample output is shown below:
Vacuuming will be done
for database.
Proceed (yes/no):yes
Password:postgres_password
Vacuum was done successfully.

CAUTION:

When prompted for the password, if you enter an incorrect password to access Postgres database, then following message is displayed:

Vacuum operation failed:
vacuumdb: could not connect to database pptdb: FATAL: password authentication
failed for user "pptadmin".

SNMP Target Configuration Script

This script is used to add as well as delete SNMP targets to PPT database. These targets are used by Notification Server (NotifServer) to send traps.


Syntax
configSnmpTarget.sh [ --help ]

This option describes the script usage.


Usage Description:

Execute this script without any option. For example:

./configSnmpTarget.sh

The script displays a list of SNMP targets currently configured in database and prompts the user to Add or Delete a target or to Exit this script. Choosing Add option prompts the user for IP address, port, SNMP version 1 or SNMP version 2c and community name. Choosing Delete option prompts user for IP address and port value. Depending on success or failure, appropriate message is displayed.

IMPORTANT:

Maximum of five SNMP targets can be configured.

The sample output of this script is shown below:
The list of SNMP targets
configured is as follows. Maximum of 5 targets can be configured.
===================================================
IP address - Port number
- SNMP version - Community
 ===================================================
 127.0.0.1 -     162          -
1 -        public
Select option to Add/Delete
SNMP target (Add/Delete/Exit):Add
Please enter SNMP target
details
IP address:1.2.3.4
Port: 667
SNMP version (1 / 2c):2c
Community: test
SNMP target added successfully
The list of SNMP targets
configured is as follows. Maximum of 5 targets can be configured.
===================================================
IP address - Port number
- SNMP version - Community
 ===================================================
 127.0.0.1 -     162          -
1 -        public
 1.2.3.4 -       667          -
2c -       test
Select option to Add/Delete
SNMP target (Add/Delete/Exit): Exit

Get Support Details Script

This script is used to collect support details information for the PPT application.

Purpose of this script is to collect debug information for PPT application. It collects different log files and captures output of certain system commands that would help in troubleshooting of a particular issue. This script collects required information and prepares a gzip file named <project_name>supportDetails.tar.gz file in the /tmp directory.

IMPORTANT:

While reporting any issue with PPT application, attach this gzip along with the problem report (PR).

The gzip file name and the directory in which this gzip file is created, are configurable via an XML file


Syntax
./getSupportDetails.pl [ --level = level_number ] [ --xmlfile = xml_filename ] [ --outputDir = outpur_dir_path ] [ --verbose ] [ --help ]

--level = level_number:

Specifies the debug level to be executed. Default: 1 and Max: 2.

Level 1 debug includes following information:
  • Recent log files
  • Current status of the product indicating whether it is in active or hanged state.
  • Current Config files of the product
  • Installation logs
  • Database logs, if available
  • Web server logs, if available
  • Operating system information. For Solaris, it collects the OS version and patch information and for Linux, only OS version is captured
  • Crontab entries
  • Output of following commands, depending upon the configuration:
    • netstat -an
    • ifconfig -a
    • df -k
    • ipcs
    • ps -eaf
    • env
    • "prstat 1 1" (SunOS) / "top -d 1 -n 1 -b" (Linux)
    • "cat /etc/release" (SunOS) / "cat /etc/redhat-release" (Linux)
    • /opt/VRTSvcs/bin/hares -state
    • /opt/VRTSvcs/bin/hagrp -state

Level 2 debug includes logs from level 1 along with the database dump.


--xmlfile = xml_filename:
Specifies the XML file to be used to collect the log information. Default xml file is getSupportDetails.xml located in same directory as the script. This XML file allows the user to configure the gzip file name and directory where gzip file is to be stored.

CAUTION:

Do not update or change any other configuration parameters in this XML file, as it may lead to un-expected results.


--outputDir = output_dir_path:

Uses specified directory output_dir_path as destination to collect logs. Default: /tmp/ as output directory to collect logs.


Displays information of the logs being collected.


This option describes the script usage.


Usage Description:
To execute this script for level 2 debugging with XML file name testXML, execute the following command:
./getSupportDetails.pl --level=2 --xmlfile=/tmp/testXML.xml

User Session Cleanup Script

This script is used to terminate the session of a particular user.


Syntax
user_session_cleanup [ --help ] | [ - u <user_name> ] 

This option describes script usage.


-u <user_name>:

Prompts to specify the username as command line interpreter, whose session is to be terminated.


Usage Description:

At any given instance, PPT application client allows only single login per user. If a user does not perform a clean log out, then their session remains valid and the application client prevent them from logging in again till completion of session time-out. Default value of the session time-out, which is configurable using administration menu from the application client is 15 minutes.

To terminate session associated with specific user:
  • Log in with administrative privileges.
  • Execute the script with u option and name of the user whose session you want to terminate.
  • The script displays session details for this user and asks for confirmation to terminate the session.
    ./user_session_cleanup
    Please enter the username
    for which session is to be terminated.
    Username:test
    User session details
    are as follows:==========================================================  
    Username     | 
       IP address   | Session Expiry Time =============================================================== 
    test        | 
     64.103.156.106  |   2012-03-22 06:43:34 ==================================================================== 
            
    Do
    you wish to terminate the session? (yes/no):
    If you want to terminate the session, enter yes or else no.
  • On receiving confirmation, the script terminates session and removes session information from PPT database.

Migrating 12.1 PPT Data to 14.x PPT Cluster

This script is used to migrate v12.1 data to v14.x PPT cluster installation.


Syntax
upgrade_to_ha [ -f <backup_file_name> ] | [ --help  ] 

-f <backup_file_name>:

Prompts to specify the name of backup file generated as the result of backup operation performed on installed v12.1 PPT application.


This option describes script usage.


Usage Description:

Usage Description

To migrate v12.1 data to v14.x PPT cluster installation:

  1. Login with administrative privileges on the system where data migration is required.
  2. Execute the following commands to create PPT v12.1 data backup in the backup directory.
    su <12.1-ppt-admin-user>
    
    cd <12.1-install-dir>
    
    ./scripts/backupAndRestore.sh
    backup <backup-directory>
    
    PPT backup will be created in the backup-directory. The filename will have the following format:backup_file-<PPT-version>-<YYYYMMDDHHSS>-<timezone offset from GMT>.tar.gz where, backup-file is the default file name which can different if overridden during v12.1 installation.
  3. Install v14.x in cluster mode and run the script upgrade_to_ha to migrate v12.1 PPT data to v14.x cluster PPT.
  4. Execute the following commands to migrate the data backup from v12.1 to v14.x.
    su <14.x-ppt-admin-user>
    
    cd <14.x-install-dir>
    
    <ppt-install-dir>/scripts/upgrade_to_ha
    -f <absolute-path-of-backup-file>
    
    where, <absolute-path-of-backup-file> is the absolute path of v12.1 data backup (including file name) which was taken earlier in Step 2.