Page 1 of 1

How do save /interface lte cell-monitor in file or variable

Posted: Sat Oct 27, 2018 6:27 pm
by wgrando1993
Hi dears;

I try to create an script to save the output of the [/interface lte number=0 cell-monitor duration=5]; to future analisys, but all files and all variables stay nil
{
:local filename "ltecellmonitor.txt";
:local content [/interface lte cell-monitor number=0 duration=5];
[/file set $filename contents=$content];
}

but i noticed what all info just are displayed while the command is running, from way, i think what is necessary to run another script in parallel to save the data ?

Re: How do save /interface lte cell-monitor in file or variable

Posted: Sat Oct 27, 2018 7:20 pm
by Jotne
I am not very good in scripting, but has used it some to graph data found in MT and send it out to using Syslog to Splunk for analyzes.
See my project here: viewtopic.php?t=137338
Taken some part from the script and modified for cell info

This should send it out using syslog
:local cell ([/interface lte cell-monitor number=0 duration=5]);
:log info message="cell_info=$cell";
PS use code tag around your code to make your post more readable.


Edit after some search found this on how to write to a file:
# Create a file with specific content.
{
# Variables.
    :local filename "test.txt"
    :local content "This is a test."
    
# Create file.
    /file print file=$filename where name=""
# Wait for the file to be created.
    :delay 1
# Set file's content.
    /file set $filename contents=$content
}
So try this:
# Create a file with specific content.
{
# Variables.
    :local filename "ltecellmonitor.txt"
    :local content  [/interface lte cell-monitor number=0 duration=5]
    
# Create file.
    /file print file=$filename where name=""
# Wait for the file to be created.
    :delay 1
# Set file's content.
    /file set $filename contents=$content
}

Re: How do save /interface lte cell-monitor in file or variable

Posted: Sat Oct 27, 2018 8:23 pm
by wgrando1993
Hi Jotne;
thanks for answering me

I have tried these forms, but the output of the cell-info command returns a NULL value, ie it is not stored in a variable, the output of the command is visible only at its execution time, already tried to display it in log, already tried with global variable, but has not yet been successful.
{
:global content [/interface lte cell-monitor number=0 duration=5];
:put $content;
}

{
:global content [:find [/interface lte cell-monitor number=0 duration=5] "BAND" -1];
:put $content;
}

{
:local content [/interface lte cell-monitor number=0 duration=5];
:put $content;
}

{
:local content [:find [/interface lte cell-monitor number=0 duration=5] "BAND" -1];
:put $content;
}

{
:global content [:execute "[/interface lte cell-monitor number=0 duration=5];"];
:put $content;
}

{
:local filename "ltecellmonitor.txt";
:global content [/interface lte cell-monitor number=0 duration=5];
[/file print file=$filename where name=""];
[/file set $filename contents=$content];
}

{
:local filename "ltecellmonitor.txt";
:local content [:execute "[/interface lte cell-monitor number=0 duration=5] ;"];
[/file print file=$filename];
[/file set $filename contents=$content];
}