Thank you Kai.

I think I am making progress, is this the output that is expected:

        "*                                                                
*", 
        "*   Disconnect IMMEDIATELY if you are not an authorized user!    
*", 
        "*    All access and use may be monitored and/or recorded.        * 
", 
        "*                                                                
*", 
        
"******************************************************************", 
        "", 
        "", 
        "SBCHA1# show sessions", 
        "11:17:24-107 Capacity=4000", 
        "Session Statistics            -- Period -- -------- Lifetime 
--------", 
        "                    Active    High   Total      Total  PerMax    
High", 
        "Total Sessions        1606    1661    3346  128530803   15238    
2452", 
        "SIP Sessions          1606    1661    3346  128530803   15238    
2452", 
        "H.323 Calls              0       0       0          0       0      
 0", 
        "", 
        "SIP Audio/Video Statistics    -- Period -- -------- Lifetime 
--------", 
        "                    Active    High   Total      Total  PerMax    
High", 
        "Audio Calls           1541    1592    2582   90699117    8060    
2096", 
        "Video Calls              0       0       0        113       7      
 2", 
        "Messaging Sessions       0       0       0          0       0      
 0", 
        "SBCHA1# sh platform cpu-load", 
        "Timestamp: 11:17:24 Thu 2020-02-13", 
        "Total load   :     9%", 
        "CPU 00 load  :     9%", 
        "CPU 01 load  :     9%", 
        "CPU 02 load  :     10%", 
        "CPU 03 load  :     9%", 
        "SBCHA1# exit", 
        "SBCHA1> "
    ]

As a note, the SBC does have a ASCII banner, not sure if it may cause 
issues.


On Wednesday, 12 February 2020 18:15:53 UTC+2, Kai Stian Olstad wrote:
>
> On Wed, Feb 12, 2020 at 02:39:08AM -0800, Gerhard Van Der Wath wrote: 
> > Hi Kai. 
> > 
> > Thank you for taking the time to get back to me. 
> > 
> > It is highly appreciated, and apologies for the formatting of my 
> request, I 
> > will correct this in future. 
> > 
> > I am in uncharted waters here as I am new to Ansible, and coding in 
> > general, but I have made some changes to the code: 
> > 
> > - name: Check CPU 
> >   hosts: 10.18.170.200 
> >   connection: local 
> >   gather_facts: yes 
> > 
> > 
> >   tasks: 
> > 
> >   - name: Get CPU load 
> >     expect: 
> >       command: ssh [email protected] <javascript:> 
> >       responses: 
> >        (?i)password: "#######" 
> > 
> >   - name: basic command 
> >     expect: 
> >       command: show platform cpu-load summary 
> >       responses: 
> >        (?i)#: 
>
> You can't split it like that. 
> Two tasks in Ansible have nothing do to with each other. 
>
> The expect command will always be the ssh and in the response section it 
> will 
> contain the command for the interface. 
>
> So it will be something like this. 
>
>   - name: Get CPU load 
>     expect: 
>       command: ssh [email protected] <javascript:> 
>       responses: 
>         (?i)password: "#######" 
>         #: 
>           - show platform cpu-load summary 
>           - exit 
>
> When expect sees "password" it will type "#######" and hit enter. 
> When it sees "#" it will write the first element in the list(show...) of 
> the 
> second time expect sees "#" it will write "exit" and hit enter. 
> (I presume exit terminate the connection, if not change it to the correct 
> command) 
>
> -- 
> Kai Stian Olstad 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/74084223-62a4-4662-b77b-48b7ed35191f%40googlegroups.com.

Reply via email to