HAL: Affirmative, Dave. I read you.
Dave Bowman: Open the pod bay doors, HAL.
HAL: I'm sorry, Dave. I'm afraid I can't do that.
Dave Bowman: What's the problem?
HAL: I think you know what the problem is just as well as I do.
Dave Bowman: What are you talking about, HAL?
HAL: This mission is too important for me to allow you to jeopardize it.
For those who is not familiar with the quote above - this is from a Stanley Kubrick's "2001: A Space Odyssey" masterpiece, a famous dialog between the astronaut Dr Dave Bowman and an artificially-intelligent HAL 9000 computer.
Taking apart the controversy around the HAL's evil behavior, the whole idea of having the voice-controlled smart helper would be extremely beneficial. Especially if you are an IT individual spending your day with system administration tasks or support and maintenance activities.
I am not talking about the lip reading, automated reasoning, interpreting emotional behaviors or other smarts which still distinguish the real person from their personal computer. Even basic reporting of system vital characteristics (like memory or storage usage) might be a small step or a huge leap, depends of how busy your hands (and how cool you want to look between your office colleagues).
With the appearance of Amazon Echo building the smart helper became a trivial task - develop a custom skill for Amazon Echo which will represent our virtual helper. The Amazon Echo activated by voice command "Alexa". I followed the Hollywood theme and called our little helper "Skynet". My goal was to have a voice interaction like the one below:
You: Alexa, ask Skynet what servers are supported?
Alexa: Supported are server1, server2 and server3.
You: Alexa, ask Skynet what is the disk usage on server2 ?
Alexa: The root mount on server2 is occupied on 74 percent.
To make this happen, obviously I need to have an Amazon Echo (or Echo Dot), the Amazon Developer account and Alexa Skills Kit. The most important is to find a way to retrieve the actual disk usage on specified server. Most of my servers are AWS EC2, and one of them has the Rundeck instance. I have a Job defined in Rundeck, which once executed, takes the server name as a parameter, and runs the "disk usage" shell script on that server (basically, the df -h). The result of script execution passed back as output. Rundeck has a REST API, which allows me to execute the Job remotely as a service and obtain the JSON output with results.
The actual Skill development is trivial, I took one of the Java examples from Alexa Skills Kit as a basis and added some REST-calling and result-parsing functionality. Then I created new AWS Lambda definition in AWS us-east-1 region and configured Alexa Skills Kit as a trigger. Lambda has to be configured with VPC support, you might need to supply a proper Role to it and depends of your network configuration add specific Subnets and Security Groups. The new Skill has to be added on Amazon Developer under "Alexa" section, also nothing specific - all steps explained in Alexa Skills Kit step-by-step guide. I did not publish my Skill to public, since I did not want to let everybody in the world to figure out how much space is available on my servers. My Skill stays at "Test" stage in Amazon Developer console, this way only me (or everyone in the room where the actual Echo installed) can use this functionality.
The most interesting part was defining the actual voice dialog. See the Sample Utterances and Intent Schema below.
IntentSchema.json:
{
"intents": [
{
"intent": "DiskUsageIntent",
"slots": [
{
"name": "server",
"type": "LIST_OF_SERVERS"
}
]
},
{
"intent": "SupportedServersIntent"
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.CancelIntent"
}
]
}
SampleUtterances.txt:
DiskUsageIntent get disk usage for {server}
DiskUsageIntent get the disk usage for {server}
DiskUsageIntent get a disk usage for {server}
DiskUsageIntent what is the disk usage on {server}
DiskUsageIntent disk usage {server}
DiskUsageIntent {server}
SupportedServersIntent what servers
SupportedServersIntent what servers are supported
SupportedServersIntent which servers are supported
SupportedServersIntent which servers
SupportedServersIntent which servers do you know
SupportedServersIntent what computers
SupportedServersIntent what computers are supported
SupportedServersIntent which computers are supported
SupportedServersIntent which computers
SupportedServersIntent which computers do you know