6 |
rodolico |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
* This file is just an easy way to create the YAML configuration file.
|
|
|
4 |
* You, as a PHP programmer, are probably more familiar with PHP than
|
|
|
5 |
* YAML, so create an array, $configuration, below, then run this
|
|
|
6 |
* script (ie, php sysinfoRead.conf-creator.php). A properly formatted
|
|
|
7 |
* YAML configuration stream will be sent to STDOUT, where you can
|
|
|
8 |
* capture it.
|
|
|
9 |
* OF COURSE, you can definitely hand code the YAML. It is actually much
|
|
|
10 |
* simpler than doing the PHP, but not if you're familiar with PHP
|
|
|
11 |
* and not so good with YAML.
|
|
|
12 |
*/
|
|
|
13 |
// Configuration file for getSysinfoMail.php, parse_sysinfo.php and other files
|
|
|
14 |
$configuration = array(
|
|
|
15 |
// set this to where the files parsed from mail should be placed.
|
|
|
16 |
'outpath' => '/home/rodolico/temp/sysinfo_reports/unprocessed',
|
|
|
17 |
'logFile' => '/home/rodolico/temp/sysinfo_reports/errors.log',
|
|
|
18 |
'datapath' => '/home/rodolico/temp/sysinfo_reports',
|
|
|
19 |
'unprocessed_path' => 'unprocessed',
|
|
|
20 |
'getMailScript' => 'getSysinfoMail.php',
|
|
|
21 |
'processMailScript' => 'parse_sysinfo.php',
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
// server connection information
|
|
|
25 |
|
|
|
26 |
'servers' => array(
|
|
|
27 |
array (
|
|
|
28 |
'servername' => 'book.dailydata.net',
|
|
|
29 |
'port' => 143,
|
|
|
30 |
'ssl' => false,
|
|
|
31 |
'mailbox' => '.Processed',
|
|
|
32 |
'username' => 'serverstats',
|
|
|
33 |
'password' => 'sachemic',
|
|
|
34 |
'deleteProcessed' => false,
|
|
|
35 |
'enabled' => false
|
|
|
36 |
),
|
|
|
37 |
array (
|
|
|
38 |
'servername' => 'book.dailydata.net',
|
|
|
39 |
'port' => 143,
|
|
|
40 |
'ssl' => false,
|
|
|
41 |
'mailbox' => 'Processed.2011',
|
|
|
42 |
'username' => 'serverstats',
|
|
|
43 |
'password' => 'sachemic',
|
|
|
44 |
'deleteProcessed' => true,
|
|
|
45 |
'enabled' => false
|
|
|
46 |
),
|
|
|
47 |
|
|
|
48 |
array (
|
|
|
49 |
'servername' => 'book.dailydata.net',
|
|
|
50 |
'port' => 143,
|
|
|
51 |
'ssl' => false,
|
|
|
52 |
'mailbox' => 'Processed.2012',
|
|
|
53 |
'username' => 'serverstats',
|
|
|
54 |
'password' => 'sachemic',
|
|
|
55 |
'deleteProcessed' => true,
|
|
|
56 |
'enabled' => false
|
|
|
57 |
),
|
|
|
58 |
|
|
|
59 |
array (
|
|
|
60 |
'servername' => 'book.dailydata.net',
|
|
|
61 |
'port' => 143,
|
|
|
62 |
'ssl' => false,
|
|
|
63 |
'mailbox' => 'Processed.2013',
|
|
|
64 |
'username' => 'serverstats',
|
|
|
65 |
'password' => 'sachemic',
|
|
|
66 |
'deleteProcessed' => true,
|
|
|
67 |
'enabled' => false
|
|
|
68 |
),
|
|
|
69 |
|
|
|
70 |
array (
|
|
|
71 |
'servername' => 'book.dailydata.net',
|
|
|
72 |
'port' => 143,
|
|
|
73 |
'ssl' => false,
|
|
|
74 |
'mailbox' => 'Processed.2014',
|
|
|
75 |
'username' => 'serverstats',
|
|
|
76 |
'password' => 'sachemic',
|
|
|
77 |
'deleteProcessed' => true,
|
|
|
78 |
'enabled' => false
|
|
|
79 |
),
|
|
|
80 |
|
|
|
81 |
array (
|
|
|
82 |
'servername' => 'book.dailydata.net',
|
|
|
83 |
'port' => 143,
|
|
|
84 |
'ssl' => false,
|
|
|
85 |
'mailbox' => 'Processed.2015',
|
|
|
86 |
'username' => 'serverstats',
|
|
|
87 |
'password' => 'sachemic',
|
|
|
88 |
'deleteProcessed' => true,
|
|
|
89 |
'enabled' => false
|
|
|
90 |
),
|
|
|
91 |
|
|
|
92 |
array (
|
|
|
93 |
'servername' => 'smtp.dailydata.net',
|
|
|
94 |
'port' => 143,
|
|
|
95 |
'ssl' => false,
|
|
|
96 |
'mailbox' => 'INBOX',
|
|
|
97 |
'username' => 'stats@dailydata.net',
|
|
|
98 |
'password' => 'los,vce',
|
|
|
99 |
'deleteProcessed' => false,
|
|
|
100 |
'enabled' => false
|
|
|
101 |
),
|
|
|
102 |
|
|
|
103 |
array (
|
|
|
104 |
'servername' => 'smtp.dailydata.net',
|
|
|
105 |
'port' => 143,
|
|
|
106 |
'ssl' => false,
|
|
|
107 |
'mailbox' => 'INBOX',
|
|
|
108 |
'username' => 'test@dailydata.net',
|
|
|
109 |
'password' => 'los,vce',
|
|
|
110 |
'deleteProcessed' => true,
|
|
|
111 |
'enabled' => true
|
|
|
112 |
)
|
|
|
113 |
),
|
|
|
114 |
|
|
|
115 |
// these are regex's that define what we want to capture. Everything between startKey and endKey, inclusive
|
|
|
116 |
// we then process it with eval, which is an anonymous function accepting one paramter (body) and returning
|
|
|
117 |
// the array represented by the associated data definition
|
|
|
118 |
'bodyContents' => array(
|
|
|
119 |
'xml' => array(
|
|
|
120 |
'startTag' => '\<sysinfo',
|
|
|
121 |
'endTag' => '\<\/sysinfo[^>]*\>',
|
|
|
122 |
// see http://stackoverflow.com/questions/6578832/how-to-convert-xml-into-array-in-php
|
|
|
123 |
'eval' => 'function ($body) { return json_decode(json_encode((array)simplexml_load_string($body)),1); }'
|
|
|
124 |
|
|
|
125 |
),
|
|
|
126 |
'yaml' => array(
|
|
|
127 |
'startTag' => '\-\-\-',
|
|
|
128 |
'endTag' => '\.\.\.',
|
|
|
129 |
'eval' => 'function ($body) { return yaml_parse( $body, 0 ); }'
|
|
|
130 |
),
|
|
|
131 |
'ini' => array( # this is an older format which we don't support, so we'll just write it out
|
|
|
132 |
'startTag' => '\[sysinfo version\]',
|
|
|
133 |
'endTag' => '',
|
|
|
134 |
|
|
|
135 |
)
|
|
|
136 |
),
|
|
|
137 |
|
|
|
138 |
'datase' => array(
|
|
|
139 |
'databaseServer' => 'localhost',
|
|
|
140 |
'databaseUsername' => 'camp',
|
|
|
141 |
'databasePassword' => 'camp',
|
|
|
142 |
'database' => 'camp',
|
|
|
143 |
),
|
|
|
144 |
'sendReport' => array(
|
|
|
145 |
'emailScript'=>'/opt/sendEmail/sendEmail.pl',
|
|
|
146 |
'mailTo'=> 'rodo@dailydata.net',
|
|
|
147 |
'mailServer' => 'smtp.dailydata.net:587',
|
|
|
148 |
'mailSubject' => 'Sysinfo Report',
|
|
|
149 |
'mailFrom' => 'sysinfo@dailydata.net',
|
|
|
150 |
'logFile' => '/tmp/mail.log',
|
|
|
151 |
'tls' => "'auto'",
|
|
|
152 |
'smtpUser' => 'stats@dailydata.net',
|
|
|
153 |
'smtpPass' => 'UrLnuCp@G85',
|
|
|
154 |
),
|
|
|
155 |
|
|
|
156 |
);
|
|
|
157 |
|
|
|
158 |
// here is where we actually generate the YAML
|
|
|
159 |
print yaml_emit( $configuration );
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
?>
|