Script to check server status from polybar
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm currently running Arch with i3 and polybar. I also maintain 6 servers, so to make my life easier I made a series of shell scripts to notify me if a server is down.
The scripts work, but it's far from an elegant solution. At the moment, I have 2 scripts for each server. One that writes to the status bar (polybar) and one that writes to a log.
This will write to the polybar:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %H:%M:%S'`
if [[ $srv == ms ]]; then
:
else
echo " 000.000.000.000 | $fail "
fi
This will write to a log file:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %F %H:%M:%S'`
log1=`ping 000.000.000.000 -c 1 -W 1`
log2=`traceroute 000.000.000.000`
if [[ $srv == ms ]]; then
:
else
echo "<---------------------------------------------->
000.000.000.000 | $fail
----------------------------------------------
$log1
----------------------------------------------
$log2
<---------------------------------------------->
" >> ~/.log/ping.log
fi
Both scripts are added as modules in my polybar config.
I tried having both of these scripts merged as one, but that would make the loading time for the error to show up in polybar too long, so I separated them in to two separate shell scripts.
I added the traceroute to see where the request fails.
I know there has got to be a better way to solve this. A total of 12 shell scripts is just way too much and it's really unefficient. Does anyone have a better solution to this? One that require less shell scripts and will still log in an efficient way?
shell-script ping i3 traceroute
add a comment |Â
up vote
0
down vote
favorite
I'm currently running Arch with i3 and polybar. I also maintain 6 servers, so to make my life easier I made a series of shell scripts to notify me if a server is down.
The scripts work, but it's far from an elegant solution. At the moment, I have 2 scripts for each server. One that writes to the status bar (polybar) and one that writes to a log.
This will write to the polybar:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %H:%M:%S'`
if [[ $srv == ms ]]; then
:
else
echo " 000.000.000.000 | $fail "
fi
This will write to a log file:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %F %H:%M:%S'`
log1=`ping 000.000.000.000 -c 1 -W 1`
log2=`traceroute 000.000.000.000`
if [[ $srv == ms ]]; then
:
else
echo "<---------------------------------------------->
000.000.000.000 | $fail
----------------------------------------------
$log1
----------------------------------------------
$log2
<---------------------------------------------->
" >> ~/.log/ping.log
fi
Both scripts are added as modules in my polybar config.
I tried having both of these scripts merged as one, but that would make the loading time for the error to show up in polybar too long, so I separated them in to two separate shell scripts.
I added the traceroute to see where the request fails.
I know there has got to be a better way to solve this. A total of 12 shell scripts is just way too much and it's really unefficient. Does anyone have a better solution to this? One that require less shell scripts and will still log in an efficient way?
shell-script ping i3 traceroute
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm currently running Arch with i3 and polybar. I also maintain 6 servers, so to make my life easier I made a series of shell scripts to notify me if a server is down.
The scripts work, but it's far from an elegant solution. At the moment, I have 2 scripts for each server. One that writes to the status bar (polybar) and one that writes to a log.
This will write to the polybar:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %H:%M:%S'`
if [[ $srv == ms ]]; then
:
else
echo " 000.000.000.000 | $fail "
fi
This will write to a log file:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %F %H:%M:%S'`
log1=`ping 000.000.000.000 -c 1 -W 1`
log2=`traceroute 000.000.000.000`
if [[ $srv == ms ]]; then
:
else
echo "<---------------------------------------------->
000.000.000.000 | $fail
----------------------------------------------
$log1
----------------------------------------------
$log2
<---------------------------------------------->
" >> ~/.log/ping.log
fi
Both scripts are added as modules in my polybar config.
I tried having both of these scripts merged as one, but that would make the loading time for the error to show up in polybar too long, so I separated them in to two separate shell scripts.
I added the traceroute to see where the request fails.
I know there has got to be a better way to solve this. A total of 12 shell scripts is just way too much and it's really unefficient. Does anyone have a better solution to this? One that require less shell scripts and will still log in an efficient way?
shell-script ping i3 traceroute
I'm currently running Arch with i3 and polybar. I also maintain 6 servers, so to make my life easier I made a series of shell scripts to notify me if a server is down.
The scripts work, but it's far from an elegant solution. At the moment, I have 2 scripts for each server. One that writes to the status bar (polybar) and one that writes to a log.
This will write to the polybar:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %H:%M:%S'`
if [[ $srv == ms ]]; then
:
else
echo " 000.000.000.000 | $fail "
fi
This will write to a log file:
#!/bin/bash
srv=`ping 000.000.000.000 -c 1 -W 1
| sed '2q;d'
| awk 'NF>1print $NF'`
fail=`date '+%a %F %H:%M:%S'`
log1=`ping 000.000.000.000 -c 1 -W 1`
log2=`traceroute 000.000.000.000`
if [[ $srv == ms ]]; then
:
else
echo "<---------------------------------------------->
000.000.000.000 | $fail
----------------------------------------------
$log1
----------------------------------------------
$log2
<---------------------------------------------->
" >> ~/.log/ping.log
fi
Both scripts are added as modules in my polybar config.
I tried having both of these scripts merged as one, but that would make the loading time for the error to show up in polybar too long, so I separated them in to two separate shell scripts.
I added the traceroute to see where the request fails.
I know there has got to be a better way to solve this. A total of 12 shell scripts is just way too much and it's really unefficient. Does anyone have a better solution to this? One that require less shell scripts and will still log in an efficient way?
shell-script ping i3 traceroute
asked Jun 14 at 18:30
discipulus
264
264
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449878%2fscript-to-check-server-status-from-polybar%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password