This is just quick and dirty post.
A oneliner to check if all your server services have started rightly after a reboot. This first attempt is aimed for Debian and derivatives:
checkservices () { for service in /etc/rc2.d/S*; do STATUS=$(/etc/init.d/$(ls -l $service | awk '{print $NF}') status 2>/dev/null); [ "$STATUS" != "" ] && printf "Status of ${service##*/}:\t$STATUS\n"; done; }
Example:
root@server:~# checkservices Status of S04openvpn: * VPN 'server' is running Status of S05bind9: * bind9 is running Status of S05dhcp3-server: Status of DHCP server: dhcpd3 is running. Status of S05sysstat: * sadc cron jobs are enabled Status of S06postfix: * postfix is running
Make it portable (Did I said that this was a quick and dirty post?) :-D
checkservices () { for service in /etc/rc$(runlevel|awk '{print $NF}').d/S*; do STATUS=$(/etc/init.d/$(ls -l $service | awk '{print $NF}') status 2>/dev/null); [ "$STATUS" != "" ] && printf "Status of ${service##*/}:\t$STATUS\n"; done; }
Example (centos server):
[root@server ~]# checkservices Status of S05kudzu: kudzu has run Status of S06cpuspeed: cpuspeed is stopped Status of S07iscsid: iscsid (pid 1980) is running... Status of S08ip6tables: Firewall is stopped. [...]
0 comments:
Post a Comment