FAQ
I think Minions regularly try to contact the master.
I believe this is just "I am here" message, but I might be wrong.

I think these are the messages I see in the output of `salt-master -l info`:
[INFO ] Clear payload received with command _auth
[INFO ] Authentication request from Mini01
[INFO ] Authentication accepted from Mini01


I would like to query date and time of the last contact for all minions the
salt-master has a key.

Format of the query result:
Minion | Last contact |
Mini01 | 2015-05-21--12:30 |
Mini02 | 2015-05-20--10:30 |

Thank you

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Markus Kramer at May 22, 2015 at 9:48 am
    After reading how-do-i-list-all-connected-salt-stack-minions
    <http://serverfault.com/questions/529049/how-do-i-list-all-connected-salt-stack-minions>
    I wrote the below script.

    The result is consistent with `salt-run manage.status`

    While I seem to have my answer, the approach needs confirmation, e.g.:
      - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
      - why manage.status waits 10 seconds?
      - is "last-seen time older than 1 hour" equivalent to "up" and "down"?


    Thank you




    '''
    GOAL
    list 'last seen' time of minions

    USAGE
    sudo python ./halloMinion.py | sort

    COMPARE WITH
    sudo salt-run manage.status

    EXAMPLE OUTPUT
    2015.05.18 10:36:43 Mini1
    2015.05.21 13:56:08 Mini2
    2015.05.21 23:25:54 Mini3
    2015.05.22 10:51:22 Mini4
    2015.05.22 10:56:56 Mini5

    WARNING
    reverse engineering, assumptions, needs offical comment.


    '''
    ##########################################################################
    import sys
    from os import listdir
    from os.path import isfile
    from os.path import isdir
    import datetime
    import os
    import os.path


    ##########################################################################
    def modification_date(filename):
         t = os.path.getmtime(filename)
         x = datetime.datetime.fromtimestamp(t)
         return x

    def datetime2string(i):
         r = i.strftime("%Y.%m.%d %H:%M:%S")
         return r


    ##########################################################################

    DIR_OF_DIR_pki = '/etc/salt/pki/master/minions/'
    '''
    Only those Minons are known
    '''



    DIR_OF_DIR_cache = '/var/cache/salt/master/minions/'
    '''
    There are more directories than there are known minons
    In each directory there are two files.
    '''

    ##########################################################################

    all_known_minions = [ f for f in listdir(DIR_OF_DIR_pki) if
    isdir(DIR_OF_DIR_pki) ]

    for one_minion in all_known_minions:
         one_minion_cache_dir = os.path.join(DIR_OF_DIR_cache, one_minion)
         age_of_d = modification_date(os.path.join(one_minion_cache_dir,
    'data.p'))
         age_of_m = modification_date(os.path.join(one_minion_cache_dir,
    'mine.p'))
         lastseen = max(age_of_d,age_of_m)
         print datetime2string( lastseen)+ "\t" + one_minion




    On Thursday, 21 May 2015 13:25:19 UTC+2, Markus Kramer wrote:

    I think Minions regularly try to contact the master.
    I believe this is just "I am here" message, but I might be wrong.

    I think these are the messages I see in the output of `salt-master -l
    info`:
    [INFO ] Clear payload received with command _auth
    [INFO ] Authentication request from Mini01
    [INFO ] Authentication accepted from Mini01


    I would like to query date and time of the last contact for all minions
    the salt-master has a key.

    Format of the query result:
    Minion | Last contact |
    Mini01 | 2015-05-21--12:30 |
    Mini02 | 2015-05-20--10:30 |

    Thank you
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colton Myers at May 28, 2015 at 8:06 pm

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    What do you mean by "stable"? They don't get deleted with new releases, if
    that's what you're asking.

    - why manage.status waits 10 seconds?
    Because if there are any minions for which we have accepted keys, but that
    are not responding, we must wait for the command to timeout before we
    declare them as "disconnected".

    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?

    I suppose that depends on your definition of "up" and "down". We don't have
    an official time limit on "up" and "down" that I know of.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC


    On Fri, May 22, 2015 at 3:48 AM, Markus Kramer wrote:

    After reading how-do-i-list-all-connected-salt-stack-minions
    <http://serverfault.com/questions/529049/how-do-i-list-all-connected-salt-stack-minions>
    I wrote the below script.

    The result is consistent with `salt-run manage.status`

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    - why manage.status waits 10 seconds?
    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?


    Thank you




    '''
    GOAL
    list 'last seen' time of minions

    USAGE
    sudo python ./halloMinion.py | sort

    COMPARE WITH
    sudo salt-run manage.status

    EXAMPLE OUTPUT
    2015.05.18 10:36:43 Mini1
    2015.05.21 13:56:08 Mini2
    2015.05.21 23:25:54 Mini3
    2015.05.22 10:51:22 Mini4
    2015.05.22 10:56:56 Mini5

    WARNING
    reverse engineering, assumptions, needs offical comment.


    '''
    ##########################################################################
    import sys
    from os import listdir
    from os.path import isfile
    from os.path import isdir
    import datetime
    import os
    import os.path


    ##########################################################################
    def modification_date(filename):
    t = os.path.getmtime(filename)
    x = datetime.datetime.fromtimestamp(t)
    return x

    def datetime2string(i):
    r = i.strftime("%Y.%m.%d %H:%M:%S")
    return r


    ##########################################################################

    DIR_OF_DIR_pki = '/etc/salt/pki/master/minions/'
    '''
    Only those Minons are known
    '''



    DIR_OF_DIR_cache = '/var/cache/salt/master/minions/'
    '''
    There are more directories than there are known minons
    In each directory there are two files.
    '''

    ##########################################################################

    all_known_minions = [ f for f in listdir(DIR_OF_DIR_pki) if
    isdir(DIR_OF_DIR_pki) ]

    for one_minion in all_known_minions:
    one_minion_cache_dir = os.path.join(DIR_OF_DIR_cache, one_minion)
    age_of_d = modification_date(os.path.join(one_minion_cache_dir,
    'data.p'))
    age_of_m = modification_date(os.path.join(one_minion_cache_dir,
    'mine.p'))
    lastseen = max(age_of_d,age_of_m)
    print datetime2string( lastseen)+ "\t" + one_minion




    On Thursday, 21 May 2015 13:25:19 UTC+2, Markus Kramer wrote:

    I think Minions regularly try to contact the master.
    I believe this is just "I am here" message, but I might be wrong.

    I think these are the messages I see in the output of `salt-master -l
    info`:
    [INFO ] Clear payload received with command _auth
    [INFO ] Authentication request from Mini01
    [INFO ] Authentication accepted from Mini01


    I would like to query date and time of the last contact for all minions
    the salt-master has a key.

    Format of the query result:
    Minion | Last contact |
    Mini01 | 2015-05-21--12:30 |
    Mini02 | 2015-05-20--10:30 |

    Thank you
    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Markus Kramer at May 29, 2015 at 2:27 pm

    On Thursday, 28 May 2015 22:06:38 UTC+2, basepi wrote:
    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    What do you mean by "stable"? They don't get deleted with new releases, if
    that's what you're asking.
    Then I kindly propose to integrate the above code as "verbose" option into
    salt.manage down.
    For me it is useful to know how long a minion is down - "down" can be two
    hours or two weeks.


    - why manage.status waits 10 seconds?
    Because if there are any minions for which we have accepted keys, but that
    are not responding, we must wait for the command to timeout before we
    declare them as "disconnected".

    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?

    I suppose that depends on your definition of "up" and "down". We don't
    have an official time limit on "up" and "down" that I know of.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC



    On Fri, May 22, 2015 at 3:48 AM, Markus Kramer <markus...@posteo.de
    <javascript:>> wrote:
    After reading how-do-i-list-all-connected-salt-stack-minions
    <http://serverfault.com/questions/529049/how-do-i-list-all-connected-salt-stack-minions>
    I wrote the below script.

    The result is consistent with `salt-run manage.status`

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    - why manage.status waits 10 seconds?
    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?


    Thank you




    '''
    GOAL
    list 'last seen' time of minions

    USAGE
    sudo python ./halloMinion.py | sort

    COMPARE WITH
    sudo salt-run manage.status

    EXAMPLE OUTPUT
    2015.05.18 10:36:43 Mini1
    2015.05.21 13:56:08 Mini2
    2015.05.21 23:25:54 Mini3
    2015.05.22 10:51:22 Mini4
    2015.05.22 10:56:56 Mini5

    WARNING
    reverse engineering, assumptions, needs offical comment.


    '''
    ##########################################################################
    import sys
    from os import listdir
    from os.path import isfile
    from os.path import isdir
    import datetime
    import os
    import os.path


    ##########################################################################
    def modification_date(filename):
    t = os.path.getmtime(filename)
    x = datetime.datetime.fromtimestamp(t)
    return x

    def datetime2string(i):
    r = i.strftime("%Y.%m.%d %H:%M:%S")
    return r


    ##########################################################################

    DIR_OF_DIR_pki = '/etc/salt/pki/master/minions/'
    '''
    Only those Minons are known
    '''



    DIR_OF_DIR_cache = '/var/cache/salt/master/minions/'
    '''
    There are more directories than there are known minons
    In each directory there are two files.
    '''

    ##########################################################################

    all_known_minions = [ f for f in listdir(DIR_OF_DIR_pki) if
    isdir(DIR_OF_DIR_pki) ]

    for one_minion in all_known_minions:
    one_minion_cache_dir = os.path.join(DIR_OF_DIR_cache, one_minion)
    age_of_d = modification_date(os.path.join(one_minion_cache_dir,
    'data.p'))
    age_of_m = modification_date(os.path.join(one_minion_cache_dir,
    'mine.p'))
    lastseen = max(age_of_d,age_of_m)
    print datetime2string( lastseen)+ "\t" + one_minion




    On Thursday, 21 May 2015 13:25:19 UTC+2, Markus Kramer wrote:

    I think Minions regularly try to contact the master.
    I believe this is just "I am here" message, but I might be wrong.

    I think these are the messages I see in the output of `salt-master -l
    info`:
    [INFO ] Clear payload received with command _auth
    [INFO ] Authentication request from Mini01
    [INFO ] Authentication accepted from Mini01


    I would like to query date and time of the last contact for all minions
    the salt-master has a key.

    Format of the query result:
    Minion | Last contact |
    Mini01 | 2015-05-21--12:30 |
    Mini02 | 2015-05-20--10:30 |

    Thank you
    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colton Myers at Jun 4, 2015 at 10:41 pm
    Perhaps a new function within that manage runner? We'd love to see a pull
    request.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Fri, May 29, 2015 at 8:27 AM, Markus Kramer wrote:


    On Thursday, 28 May 2015 22:06:38 UTC+2, basepi wrote:

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    What do you mean by "stable"? They don't get deleted with new releases,
    if that's what you're asking.
    Then I kindly propose to integrate the above code as "verbose" option into
    salt.manage down.
    For me it is useful to know how long a minion is down - "down" can be two
    hours or two weeks.


    - why manage.status waits 10 seconds?
    Because if there are any minions for which we have accepted keys, but
    that are not responding, we must wait for the command to timeout before we
    declare them as "disconnected".

    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?

    I suppose that depends on your definition of "up" and "down". We don't
    have an official time limit on "up" and "down" that I know of.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC



    On Fri, May 22, 2015 at 3:48 AM, Markus Kramer <markus...@posteo.de>
    wrote:
    After reading how-do-i-list-all-connected-salt-stack-minions
    <http://serverfault.com/questions/529049/how-do-i-list-all-connected-salt-stack-minions>
    I wrote the below script.

    The result is consistent with `salt-run manage.status`

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    - why manage.status waits 10 seconds?
    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?


    Thank you




    '''
    GOAL
    list 'last seen' time of minions

    USAGE
    sudo python ./halloMinion.py | sort

    COMPARE WITH
    sudo salt-run manage.status

    EXAMPLE OUTPUT
    2015.05.18 10:36:43 Mini1
    2015.05.21 13:56:08 Mini2
    2015.05.21 23:25:54 Mini3
    2015.05.22 10:51:22 Mini4
    2015.05.22 10:56:56 Mini5

    WARNING
    reverse engineering, assumptions, needs offical comment.


    '''

    ##########################################################################
    import sys
    from os import listdir
    from os.path import isfile
    from os.path import isdir
    import datetime
    import os
    import os.path



    ##########################################################################
    def modification_date(filename):
    t = os.path.getmtime(filename)
    x = datetime.datetime.fromtimestamp(t)
    return x

    def datetime2string(i):
    r = i.strftime("%Y.%m.%d %H:%M:%S")
    return r



    ##########################################################################

    DIR_OF_DIR_pki = '/etc/salt/pki/master/minions/'
    '''
    Only those Minons are known
    '''



    DIR_OF_DIR_cache = '/var/cache/salt/master/minions/'
    '''
    There are more directories than there are known minons
    In each directory there are two files.
    '''


    ##########################################################################

    all_known_minions = [ f for f in listdir(DIR_OF_DIR_pki) if
    isdir(DIR_OF_DIR_pki) ]

    for one_minion in all_known_minions:
    one_minion_cache_dir = os.path.join(DIR_OF_DIR_cache, one_minion)
    age_of_d = modification_date(os.path.join(one_minion_cache_dir,
    'data.p'))
    age_of_m = modification_date(os.path.join(one_minion_cache_dir,
    'mine.p'))
    lastseen = max(age_of_d,age_of_m)
    print datetime2string( lastseen)+ "\t" + one_minion




    On Thursday, 21 May 2015 13:25:19 UTC+2, Markus Kramer wrote:

    I think Minions regularly try to contact the master.
    I believe this is just "I am here" message, but I might be wrong.

    I think these are the messages I see in the output of `salt-master -l
    info`:
    [INFO ] Clear payload received with command _auth
    [INFO ] Authentication request from Mini01
    [INFO ] Authentication accepted from Mini01


    I would like to query date and time of the last contact for all minions
    the salt-master has a key.

    Format of the query result:
    Minion | Last contact |
    Mini01 | 2015-05-21--12:30 |
    Mini02 | 2015-05-20--10:30 |

    Thank you
    --
    You received this message because you are subscribed to the Google
    Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to salt-users+...@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Markus Kramer at Jun 6, 2015 at 5:52 pm
    Good - I then finally have a reason to understand how to do a pull
    request :-)

    Am 05.06.2015 00:40 schrieb Colton Myers:
    Perhaps a new function within that manage runner? We'd love to see a pull request.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC

    On Fri, May 29, 2015 at 8:27 AM, Markus Kramer wrote:

    On Thursday, 28 May 2015 22:06:38 UTC+2, basepi wrote:
    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?

    What do you mean by "stable"? They don't get deleted with new releases, if that's what you're asking.
    Then I kindly propose to integrate the above code as "verbose" option
    into salt.manage down.
    For me it is useful to know how long a minion is down - "down" can be
    two hours or two weeks.
    - why manage.status waits 10 seconds?
    Because if there are any minions for which we have accepted keys, but that are not responding, we must wait for the command to timeout before we declare them as "disconnected".
    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?
    I suppose that depends on your definition of "up" and "down". We don't have an official time limit on "up" and "down" that I know of.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC

    On Fri, May 22, 2015 at 3:48 AM, Markus Kramer wrote:

    After reading how-do-i-list-all-connected-salt-stack-minions [1] I wrote the below script.

    The result is consistent with `salt-run manage.status`

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    - why manage.status waits 10 seconds?
    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?

    Thank you

    '''
    GOAL
    list 'last seen' time of minions

    USAGE
    sudo python ./halloMinion.py | sort

    COMPARE WITH
    sudo salt-run manage.status

    EXAMPLE OUTPUT
    2015.05.18 10:36:43 Mini1
    2015.05.21 13:56:08 Mini2
    2015.05.21 23:25:54 Mini3
    2015.05.22 10:51:22 Mini4
    2015.05.22 10:56:56 Mini5

    WARNING
    reverse engineering, assumptions, needs offical comment.

    '''
    ##########################################################################
    import sys
    from os import listdir
    from os.path import isfile
    from os.path import isdir
    import datetime
    import os
    import os.path

    ##########################################################################
    def modification_date(filename):
    t = os.path.getmtime(filename)
    x = datetime.datetime.fromtimestamp(t)
    return x

    def datetime2string(i):
    r = i.strftime("%Y.%m.%d %H:%M:%S")
    return r

    ##########################################################################

    DIR_OF_DIR_pki = '/etc/salt/pki/master/minions/'
    '''
    Only those Minons are known
    '''

    DIR_OF_DIR_cache = '/var/cache/salt/master/minions/'
    '''
    There are more directories than there are known minons
    In each directory there are two files.
    '''

    ##########################################################################

    all_known_minions = [ f for f in listdir(DIR_OF_DIR_pki) if isdir(DIR_OF_DIR_pki) ]

    for one_minion in all_known_minions:
    one_minion_cache_dir = os.path.join(DIR_OF_DIR_cache, one_minion)
    age_of_d = modification_date(os.path.join(one_minion_cache_dir, 'data.p'))
    age_of_m = modification_date(os.path.join(one_minion_cache_dir, 'mine.p'))
    lastseen = max(age_of_d,age_of_m)
    print datetime2string( lastseen)+ "t" + one_minion

    On Thursday, 21 May 2015 13:25:19 UTC+2, Markus Kramer wrote:
    I think Minions regularly try to contact the master.
    I believe this is just "I am here" message, but I might be wrong.

    I think these are the messages I see in the output of `salt-master -l info`:
    [INFO ] Clear payload received with command _auth
    [INFO ] Authentication request from Mini01
    [INFO ] Authentication accepted from Mini01

    I would like to query date and time of the last contact for all minions the salt-master has a key.

    Format of the query result:
    Minion | Last contact |
    Mini01 | 2015-05-21--12:30 |
    Mini02 | 2015-05-20--10:30 |
    Thank you

    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout [2].
      --
      You received this message because you are subscribed to the Google
    Groups "Salt-users" group.
      To unsubscribe from this group and stop receiving emails from it, send
    an email to salt-users+unsubscribe@googlegroups.com.
      For more options, visit https://groups.google.com/d/optout [2].

      --
      You received this message because you are subscribed to a topic in the
    Google Groups "Salt-users" group.
      To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/salt-users/MBQJSiHHNSI/unsubscribe
    [3].
      To unsubscribe from this group and all its topics, send an email to
    salt-users+unsubscribe@googlegroups.com.
      For more options, visit https://groups.google.com/d/optout [2].

    Links:
    ------
    [1]
    http://serverfault.com/questions/529049/how-do-i-list-all-connected-salt-stack-minions
    [2] https://groups.google.com/d/optout
    [3] https://groups.google.com/d/topic/salt-users/MBQJSiHHNSI/unsubscribe

    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Colton Myers at Jun 11, 2015 at 6:55 pm
    Great resources here! =)
    https://docs.saltstack.com/en/latest/topics/development/contributing.html

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Sat, Jun 6, 2015 at 11:52 AM, wrote:

    Good - I then finally have a reason to understand how to do a pull
    request :-)

    Am 05.06.2015 00:40 schrieb Colton Myers:

    Perhaps a new function within that manage runner? We'd love to see a pull
    request.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Fri, May 29, 2015 at 8:27 AM, Markus Kramer wrote:


    On Thursday, 28 May 2015 22:06:38 UTC+2, basepi wrote:

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?

    What do you mean by "stable"? They don't get deleted with new releases,
    if that's what you're asking.
    Then I kindly propose to integrate the above code as "verbose" option
    into salt.manage down.
    For me it is useful to know how long a minion is down - "down" can be two
    hours or two weeks.


    - why manage.status waits 10 seconds?

    Because if there are any minions for which we have accepted keys, but
    that are not responding, we must wait for the command to timeout before we
    declare them as "disconnected".

    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?

    I suppose that depends on your definition of "up" and "down". We don't
    have an official time limit on "up" and "down" that I know of.

    --
    Colton Myers
    Platform Engineer, SaltStack
    @basepi on Twitter/Github/IRC


    On Fri, May 22, 2015 at 3:48 AM, Markus Kramer <markus...@posteo.de>
    wrote:
    After reading how-do-i-list-all-connected-salt-stack-minions
    <http://serverfault.com/questions/529049/how-do-i-list-all-connected-salt-stack-minions>
    I wrote the below script.

    The result is consistent with `salt-run manage.status`

    While I seem to have my answer, the approach needs confirmation, e.g.:
    - how stable (across releases) are the file structures of
    /etc/salt/pki/master/minions and /var/cache/salt/master/minions ?
    - why manage.status waits 10 seconds?
    - is "last-seen time older than 1 hour" equivalent to "up" and "down"?


    Thank you




    '''
    GOAL
    list 'last seen' time of minions

    USAGE
    sudo python ./halloMinion.py | sort

    COMPARE WITH
    sudo salt-run manage.status

    EXAMPLE OUTPUT
    2015.05.18 10:36:43 Mini1
    2015.05.21 13:56:08 Mini2
    2015.05.21 23:25:54 Mini3
    2015.05.22 10:51:22 Mini4
    2015.05.22 10:56:56 Mini5

    WARNING
    reverse engineering, assumptions, needs offical comment.


    '''

    ##########################################################################
    import sys
    from os import listdir
    from os.path import isfile
    from os.path import isdir
    import datetime
    import os
    import os.path



    ##########################################################################
    def modification_date(filename):
    t = os.path.getmtime(filename)
    x = datetime.datetime.fromtimestamp(t)
    return x

    def datetime2string(i):
    r = i.strftime("%Y.%m.%d %H:%M:%S")
    return r



    ##########################################################################

    DIR_OF_DIR_pki = '/etc/salt/pki/master/minions/'
    '''
    Only those Minons are known
    '''



    DIR_OF_DIR_cache = '/var/cache/salt/master/minions/'
    '''
    There are more directories than there are known minons
    In each directory there are two files.
    '''


    ##########################################################################

    all_known_minions = [ f for f in listdir(DIR_OF_DIR_pki) if
    isdir(DIR_OF_DIR_pki) ]

    for one_minion in all_known_minions:
    one_minion_cache_dir = os.path.join(DIR_OF_DIR_cache, one_minion)
    age_of_d = modification_date(os.path.join(one_minion_cache_dir,
    'data.p'))
    age_of_m = modification_date(os.path.join(one_minion_cache_dir,
    'mine.p'))
    lastseen = max(age_of_d,age_of_m)
    print datetime2string( lastseen)+ "\t" + one_minion




    On Thursday, 21 May 2015 13:25:19 UTC+2, Markus Kramer wrote:

    I think Minions regularly try to contact the master.
    I believe this is just "I am here" message, but I might be wrong.

    I think these are the messages I see in the output of `salt-master -l
    info`:
    [INFO ] Clear payload received with command _auth
    [INFO ] Authentication request from Mini01
    [INFO ] Authentication accepted from Mini01


    I would like to query date and time of the last contact for all
    minions the salt-master has a key.

    Format of the query result:
    Minion | Last contact |
    Mini01 | 2015-05-21--12:30 |
    Mini02 | 2015-05-20--10:30 |

    Thank you
    --
    You received this message because you are subscribed to the Google
    Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to salt-users+...@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Salt-users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/salt-users/MBQJSiHHNSI/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedMay 21, '15 at 11:25a
activeJun 11, '15 at 6:55p
posts7
users2

2 users in discussion

Markus Kramer: 4 posts Colton Myers: 3 posts

People

Translate

site design / logo © 2021 Grokbase