-
Notifications
You must be signed in to change notification settings - Fork 1
/
ServerCheck.sh
29 lines (24 loc) · 907 Bytes
/
ServerCheck.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# CyberArk health check of PSMP servers for SSH
# File path: /root/ServerCheck.sh
# Add to cron job to automate:
# crontab -e
# 0 5 * * mon /root/ServerCheck.sh
# service cron reload
# systemctl start crond.service or systemctl restart crond.service
# Get the current time and date
today=$(date +"%H:%M %Y-%m-%d")
# Create the output file
outfile="servercheck_$today.txt" # Include timestamp in filename
echo "Time and Date of check: ${today}" > "$outfile"
echo "Hostname of Server:" >> "$outfile"
hostname >> "$outfile"
# Check CyberArk PSMP service status
echo "CyberArk PSMP Service Status:" >> "$outfile"
systemctl status psmpsrv --no-pager >> "$outfile" # Use systemctl for service status
# Check disk usage
echo "Disk Usage:" >> "$outfile"
df -h >> "$outfile"
# Check CPU usage
echo "CPU Usage:" >> "$outfile"
top -b -n 1 | head -n 6 >> "$outfile"