Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Commit 51da041

Browse files
authored
Merge pull request #11 from apollo-lhc/release-v1.1
Release v1.1
2 parents 3988559 + 2c6b2d5 commit 51da041

36 files changed

+1887
-513
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
*.txt
66
main
77
*.config
8-
!config/*.config
8+
!config/*.config
9+
build
10+
bin

Makefile

Lines changed: 127 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,141 @@
1+
12
CXX=g++
3+
SRC=src
4+
BUILD=build
5+
BIN=bin
6+
LIB=lib
7+
INSTALL_PATH?=./install
28

3-
CXXFLAGS=-Iinclude -std=c++11
9+
CXX_FLAGS=-Iinclude -std=c++11 -fPIC -Wall -g -O3 -Werror -Wpedantic
10+
LD_FLAGS=-lboost_program_options -lboost_system -Wl,-rpath=$(PWD)/lib
411

5-
LD_FLAGS=-lfreeipmi -lboost_program_options
12+
#================================================================================
13+
#== GRAPHITE_MONITOR
14+
#================================================================================
15+
GRAPHITE_MONITOR_LD_FLAGS=$(LD_FLAGS) -L$(LIB)
16+
GRAPHITE_MONITOR_LIBS=""
17+
GRAPHITE_MONITOR_OBJ=$(BUILD)/graphite_monitor.o
618

7-
SRC=src
19+
#================================================================================
20+
#== Sensor's and Sensor factory
21+
#================================================================================
22+
SENSOR_BASE_SRC=$(wildcard $(SRC)/base/*.cc)
23+
SENSOR_BASE_OBJ=$(patsubst $(SRC)/%.cc,$(BUILD)/%.o,$(SENSOR_BASE_SRC))
24+
GRAPHITE_MONITOR_OBJ += $(SENSOR_BASE_OBJ)
825

9-
DEPS=include/%.hh
26+
#================================================================================
27+
#== FreeIPMI based Sensor
28+
#================================================================================
29+
ATCA_LIB=$(LIB)/libATCA.so
30+
ATCA_SRC=$(wildcard $(SRC)/atca/*.cc)
31+
ATCA_OBJ=$(patsubst $(SRC)/%.cc,$(BUILD)/%.o,$(ATCA_SRC))
32+
ATCA_LIBS=-lfreeipmi
33+
ATCA_LD_FLAGS=-shared -fPIC -Wall -g -O3 -rdynamic
34+
ifneq ("$(wildcard $(ATCA_LIB))","")
35+
GRAPHITE_MONITOR_LIB+=-lATCA
36+
endif
1037

11-
BUILD=build
38+
#================================================================================
39+
#== Apoll Monitor Sensor
40+
#================================================================================
41+
CACTUS_ROOT?=/opt/cactus
42+
APOLLO_PATH?=/opt/BUTool
43+
APOLLO_MONITOR_LIB=$(LIB)/libApolloMonitor.so
44+
APOLLO_MONITOR_SRC=$(wildcard $(SRC)/ApolloMonitor/*.cc)
45+
APOLLO_MONITOR_OBJ=$(patsubst $(SRC)/%.cc,$(BUILD)/%.o,$(APOLLO_MONITOR_SRC))
46+
APOLLO_MONITOR_LIBS= -lBUTool_Helpers \
47+
-lBUTool_ApolloSM \
48+
-lToolException \
49+
-lBUTool_IPBusIO
50+
APOLLO_MONITOR_CXX_FLAGS=-I$(APOLLO_PATH)/include -I$(CACTUS_ROOT)/include
51+
APOLLO_MONITOR_LD_FLAGS=-L$(APOLLO_PATH)/lib -Wl,-rpath=$(APOLLO_PATH)/lib -shared -fPIC -Wall -g -O3 -rdynamic
52+
ifneq ("$(wildcard $(APOLLO_MONITOR_LIB))","")
53+
GRAPHITE_MONITOR_LIB+=-lApolloMonitor
54+
endif
1255

13-
LIB=lib
56+
#================================================================================
57+
#== Apoll Monitor Sensor
58+
#================================================================================
59+
#SHELF_SCAN_OBJ=$(BUILD)/shelf_scan.o $(BASE_OBJ) $(ATCA_OBJ)
60+
SHELF_SCAN_OBJ=$(BUILD)/shelf_scan.o $(BUILD)/atca/FRUReader.o
61+
#LD_FLAGS += -Llib
62+
SHELF_SCAN_LIB=-lfreeipmi
63+
#================================================================================
1464

15-
OBJ= main.o net_helpers.o TimeSensor.o Sensor.o IpmiTemperatureSensor.o IpmiFanSpeedSensor.o ApolloBlade.o
1665

17-
.PHONEY: all clean
66+
.PHONEY: all clean distclean graphite_monitor shelf_scan lib_ApolloMonitor lib_ATCA list install
67+
all: graphite_monitor
1868

19-
all: main
69+
#================================================================================
70+
#== Aliases
71+
#================================================================================
72+
graphite_monitor: $(BIN)/graphite_monitor
73+
shelf_scan: $(BIN)/shelf_scan
74+
lib_ApolloMonitor: $(APOLLO_MONITOR_LIB)
75+
lib_ATCA: $(ATCA_LIB)
2076

21-
main: $(OBJ)
22-
$(CXX) -o $@ $^ $(LD_FLAGS)
77+
#================================================================================
78+
#== EXEs
79+
#================================================================================
80+
$(BIN)/graphite_monitor: $(GRAPHITE_MONITOR_OBJ)
81+
@mkdir -p $(dir $@)
82+
@echo $(GRAPHITE_MONITOR_OBJ)
83+
@echo $(SENSOR_BASE_OBJ)
84+
$(CXX) -o $@ $^ -Wl,--no-as-needed $(GRAPHITE_MONITOR_LD_FLAGS) $(GRAPHITE_MONITOR_LIB) $(INSTALL_LD_FLAGS)
2385

24-
%.o: $(SRC)/%.cc
25-
$(CXX) -c -o $@ $< $(CXXFLAGS)
86+
$(BIN)/shelf_scan: $(SHELF_SCAN_OBJ)
87+
@mkdir -p $(dir $@)
88+
$(CXX) -o $@ $^ $(LD_FLAGS) $(SHELF_SCAN_LIB)
2689

90+
#================================================================================
91+
#== Sensor Libs
92+
#================================================================================
93+
$(APOLLO_MONITOR_LIB) : $(APOLLO_MONITOR_OBJ)
94+
@mkdir -p $(LIB)
95+
$(CXX) -o $@ $^ $(LD_FLAGS) $(APOLLO_MONITOR_LD_FLAGS) $(APOLLO_MONITOR_LIBS)
96+
97+
$(ATCA_LIB) : $(ATCA_OBJ)
98+
@mkdir -p $(LIB)
99+
$(CXX) -o $@ $^ $(LD_FLAGS) $(ATCA_LD_FLAGS) $(ATCA_LIBS)
100+
101+
#================================================================================
102+
#== Generic rules
103+
#================================================================================
104+
#Build cc files
105+
$(BUILD)/%.o: $(SRC)/%.cc
106+
@mkdir -p $(dir $@)
107+
$(CXX) -c -o $@ $< $(CXX_FLAGS)
108+
#Build cxx files
109+
$(BUILD)/%.o: $(SRC)/%.cxx
110+
@mkdir -p $(dir $@)
111+
$(CXX) -c -o $@ $< $(CXX_FLAGS)
112+
#build ApolloMonitor cc files
113+
$(BUILD)/ApolloMonitor/%.o: $(SRC)/ApolloMonitor/%.cc
114+
@mkdir -p $(dir $@)
115+
$(CXX) -c -o $@ $< $(CXX_FLAGS) $(APOLLO_MONITOR_CXX_FLAGS)
116+
117+
#================================================================================
118+
#== Install
119+
#================================================================================
120+
121+
install: $(GRAPHITE_MONITOR_OBJ)
122+
rm -f $(BIN)/graphite_monitor
123+
make $(BIN)/graphite_monitor INSTALL_LD_FLAGS='-Wl,-rpath=$(INSTALL_PATH)/lib'
124+
install -m 775 -d $(INSTALL_PATH)/lib
125+
install -m 775 -d $(INSTALL_PATH)/bin
126+
install -b -m 775 $(BIN)/graphite_monitor ${INSTALL_PATH}/bin
127+
install -b -m 775 $(LIB)/* ${INSTALL_PATH}/lib
128+
129+
#================================================================================
130+
#== Cleanup & helpers
131+
#================================================================================
27132
clean:
28-
rm -f $(OBJ)
133+
rm -rf $(BUILD)
134+
distclean: clean
135+
rm -rf $(BIN)
136+
rm -rf $(LIB)
137+
138+
#list magic: https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile
139+
list:
140+
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | column
141+

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Grafana / Graphite Monitoring Code
2+
3+
This code monitors a range of sensors and pushes their information to a Graphite/Grafana server for plotting.
4+
5+
## shelf_monitor
6+
This executable reads a config file (/etc/graphite_monitor or CL arg) that contains the Graphite connection information and a list of sensors to be built.
7+
8+
The different kinds of sensors are added at link-time.
9+
The procedure for this is to first build the sensor libs you want, which will put the lib so files in lib/, then build the main executable which will link in all the libs in lib/.
10+
11+
```bash
12+
[root@apollo06 Grafana-Monitor]# make list
13+
all distclean lib/libATCA.so
14+
bin/shelf_monitor lib_ApolloMonitor shelf_monitor
15+
bin/shelf_scan lib_ATCA shelf_scan
16+
clean lib/libApolloMonitor.so
17+
[root@apollo06 Grafana-Monitor]# make lib_ApolloMonitor
18+
g++ -c -o build/ApolloMonitor/ApolloMonitor.o src/ApolloMonitor/ApolloMonitor.cc -Iinclude -std=c++11 -fPIC -Wall -g -O3 -I/opt/BUTool/include -I/opt/cactus/include
19+
g++ -o lib/libApolloMonitor.so build/ApolloMonitor/ApolloMonitor.o -lboost_program_options -lboost_system -L/opt/BUTool/lib -Wl,-rpath=/opt/BUTool/lib -shared -fPIC -Wall -g -O3 -rdynamic -lBUTool_Helpers -lBUTool_ApolloSM -lToolException -lBUTool_IPBusIO
20+
[root@apollo06 Grafana-Monitor]# make
21+
g++ -c -o build/shelf_monitor.o src/shelf_monitor.cxx -Iinclude -std=c++11 -fPIC -Wall -g -O3
22+
g++ -c -o build/base/SensorFactory.o src/base/SensorFactory.cc -Iinclude -std=c++11 -fPIC -Wall -g -O3
23+
src/base/SensorFactory.cc:8:13: warning: ‘bool CLIArgsValid(const string&, const string&)’ defined but not used [-Wunused-function]
24+
static bool CLIArgsValid(std::string const & flag,std::string const & full_flag){
25+
^
26+
g++ -c -o build/base/Sensor.o src/base/Sensor.cc -Iinclude -std=c++11 -fPIC -Wall -g -O3
27+
g++ -c -o build/base/net_helpers.o src/base/net_helpers.cc -Iinclude -std=c++11 -fPIC -Wall -g -O3
28+
build/shelf_monitor.o build/base/SensorFactory.o build/base/Sensor.o build/base/net_helpers.o
29+
build/base/SensorFactory.o build/base/Sensor.o build/base/net_helpers.o
30+
g++ -o bin/shelf_monitor build/shelf_monitor.o build/base/SensorFactory.o build/base/Sensor.o build/base/net_helpers.o -lboost_program_options -lboost_system -Llib -lApolloMonitor
31+
```
32+
33+

config/Schroff.config

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#SCHROFF
22

3-
sensor=IpmiTemperature Controller 6 192.168.10.172 0x5a
4-
sensor=IpmiTemperature Left 7 192.168.10.172 0x5a
5-
sensor=IpmiTemperature Center 10 192.168.10.172 0x5a
6-
sensor=IpmiTemperature Right 9 192.168.10.172 0x5a
73

4+
graphite_server=192.168.10.20
5+
graphite_port=2003
6+
poll_period=30
87

9-
sensor=IpmiFanspeed SCHROFF-Fan1 10 192.168.10.172 0x5a
10-
sensor=IpmiFanspeed SCHROFF-Fan2 11 192.168.10.172 0x5a
11-
sensor=IpmiFanspeed SCHROFF-Fan3 12 192.168.10.172 0x5a
12-
sensor=IpmiFanspeed SCHROFF-Fan4 13 192.168.10.172 0x5a
13-
sensor=IpmiFanspeed SCHROFF-Fan5 14 192.168.10.172 0x5a
14-
sensor=IpmiFanspeed SCHROFF-Fan6 15 192.168.10.172 0x5a
8+
9+
sensor=IpmiTemp Controller Shelf.SCHROFF 6 192.168.10.172 0x5a
10+
sensor=IpmiTemp Left Shelf.SCHROFF 7 192.168.10.172 0x5a
11+
sensor=IpmiTemp Center Shelf.SCHROFF 10 192.168.10.172 0x5a
12+
sensor=IpmiTemp Right Shelf.SCHROFF 9 192.168.10.172 0x5a
13+
14+
15+
sensor=IpmiFanspeed Fan1 Shelf.SCHROFF 10 192.168.10.172 0x5a
16+
sensor=IpmiFanspeed Fan2 Shelf.SCHROFF 11 192.168.10.172 0x5a
17+
sensor=IpmiFanspeed Fan3 Shelf.SCHROFF 12 192.168.10.172 0x5a
18+
sensor=IpmiFanspeed Fan4 Shelf.SCHROFF 13 192.168.10.172 0x5a
19+
sensor=IpmiFanspeed Fan5 Shelf.SCHROFF 14 192.168.10.172 0x5a
20+
sensor=IpmiFanspeed Fan6 Shelf.SCHROFF 15 192.168.10.172 0x5a
1521
#
16-
apollo=Apollo2 2 0 192.168.10.172 0x8c
17-
apollo=Apollo6 6 0 192.168.10.172 0x86
22+
sensor=ApolloBlade 2 Blades 192.168.10.172 0x8c
23+
sensor=ApolloBlade 6 Blades 192.168.10.172 0x86
1824
#apollo=Apollo7 7 0 192.168.10.172 0x88

config/example.config

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,10 @@
1919
## ex. SCHROFF crate:
2020
# sensor=Apollo 2 0 192.168.10.172 0x8c
2121

22-
sensor=IpmiTemperature Controller 6 192.168.10.172 0x5a
23-
sensor=IpmiTemperature Left 7 192.168.10.172 0x5a
24-
sensor=IpmiTemperature Center 10 192.168.10.172 0x5a
25-
sensor=IpmiTemperature Right 9 192.168.10.172 0x5a
22+
graphite_server=192.168.10.20
23+
graphite_port=2003
2624

27-
28-
sensor=IpmiFanspeed SCHROFF-Fan1 10 192.168.10.172 0x5a
29-
sensor=IpmiFanspeed SCHROFF-Fan2 11 192.168.10.172 0x5a
30-
sensor=IpmiFanspeed SCHROFF-Fan3 12 192.168.10.172 0x5a
31-
sensor=IpmiFanspeed SCHROFF-Fan4 13 192.168.10.172 0x5a
32-
sensor=IpmiFanspeed SCHROFF-Fan5 14 192.168.10.172 0x5a
33-
sensor=IpmiFanspeed SCHROFF-Fan6 15 192.168.10.172 0x5a
34-
35-
sensor=Apollo 2 0 192.168.10.172 0x8c
25+
sensor=ApolloMonitor /opt/address_tables/connections.xml Apollo06 CM_MON 3
26+
sensor=ApolloMonitor /opt/address_tables/connections.xml Apollo06 C2C 1
27+
sensor=ApolloMonitor /opt/address_tables/connections.xml Apollo06 ZYNQ_OS 1
28+
sensor=ApolloMonitor /opt/address_tables/connections.xml Apollo06 CM_FF_MON 3

include/ApolloBlade.hh

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef __APOLLO_MONITOR_HH__
2+
#define __APOLLO_MONITOR_HH__
3+
#include <base/SensorFactory.hh>
4+
#include <base/Sensor.hh>
5+
#include <ApolloSM/ApolloSM.hh>
6+
7+
class ApolloMonitor : public Sensor {
8+
9+
public:
10+
ApolloMonitor(std::vector<std::string> const & args);
11+
virtual int Report();
12+
virtual float GetVal();
13+
private:
14+
void ReplaceSN(std::string &);
15+
void ReplaceRN(std::string &);
16+
void ReplaceShelfID(std::string &);
17+
void ReplaceZynqIP(std::string &);
18+
void ReplaceIPMCIP(std::string &);
19+
20+
void SetSensors();
21+
std::string base;
22+
ApolloSM * SM;
23+
int level;
24+
std::string table;
25+
};
26+
27+
RegisterSensor(ApolloMonitor,"ApolloMonitor")
28+
#endif

include/IpmiFanSpeedSensor.hh

Lines changed: 0 additions & 22 deletions
This file was deleted.

include/IpmiTemperatureSensor.hh

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)