Subversion Repositories computer_asset_manager_v1

Rev

Rev 3 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

This is designed to capture camp-sysinfo-client reports (v2 & v3) which have been sent via e-mail.

That would run the doReports.pl perl script that does the following:

NOTE: The system assumes you have installed sendEmail.pl written by Brandon Zehm. This is a Perl script, somewhat old but still works very, very well. It can be downloaded from
http://caspian.dotconf.net/menu/Software/SendEmail/
There is a bug I don't like in this 2009 script, but a copy of the patched script should be available with CAMP. Place this file someplace (I use /opt/sendEmail/sendEmail.pl) and put the correct path in the configuration file.

The following scripts, and their purposes

doReports.pl
script which ties everything together; read the mail, process the report into the database, then store the file (after processing) wherever it needs to be.
A) uses getSysinfoMail.php to download all e-mail messages, storing them on disk with a name based on report date, client name, machine name and serial number. The file will have a yaml/xml/ini suffix based on its type.
B) for each sorted list of files (sorted by file name, so date, then client name, then machine name, then serial number), send the file to be processed by parse_sysinfo.php
C) When file is processed, it is moved to a directory based on what the processor says. If it was successfuly processed, it is placed in a directory tree (year/month/file).
D) A report is sent to the administrator using sendEmail.pl

getSysinfoMail.php
Reads mail from one or more e-mail accounts, looking for sysinfo reports. When one is found, it is downloaded and parsed, then placed in an "unprocessed" directory. The target file is named as follows:
Report Date + Client Name + Machine Name + Serial Number
all separated by underscores. These values are taken from the report itself. Additionally, the file timestamp is set to the report date.
The appropriate suffix is added to the file (.yaml, .xml or .ini)
If requested in the configuration file, once successfully brought down to the local machine, it is deleted from the mail server.

library.php
This is the standard php library used by a lot of my scripts. I replicated it here so it could be immediately available instead of trying to find it. Sloppy, but I'll fix it later.

parse_sysinfo.php
Script reads ONE file, either passed as a parameter on the command line, or more generally from STDIN. It then processes it as a sysinfo report, placing the resulting values in the database.
Script detects whether a report is valid, duplicate, new or invalid and returns a value based on that (see doReports.pl or this script). This value then allows doReports.pl to determine which directory to move it to.
Script returns one or more lines of comments saying what happened in the script (ie, added new device, updated some software, etc...)

sysinfoRead.conf-creator.php
I decided to use YAML for the configuration file, due to its portability. However, I suck at YAML, so I wrote the configuration file up as a PHP file, then added a line to convert that to YAML. Cheat!

sysinfoRead.conf.yaml
This is the main configuration file for the scripts, in a YAML format. I chose this since there are libraries for PHP and Perl (and most other languages) to import it, so it is language neutral.
This file contains SENSITIVE INFORMATION and should be set 600 in a directory secured against intruston. It contains username/password for one or more e-mail accounts.
The location of this file can be in any of the following directories /etc/camp, /opt/camp, /opt/camp/sysinfo, $_SERVER['SCRIPT_FILENAME'], getcwd(). They are searched in order, and the first one found is used.

INSTALLATION (recommended)
create a symbolic link of the cli directory to /opt/camp/sysinfo
In a separate location, modify sysinfoRead.conf-creator.php to meet your needs, then run it, piping the output to /etc/camp/sysinfoRead.conf.yaml
Test the installation
Create /etc/cron.d/sysinforeports with the following contents
----------------------------------------------------------------------
# Run sysinfo reports at 3pm every day
0 15 * * *     myuser   /opt/camp/sysinfo/doReports.pl
----------------------------------------------------------------------

Note: myuser must have read access to /opt/camp/sysinfo/*, /etc/sysinfo/sysinfoRead.conf.yaml, sendEmail.pl, and full write access to datapath defined in the configuration file. The user must also be able to invoke perl and php.