Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

salt-stack highstate - find slow states

Tags:

salt-stack

Running an initial install takes about 20 minutes, running a salt-call state.highstate takes about 6 minutes. That's not unreasonable, but I'd like to speed it up, but I'm not sure how to find the slowest states.

Is there any way to find how long each state takes to run other than watching my screen with a stopwatch for 6 minutes?

like image 624
Redzarf Avatar asked Apr 24 '15 16:04

Redzarf


People also ask

What is Highstate in Saltstack?

A “highstate” is a way for Salt to dynamically determine which Salt Formulas should be applied to a certain minion. To start with you execute a “highstate” like this: salt 'minion01' state.highstate. This command causes the Minion to download and examine a file from the Salt Master called the “top file”.

What are salt states?

States in the salt belt include Alaska, Connecticut, Delaware, Illinois, Indiana, Iowa, Kansas, Kentucky, Maine, Maryland, Massachusetts, Michigan, Minnesota, Missouri, Nebraska, New Hampshire, New Jersey, New York, North Dakota, Ohio, Pennsylvania, Rhode Island, South Dakota, Vermont, Virginia, West Virginia, ...

Where are salt states stored?

States are stored in text files on the master and transferred to the minions on demand via the master's File Server.

What is salt command?

salt : This command is used to target minions in order to run ad-hoc execution modules. This is the main tool used for remote execution. salt-ssh : This command allows you to use SSH as an alternative to ZeroMQ for the transport mechanism. salt-run : This command is used to run runner modules on the master server.


1 Answers

sudo salt-call state.highstate provides start-time and duration for each state.

----------
          ID: ntp-removed
    Function: pkg.removed
      Result: True
     Comment: None of the targeted packages are installed
     Started: 12:45:04.430901
    Duration: 0.955 ms
     Changes:   

You can capture this for processing:

salt-call state.highstate test=True --out json | tee output.json
python -c 'import json; j=json.load(open("output.json"))["local"];\
           print [x["name"] for x in j.values() if x["duration"] > 1000];'

[u'munin-node']
like image 161
Dan Garthwaite Avatar answered Oct 01 '22 02:10

Dan Garthwaite