If you're looking for an easy way to get notifications from various services and scripts on your Linux data center servers to your Android or iOS phone, Pushover might be just the thing.
Your data center is probably filling up with Linux servers. You might be using them for web, FTP, containers, cloud, development, or any given service. That means you need to keep tabs on the commands and services that either successfully or unsuccessfully run. How do you do that when you're busier and busier by the minute?
You could use a service called Pushover. This paid subscription service makes it possible for you to send notifications from your Linux servers to either Android or iOS devices. You could use this for failed backups, failed commands, low disk space, and just about anything (especially in your own bash scripts) that would give you a notification on Linux.
I'm going to walk you through the process of setting this up.
Note: Pushover does offer a seven-day free trial. Once that trial is over the service requires a subscription. An individual license is a one-time $5 for each platform (Android, iOS, or desktop) where you want to receive notifications. Team pricing is $5 per month/per user.
What you'll need
I'll be demonstrating with Ubuntu Server and Android 11. If you opt to use a different combination, you might have to alter the instructions slightly. You will also need a Pushover account. So before you start, make sure to sign up.
After you sign up, you'll receive two different user keys: One for the mobile app and one for email. Obviously, we're going to be working with the mobile option.
How to install the necessary components
The first thing to do is open the Google Play Store app on your Android device, search for the Pushover app and tap Install.
Once the app installs, you'll be prompted to give the device a name (Figure A).
Figure A
After you've given the device a name, tap Add Device. Once you've done that, you'll be presented with your user key, which you can also retrieve from your Pushover account page.
How to create an App Key
Before you can use Pushover, you must first create an App Key. To do this, head over to your Pushover account and click Integrations in the top menu. From the resulting page, click Create New Application.
In the app creation window, give the new app/API a name and optional description, URL, and icon. Click the checkbox for the TOS and click Create Application (Figure B).
Figure B
Once you've created your app, you'll be given a token for that app. Copy that token.
How to use your key
Log in to your Linux server and create a new shell script with the command:
nano ~/pushover.sh
In that script, paste the following contents:
#!/usr/bin/env bash # TOKEN INFORMATION _token="APPTOKEN _user='USERTOKEN' # Bash function to push notification to registered device push_to_mobile(){ local t="${1:cli-app}" local m="$2" [[ "$m" != "" ]] && curl -s \ --form-string "token=${_token}" \ --form-string "user=${_user}" \ --form-string "title=$t" \ --form-string "message=$m" \ https://api.pushover.net/1/messages.json }
Where APPTOKEN is the token for your newly created app and USERTOKEN is your Pushover user key.
Save and close the file.
Give the script executable permissions with the command:
chmod u+x pushover.sh
Copy the script to a directory in your $PATH with the command:
cp pushover.sh /usr/local/bin/
Change the ownership of the script with the command:
chown $USER:$USER /usr/local/bin/pushover.sh
You can now test the script with the command:
ls | pushover.sh
The above command will send the output of the ls command to your Android device which is a listing of the present working directory contents.
That's it. You've created a script that can be called from any script or command you use on Linux, and send the output of the script or command to your Pushover account. Also, make sure to create new app tokens for specific applications/services (such as backups) and integrate the newly created pushover.sh into those scripts to receive notifications directly to your Android device.
How you use the pushover.sh script is up to you. Make sure to read through the Pushover documentation to find out how you can better integrate Pushover into your servers/services.
Also see
"device" - Google News
July 28, 2020 at 11:36PM
https://ift.tt/2CVpr3k
How to use Pushover to get notifications sent to your Android device from your Linux servers - TechRepublic
"device" - Google News
https://ift.tt/2KSbrrl
https://ift.tt/2YsSbsy
Bagikan Berita Ini
0 Response to "How to use Pushover to get notifications sent to your Android device from your Linux servers - TechRepublic"
Post a Comment