Thanks Vladimir  !!!

On Tuesday, February 28, 2023 at 12:41:46 PM UTC+5:30 Vladimir Botka wrote:

> On Mon, 27 Feb 2023 21:07:45 -0800 (PST)
> Veera <[email protected]> wrote:
>
> > load_avg: "{{ up_out.stdout_lines[0].split()[7:] }}"
>
> Given the registered variable *up_out*
>
> - command: uptime
> register: up_out
>
> Use the filter community.general.jc to parse the stdout. The utility
> *jc* "converts the output of many commands, file-types, and strings
> to JSON or YAML". For example,
>
> uptime: "{{ up_out.stdout|community.general.jc('uptime') }}"
>
> gives
>
> uptime:
> load_15m: 1.21
> load_1m: 1.84
> load_5m: 1.41
> time: 07:57:41
> time_hour: 7
> time_minute: 57
> time_second: 41
> uptime: 11 days, 18:12
> uptime_days: 11
> uptime_hours: 18
> uptime_minutes: 12
> uptime_total_seconds: 1015920
> users: 2
>
> The first three attributes come from "load average". Quoting from man
> uptime: "The averages are taken over the three time intervals." Now,
> the usage is trivial. For example,
>
> load_average: >
> {{ uptime.load_1m }},
> {{ uptime.load_5m}},
> {{ uptime.load_15m }}
>
> gives
>
> load_average: |-
> 1.84, 1.41, 1.21
>
> -- 
> Vladimir Botka
>

-- 
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/5e9ee466-5e48-4e6a-87f9-0e67834443a8n%40googlegroups.com.

Reply via email to