Package: machine-stats
Machine Stats for Unix-like systemsA simple and effective way to gather machine statistics (RAM, Storage, CPU)
from a server environment as a first layer of aTidal discovery process.Machine Stats for Linux/Unix leveragesAnsibleto
gather facts in a cross-platform way.Interactive tutorialGet familiar with Machine Stats, Tidal Tools and Tidal Accelerator!InstallationInstall locally in a Python 3 environment:python3-mpipinstallmachine-statsNeed to install in an environment without internet access?Checkout how to do that below.Distribution-specific installation instructionsUbuntu 16.04Make surepipis installed and is one of the latest version available:sudoaptupdate&&\sudoaptinstall-ypython3-pip&&\python3-mpipinstall--userpip==18.1&&\python3-mpipinstall--upgrade--userpipNote:Direct upgrade to the latest availablepipversion results with an unusablepipinstallation. That's why we perform the upgrade through the intermediate version (18.1).Installmachine-stats:python3-mpipinstallmachine-statsDebian 9/Ubuntu 18.04Make surepipis installed and is one of the latest version:sudoaptupdate&&\sudoaptinstall-ypython3-pip&&\python3-mpipinstall--upgradepipInstallmachine-stats:python3-mpipinstallmachine-statsDebian 10/Debian 11/Ubuntu 20.04/Ubuntu 21.04Make surepipis installed:sudoaptupdate&&\sudoaptinstall-ypython3-pipInstallmachine-stats:python3-mpipinstallmachine-statsCentOS 7/CentOS 8/CentOS Stream/Red Hat Enterprise Linux 7/Red Hat Enterprise Linux 8/Rocky Linux 8Install Python 3:sudoyuminstall-ypython3Upgradepipto the latest available version:python3-mpipinstall--upgrade--userpipInstallmachine-stats:python3-mpipinstallmachine-statsSUSE Linux Enterprise Server 12Install Python 3.6:sudozypperinstall-ypython36-baseInstallmachine-stats:pipinstallmachine-statsSUSE Linux Enterprise Server 15Installpip:sudozypperinstall-ypython3-pipInstallmachine-stats:pipinstallmachine-statsData capturedFor Linux/Unix based systems, by default, the following metrics are captured
from the resources and sent and stored in Tidal Accelerator:Host NameFQDNIP AddressesRAM Allocated (GB)RAM Used (GB)Storage Allocated (GB)Storage Used (GB)CPU CountOperating SystemOperating System VersionCPU nameYou also can optionally capture metrics about processes running on the server:UserProcess NameProcess PathMemory Used (MB)Max Memory Used (MB)Total Alive TimeTo enable capturing process metrics add the command-line flag--process-stats:machine-stats--process-statsMinimal exampleCreate ahostsfile in the current directory. Seebelowon a couple ways
you can easily create this.Add connection strings in the form ofssh-user@ip-addressorssh-user@domainto thehostsfile one per line If thessh-user@part
is omitted, then the current user name is used.If you need to use a custom SSH identity file for some particular host,
provide it as the following:my-user@example.comansible_ssh_private_key_file=path/to/key-file.pemMake sure that Python 2.6+ is installed on the machines fromhostsfile.Ifpythonexecutable was installed into non-default location (notin/usr/bin/python), add theansible_python_interpreterparameter to thehostsfile after the host IP/domain, for example:freebsd.example.com ansible_python_interpreter=/usr/local/bin/pythonExecutemachine-statsand pipe its output to Tidal Tools:machine-stats|tidalsyncserversAdditional notesBy default Machine Stats looks for thehostsfile in current working
directory. If your inventory file has another name or is located on another
path, then you should specify it explicitly:machine-stats/path/to/myhosts|tidalsyncserversYou can specify multiple inventory files as the following:machine-statshostsmyhosts/path/to/myhostsConfigurationMachine Stats uses Ansible under the hood. Most of theAnsible configuration
optionscan be used with Machine Stats too. By default, Machine Stats will look for
configuration files in the following locations:$PWD/machine_stats.cfg$PWD/machine-stats.cfg$PWD/machinestats.cfg$PWD/ansible.cfg$HOME/.machine_stats.cfg$HOME/.machine-stats.cfg$HOME/.machinestats.cfg$HOME/.ansible.cfg/etc/ansible/ansible.cfgAlso, it is possible to specify the custom configuration file location by
setting theANSIBLE_CONFIGenvironment variable, for example:ANSIBLE_CONFIG=/path/to/my/machine_stats.cfgmachine_stats/path/to/my/hostsNote:ifANSIBLE_CONFIGvalue points to a directory, then Machine Stats
will look foransible.cfgin that directory.Getting information about RHEL 5 hostsRed Hat Enterprise Linux 5 is shipped with Python 2.4 butmachine_statsrequires at least Python 2.6. To install Python 2.6 on your RHEL 5 machine
follow these steps.NOTE:this doesn't update the existing Python packages,
but installs Python 2.6 alongside with system Python packages.Download Python 2.6 package and its dependencies from EPEL repository:sudo curl -L -OOO -k \http://download.fedoraproject.org/pub/archive/epel/5/x86_64/{python26-libs-2.6.8-2.el5.x86_64.rpm,libffi-3.0.5-1.el5.x86_64.rpm,python26-2.6.8-2.el5.x86_64.rpm}Install the packages:sudo rpm -ivh python26*.rpm libffi*.rpmUse non-standard Python location in yourhostsfile:my-user@rhel5.example.com ansible_python_interpreter=/usr/bin/python2.6Offline installationNOTE:Creating the packages archive for offline installation and the actual
offline installation process must be performed on machines with the same OS and
Python versions.On the machine with internet connection create the packages archive using
the following commands:python3-mpipdownload-dmachine-stats-offlinemachine-stats
tarczfmachine-stats-offline.tar.gzmachine-stats-offlineTransfer the archive to the machine where you need to perform the offline
installation (replace<remote-host>and<remote-dir>with the
appropriate values):scpmachine-stats-offline.tar.gz<remote-host>:/<remote-dir>/On the remote host, extract the archive and switch to extracted directory:tarxfmachine-stats-offline.tar.gzcdmachine-stats-offlineInstall Machine Stats and its dependencies:python3-mpipinstall--no-index--find-links.machine_stats-*.whlGenerating ahostsfile from Tidal AcceleratorYou can easily generate a hosts file directly from your server inventory in
Tidal Accelerator. For example you can use this command:tidalexportservers|jq'.[].host_name'>hostsThis will create a file (hosts), in your current directory, that you can
use above in Step 1.Alternatively, if you use Tidal AcceleratorAnsible Tower integration
scriptyou can
use its output to generate thehostsfile formachine_stats.RequirementsjqUsagecdansible-tower-integration
./tidal_inventory.py|jq-r'.servers.hosts[]'>path/to/hostsTroubleshootingmachine-stats: command not foundIf running Machine Stats as a CLI failed, try running it as the following:python3-mmachine_statsHow to permanently enable the Python 3.8 software collection on RHEL 7You should always enable the Python software collection before usingpipenvwith the following command:sclenablerh-python38bashTo permanently add Python 3 to your$PATH, you can add anscl_sourcecommand to the “dot files” for your specific user. The benefit of this approach
is that the collection is already enabled at every login.Using your preferred text editor, add the following line to your~/.bashrc:# Add RHSCL Python 3 to my login environmentsourcescl_sourceenablerh-python38