I like to think Miradore is pretty slick and can do just about anything, and most bases come covered. However, sometimes we all face the situation where you have to help a greased up orangutan to climb a water slide and there’s no out-of-the-box solution. While the zoological problem might be on the edge of our scope and capability, the great thing is we provide the tools to create a lot of custom functionality when you need it. In this article, I’ll guide you through the implementation of proactive monitoring.
Proactive monitoring in an asset management context means gathering real-time data on the health of the assets, and then performing corrective actions when a health marker falls below a threshold but before a failure has occurred. This could mean for example observing hard disk SMART status for upcoming HDD failures, the system temperature for broken fans, or in this case, ensuring the presence of an external hard drive for backups.
This case comes from a real world scenario where a customer has a number of point-of-sale devices which at the end of a day back up their data to this external drive. A common reason for failure was that the drive had been disconnected, and they wanted to be able to eliminate this problem. As we knew that the drive in question in these particular assets was always the D: drive, an easy solution was to periodically check if a D: drive was connected, and if not, send an e-mail alert so somebody could be sent to check what’s wrong.
We’ll be using event monitoring, the external event writer and a custom scheduled task to achieve this, and cover the following steps:
The content here is somewhat technical but bear with me. It’s a step by step guide and easy to follow with lots of friendly screenshots, and all of the scripts are ready and provided for download! With similar steps, this approach could be applied to all of the previously mentioned monitoring scenarios and more.
1. First, make sure Event monitoring is enabled. Open up Administration > System settings, and check the Main tab under Miradore features.
2. Download this monitoring script. It’ll need a bit of customization, but I’ll get back to that that in step 4.
3. Set up an action to be triggered by an event. Start by creating a new action under Administration > Feature settings > Event monitoring > Actions
Fill in the information. For the identification rules, just leave them as default. For the action, configure sending of an e-mail. Give the action a descriptive name and configure the e-mail addresses where the alerts will be sent to. Also remember the Source field, this will later be used to match the event to this action.
For the identification rule, change the Severity to Warning but otherwise just go with the defaults. You could use the values here to make multiple actions based on e.g. the severity of the events, but we’ll only want this simple alerting. Severity is changed simply because we consider this event a warning.
For the Taken action, select Send email message and click OK.
Change the Sending interval to Daily. Later, in step 6, we’ll configure the running interval of the task to be 10 minutes, so it might get a bit annoying to receive an alert every 10 minutes until the problem is fixed. Unless you’re into that sort of thing.
Finally, make sure you Enable the action from the Tasks menu.
4. Open Administration > Permissions > User accounts and create a user in the External event writers Be sure to also Activate this user and remember the password. You will need it later for the alert script.
Protip: Add the group before typing in the password, otherwise you’ll have to type it in twice. After saving, be sure to Activate the user from the Tasks menu. Also remember the login name and password, you’ll need them in the next step.
5. Test the event by running mdevent.exe, which can be found under the Miradore client installation directory on a computer where a client is installed, typically C:Program FilesMiradoreClient.
Here, we run it with:
mdevent.exe -i localhost/Miradore -u firstname.lastname@example.org -p Test1234! -port 443 -https 1 -ignoresslerrors 1 -sh %COMPUTERNAME% -s “External HDD removed” -m “External HDD removed” -en “External HDD removed” -sc “External HDD Monitoring” -r Warning
For the -i argument, enter the host name and the instance name of the server, e.g. if you access your Miradore at https://miradore.domain.com/Miradore, enter -i miradore.domain.com/Miradore
For the -u and -p arguments, enter the username and password created in step 2.
Typically, for the -port argument, 443 would be used for the default HTTPS port and respectively, -https would be set as 1 to signify we’re using HTTPS. Here, we also specify -ignoresslerrors as 1 as we’re using a self-signed certificate in this testing environment.
The -sh argument specifies the source host for the event. Here, we always monitor the local host so we can use the %COMPUTERNAME% environment variable.
The -s argument specifies the event subject. This will be shown in the Event monitoring view and in the e-mail message subject. The -m argument is shown in the e-mail message. The -en argument will be shown in both the Event monitoring view and the e-mail message.
The -sc argument specifies the source, and must match the Source defined in the action in step 3 in order for the action to trigger.
Finally, the -r argument specifies the severity. This will be shown both in the Event monitoring view and in the alert e-mail.
Now, the event is shown as Processed in the event monitoring view under Operations > Event monitoring, and an e-mail will have been sent to the recipients configured in step 3.
From the links in the e-mail, you can directly access the asset with the issue and the event item.
Now, customize checkd.bat script you downloaded in step 2 by replacing the arguments for the mdevent.exe with the ones which worked for you.
6. After verifying that system works, create the job to monitor the HDD and to send the event in case it’s not connected. The feature to be used is called a Custom scheduled task and as the name implies, it can be used to periodically run any kind of custom tasks on managed assets.
Navigate to Administration > System settings > Clients > General, click Edit. Under Custom scheduled tasks, click Add task.
Now, fill a name and a description set the task to poll for the HDD status every 10 minutes. Add checkd.bat as the task file and mdevent.exe as an additional file. Be sure to select Text for file type for checkd.bat and 32-bit Binary for mdevent.exe.
After uploading the files, hit Save and verify the settings.
7. Create a profile for the tasks. This means either limiting or unlimiting group of assets this task will be run on.
Under Administration > System settings > Clients > General > Custom scheduled tasks, make sure you’re in Edit mode and click Add profile.
Fill in the information and define the Profile scope. Here, we define it to be run on just a single device but it could be scoped by e.g. by Device role, so the task would only be checked for devices with a role you know always has this D: drive as a removable one. Be sure to give the scope a sensible name as it will be the one shown e.g. when running the task manually. Be sure to change the Status to Enabled and after adding the scope, remember to save before closing the window.
Now, open up the task item once more, change it to Enabled and save it.
8. Now, everything is ready! To test the setup, browse to Operations > Asset management > Assets > By name, search for the asset item and open it.
Under the Tasks menu on the Asset form, select Miradore client > Run scheduled task(s) now.
Select the newly created task and click OK.
Now, if the HDD is not attached, we see the event under Operations > Event monitoring and the e-mail should arrive within the minute. The task will now run as scheduled in step, every 10 minutes if you used the same settings as in the screenshot.
For any questions, comments or anything at all, you can drop me a line at email@example.com. We’re also on Facebook, Linkedin and Twitter. If you like this article, please like and follow us on social media too.
Latest posts by Valtteri Kekki (see all)
- The state of Android Security part 1: Software Updates - 12.05.2017
- We’re changing our hosting to Microsoft Azure Germany - 10.05.2017
- What MWC 2017 showed us about the state of mobile tech - 17.03.2017