0
0
Bash Scriptingscripting~20 mins

Network monitoring script in Bash Scripting - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Network Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of ping command in a monitoring script
What is the output of this command snippet when the host is reachable?
Bash Scripting
ping -c 1 8.8.8.8 | grep '1 packets transmitted' | awk '{print $4, "received"}'
A0 received
B1 packets transmitted
C1 received
DDestination Host Unreachable
Attempts:
2 left
💡 Hint
Look for the part of the ping output that shows how many packets were received.
Configuration
intermediate
2:00remaining
Correct crontab entry for running a network check every 5 minutes
Which crontab entry correctly runs a script located at /usr/local/bin/netcheck.sh every 5 minutes?
A5 * * * * /usr/local/bin/netcheck.sh
B*/5 * * * * /usr/local/bin/netcheck.sh
C0 5 * * * /usr/local/bin/netcheck.sh
D* * 5 * * /usr/local/bin/netcheck.sh
Attempts:
2 left
💡 Hint
The first field controls minutes and '*/5' means every 5 minutes.
Troubleshoot
advanced
3:00remaining
Why does this network monitoring script fail to detect downtime?
Given this script snippet: #!/bin/bash ping -c 1 192.168.1.1 if [ $? -eq 0 ]; then echo "Host is up" else echo "Host is down" fi Why might it fail to detect downtime correctly?
Bash Scripting
#!/bin/bash
ping -c 1 192.168.1.1
if [ $? -eq 0 ]; then
  echo "Host is up"
else
  echo "Host is down"
fi
AThe ping command may succeed but the host could still be unreachable due to firewall.
BThe script does not redirect ping output, so errors are missed.
CThe script checks the exit status immediately, but ping may take time to respond.
DThe script uses $? incorrectly; it should check the output string instead.
Attempts:
2 left
💡 Hint
Consider network conditions beyond ping success.
🔀 Workflow
advanced
3:00remaining
Order the steps to create a basic network monitoring script
Put these steps in the correct order to create a simple network monitoring script that alerts on downtime.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about the logical flow from script creation to scheduling.
Best Practice
expert
3:00remaining
Best practice for handling false positives in network monitoring scripts
Which approach best reduces false positives when a network monitoring script detects downtime?
AIgnore ping failures and rely on manual checks.
BAlert immediately on the first failed ping attempt.
CIncrease the ping timeout to a very high value.
DRun multiple ping attempts and alert only if all fail.
Attempts:
2 left
💡 Hint
Think about confirming failure before alerting.