Replace eventcentral

use winexe :

install wmi-client

winexe -U DOMAIN/user //MACHINE "cmd /C psloglist" | iconv -t UTF-8 -f ISO_8859-1 > test

tables

CREATE TABLE IF NOT EXISTS `glpi_plugin_eventlog_servers` (
  `id` int(11) NOT NULL auto_increment,
  `computers_id` int(11) NOT NULL default '0',
  `path` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_eventlog_configs` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) collate utf8_unicode_ci default NULL,
  `password` char(40) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_eventlog_eventlog` (
  `id` int(11) NOT NULL auto_increment,
  `entities_id` int(11) NOT NULL default '0',
  `is_recursive` tinyint(1) NOT NULL default '0',
  `name` varchar(255) collate utf8_unicode_ci default NULL,
  `log` varchar(255) collate utf8_unicode_ci default NULL,
  `source` varchar(255) collate utf8_unicode_ci default NULL,
  `eventID` int(11) NOT NULL default '0',
  `type` varchar(255) collate utf8_unicode_ci default NULL,
  `datetime` datetime default NULL,
  `user` varchar(255) collate utf8_unicode_ci default NULL,
  `strings` longtext collate utf8_unicode_ci,
  `is_deleted` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `name` (`name`),
  KEY `entities_id` (`entities_id`),
  KEY `is_deleted` (`is_deleted`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `glpi_plugin_eventlog_ticketcategories`
CREATE TABLE `glpi_plugin_eventlog_knowbaseitemcategories`
CREATE TABLE `glpi_plugin_eventlog_defaulttypes`
CREATE TABLE `glpi_plugin_eventlog_defaultlogs`
CREATE TABLE `glpi_plugin_eventlog_profiles`

Python script

  1. Specification draft
  1. MySQL Tables

CREATE TABLE eventlogs_config (
server varchar(255),
eventlog varchar(255),
type varchar(255)
)

CREATE TABLE eventlogs_list (
unique_id int(16) NOT NULL auto_increment,
server varchar(255),
eventlog varchar(255),
type varchar(255),
time date,
event_id int(16),
desc varchar(255)
)

#Algorithm

eventlogs_config = db.exec("SELECT * FROM eventlogs_config;")

for eventlog_config in eventlogs_config:
today = date.date()
yesterday = date.date() - 24*3600
res = system.exec("psloglist.exe \\\\%s -a %s -b %s -s \"%s\"" % (eventlog_config["server"], yesterday, today, eventlog_config["eventlog"]))
events = parse(res, eventlog_config["type"])
for event in events:
db.exec("INSERT INTO eventlogs_list (server, eventlog, type, time, event_id, desc) VALUES (%s, %s, %s, %s, %s, %s);", (event["server"], event["eventlog"], event["type"], event["time"], event["event_id"], event["desc"]))

New database schema draft

--
-- Table structure for table 'eventlogs_config'
--

CREATE TABLE IF NOT EXISTS eventlogs_config (
  server varchar(16) collate utf8_unicode_ci NOT NULL,
  eventlog varchar(16) collate utf8_unicode_ci NOT NULL,
  `type` varchar(16) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (server,eventlog,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table 'eventlogs_list'
--

CREATE TABLE IF NOT EXISTS eventlogs_list (
  id int(16) NOT NULL auto_increment,
  server varchar(16) collate utf8_unicode_ci NOT NULL,
  eventlog varchar(16) collate utf8_unicode_ci NOT NULL,
  `type` varchar(16) collate utf8_unicode_ci NOT NULL,
  `date` datetime NOT NULL,
  event_id int(16) NOT NULL,
  `user` varchar(256) collate utf8_unicode_ci NOT NULL,
  description text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY event (server,eventlog,event_id,description(255),`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

python-glpi-eventlog.tar.bz2 - Python prototype (12 KB) vinc, 08/06/2010 05:09 PM