Menu

#24 fog/service/greenfogex.php

Unstable (example)
closed
nobody
None
5
2016-12-13
2010-01-04
D. Wilson
No

This modified greenfog.php implements the backend of per-host and per-group Green FOG tasks. It relies on a slightly modified database schema, as follows:
CREATE TABLE `fog`.`greenFogEx` (
`gfID` int(10) unsigned NOT NULL auto_increment,
`gfHostID` int(10) unsigned NOT NULL,
`gfGroupID` int(10) unsigned NOT NULL,
`gfHour` int(10) unsigned NOT NULL,
`gfMin` int(10) unsigned NOT NULL,
`gfAction` varchar(2) NOT NULL,
`gfDays` varchar(25) NOT NULL,
PRIMARY KEY (`gfID`),
KEY `host_index` (`gfHostID`),
KEY `group_index` (`gfGroupID`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

Example per-host shutdown task (gfHostID = target host ID, gfGroupID=0):
INSERT INTO greenFogEx VALUES (DEFAULT, 57, 0, 17, 0, 's', '');

Example per-group reboot task (gfHostID = 0, gfGroupID = target group ID):
INSERT INTO greenFogEx VALUES (DEFAULT, 0, 1, 5, 0, 'r', '');

Global tasks will have gfHostID and gfGroupID set to 0:
INSERT INTO greenFogEx VALUES (DEFAULT, 0, 0, 23, 0, 's', '');
Or they can go in the existing greenFog table, too. greenfogex.php looks in both tables for global green FOG tasks.

Oh yeah, if you're wondering why I did it this way, it was to allow testing in a production environment with (hopefully) no side effects. The clients will need to use my enhanced GreenFog.dll (source code posted in previous patch entry) and you will need to make the following change in the [greenfog] section of config.ini:
urlpostfix=/fog/service/greenfogex.php

The only way to create these host- and group-specific tasks right now is direct database manipulation. Not pretty, I know! I'm working on adding this stuff to the web management interface as time permits.

Discussion

  • D. Wilson

    D. Wilson - 2010-01-04

    greenfog.php enhanced

     
  • D. Wilson

    D. Wilson - 2010-01-06

    My apologies! The following correction is needed on line 99:
    $sql = "SELECT * FROM groupMembers JOIN groups ON groupMembers.gmGroupID=groups.groupID WHERE groupMembers.gmHostID=$hostID ORDER BY groupMembers.gmID ASC LIMIT 1";

    Also, I forgot to mention that this is a drop-in replacement for the existing greenfog.php because if no MAC is sent in the request, it falls back to the old behavior of returning global entries from the greenFog table. So you don't really have to change the urlpostfix in your config.ini

     
  • mastacontrola

    mastacontrola - 2016-12-13
    • status: open --> closed
    • Group: --> Unstable (example)
     

Log in to post a comment.