Terminal Batch doesn't work always

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Terminal Batch doesn't work always

Lutz Mader
Hello Tildeslash,
I try to gather the Service status summary via a curl request from an
other/remote monit system to use the status in a local monit check
program script.

curl 'http://admin:monit@...:2812/_summary?format=xml'
or
curl 'http://admin:monit@...:2812/_summary?format=text'

Unfortunately, I got the output in the terminal output format only.

I try to disable tabular output and colours completely in the monitrc
used by monit.

set terminal batch

Nothing was happened, I got the terminal text format with tabular output
and colours. But the tabular and colours are removed from the local
monit command output (the monit daemon was restarted), the set terminal
batch mode seems to be used (handled like -B).

My question is this the normal behaviour?
How to get text only or xml output via curl for _summary?

With _status and format xml I got xml output, but many other
informations also. And with format text I got the coloured output as well.

Thanks for any help or suggestion,
Lutz

p.s.
I use Monit 5.25.1 and 5.22.0, 5.19.0.

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: Terminal Batch doesn't work always

martinp@tildeslash.com
Hello Lutz,

the color (ANSI escape sequence) is set on server-side and stripped by monit CLI if in batch mode. If you use curl to fetch the status in txt format directly, you need to strip the escape sequence yourselves, for example:

curl http://127.0.0.1:2812/_status | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"

We'll simplify the color handling in the future release.

Best regards,
Martin




On 23 Mar 2018, at 14:19, Lutz Mader <[hidden email]> wrote:

Hello Tildeslash,
I try to gather the Service status summary via a curl request from an
other/remote monit system to use the status in a local monit check
program script.

curl 'http://admin:monit@...:2812/_summary?format=xml'
or
curl 'http://admin:monit@...:2812/_summary?format=text'

Unfortunately, I got the output in the terminal output format only.

I try to disable tabular output and colours completely in the monitrc
used by monit.

set terminal batch

Nothing was happened, I got the terminal text format with tabular output
and colours. But the tabular and colours are removed from the local
monit command output (the monit daemon was restarted), the set terminal
batch mode seems to be used (handled like -B).

My question is this the normal behaviour?
How to get text only or xml output via curl for _summary?

With _status and format xml I got xml output, but many other
informations also. And with format text I got the coloured output as well.

Thanks for any help or suggestion,
Lutz

p.s.
I use Monit 5.25.1 and 5.22.0, 5.19.0.

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
Reply | Threaded
Open this post in threaded view
|

Re: Terminal Batch doesn't work always

Lutz Mader
Hello Martin,
thanks or your suggestion to strip the ANSI escape codes.

I'm not aware that the ANSI codes set on the server side all the time an
stripped by the monit CLI in the batch mode. Nice to know someone try to
make the color handling more easy.

With regards,
I'm happy,
Lutz

p.s.
Someone should make the xml-format for the _summary available also.


Am 23.03.18 um 21:45 schrieb [hidden email]:

> Hello Lutz,
>
> the color (ANSI escape sequence) is set on server-side and stripped by monit CLI if in batch mode. If you use curl to fetch the status in txt format directly, you need to strip the escape sequence yourselves, for example:
>
> curl http://127.0.0.1:2812/_status <http://127.0.0.1:2812/_status> | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
>
> We'll simplify the color handling in the future release.
>
> Best regards,
> Martin
>
>
>
>
>> On 23 Mar 2018, at 14:19, Lutz Mader <[hidden email]> wrote:
>>
>> Hello Tildeslash,
>> I try to gather the Service status summary via a curl request from an
>> other/remote monit system to use the status in a local monit check
>> program script.
>>
>> curl 'http://admin:monit@...:2812/_summary?format=xml'
>> or
>> curl 'http://admin:monit@...:2812/_summary?format=text'
>>
>> Unfortunately, I got the output in the terminal output format only.
>>
>> I try to disable tabular output and colours completely in the monitrc
>> used by monit.
>>
>> set terminal batch
>>
>> Nothing was happened, I got the terminal text format with tabular output
>> and colours. But the tabular and colours are removed from the local
>> monit command output (the monit daemon was restarted), the set terminal
>> batch mode seems to be used (handled like -B).
>>
>> My question is this the normal behaviour?
>> How to get text only or xml output via curl for _summary?
>>
>> With _status and format xml I got xml output, but many other
>> informations also. And with format text I got the coloured output as well.
>>
>> Thanks for any help or suggestion,
>> Lutz
>>
>> p.s.
>> I use Monit 5.25.1 and 5.22.0, 5.19.0.
>>
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
>
>
>
>


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general