Worklet for 'yum update check; echo $?' ?

  • 20 July 2021
  • 5 replies
  • 107 views

First time user of Automox/worklets in general. Wanted to create a worklet to run against CentOS servers for the following command: ‘yum update check; echo $?’. My goal is if the command returns a 1 (which means there’s some error(s)), is there a way for the worklet/Automox to let I (or anyone in general know) that that server needs to be looked at.


For the remediation code, I would believe it’s something as simple as:

yum update check; echo $?


But not sure what I would need for the Evaluation code & how to alert which server(s) return a code of ‘1’ so they could be looked at. Again, apologies, this is my first time using a worklet so as much help will greatly be appreciated. Thank you.


5 replies

Userlevel 1

You could just throw something in the evaluation script that checks for the existence of yum. Unfortunately, you can’t generate output from an evaluation script.


The remediation script would look something like this:

#!/bin/bash

yum check-update

if [ $? -eq 0 ]

then

echo “Exit status was 0, no attention needed” 2>&1

else

echo “Update-check returned a non-zero value. System needs attention.” 2>&1

fi


You could simply generate no output when no updates are needed to help sort things out within the console output.


Is there any way for this part, it can send an e-mail/alert to a hard coded e-mail address?

Userlevel 1

I don’t know any easy way to do so. The easiest option is to alert to the Automox console and look at the results from the worklet.


Unless you have email configured already on all of your endpoints there’s no easy way to send an email from a script. If that’s something you’re interested in doing though, there are packages available that make it easier. But you’d need to install the email from script package on all of the endpoints you intend to utilize that functionality from.


You could probably find something available in yum if you’re interested in continuing to explore email alerting.


How to do this exactly?

Userlevel 1

That redirect in the script I provided will properly redirect the output so it appears in the worklet output within the console. Only from the remediation script though. The evaluation script currently has no option for output.

Reply