I need a custom PERL script that checks the health status of a linux system. The first line in the script should be #!/path/to/perl -w
followed by use strict;. Clean and good code is therefore required and warnings about uninitialized variables or else are not accepted.
The Script shall work with the attached xml file.
As command line parameters a configuration file, an IP address, a [url removed, login to view] and a [url removed, login to view] file are given.
./[url removed, login to view] [url removed, login to view] 127.0.0.1 [url removed, login to view] [url removed, login to view]
The script gathers data about current load, cpu-, mem-, disk- and network usage and compares them against a threshold. If the usage is higher than the threshold an error is thrown. The %s is replaced through the real current value. As soon as an error is detected the script execution can be terminated and the status file shall be written. For each check a log line should be produced in the following format:
YYYY-MM-YY <ID> OK or ERROR
The [url removed, login to view] should look like that:
Either status is OK if all tests have passed or you put in there the error message.
After load, cpu, mem, disk and network usage have been checked the running proccesses have to be checked. Configuration settings for this section you find in <processes>. The name/command line has to match exactly and <min> specifies how many of the processes you have to see at least so that the check is okay. Error, logfile and status as above.
The third check verifies open and listening ports. Here you have to check it the configured ports in <ports> for the specific protocol (TCP/UDP) are listening for the IP address given in the command line (if localhost = no) or for the localhost (if localhost = yes). Error, logfile and status as above.
Afterwards you have to execute bash scripts or other applications defined in <applications>. If their exit/status code is 0 everything is fine. Everything else has to be considered as error. Error, logfile and status as above.
In general if <active> is yes the check is carried out, if <active> is no the check is not carried out. If the option is not found take <active> as yes. If you find a <reanimate> setting execute it as a script if the status of the check is error.
As in all our biddings - since we're an incorporated german company - the service provider has to be able to issue a valid invoice for his work - either with local tax payer id or vat code (if it's a company).