Package: ox_mon
IntroductionTheox_monpackage provides some
tools to keep monitor your machine to keep it up to date, free of
viruses, and generally working properly.Basically, there are lots of little monitoring and checking tasks you
may find yourself needing to do. You could write a separate script for
each such task, but it would be nice to have some basic scaffolding for
things like notifications, logging, testing, and so on to simplify
machine monitoring. Better yet, by having a common framework many
developers can contribute small snippets of such tools that work in a
similar way to simplify life for everyone.Once you installox_monas described in theInstallationsection, you can do something
likeox_moncheck<thing>[<OPTIONS]to run various checks discussed in theCheckerssection with a consistent reporting system described in theNotifierssection.One useful feature ofox_monis that you can sign-up for free for
the Sentry service athttps://sentry.ioand either set the environment
variableSENTRY_DSNor provide the--SENTRYargument to yourox_moncommands and get notifications via sentry. This provides an
easy way to runox_moncommands in cron or other scripts and get
convenient error notification on failures without having to configure a
mail server or other tools.InstallationYou can install via the usualpip install ox_mon. If you want to
install and be able to edit your installation, you may consider doing
something likepip install--editableox_mon.UsageYou can see the list of possible commands viaox_mon--helpCheckersOne of the most useful commands isox_mon check. If you tryox_moncheck--helpyou will see a list of possible checkers you can run. These all use the
same general syntax for things like how to notify an administrator if
issues are found while also checker specific customization.Checker: aptTheaptchecker will check your Ubuntu installation to see if you
have the latest security updates installed. If you do, then nothing
happens. If you have not doneapt updaterecently or you doNOThave the latest security packages installed, then you will be notified.You can control the notification methods and how many days have passed
since you didapt updateusing command line options. For example,
doingox_moncheckapt--notifierecho--age-in-days7would not notify you provided that you have doneapt updatewithin 7
days. If your packages are stale, the notification will just print a
message. See theNotifiers sectionfor
notification options.Checker: diskThediskchecker will check your system to see if the disk is too
full. If so, you will be notified as described in theNotifierssection.You can control the notification methods and how full the disk is
allowed to be before it triggers an alarm. For example, doingox_moncheckdisk--notifierloginfo--max-used-pct5would not notify you using python’slogging.INFOstream (which
usually goes tostderr) if your disk is more than5%full.Checker: anti-virusTheclamscanchecker will useClamAV(assuming you have it installed) to virus scan your system. You can
control the target location to scan via something likeox_moncheckclamscan--target$HOMEBackupTheox_mon backupcommand group provides a way to useox_monfor
backups. Tryox_monbackup--helpfor information.Raw commandsIdeally it is nicer to right your scripts using theox_monlibrary
interface since python is often more robust than shell scripts. If you
have a quick task, however, you can usegcmd rawto run a generic
raw command via something like:ox_mongcmdraw--cmd/bin/lsYou can also provide arguments or options for your raw command by using
the--argsoption togcmdand using colons instead of dashes
(one outstanding feature request is to clean-up the colon syntax to make
this less ugly):ox_mongcmdraw--cmd/bin/ls--args:ltThe benefit of usinggcmd rawis that you can include sentry or
other notifiers to report results of the command.NotifiersThere are a variety of ways to get notifications:echo: Just echoes notification to stdout.email: Will send you an email provided you specify the following:OX_MON_EMAIL_TO: A comma separated list of email addresses
(e.g.,foo@exmaple.comorfoo@exmaple.com,bar@example.com)
to send email to. If not set, will attempt to lookup from
environment variable.OX_MON_EMAIL_FROM: Sending email address. If not set, will
attempt to lookup from environment variable.OX_MON_GMAIL_PASSWD: A password to use if you want to use
gmail as the SMTP relay to send mail from. This password should
correspond to the username inOX_MON_EMAIL_FROM.OX_MON_SES_PROFILE: If provided and email notifier is
requested, will use this to send email via AWS SES. If not set,
will attempt lookup from environment.IMPORTANT: EitherOX_MON_SES_PROFILEorOX_MON_GMAIL_PASSWDis required to send emails.loginfo: Will use Python’slogging.infoto send notification.
This can be useful if you do not want the notifications in stdout but
in stderr.sentry: Will use the Sentry service fromhttps://sentry.io.SENTRY: The sentry DSN for the project to notify. The default
value for this will be taken from theSENTRY_DSNenvironment
variable if it exists.