File: 0.04.19a/server/base/view.inc.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS 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: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: function LocalTestDesc($ltid) 24: { 25: global $NATS; 26: $q="SELECT nodeid,testtype,testparam,testname FROM fnlocaltest WHERE localtestid=".ss($ltid); 27: $r=$NATS->DB->Query($q); 28: if ($row=$NATS->DB->Fetch_Array($r)) 29: { 30: if ($row['testname']!="") $ret=$row['testname']; 31: else 32: { 33: $ret=lText($row['testtype']); 34: //if ($row['testparam']!="") $ret.=" (".substr($row['testparam'],0,20).")"; 35: if ($row['testparam']!="") $ret.=" (".$row['testparam'].")"; 36: } 37: $ret.=" on ".$row['nodeid']; 38: } 39: else $ret="Unknown on Unknown"; 40: return $ret; 41: } 42: 43: function ViewItemTxt($type,$option) 44: { 45: global $NATS; // must be set if you're using a view! 46: switch ($type) 47: { 48: case "node": return "Node - ".$option; 49: case "allnodes": return "All Active Nodes"; 50: case "alertnodes": return "All Alerting Nodes"; 51: 52: case "group": 53: $q="SELECT groupname FROM fngroup WHERE groupid=".ss($option)." LIMIT 0,1"; 54: $r=$NATS->DB->Query($q); 55: if ($row=$NATS->DB->Fetch_Array($r)) $ret="Group - ".$row['groupname']; 56: else $ret="Group (".$option.")"; 57: $NATS->DB->Free($r); 58: return $ret; 59: 60: case "allgroups": return "All Groups"; 61: case "alertgroups": return "All Alerting Groups"; 62: case "alerts": return "Current Alerts"; 63: case "title": return "Title (".$option.")"; 64: case "testdetail": 65: $tt=substr($option,0,1); 66: $tid=substr($option,1,128); 67: if ($tt=="L") return "Test Detail for ".LocalTestDesc($tid); 68: return "Detail for Test (".$option.")"; 69: case "testgraph": 70: $tt=substr($option,0,1); 71: $tid=substr($option,1,128); 72: 73: $sl=strpos($tid,"/"); 74: if ($sl===false) return "Test Graph for ".LocalTestDesc($tid)." (default)"; // will break on non-local sets, refine logic here 75: // otherwise as a return 76: $hrs=substr($tid,$sl+1,32); 77: $tid=substr($tid,0,$sl); 78: if ($tt=="L") return "Test Graph for ".LocalTestDesc($tid)." (".$hrs." hours)"; 79: return "History Graph for Test (".$option.")"; 80: default: return "Unknown Item Type (".$type."/".$option.")"; 81: } 82: } 83: 84: 85: 86: ?>