1#!/usr/bin/env php 2<?php 3/* 4 +-------------------------------------------------------------------------+ 5 | Copyright (C) 2004-2021 The Cacti Group | 6 | | 7 | This program is free software; you can redistribute it and/or | 8 | modify it under the terms of the GNU General Public License | 9 | as published by the Free Software Foundation; either version 2 | 10 | of the License, or (at your option) any later version. | 11 | | 12 | This program is distributed in the hope that it will be useful, | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | GNU General Public License for more details. | 16 +-------------------------------------------------------------------------+ 17 | Cacti: The Complete RRDtool-based Graphing Solution | 18 +-------------------------------------------------------------------------+ 19 | This code is designed, written, and maintained by the Cacti Group. See | 20 | about.php and/or the AUTHORS file for specific developer information. | 21 +-------------------------------------------------------------------------+ 22 | http://www.cacti.net/ | 23 +-------------------------------------------------------------------------+ 24*/ 25 26error_reporting(0); 27 28if (!isset($called_by_script_server)) { 29 include_once(dirname(__FILE__) . '/../include/cli_check.php'); 30 31 array_shift($_SERVER['argv']); 32 33 print call_user_func_array('ss_hstats', $_SERVER['argv']); 34} 35 36function ss_hstats($host_id, $stat) { 37 switch ($stat) { 38 case 'polling_time': 39 $column = $stat; 40 break; 41 case 'min_time': 42 $column = $stat; 43 break; 44 case 'max_time': 45 $column = $stat; 46 break; 47 case 'cur_time': 48 $column = $stat; 49 break; 50 case 'avg_time': 51 $column = $stat; 52 break; 53 case 'uptime': 54 $column = 'snmp_sysUpTimeInstance'; 55 break; 56 case 'failed_polls': 57 $column = $stat; 58 break; 59 case 'availability': 60 $column = $stat; 61 break; 62 default: 63 return '0'; 64 } 65 66 if ($host_id > 0) { 67 $value = db_fetch_cell_prepared("SELECT $column 68 FROM host 69 WHERE id = ?", 70 array($host_id)); 71 72 return ($value == '' ? 'U' : $value); 73 } 74 75 return '0'; 76} 77 78