File:
0.02.76a/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=$row['testtype'];
34: if ($row['testparam']!="") $ret.=" (".substr($row['testparam'],0,20).")";
35: }
36: $ret.=" on ".$row['nodeid'];
37: }
38: else $ret="Unknown on Unknown";
39: return $ret;
40: }
41:
42: function ViewItemTxt($type,$option)
43: {
44: global $NATS; // must be set if you're using a view!
45: switch ($type)
46: {
47: case "node": return "Node - ".$option;
48: case "allnodes": return "All Active Nodes";
49: case "alertnodes": return "All Alerting Nodes";
50:
51: case "group":
52: $q="SELECT groupname FROM fngroup WHERE groupid=".ss($option)." LIMIT 0,1";
53: $r=$NATS->DB->Query($q);
54: if ($row=$NATS->DB->Fetch_Array($r)) $ret="Group - ".$row['groupname'];
55: else $ret="Group (".$option.")";
56: $NATS->DB->Free($r);
57: return $ret;
58:
59: case "allgroups": return "All Groups";
60: case "alertgroups": return "All Alerting Groups";
61: case "alerts": return "Current Alerts";
62: case "title": return "Title (".$option.")";
63: case "testdetail":
64: $tt=substr($option,0,1);
65: $tid=substr($option,1,128);
66: if ($tt=="L") return "Test Detail for ".LocalTestDesc($tid);
67: return "Detail for Test (".$option.")";
68: case "testgraph":
69: $tt=substr($option,0,1);
70: $tid=substr($option,1,128);
71:
72: $sl=strpos($tid,"/");
73: if ($sl===false) return "Test Graph for ".LocalTestDesc($tid)." (default)"; // will break on non-local sets, refine logic here
74: // otherwise as a return
75: $hrs=substr($tid,$sl+1,32);
76: $tid=substr($tid,0,$sl);
77: if ($tt=="L") return "Test Graph for ".LocalTestDesc($tid)." (".$hrs." hours)";
78: return "History Graph for Test (".$option.")";
79: default: return "Unknown Item Type (".$type."/".$option.")";
80: }
81: }
82:
83:
84:
85: ?>