Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Kip_Banfield
Explorer
Jump to solution

SmartConsole Result parsing

Is there a way to parse out or filter your results in the SmartConsole CLI like something comparable to grep?

0 Kudos
1 Solution

Accepted Solutions
Danny
Champion Champion
Champion

The SmartConsole CLI can be directly accessed from within SmartConsole by clicking the image.png icon on the bottom left corner or from the Gaia CLI shell (clish), where you need to login as a management user first.

SmartConsole -> Management CLI:

To access the Management CLI In Gaia's CLI shell (clish) type:

mgmt login‍

or

mgmt login user myname‍

After that you remain in the familiar Gaia shell, but now you can use the management APIs.

 

Example:

> mgmt login user 
Enter password: ******

> show interfaces
eth0
eth0.3
lo
> mgmt add host name myHost12 ip-address 3.3.3.3
> mgmt publish

        message "OK"
        number-of-published-changes     1

>     ‍‍‍‍‍‍‍‍‍‍‍‍‍‍
  • The syntax is identical to the commands that you run in the SmartConsole GUI.
  • All management commands start with the word "mgmt".

Neither Gaia clish not the Management CLI (SmartConsole CLI ) feature any result filters, such as grep, at the moment.
However, you can access these CLI's from Gaia's expert mode and filter results via grep there.

Example:

[Expert@Management:0]# clish -c "mgmt login user USERNAME password PASSWORD"
[Expert@Management:0]# clish -c "mgmt show-version" | grep edition
os-edition: "64-bit"‍‍‍

Related article: sk98877

View solution in original post

6 Replies
Vladimir
Champion
Champion

From the expert mode, yes:

[Expert@GW8010:0]# cplic print | grep 419AQF2

11 | 419AQF2 | 13Sep2018 | CPSB-ASPM-DEMO
[Expert@GW8010:0]#

From clish, not really.

0 Kudos
Danny
Champion Champion
Champion

The SmartConsole CLI can be directly accessed from within SmartConsole by clicking the image.png icon on the bottom left corner or from the Gaia CLI shell (clish), where you need to login as a management user first.

SmartConsole -> Management CLI:

To access the Management CLI In Gaia's CLI shell (clish) type:

mgmt login‍

or

mgmt login user myname‍

After that you remain in the familiar Gaia shell, but now you can use the management APIs.

 

Example:

> mgmt login user 
Enter password: ******

> show interfaces
eth0
eth0.3
lo
> mgmt add host name myHost12 ip-address 3.3.3.3
> mgmt publish

        message "OK"
        number-of-published-changes     1

>     ‍‍‍‍‍‍‍‍‍‍‍‍‍‍
  • The syntax is identical to the commands that you run in the SmartConsole GUI.
  • All management commands start with the word "mgmt".

Neither Gaia clish not the Management CLI (SmartConsole CLI ) feature any result filters, such as grep, at the moment.
However, you can access these CLI's from Gaia's expert mode and filter results via grep there.

Example:

[Expert@Management:0]# clish -c "mgmt login user USERNAME password PASSWORD"
[Expert@Management:0]# clish -c "mgmt show-version" | grep edition
os-edition: "64-bit"‍‍‍

Related article: sk98877

Vladimir
Champion
Champion

Danny,

When I am trying to execute clish -c "mgmt xxx", I am getting database lock errors:

SMS8010> lock database override
CLICMD0201 Config lock is already turned on.
SMS8010> expert
Enter expert password:


Warning! All configurations should be done through clish
You are in expert mode now.

[Expert@SMS8010:0]# clish -c "mgmt login user admin password FakePWD"
CLINFR0771 Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.
[Expert@SMS8010:0]# clish -c "mgmt login user admin"
CLINFR0771 Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.
Enter password:
[Expert@SMS8010:0]# clish -c "mgmt show-version"
CLINFR0771 Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.
MGMT9205 You are not logged in to management server, in order to log-in you will need to run "mgmt login user [user name]"
[Expert@SMS8010:0]#

CLI is the only active session.

Any ideas?

0 Kudos
Kip_Banfield
Explorer

When I go into SmartConsole CLI  From the Icon and try and type mgmt login it tells me message: "Requested API command: [Mgmt] not found". What I would like to be able to do is do a show_group and parse out just the member names without displaying out the rest of the Information. I can do it from the mgmt_cli when I ssh directly into the management station with this command "mgmt_cli show-group name "Group Name" --root true --format json | $CPDIR/jq/jq ".members[].name" but would like to do the from the SmartConsole CLI. 

0 Kudos
PhoneBoy
Admin
Admin

When you are in the SmartConsole CLI, you do not need to login as you are already logged in.

As far as I know, you cannot pipe output from the SmartConsole CLI to another Unix shell command.

0 Kudos
Tomer_Sole
Mentor
Mentor

Hi, please notice that the beginning of the API syntax differs if it runs from within SmartConsole CLI, Gaia clish, expert mode mgmt_cli or via web services.

API execution modePrefix for commandsExampleSupports login / publish?Can grep results?
SmartConsole CLIno prefix.add host name "New Host 1" ip-address "192.0.2.1"No, because it runs on the session that was already logged in. Publish is only supported via GUI button in this case.No
Gaia clishmgmtmgmt add host name "New Host 1" ip-address "192.0.2.1"YesYes
Expert mode mgmt_climgmt_climgmt_cli add host name "New Host 1" ip-address "192.0.2.1"YesYes
Web servicessending an HTTP POST request. Notice the command name has all hyphens and no spaces unlike the othersPOST {{server}}/add-host
Content-Type: application/json
X-chkp-sid: {{session}} 

{
   "name" : "New Host 1",
   "ip-address" : "192.0.2.1"
}
YesNot directly

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events