Beruflich Dokumente
Kultur Dokumente
JUNOScript
External inventory applications can extract inventory data, such as hardware, software, licensed features, and inventory scan events, from the JUNOScope Inventory Management System database. A unique username and password must be configured during the JUNOScope software installation to enable read-only access to the Inventory Management System database. JUNOScope versions 7.4 and higher support extracting Inventory Management System database information to an external inventory application.
339
This chapter also describes the SQL database schema to facilitate data export, and also describes each database table. A demo Inventory Management System database is bundled with the JUNOScope installation, which consists of tables populated with sample inventory data. You can develop scripts or programs to practice extracting data from the demonstration database without having to scan real inventory data into the production Inventory Management System database. For more information about the demo tables, see Demo Inventory Management System Database Tables on page 350. This chapter includes the following topics: Inventory Management System Database Entity Relationship on page 341 Enabling Access to the Inventory Management System SQL Interface on page 342 Changing the Username and Password and Creating Additional Users for the Inventory Management System SQL Interface on page 342 Inventory Management System Database Tables on page 345 Demo Inventory Management System Database Tables on page 350 Demo Inventory Management System Reports on page 350 Connecting to the Inventory Management System SQL Interface on page 351 Querying All Hardware Inventory Items on page 352 Querying All Hardware Inventory Items of a Device on page 353 Querying JUNOS Software and Package Inventory Items on page 353 Querying All Licensed Feature Inventory Data on page 354 Querying Inventory Events Data on page 354
340
hardware_inventory module_interface_version PK module version PK FK1 U1 U1 U1 id device_id serial_number part_number deleted_on chassis_id version name description last_scanned last_modified created_on comment module submodule subsubmodule inventory_event_types PK id event_type
has
has
has
packages_inventory PK FK1, U1 U1 U1 U1 has id device_id routing_engine name deleted_on comment last_scanned last_modified created_on has events_inventory PK FK1 FK2 FK3 FK4 FK5 id hardware_id software_id package_id licensing_id device_id item type event_time deleted_on description annotation
has
has
licensing_inventory PK id FK1, U1 device_id U1 feature_name U1 deleted_on feature_description licensed_count used_count given_count given_hint needed_count last_scanned last_modified created_on
has
has
PK: Primary Key FK: Foreign Key U: Unique index Underline: identifier Bold: required attributes Exactly one Zero or one One or more
g002315
341
password have been added during JUNOScope software installation, the JUNOScope software will not prompt again to add them for reconfiguration.
Changing the Username and Password and Creating Additional Users for the Inventory Management System SQL Interface
The database administrator can change the password of the database user already configured to access the Inventory Management System SQL interface. The database administrator can also create additional users to access the Inventory Management System SQL interface and grant the required privileges by using the sample SQL query below. An SQL user with grant privileges (for example, root) can execute these statements:
-- grant read-only privilege to the inventory tables of @DBNAME@ for @DBUSER_IMS@, -- per the specification of the interface module 'core' and 'ims'. -- @DBNAME@ is the name of the database, e.g. 'jtk' or 'demo' -- @DBUSER_IMS@ is the name of the database user for the SQL interface to IMS -- @DBUSER_IMS_PASSWORD@ is the password of the database user for the SQL interface to IMS GRANT SELECT (id) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (id) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (id) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (id) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (id) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; TO @DBUSER_IMS@@localhost IDENTIFIED BY TO @DBUSER_IMS@@"127.0.0.1" IDENTIFIED BY TO @DBUSER_IMS@@"@HOST_NAME@" IDENTIFIED TO @DBUSER_IMS@@"@HOST_IP@" IDENTIFIED BY TO @DBUSER_IMS@@"%" IDENTIFIED BY
GRANT SELECT (name) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (name) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (name) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (name) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (name) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@';
TO @DBUSER_IMS@@localhost IDENTIFIED BY TO @DBUSER_IMS@@"127.0.0.1" IDENTIFIED TO @DBUSER_IMS@@"@HOST_NAME@" IDENTIFIED TO @DBUSER_IMS@@"@HOST_IP@" IDENTIFIED TO @DBUSER_IMS@@"%" IDENTIFIED BY
GRANT SELECT (hostname) ON @DBNAME@.devices TO @DBUSER_IMS@@localhost IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (hostname) ON @DBNAME@.devices TO @DBUSER_IMS@@"127.0.0.1"
342
IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (hostname) ON @DBNAME@.devices TO @DBUSER_IMS@@"@HOST_NAME@" IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (hostname) ON @DBNAME@.devices TO @DBUSER_IMS@@"@HOST_IP@" IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (hostname) ON @DBNAME@.devices TO @DBUSER_IMS@@"%" IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (model) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (model) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (model) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (model) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (model) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@'; TO @DBUSER_IMS@@localhost IDENTIFIED BY TO @DBUSER_IMS@@"127.0.0.1" IDENTIFIED TO @DBUSER_IMS@@"@HOST_NAME@" TO @DBUSER_IMS@@"@HOST_IP@" IDENTIFIED TO @DBUSER_IMS@@"%" IDENTIFIED BY
GRANT SELECT (comment) ON @DBNAME@.devices BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (comment) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (comment) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (comment) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (comment) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@';
GRANT SELECT (deleted_on) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (deleted_on) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (deleted_on) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (deleted_on) ON @DBNAME@.devices IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT (deleted_on) ON @DBNAME@.devices '@DBUSER_IMS_PASSWORD@';
GRANT SELECT ON @DBNAME@.module_interface_version IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.module_interface_version IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.module_interface_version IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.module_interface_version IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.module_interface_version BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.hardware_inventory BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.hardware_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.hardware_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.hardware_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.hardware_inventory '@DBUSER_IMS_PASSWORD@';
Changing the Username and Password and Creating Additional Users for the Inventory Management System SQL Interface
343
GRANT SELECT ON @DBNAME@.software_inventory BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.software_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.software_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.software_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.software_inventory '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.packages_inventory BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.packages_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.packages_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.packages_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.packages_inventory '@DBUSER_IMS_PASSWORD@';
GRANT SELECT ON @DBNAME@.licensing_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.licensing_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.licensing_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.licensing_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.licensing_inventory '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.events_inventory BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.events_inventory BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.events_inventory IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.events_inventory BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.events_inventory '@DBUSER_IMS_PASSWORD@';
GRANT SELECT ON @DBNAME@.inventory_event_types IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.inventory_event_types IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.inventory_event_types IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.inventory_event_types IDENTIFIED BY '@DBUSER_IMS_PASSWORD@'; GRANT SELECT ON @DBNAME@.inventory_event_types '@DBUSER_IMS_PASSWORD@';
344
Changing the Username and Password and Creating Additional Users for the Inventory Management System SQL Interface
devices Table
The devices database table stores all Juniper Networks devices added in JUNOScope. For information about adding devices, see Setting Up Devices on page 59. Table 32 shows the fields and columns in the devices table.
Table 32: devices Table Field
id name hostname model comment deleted_on
Type
int(11) varchar(40) varchar(40) varchar(20) text timestamp(14)
Null
Key
PRI
Default
Extra
auto_increment
345
hardware_inventory Table
The hardware_inventory database table stores information about all hardware components installed in devices added in JUNOScope. Table 33 shows the fields and columns in the hardware_inventory table.
Table 33: hardware_inventory Table Field
id device_id chassis_id version part_number serial_number name module submodule subsubmodule description comment last_scanned last_modified created_on deleted_on
Type
int(11) int(11) varchar(20) varchar(20) varchar(20) varchar(20) varchar(40) varchar(40) varchar(40) varchar(40) varchar(40) text timestamp(14) timestamp(14) timestamp(14) timestamp(14)
Null
PRI
Key
Default
Extra
auto_increment
software_inventory Table
The software_inventory database table stores information about all JUNOS software packages installed on devices added in JUNOScope. Table 34 shows the fields and columns in the software_inventory table.
Table 34: software_inventory Table Field
id device_id routing_engine version last_scanned last_modified created_on deleted_on
Type
int(11) int(11) varchar(10) varchar(20) timestamp(14) timestamp(14) timestamp(14) timestamp(14)
Null
Key
PRI
Default
Extra
auto_increment
346
packages_inventory Table
The packages_inventory database table stores all JUNOS software packages installed on devices added in JUNOScope. Table 35 shows the fields and columns in the packages_inventory table.
Table 35: packages_inventory Table Field
id device_id routing_engine name comment last_scanned last_modified created_on deleted_on
Type
int(11) int(11) varchar(10) varchar(20) varchar(100) timestamp(14) timestamp(14) timestamp(14) timestamp(14)
Null
Key
PRI
Default
Extra
auto_increment
licensing_inventory Table
The licensing_inventory database table stores information about all licensed features installed on devices added in JUNOScope. Table 36 shows the fields and columns in the licensing_inventory table.
Table 36: licensing_inventory Table Field
id device_id feature_name feature_description licensed_count used_count given_count given_hint needed_count last_scanned last_modified created_on deleted_on
Type
int(11) int(11) varchar(64) varchar(64) int(11) int(11) int(11) varchar(64) int(11) timestamp(14) timestamp(14) timestamp(14) timestamp(14)
Null
Key
PRI
Default
Extra
auto_increment
0 0 0
347
events_inventory Table
The events_inventory database table stores all events that occur during an inventory scan using the Inventory Management System. For more information about running an inventory scan, see Scanning Inventory Data on page 279. Table 37 shows the fields and columns in the events_inventory table.
Table 37: events_inventory Table Field
id device_id hardware_id software_id package_id licensing_id item type description annotation event_time deleted_on
Type
int(11) int(11) int(11) int(11) int(11) int(11) varchar(40) varchar(10) text text timestamp(14) timestamp(14)
Null
Key
PRI
Default
Extra
auto_increment
0 0 0 0 0
inventory_events_types Table
The inventory_events_types database table stores all inventory scan event types. Table 38 shows the fields and columns in the inventory_events_types table.
Table 38: inventory_events_types Table Field
id event_type
Type
int(11) varchar(10)
Null
Key
PRI
Default
Extra
auto_increment
348
module_interface_version Table
The module_interface_version database table stores and identifies the module name and version of the Inventory Management System database. Table 39 shows the fields and columns in the module_interface_version table.
Table 39: module_interface_version Table Field
module version
Type
varchar(40) int(11)
Null
Key
PRI
Default
Extra
The version field is incremented when an update is made to the documented SQL interface with respect to the module. An update occurs when: A new public column is added. The meaning of a public column changes. A public column is removed. The module version identifies the public subset of the JUNOScope database schema.
Table-to-Module Mapping
Two modules are currently defined: ims and core. ims Module Version 1 of the ims module consists of the following tables: hardware_inventory Table on page 346 software_inventory Table on page 346 packages_inventory Table on page 347 licensing_inventory Table on page 347 events_inventory Table on page 348 inventory_events_types Table on page 348 core Module The core module (version 1) consists of the devices table listed in Table 32 on page 345.
349
350
Where:
<JTK_INSTALL> is the path of the JUNOScope installation. <DBPORT> is the port number of the database connection. The default port number is 3306. <HOSTNAME> is the hostname of database server. <DBUSER_IMS> is the database user for read-only access to the Inventory
Management System. This is the username that the JUNOScope administrator provided during the installation process.
<DBUSER_IMS_PASSWORD> is the password for the Inventory Management System database user. This is the password that the JUNOScope administrator provided during the installation process. <DBNAME> is the database name jtk for accessing the production Inventory Management System database, or demo for accessing the demonstration
database.
351
When an item is no longer active, the deleted_on field is updated with the time the entry was removed. You can make an entry inactive in one of two ways: When the item is no longer part of the network (for example, a PIC is removed from a chassis). The row is administratively removed from the database by marking the deleted_on field to non-zero, making it virtually hidden from the user. This is not done by user action, but by manually setting the deleted_on field in the database. The last_scanned field stores the timestamp of the item (row) when it was last updated and processed by the Inventory Management System, regardless of whether the item (row) itself was modified. The created_on field stores the timestamp of the item (row) when it was first scanned and processed by the Inventory Management System. If this item is removed from one chassis and moved to another, the created_on timestamp will remain the same.
352
353
354