{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/check-how-many-saltstack-minions-are-connected","result":{"data":{"allGhostPost":{"edges":[{"node":{"title":"Check How Many SaltStack Minions are Connected","html":"

As you might know, you can run salt '*' test.ping to see which minions are connected. However, if you have a lot of minions set up, it's hard to keep track of which servers are missing from test.ping's output.

\n

salt-key --list connected is another handy command that outputs all of the minions whose keys are accepted.

\n

With these two commands, I was able to create a simple bash script that outputs the amount of minions that are actually connected to the master.

\n

Sample output:

\n\n
╭─user@saltmaster ~\n╰─➤  ./connected.sh\n26/26 (100.00%)\n
\n

How to install

\n

Simply create a file called connected.sh for instance with the contents of the connected.sh script below, and set executable permissions on it:

\n

chmod u+x connected.sh

\n
#!/bin/bash\nTOTAL=`salt-key --list accepted | wc -l`\nTOTAL=`echo "$TOTAL-1" | bc`\n\nCONNECTED=`salt '*' test.ping | wc -l`\nCONNECTED=`echo "$CONNECTED/2" | bc`\n\nPERCENT=`echo "scale=2;$CONNECTED/$TOTAL*100" | bc`\n\necho "$CONNECTED/$TOTAL ($PERCENT%)"\n
\n","published_at":"2013-10-22T19:44:00.000+03:00","slug":"check-how-many-saltstack-minions-are-connected","tags":[],"plaintext":"As you might know, you can run salt '*' test.ping to see which minions are\nconnected. However, if you have a lot of minions set up, it's hard to keep track\nof which servers are missing from test.ping's output.\n\nsalt-key --list connected is another handy command that outputs all of the\nminions whose keys are accepted.\n\nWith these two commands, I was able to create a simple bash script that outputs\nthe amount of minions that are actually connected to the master.\n\nSample output:\n\n╭─user@saltmaster ~\n╰─➤ ./connected.sh\n26/26 (100.00%)\n\n\nHow to install\nSimply create a file called connected.sh for instance with the contents of the \nconnected.sh script below, and set executable permissions on it:\n\nchmod u+x connected.sh\n\n#!/bin/bash\nTOTAL=`salt-key --list accepted | wc -l`\nTOTAL=`echo \"$TOTAL-1\" | bc`\n\nCONNECTED=`salt '*' test.ping | wc -l`\nCONNECTED=`echo \"$CONNECTED/2\" | bc`\n\nPERCENT=`echo \"scale=2;$CONNECTED/$TOTAL*100\" | bc`\n\necho \"$CONNECTED/$TOTAL ($PERCENT%)\"","meta_description":null}}]}},"pageContext":{"slug":"check-how-many-saltstack-minions-are-connected","prev":"nginx-and-ssl-root-key-security","next":"publishing-screenshots-screencasts-and-other-files-on-digitalocean-spaces"}},"staticQueryHashes":["3649515864"]}