Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-19-2020, 07:39 PM
aqelmo aqelmo is offline
Registered User
 
Join Date: Mar 2020
Posts: 6
Unhappy Geting logs from multiple nodes

Hi.

Scripting is not my field so I'm having issues with making a script.

This is the situation: I'm connected to the system and authorized. I want to connect to several RBSs and get alarms from them.

Basically I need to do this on for each node:

Code:
	crt.Screen.Send "amos nodeID" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "alt" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "q" & chr(13)
I know I should be able to load nodes from a host file and then iterate this over that list but the example scripts are way too complicated and when I try to change anything it all fails miserably. I know how to log to separate files but this part is way over my head.

Some help would be appreciated.
Reply With Quote
  #2  
Old 03-20-2020, 07:26 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,282
Hi aqelmo,

Version of SecureCRT?

Quote:
I'm connected to the system and authorized. I want to connect to several RBSs and get alarms from them.
So "system" is different than RBSs? Do you need to make the connection from system to the RBS?

Please list the *explicit* steps as to how you would accomplish the task manually.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 03-21-2020, 05:50 AM
aqelmo aqelmo is offline
Registered User
 
Join Date: Mar 2020
Posts: 6
Hi,

Unfortunately, I'm using a really old version, 6.1.4.
Apparently "it's working and you don't need a new one".

It's Ericsson system for managing radio base stations.

Literally what I need to do is:

amos node1 (connect to node node1)
al (list alarms)
q (disconnect)
amos node2
al
q
amos node3
al
q
.
.
.



I would also append to separate log files for each node, that I know how to do.
Reply With Quote
  #4  
Old 03-22-2020, 12:58 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,282
Hi aqelmo,

It is still not clear to me if you are connected to the nodes or need to connect in the script.

If already connected, it is fairly easy to iterate over the connected tabs with a For/Next loop:

Code:
Sub Main()
    Do
        ' Iterate through all tabs, running commands
        For i = 1 To crt.GetTabCount
            Set objTab = crt.GetTab(i)
            ' Run Commands and disconnect
        Next
    Loop
End Sub
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 03-24-2020, 04:00 PM
aqelmo aqelmo is offline
Registered User
 
Join Date: Mar 2020
Posts: 6
Hi.

I'm initially connected to the management system (jump host?) and then within the same session connect, issue commands and disconnect from managed nodes.
If I record the session as a script it looks like this:

Code:
Sub Main
	crt.Screen.Send "amos 0001" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "al" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "q" & chr(13)
crt.Screen.WaitForString chr(126) & "]$ "
	crt.Screen.Send "amos 0002" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "al" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "q" & chr(13)
crt.Screen.WaitForString chr(126) & "]$ "
	crt.Screen.Send "amos 0003" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "al" & chr(13)
	crt.Screen.WaitForString "[0m> "
	crt.Screen.Send "q" & chr(13)
End Sub


Code:
Sub Main
	crt.Screen.Send "amos 0001" & chr(13) <- connect to node 0001
	crt.Screen.WaitForString "[0m> " <- node prompt
	crt.Screen.Send "al" & chr(13) <- send command
	crt.Screen.WaitForString "[0m> " <- node prompt
	crt.Screen.Send "q" & chr(13) <- send disconnect command
crt.Screen.WaitForString chr(126) & "]$ " <- management system prompt
	crt.Screen.Send "amos 0002" & chr(13)  <- connect to node 0002
	crt.Screen.WaitForString "[0m> "  <- node prompt
	crt.Screen.Send "al" & chr(13) <- send command
	crt.Screen.WaitForString "[0m> "  <- node prompt
	crt.Screen.Send "q" & chr(13) <- send disconnect command
crt.Screen.WaitForString chr(126) & "]$ " <- management system prompt
	crt.Screen.Send "amos 0003" & chr(13)  <- connect to node 0003
	crt.Screen.WaitForString "[0m> " <- node prompt
	crt.Screen.Send "al" & chr(13)  <- send command
	crt.Screen.WaitForString "[0m> "   <- node prompt
	crt.Screen.Send "q" & chr(13)  <- send disconnect command
