SmartMachine Tools Package

SmartMachine Tools Package

Starting from  2012Q1 pkgsrc and later, you can download a toolset, a package called smtools from the Joyent pkgsrc repository which can benefit SmartMachine users in many ways. You can find more information here.

The one currently I have in my own SmartMachine is the 20130103 package

# pkgin se smtools
smtools-20130103 = Joyent tools relevant to SmartOS and SmartMachines

and many useful tools are added overtime. After the installation the toolset through pkgin ( see here, for how to use pkgin ), all of the files in the toolset is placed in /opt/local/bin for your disposal:

[root@machine-unix /opt/local/bin]# ls sm-*
sm-cpuinfo sm-list-dbs sm-prepare-image sm-set-timezone
sm-create-db sm-list-dbusers sm-reboot sm-shutdown
sm-create-dbuser sm-list-timezones sm-rebuild-pkgsrc sm-summary
sm-create-vhost sm-lsof sm-remove-db
sm-install-drupal sm-meminfo sm-remove-dbuser
sm-install-wordpress sm-pkghelp sm-set-hostname

One of the favorite tool I use above must be the sm-summary tool, because it indeed gives you an overall picture of your smartmachine in a high level:

[root@machine-unix ~]# sm-summary
* Gathering SmartMachine summary..
SM UUID ea71ea63-c757-4222-801d-503a2300ca14
SmartOS build joyent_20130111T180733Z
Image standard64 1.0.4
Base Image NA
Processes 51
Memory (RSS) Cap 1024M
Memory (RSS) Used 614M
Memory (RSS) Free 410M
Swap Cap 2048M
Swap Used 504M
/tmp Used 16K
Disk Quota 32G
% Disk Used 17%

I find the information above so useful, I ended up putting some parts of it  in a daily monitoring script I use for the SmartMachine I have and placed it in crontab so that I can get daily mails about the status of my SmartMachine. Following is the part of bash script I use for this purpose:


#Author : Deniz Rende
#Date : 01/14/12

#Specify an email

#Email Body(s)
BODY1=”`date` ”


SUBJECT1=”My Machine Status ”

# Create a file to put all of your output
echo “” >> dfh_output

# Get df -h output
echo “df -h output” >> dfh_output
echo “————–” >> dfh_output
df -h >> dfh_output
echo “” >> dfh_output

echo “My Web Space” >> dfh_output
echo “————–” >> dfh_output

du -hs /Path/to/your/webspace/* | sort -hr >> dfh_output
echo “” >> dfh_output

# Get SmartMachine Summary using smtools
echo “Smart Machine Summary” >> dfh_output
echo “——————–” >> dfh_output
sm-summary >> dfh_output
echo “” >> dfh_output

#Get the space usage in your Backup Directory
echo “Your Backup Directory” >> dfh_output
echo “——————–” >> dfh_output
ls -lah /var/tmp/backups >> dfh_output
# Append the Body statement to the file and sends the output to the specified email
echo $BODY1 | cat – dfh_output > /tmp/out && mv /tmp/out dfh_output

#Temporary file is now removed
rm dfh_output

It is a very simple script but it works well for its purpose. One can improve this script by adding more smtools in there and get more detailed email every single day. Adding sm-lsof with various flags could be a very nice option for example. So check smtools out and let me know how you utilize it and I think there are many ways of doing it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>