static std::vector<String> GetLogLevelCompletionSuggestions(const String& arg)
{
std::vector<String> result;
-
+
String debugLevel = "debug";
if (debugLevel.Find(arg) == 0)
result.push_back(debugLevel);
} else if (command && command->GetImpersonationLevel() == ImpersonateIcinga) {
String group = Application::GetRunAsGroup();
String user = Application::GetRunAsUser();
-
+
errno = 0;
struct group *gr = getgrnam(group.CStr());
-
+
if (!gr) {
if (errno == 0) {
Log(LogCritical, "cli")
return EXIT_FAILURE;
}
}
-
+
if (getgid() != gr->gr_gid) {
if (!vm.count("reload-internal") && setgroups(0, NULL) < 0) {
Log(LogCritical, "cli")
<< "Please re-run this command as a privileged user or using the \"" << user << "\" account.";
return EXIT_FAILURE;
}
-
+
if (setgid(gr->gr_gid) < 0) {
Log(LogCritical, "cli")
<< "setgid() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
return EXIT_FAILURE;
}
}
-
+
errno = 0;
struct passwd *pw = getpwnam(user.CStr());
-
+
if (!pw) {
if (errno == 0) {
Log(LogCritical, "cli")
return EXIT_FAILURE;
}
}
-
+
// also activate the additional groups the configured user is member of
if (getuid() != pw->pw_uid) {
if (!vm.count("reload-internal") && initgroups(user.CStr(), pw->pw_gid) < 0) {
<< "Please re-run this command as a privileged user or using the \"" << user << "\" account.";
return EXIT_FAILURE;
}
-
+
if (setuid(pw->pw_uid) < 0) {
Log(LogCritical, "cli")
<< "setuid() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
break;
DWORD exitStatus;
-
+
if (!GetExitCodeProcess(pi.hProcess, &exitStatus))
break;
VALUE "ProductVersion", VERSION
END
END
-
+
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 0x04E4
sei.nShow = SW_HIDE;
if (!ShellExecuteEx(&sei))
return false;
-
+
if (!sei.hProcess)
return false;
return 1;
_rmdir(installPath.c_str());
- }
+ }
return 0;
}
MainFormBase::MainFormBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( 800,569 ), wxDefaultSize );
-
+
m_MenuBar = new wxMenuBar( 0 );
wxMenu* m_FileMenu;
m_FileMenu = new wxMenu();
wxMenuItem* m_QuitMenuItem;
m_QuitMenuItem = new wxMenuItem( m_FileMenu, wxID_EXIT, wxString( wxT("&Quit") ) , wxEmptyString, wxITEM_NORMAL );
m_FileMenu->Append( m_QuitMenuItem );
-
+
m_MenuBar->Append( m_FileMenu, wxT("&File") );
-
+
wxMenu* m_HelpMenu;
m_HelpMenu = new wxMenu();
wxMenuItem* m_AboutMenuItem;
m_AboutMenuItem = new wxMenuItem( m_HelpMenu, wxID_ABOUT, wxString( wxT("&About Icinga Studio...") ) , wxEmptyString, wxITEM_NORMAL );
m_HelpMenu->Append( m_AboutMenuItem );
-
+
m_MenuBar->Append( m_HelpMenu, wxT("&Help") );
-
+
this->SetMenuBar( m_MenuBar );
-
+
wxBoxSizer* m_DialogSizer;
m_DialogSizer = new wxBoxSizer( wxVERTICAL );
-
+
wxBoxSizer* m_ConnectionDetailsSizer;
m_ConnectionDetailsSizer = new wxBoxSizer( wxHORIZONTAL );
-
+
m_TypesTree = new wxTreeCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( 315,-1 ), wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT );
m_ConnectionDetailsSizer->Add( m_TypesTree, 0, wxALL|wxEXPAND, 2 );
-
+
wxBoxSizer* m_ObjectDetailsSizer;
m_ObjectDetailsSizer = new wxBoxSizer( wxVERTICAL );
-
+
m_ObjectsList = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
m_ObjectDetailsSizer->Add( m_ObjectsList, 1, wxALL|wxEXPAND, 2 );
-
+
m_PropertyGrid = new wxPropertyGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_DEFAULT_STYLE);
m_ObjectDetailsSizer->Add( m_PropertyGrid, 1, wxALL|wxEXPAND, 5 );
-
-
+
+
m_ConnectionDetailsSizer->Add( m_ObjectDetailsSizer, 1, wxEXPAND, 5 );
-
-
+
+
m_DialogSizer->Add( m_ConnectionDetailsSizer, 1, wxEXPAND, 5 );
-
-
+
+
this->SetSizer( m_DialogSizer );
this->Layout();
m_StatusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
-
+
this->Centre( wxBOTH );
-
+
// Connect Events
this->Connect( m_QuitMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnQuitClicked ) );
this->Connect( m_AboutMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnAboutClicked ) );
this->Disconnect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFormBase::OnAboutClicked ) );
m_TypesTree->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( MainFormBase::OnTypeSelected ), NULL, this );
m_ObjectsList->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFormBase::OnObjectSelected ), NULL, this );
-
+
}
ConnectFormBase::ConnectFormBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
-
+
wxBoxSizer* m_DialogSizer;
m_DialogSizer = new wxBoxSizer( wxVERTICAL );
-
+
wxPanel* m_ConnectionDetailsPanel;
m_ConnectionDetailsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxStaticBoxSizer* m_DetailsSizer;
m_DetailsSizer = new wxStaticBoxSizer( new wxStaticBox( m_ConnectionDetailsPanel, wxID_ANY, wxT("Connection Details") ), wxVERTICAL );
-
+
wxStaticText* m_HostLabel;
m_HostLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("Host:"), wxDefaultPosition, wxDefaultSize, 0 );
m_HostLabel->Wrap( -1 );
m_DetailsSizer->Add( m_HostLabel, 0, wxALL, 5 );
-
+
m_HostText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_OK, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailsSizer->Add( m_HostText, 0, wxALL|wxEXPAND, 5 );
-
+
wxStaticText* m_PortLabel;
m_PortLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("Port:"), wxDefaultPosition, wxDefaultSize, 0 );
m_PortLabel->Wrap( -1 );
m_DetailsSizer->Add( m_PortLabel, 0, wxALL, 5 );
-
+
m_PortText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailsSizer->Add( m_PortText, 0, wxALL, 5 );
-
+
wxStaticText* m_UserLabel;
m_UserLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("API User:"), wxDefaultPosition, wxDefaultSize, 0 );
m_UserLabel->Wrap( -1 );
m_DetailsSizer->Add( m_UserLabel, 0, wxALL, 5 );
-
+
m_UserText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DetailsSizer->Add( m_UserText, 0, wxALL|wxEXPAND, 5 );
-
+
wxStaticText* m_PasswordLabel;
m_PasswordLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("API Password:"), wxDefaultPosition, wxDefaultSize, 0 );
m_PasswordLabel->Wrap( -1 );
m_DetailsSizer->Add( m_PasswordLabel, 0, wxALL, 5 );
-
+
m_PasswordText = new wxTextCtrl( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
m_DetailsSizer->Add( m_PasswordText, 0, wxALL|wxEXPAND, 5 );
-
+
wxStaticText* m_InfoLabel;
m_InfoLabel = new wxStaticText( m_DetailsSizer->GetStaticBox(), wxID_ANY, wxT("You can find the username and password for the default user in /etc/icinga2/conf.d/api-users.conf."), wxDefaultPosition, wxDefaultSize, 0 );
m_InfoLabel->Wrap( 270 );
m_DetailsSizer->Add( m_InfoLabel, 0, wxALL, 5 );
-
-
+
+
m_ConnectionDetailsPanel->SetSizer( m_DetailsSizer );
m_ConnectionDetailsPanel->Layout();
m_DetailsSizer->Fit( m_ConnectionDetailsPanel );
m_DialogSizer->Add( m_ConnectionDetailsPanel, 1, wxEXPAND | wxALL, 5 );
-
+
wxPanel* m_ButtonsPanel;
m_ButtonsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* m_ButtonsSizer;
m_ButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
-
+
m_Buttons = new wxStdDialogButtonSizer();
m_ButtonsOK = new wxButton( m_ButtonsPanel, wxID_OK );
m_Buttons->AddButton( m_ButtonsOK );
m_ButtonsCancel = new wxButton( m_ButtonsPanel, wxID_CANCEL );
m_Buttons->AddButton( m_ButtonsCancel );
m_Buttons->Realize();
-
+
m_ButtonsSizer->Add( m_Buttons, 1, wxEXPAND, 5 );
-
-
+
+
m_ButtonsPanel->SetSizer( m_ButtonsSizer );
m_ButtonsPanel->Layout();
m_ButtonsSizer->Fit( m_ButtonsPanel );
m_DialogSizer->Add( m_ButtonsPanel, 0, wxEXPAND | wxALL, 5 );
-
-
+
+
this->SetSizer( m_DialogSizer );
this->Layout();
m_DialogSizer->Fit( this );
-
+
this->Centre( wxBOTH );
}
AboutFormBase::AboutFormBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
-
+
wxBoxSizer* m_DialogSizer;
m_DialogSizer = new wxBoxSizer( wxVERTICAL );
-
+
wxBoxSizer* m_InfoSizer;
m_InfoSizer = new wxBoxSizer( wxHORIZONTAL );
-
+
wxStaticBitmap* m_ProductIcon;
m_ProductIcon = new wxStaticBitmap( this, wxID_ANY, wxBitmap( icinga_xpm ), wxDefaultPosition, wxDefaultSize, 0 );
m_InfoSizer->Add( m_ProductIcon, 0, wxALL, 5 );
-
+
wxBoxSizer* m_AboutInfoSizer;
m_AboutInfoSizer = new wxBoxSizer( wxVERTICAL );
-
+
wxStaticText* m_ProductNameLabel;
m_ProductNameLabel = new wxStaticText( this, wxID_ANY, wxT("Icinga Studio"), wxDefaultPosition, wxDefaultSize, 0 );
m_ProductNameLabel->Wrap( -1 );
m_AboutInfoSizer->Add( m_ProductNameLabel, 0, wxALL, 5 );
-
+
m_VersionLabel = new wxStaticText( this, wxID_ANY, wxT("Version"), wxDefaultPosition, wxDefaultSize, 0 );
m_VersionLabel->Wrap( -1 );
m_AboutInfoSizer->Add( m_VersionLabel, 0, wxALL, 5 );
-
+
wxStaticText* m_CopyrightLabel;
m_CopyrightLabel = new wxStaticText( this, wxID_ANY, wxT("Copyright (c) 2015 Icinga Development Team"), wxDefaultPosition, wxDefaultSize, 0 );
m_CopyrightLabel->Wrap( -1 );
m_AboutInfoSizer->Add( m_CopyrightLabel, 0, wxALL, 5 );
-
-
+
+
m_InfoSizer->Add( m_AboutInfoSizer, 1, wxEXPAND, 5 );
-
-
+
+
m_DialogSizer->Add( m_InfoSizer, 1, wxEXPAND, 5 );
-
+
wxPanel* m_ButtonsPanel;
m_ButtonsPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* m_ButtonsSizer;
m_ButtonsSizer = new wxBoxSizer( wxVERTICAL );
-
+
wxStdDialogButtonSizer* m_Buttons;
wxButton* m_ButtonsOK;
m_Buttons = new wxStdDialogButtonSizer();
m_ButtonsOK = new wxButton( m_ButtonsPanel, wxID_OK );
m_Buttons->AddButton( m_ButtonsOK );
m_Buttons->Realize();
-
+
m_ButtonsSizer->Add( m_Buttons, 0, wxEXPAND, 5 );
-
-
+
+
m_ButtonsPanel->SetSizer( m_ButtonsSizer );
m_ButtonsPanel->Layout();
m_ButtonsSizer->Fit( m_ButtonsPanel );
m_DialogSizer->Add( m_ButtonsPanel, 0, wxEXPAND | wxALL, 5 );
-
-
+
+
this->SetSizer( m_DialogSizer );
this->Layout();
m_DialogSizer->Fit( this );
-
+
this->Centre( wxBOTH );
}
class MainFormBase : public wxFrame
{
private:
-
+
protected:
wxMenuBar* m_MenuBar;
wxTreeCtrl* m_TypesTree;
wxListCtrl* m_ObjectsList;
wxPropertyGrid* m_PropertyGrid;
wxStatusBar* m_StatusBar;
-
+
// Virtual event handlers, overide them in your derived class
virtual void OnQuitClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAboutClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTypeSelected( wxTreeEvent& event ) { event.Skip(); }
virtual void OnObjectSelected( wxListEvent& event ) { event.Skip(); }
-
-
+
+
public:
-
+
MainFormBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Icinga Studio"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 800,569 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
-
+
~MainFormBase();
-
+
};
///////////////////////////////////////////////////////////////////////////////
class ConnectFormBase : public wxDialog
{
private:
-
+
protected:
wxTextCtrl* m_HostText;
wxTextCtrl* m_PortText;
wxStdDialogButtonSizer* m_Buttons;
wxButton* m_ButtonsOK;
wxButton* m_ButtonsCancel;
-
+
public:
-
+
ConnectFormBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Icinga Studio - Connect"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
~ConnectFormBase();
-
+
};
///////////////////////////////////////////////////////////////////////////////
class AboutFormBase : public wxDialog
{
private:
-
+
protected:
wxStaticText* m_VersionLabel;
-
+
public:
-
+
AboutFormBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About Icinga Studio"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
~AboutFormBase();
-
+
};
#endif //__FORMS_H__
VALUE "ProductVersion", VERSION
END
END
-
+
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 0x04E4
SetTitle(title);
m_ObjectsList->InsertColumn(0, "Name", 0, 300);
-
+
m_PropertyGrid->SetColumnCount(3);
}
return prop;
} else if (value.IsObjectType<Dictionary>()) {
wxStringProperty *prop = new wxStringProperty(name.GetData(), wxPG_LABEL);
-
+
Dictionary::Ptr dict = value;
{
Object::Ptr Array::Clone(void) const
{
Array::Ptr arr = new Array();
-
+
ObjectLock olock(this);
for (const Value& val : m_Data) {
arr->Add(val.Clone());
}
-
+
return arr;
}
BIO_set_flags(bio64, BIO_FLAGS_BASE64_NO_NL);
char *outbuf = new char[input.GetLength()];
-
+
size_t len = 0;
int rc;
std::vector<String> GetKeys(void) const;
static Object::Ptr GetPrototype(void);
-
+
virtual Object::Ptr Clone(void) const override;
virtual String ToString(void) const override;
static int DecodeStartArray(void *ctx)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
-
+
try {
context->Push(new Array());
} catch (...) {
#endif /* I2_DEBUG */
static Object::Ptr GetPrototype(void);
-
+
virtual Object::Ptr Clone(void) const;
static intrusive_ptr<Type> TypeInstance;
return object;
Object::Ptr instance;
-
+
if (object)
instance = object;
else
continue;
int fid = type->GetFieldId(kv.first);
-
+
if (fid < 0)
continue;
X509_REQ_set_version(req, 0);
X509_REQ_set_pubkey(req, key);
-
+
X509_NAME *name = X509_REQ_get_subject_name(req);
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char *)cn.CStr(), -1, -1, 0);
-
+
if (!ca) {
String san = "DNS:" + cn;
X509_EXTENSION *subjectAltNameExt = X509V3_EXT_conf_nid(NULL, NULL, NID_subject_alt_name, const_cast<char *>(san.CStr()));
}
X509_REQ_sign(req, key, EVP_sha256());
-
+
Log(LogInformation, "base")
<< "Writing certificate signing request to '" << csrfile << "'.";
-
+
bio = BIO_new_file(const_cast<char *>(csrfile.CStr()), "w");
if (!bio) {
}
BIO_free(bio);
-
+
X509_REQ_free(req);
}
virtual Value GetField(int id) const override;
virtual std::vector<String> GetLoadDependencies(void) const;
-
+
typedef std::function<void (const Object::Ptr&, const Value&)> AttributeHandler;
virtual void RegisterAttributeHandler(int fieldId, const AttributeHandler& callback);
virtual int GetFieldId(const String& name) const override;
virtual Field GetFieldInfo(int id) const override;
virtual int GetFieldCount(void) const override;
-
+
static Object::Ptr GetPrototype(void);
protected:
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Type::Ptr self = static_cast<Type::Ptr>(vframe->Self);
-
+
int fid = self->GetFieldId(fieldName);
self->RegisterAttributeHandler(fid, std::bind(&InvokeAttributeHandlerHelper, callback, _1, _2));
}
String GetTypeName(void) const;
Type::Ptr GetReflectionType(void) const;
-
+
Value Clone(void) const;
template<typename T>
Downtime::OnDowntimeTriggered.connect(std::bind(&CompatLogger::TriggerDowntimeHandler, this, _1));
Downtime::OnDowntimeRemoved.connect(std::bind(&CompatLogger::RemoveDowntimeHandler, this, _1));
Checkable::OnEventCommandExecuted.connect(std::bind(&CompatLogger::EventCommandHandler, this, _1));
-
+
Checkable::OnFlappingChanged.connect(std::bind(&CompatLogger::FlappingChangedHandler, this, _1));
Checkable::OnEnableFlappingChanged.connect(std::bind(&CompatLogger::EnableFlappingChangedHandler, this, _1));
-
+
ExternalCommandProcessor::OnNewExternalCommand.connect(std::bind(&CompatLogger::ExternalCommandHandler, this, _2, _3));
m_RotationTimer = new Timer();
String flapping_state_str;
String flapping_output;
-
+
if (checkable->IsFlapping()) {
flapping_output = "Checkable appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThresholdHigh()) + "% threshold)";
flapping_state_str = "STARTED";
if (checkable->GetEnableFlapping())
return;
-
+
String flapping_output = "Flap detection has been disabled";
String flapping_state_str = "DISABLED";
}
| rterm_side_effect
;
-
+
rterm_items: /* empty */
{
$$ = new std::vector<Expression *>();
void SetZone(const String& zone);
String GetZone(void) const;
-
+
void SetPackage(const String& package);
String GetPackage(void) const;
Dictionary::Ptr GetScope(void) const;
ConfigObject::Ptr GetObject(void) const;
-
+
static ConfigItem::Ptr GetByTypeAndName(const Type::Ptr& type,
const String& name);
BinaryExpression(Expression *operand1, Expression *operand2, const DebugInfo& debugInfo = DebugInfo())
: DebuggableExpression(debugInfo), m_Operand1(operand1), m_Operand2(operand2)
{ }
-
+
~BinaryExpression(void)
{
delete m_Operand1;
friend I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
};
-
+
class I2_CONFIG_API NegateExpression : public UnaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API LogicalNegateExpression : public UnaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API SubtractExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API MultiplyExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API DivideExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API BinaryOrExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API ShiftLeftExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API ShiftRightExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API EqualExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API NotEqualExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API LessThanExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API GreaterThanExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API LessThanOrEqualExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API GreaterThanOrEqualExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API InExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API NotInExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API LogicalAndExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API LogicalOrExpression : public BinaryExpression
{
public:
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
-
+
class I2_CONFIG_API FunctionCallExpression : public DebuggableExpression
{
public:
Expression *m_FName;
std::vector<Expression *> m_Args;
};
-
+
class I2_CONFIG_API ArrayExpression : public DebuggableExpression
{
public:
private:
std::vector<Expression *> m_Expressions;
};
-
+
class I2_CONFIG_API DictExpression : public DebuggableExpression
{
public:
friend I2_CONFIG_API void BindToScope(Expression *& expr, ScopeSpecifier scopeSpec);
};
-
+
class I2_CONFIG_API SetExpression : public BinaryExpression
{
public:
std::map<String, Expression *> *m_ClosedVars;
std::shared_ptr<Expression> m_Expression;
};
-
+
class I2_CONFIG_API ForExpression : public DebuggableExpression
{
public:
{
String flapping_state_str;
String flapping_output;
-
+
if (checkable->IsFlapping()) {
flapping_output = "Service appears to have started flapping (" + Convert::ToString(checkable->GetFlappingCurrent()) + "% change >= " + Convert::ToString(checkable->GetFlappingThresholdHigh()) + "% threshold)";
flapping_state_str = "STARTED";
{
if (!checkable->GetEnableFlapping())
return;
-
+
String flapping_output = "Flap detection has been disabled";
String flapping_state_str = "DISABLED";
if (!checkable->GetEnableFlapping())
return;
-
+
fields1->Set("event_type", 1001);
fields1->Set("reason_type", 2);
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
-
+
Dictionary::Ptr dict = vinstances;
for (const String& key : dict->GetKeys()) {
else
m_Child = childHost->GetServiceByShortName(GetChildServiceName());
}
-
+
if (!m_Child)
BOOST_THROW_EXCEPTION(ScriptError("Dependency '" + GetName() + "' references a child host/service which doesn't exist.", GetDebugInfo()));
else
m_Parent = parentHost->GetServiceByShortName(GetParentServiceName());
}
-
+
if (!m_Parent)
BOOST_THROW_EXCEPTION(ScriptError("Dependency '" + GetName() + "' references a parent host/service which doesn't exist.", GetDebugInfo()));
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
-
+
Dictionary::Ptr dict = vinstances;
for (const String& key : dict->GetKeys()) {
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
-
+
Dictionary::Ptr dict = vinstances;
for (const String& key : dict->GetKeys()) {
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
-
+
Dictionary::Ptr dict = vinstances;
for (const String& key : dict->GetKeys()) {
protected:
Aggregator(void);
-
+
Filter::Ptr GetFilter(void) const;
-
+
private:
Filter::Ptr m_Filter;
};
typedef std::function<void(boost::exception_ptr, const Value&)> ExecuteScriptCompletionCallback;
void ExecuteScript(const String& session, const String& command, bool sandboxed,
const ExecuteScriptCompletionCallback& callback) const;
-
+
typedef std::function<void(boost::exception_ptr, const Array::Ptr&)> AutocompleteScriptCompletionCallback;
void AutocompleteScript(const String& session, const String& command, bool sandboxed,
const AutocompleteScriptCompletionCallback& callback) const;
/* filesync */
static Value ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
-
+
/* configsync */
static void ConfigUpdateObjectHandler(const ConfigObject::Ptr& object, const Value& cookie);
static Value ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static Value ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
-
+
static Value HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void UpdateObjectAuthority(void);
}
std::vector<String> ConsoleHandler::GetAutocompletionSuggestions(const String& word, ScriptFrame& frame)
-{
+{
std::vector<String> matches;
for (const String& keyword : ConfigWriter::GetKeywords()) {
ObjectLock olock(attrs);
for (const String& attr : attrs) {
String userAttr;
-
+
if (isJoin) {
String::SizeType dpos = attr.FindFirstOf(".");
if (dpos == String::NPos)
ret = check_drives(vDrives, printInfo.exclude_drives);
else
ret = check_drives(vDrives, printInfo);
-
+
if (ret != -1)
return ret;
return 3;
}
}
-
+
if (vm.count("path"))
printInfo.drives = vm["path"].as<std::vector<std::wstring>>();
if (printInfo.showUsed)
output = L"DISK OK - used space:";
-
+
double tCap = 0, tFree = 0, tUsed = 0;
for (std::vector<drive>::iterator it = vDrives.begin(); it != vDrives.end(); it++) {
if (state == WARNING) {
output = L"DISK WARNING - free space:";
-
+
if (printInfo.showUsed)
output = L"DISK WARNING - used space:";
}
ret = check_network(vInterfaces);
if (ret != -1)
return ret;
-
+
return printOutput(printInfo, vInterfaces, mapNames);
}
return 3;
}
}
-
+
if (vm.count("debug"))
debug = TRUE;
err = PdhAddEnglishCounter(phQuery, perfIn, NULL, &phCounterIn);
if (!SUCCEEDED(err))
goto die;
-
+
err = PdhAddEnglishCounter(phQuery, perfOut, NULL, &phCounterOut);
if (!SUCCEEDED(err))
goto die;
-
+
if (debug)
std::wcout << L"Collecting first batch of query data" << '\n';
if (debug)
std::wcout << L"Creating formatted counter arrays" << '\n';
-
+
err = PdhGetFormattedCounterArray(phCounterIn, PDH_FMT_LONG, &dwBufferSizeIn, &dwItemCount, pDisplayValuesIn);
if (err == PDH_MORE_DATA || SUCCEEDED(err))
pDisplayValuesIn = reinterpret_cast<PDH_FMT_COUNTERVALUE_ITEM*>(new BYTE[dwItemCount*dwBufferSizeIn]);
else
goto die;
-
+
err = PdhGetFormattedCounterArray(phCounterOut, PDH_FMT_LONG, &dwBufferSizeOut, &dwItemCount, pDisplayValuesOut);
if (err == PDH_MORE_DATA || SUCCEEDED(err))
pDisplayValuesOut = reinterpret_cast<PDH_FMT_COUNTERVALUE_ITEM*>(new BYTE[dwItemCount*dwBufferSizeIn]);
std::wcout << L"Dropped: echo reply status " << pEchoReply->Status << '\n';
continue;
}
-
+
rtt += pEchoReply->RoundTripTime;
if (debug)
DomainName = NULL;
dwAcctName = 1;
dwDomainName = 1;
-
+
if (debug)
std::wcout << L"Looking up SID" << '\n';
(LPDWORD)&dwAcctName, DomainName, (LPDWORD)&dwDomainName, &sidNameUse)
&& GetLastError() != ERROR_INSUFFICIENT_BUFFER)
continue;
-
+
AcctName = reinterpret_cast<LPWSTR>(new WCHAR[dwAcctName]);
DomainName = reinterpret_cast<LPWSTR>(new WCHAR[dwDomainName]);
if (debug)
std::wcout << L"Is process of " << wuser << L" (" << numProcs << L")" << '\n';
}
-
+
delete[] reinterpret_cast<LPWSTR>(AcctName);
delete[] reinterpret_cast<LPWSTR>(DomainName);
if (vm.count("D"))
debug = TRUE;
-
+
return -1;
}
hService = OpenService(hSCM, printInfo.service.c_str(), SERVICE_QUERY_STATUS);
if (hService == NULL)
goto die;
-
+
QueryServiceStatusEx(hService, SC_STATUS_PROCESS_INFO, NULL, 0, &cbBufSize);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
goto die;
INT ret = parseArguments(argc, argv, vm, printInfo);
if (ret != -1)
return ret;
-
+
ret = check_update(printInfo);
if (ret != -1)
return ret;
po::variables_map vm;
printInfoStruct printInfo = { };
INT ret = parseArguments(argc, argv, vm, printInfo);
-
+
if (ret != -1)
return ret;
WCHAR *progName = PathFindFileName(namePath);
po::options_description desc;
-
+
desc.add_options()
("help,h", "Print help message and exit")
("version,V", "Print version and exit")
std::wcout << L"Getting uptime in milliseconds" << '\n';
boost::chrono::milliseconds uptime = boost::chrono::milliseconds(GetTickCount64());
-
+
if (debug)
std::wcout << L"Converting requested unit (default: seconds)" << '\n';
if (debug)
std::wcout << L"Trying to enumerate terminal sessions" << '\n';
-
+
if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pSessionInfo, &count)) {
std::wcout << L"Failed to enumerate terminal sessions" << '\n';
die();
if (!len)
continue;
-
+
if (pSessionInfo[index].State == WTSActive || pSessionInfo[index].State == WTSDisconnected) {
users++;
if (debug)
.append(upperStr).append(L"]");
} else
s.append(lowerStr);
-
+
return s;
}