End Sub
I was looking at RunCommandsOnMultipleHostsAndLogResults and JumpHost-HandleSecondaryHostConnectionAttempts but both are just too much code go get few things I need.

Last edited by aqelmo; 03-24-2020 at 11:41 PM.
Reply With Quote
  #6  
Old 03-25-2020, 07:18 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,282
Hi aqelmo,

How do you know what that first send is going to be?

Is it always amos 0001, amos 0002, amos 0003?

If not, where do you get the data from? How do you know what node(s) you will connect to?

Because even in a script, you have to know how to determine what to send, if that makes sense.

If just the three …
Code:
For i = 1 to 3
    crt.Screen.WaitForString chr(126) & "]$ "
    crt.Screen.Send "amos 000" & i & chr(13)
    crt.Screen.WaitForString "[0m> "
    crt.Screen.Send "al" & chr(13)
    crt.Screen.WaitForString "[0m> "
    crt.Screen.Send "q" & chr(13)
Next
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 03-25-2020 at 07:19 AM. Reason: Put WFS in loop
Reply With Quote
  #7  
Old 03-25-2020, 12:23 PM
aqelmo aqelmo is offline
Registered User
 
Join Date: Mar 2020
Posts: 6
Hi.

There are a few hundred nodes. I can export the list of nodes and get a file with single node ID per line. That should be an OK format for import? Since the list of nodes changes over time, it would be best to have it separately and not hardcoded into the script.
Reply With Quote
  #8  
Old 03-25-2020, 01:27 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,282
Hi aquelmo,

So are all worked on at the same time?

Or could it be amos 0015 to amos 0102, for example, at any given time?

If so, you can prompt the user for which nodes they will be working on (assuming they all have the amos prefix). Or you could pass those as arguments to the script.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #9  
Old 03-27-2020, 09:08 AM
aqelmo aqelmo is offline
Registered User
 
Join Date: Mar 2020
Posts: 6
After a lot of try and error, I managed to hack something that does what I want to do.


stop logging my session

loop
connect to node
get alarms
append to log file for that node
quit
stop logging
end loop

start logging my normal session



Now I need to get it to populate hosts aray from a file, instead of hardcoding it.
But coffee 1st.


Code:
# $language = "VBScript"
# $interface = "1.0"

g_strLogFileTemplate = "C:\path\Log\NODEID.txt"
crt.Screen.Synchronous = True
vHosts = Array(_
    "0001",_
    "0002",_
    "0003")


nIndex = 0

	crt.Session.Log False
Do
    Do
		crt.Screen.Send "amos " & vHosts(nIndex) & chr(13)
		crt.Screen.WaitForString "[0m> "
		crt.Screen.Send "alt" & chr(13)
		crt.Session.LogFileName = Replace( _
            g_strLogFileTemplate, _
            "NODEID", _
             vHosts(nIndex))
			crt.Session.Log True, True
		crt.Screen.WaitForString "[0m> "
		crt.Session.Log False
		crt.Screen.Send "q" & chr(13)
		crt.Screen.WaitForString chr(126) & "]$ "
                Exit Do
    Loop

    nIndex = nIndex + 1


    If nIndex > Ubound(vHosts) Then Exit Do

Loop
	crt.Session.LogFileName = "C:\path\logs\%Y.%M.%D - %S_ENM.log"
	crt.Session.Log True, True

Last edited by aqelmo; 03-27-2020 at 09:15 AM.
Reply With Quote
  #10  
Old 03-27-2020, 09:47 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,282
Hi aqelmo,

Congrats on your progress!

The previously referenced script (RunCommandsOnMultipleHostsAndLogResults) illustrates reading from a file. I understand when users feel a script has "more than they need" but it can still be used to borrow the relevant pieces of code.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #11  
Old 03-27-2020, 09:56 AM
aqelmo aqelmo is offline
Registered User
 
Join Date: Mar 2020
Posts: 6
I'm looking at it atm.
That and scripting essentials pdf.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:53 PM.