NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
disk_monitor.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef DISK_MONITOR_DISK_MONITOR_H_
20 #define DISK_MONITOR_DISK_MONITOR_H_
21 
22 #include <pluginlib/class_list_macros.h>
23 
24 #include <ros/ros.h>
25 #include <ros/package.h>
26 
27 #include <errno.h>
28 #include <stdint.h>
29 
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <sys/statvfs.h>
33 
35 #include <ff_msgs/DiskState.h>
36 #include <ff_msgs/DiskStateStamped.h>
37 #include <ff_common/ff_names.h>
38 #include <ff_util/ff_nodelet.h>
39 
40 #include <memory>
41 #include <string>
42 #include <vector>
43 
44 namespace disk_monitor {
45 
47  public:
48  DiskMonitor();
49  ~DiskMonitor();
50  bool PathExists(std::string path);
51 
52  protected:
53  virtual void Initialize(ros::NodeHandle *nh);
54  bool ReadParams(ff_util::FaultKeys fault_key);
55 
56  struct PathInfo {
57  PathInfo();
58  PathInfo(std::string const& path_name_in,
59  bool const check_load_high_fault_in,
60  float const high_thres_percent_in,
61  float const too_high_thres_percent_in);
62  std::string path_name;
66  };
67 
68  private:
69  void ReloadParams();
70  bool LoadParams(ff_util::FaultKeys fault_key);
71  void OnCheckTimer(ros::TimerEvent const& event);
72  bool CheckAndPublish();
73 
74  bool usage_high_fault_triggered_, usage_too_high_fault_triggered_;
75 
76  config_reader::ConfigReader config_params_;
77 
78  ff_msgs::DiskStateStamped disk_stats_msg_;
79 
80  int pub_queue_size_, update_freq_;
81 
82  ros::Publisher pub_disk_stats_;
83  ros::Timer reload_params_timer_, stats_timer_;
84 
85  std::shared_ptr<std::vector<PathInfo>> paths_info_;
86  std::string pub_topic_disk_stats_, processor_name_;
87  std::string disks_high_, disks_too_high_;
88 };
89 
90 } // namespace disk_monitor
91 
92 #endif // DISK_MONITOR_DISK_MONITOR_H_
disk_monitor::DiskMonitor
Definition: disk_monitor.h:46
disk_monitor::DiskMonitor::PathInfo::path_name
std::string path_name
Definition: disk_monitor.h:62
disk_monitor::DiskMonitor::PathInfo::PathInfo
PathInfo()
Definition: disk_monitor_node.cc:328
disk_monitor::DiskMonitor::PathExists
bool PathExists(std::string path)
Definition: disk_monitor_node.cc:37
disk_monitor
Definition: disk_monitor.h:44
ff_nodelet.h
disk_monitor::DiskMonitor::ReadParams
bool ReadParams(ff_util::FaultKeys fault_key)
Definition: disk_monitor_node.cc:139
disk_monitor::DiskMonitor::DiskMonitor
DiskMonitor()
Definition: disk_monitor_node.cc:24
disk_monitor::DiskMonitor::PathInfo::critical_thres_percent
float critical_thres_percent
Definition: disk_monitor.h:65
ff_util::FreeFlyerNodelet
Definition: ff_nodelet.h:57
ff_names.h
config_reader::ConfigReader
Definition: config_reader.h:48
disk_monitor::DiskMonitor::~DiskMonitor
~DiskMonitor()
Definition: disk_monitor_node.cc:34
disk_monitor::DiskMonitor::Initialize
virtual void Initialize(ros::NodeHandle *nh)
Definition: disk_monitor_node.cc:42
disk_monitor::DiskMonitor::PathInfo
Definition: disk_monitor.h:56
config_reader.h
disk_monitor::DiskMonitor::PathInfo::check_load_high_fault
bool check_load_high_fault
Definition: disk_monitor.h:63
disk_monitor::DiskMonitor::PathInfo::high_thres_percent
float high_thres_percent
Definition: disk_monitor.h:64
ff_util::FaultKeys
FaultKeys
Definition: ff_faults.h:28