SMART (Smart Monitoring and Rebooting Tool)

If you want an agent to monitor and control services, you'll need to get SMART.

This way, we disable syslog logging when sudo is executed by user root, and we assign root privileges to user sysman, at the host server, only for the execution of commands /home/sysman/check-service and /sbin/reboot, without asking sysman for the password every time.

Verifications

Through the PID file defined in the configuration file, we obtain the parent process identifier (PID), and we determine the number of active processes generated by this service. Next we check whether:

  • The service is responding to petitions within the defined time period.

  • The number of processes generated by the service doesn't exceed the maximum and minimum defined thresholds.

Status Determination

Considering the results obtained in former verifications, we classify the service status:

  • 0: service is responding to requests within the defined time period, the number of processes generated by service remains between the defined thresholds, and the information provided by the PID file is correct.

  • 1: service is responding to requests within the defined time period and the number of processes generated by service remains between the defined thresholds, but either the information provided by the PID file is incorrect or this file doesn't exist, even though it has been defined.

  • 2: service is responding to requests within the defined time period, but the number of processes generated by the service is beyond the defined thresholds (this could be the case of an overloaded but operative Web server).

  • 3: the number of generated processes is out of thresholds, and we don't have any tool (script) to check whether the service is operative (this could be the case of processes such as syslogd, crond and xinetd).

  • 4: service is not responding to requests within the defined time period.

We group the above five situations in three more general cases:

  • OK (status 0 and 1).

  • WARN (status 2).

  • DOWN (status 3 and 4).

Decision

When executing the program with no parameters, it simply will determine the status of services defined in the configuration file and will display the results. If we want the program to work in an active way, we need to use some of the following parameters:

  • -w: restart services in WARN status and send a notification (e-mail) for each one of them.

  • -d: restart services in DOWN status and send a notification for each one of them.

  • -wd: restart services in WARN and DOWN status and send a notification for each one of them.

  • --all: restart all services independently of their status and send a notification for each service with WARN or DOWN status.

  • --reboot: restart the whole system independently of service's status and send a general notification.

Once the service status has been determined, and according to the parameter specified in the execution, the action carried out for each service will consist of that shown in Table 1.

Table 1. Service Actions

StatusParametersAction
OK--allRestart the service
WARN-w, -wd, --allRestart the service
  Send a notification relating to service
 -dSend a notification relating to service
DOWN-d, -wd, --allRestart the service
  Send a notification relating to service

Furthermore, independently of the service's status, with the parameters --all and --reboot, a notification via e-mail is sent to the administrator about the performed action.

Listing 3 shows a sample of SMART in action, executed from a console with parameter -d (recovery of services in DOWN status).

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState