File: poller_helper.php

package info (click to toggle)
jffnms 0.8.3dfsg.1-2.1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 4,928 kB
  • ctags: 5,050
  • sloc: php: 19,981; sh: 266; makefile: 91; perl: 52
file content (54 lines) | stat: -rw-r--r-- 1,704 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?
/* Poller Helper. This file is part of JFFNMS
 * Copyright (C) <2004> Javier Szyszlican <javier@szysz.com>
 * This program is licensed under the GNU GPL, full terms in the LICENSE file
 */

    $jffnms_functions_include="engine";
    include_once("../conf/config.php");
    
    $poller_helper_time = time_usec();
    
    $my_sat_id = satellite_my_id();

    $jffnms_poller_command = "poller.php";

    $query_hosts="SELECT * FROM hosts WHERE id > 1 AND poll > 0 AND satellite = $my_sat_id";
    $result_hosts = db_query ($query_hosts) or die ("Query failed - R2 - ".db_error());

    while ($host = db_fetch_array($result_hosts)) {
    
	$host_id = $host["id"];

	// Poll DMIIs
        // ----------

	if ($host["dmii"]!=1) { 
	    logger(" :  H ".str_pad($host["id"],3," ",STR_PAD_LEFT)." : Polling DMIIs.\n");
	    spawn ("$php_executable -q poller.php","$host_id dmii",1);
	    sleep(2);
	}
	
	// Poll Alarmed Interfaces
        // -----------------------
    
	$alarms = alarms_list(0,array("alarm_state"=>ALARM_DOWN,"host"=>$host["id"]));

	unset ($interface_id);
	foreach ( $alarms as $alarm ) { //get all the interface ids from this host
	    $int = current(interfaces_list ($alarm["interface"]));
	    if ($int["poll"] > 0)
		$interface_id[]=$alarm["interface"];
	}
	
	if (count($interface_id) > 0) {
	    logger( " :  H ".str_pad($host["id"],3," ",STR_PAD_LEFT)." : Polling Alarmed/Down: ".count($interface_id)." Interfaces.\n");
	    
	    spawn ("$php_executable -q poller.php","$host_id ".join(",",$interface_id),1);
	    sleep(5);
	}
    }

    $poller_helper_time = time_usec_diff($poller_helper_time);
    logger(" : Poller Helper Ended, Total Time: $poller_helper_time msec.\n");
?>