Пример #1
0
        public void Init(SSHParam inparam, STRule inrule, string innodename)
        {
            sshParam = inparam;
            string filepathname = string.Format("/tmp/{0}{1}{2}", innodename, DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"), inrule.rFileName);

            inrule.rFileName = filepathname;
            STTask task = new STTask();

            task.myRule = inrule;
            task.hName  = innodename;
            task.GetCmdLine();
            myTask = task;
            try {
                sshclient = new SshClient(sshParam.hostIP, sshParam.userName, sshParam.userPWD);
                if (sshclient == null)
                {
                    return;
                }
                sshclient.Connect();
                sshcmd     = sshclient.CreateCommand(task.GetCmdLine());
                ssharesult = sshcmd.BeginExecute();
            } catch (Exception exc) {
                exc.ToString();
            }
        }
Пример #2
0
 void Bt_delruleClick(object sender, EventArgs e)
 {
     if (listBox_allrules.SelectedIndex >= 0)
     {
         editRule = listBox_allrules.SelectedItem as STRule;
         allRules.Remove(editRule);
     }
 }
Пример #3
0
 void Bt_editruleClick(object sender, EventArgs e)
 {
     if (listBox_allrules.SelectedIndex >= 0)
     {
         editRule = listBox_allrules.SelectedItem as STRule;
         param_2_ctrl(editRule);
     }
 }
Пример #4
0
 public void RulesInit()
 {
     journal_short_rule             = new STRule();
     journal_short_rule.RuleName    = "journalctl rule with short-precise option";
     journal_short_rule.rType       = STRuleType.Block;
     journal_short_rule.rFileOption = string.Empty;
     journal_short_rule.rFileName   = string.Empty;
     RulesUpdate();
 }
Пример #5
0
        public NonBlockFileSession(string inHost, string inUserName, string inPwd, string inCmd, string inOP, string infilename, string innodename)
        {
            SSHParam para = new SSHParam(inHost, inUserName, inPwd);
            STRule   rule = new STRule();

            rule.rCmdLine    = inCmd;
            rule.rFileOption = inOP;
            rule.rFileName   = infilename;
            rule.rType       = STRuleType.NonBlockFile;
            rule.rName       = "NonBlockFileSession internal";
            Init(para, rule, innodename);
        }
Пример #6
0
 void Bt_saveClick(object sender, EventArgs e)
 {
     if (editRule != null)
     {
         if (this.allRules.Contains(editRule) == false)
         {
             this.allRules.Add(editRule);
         }
     }
     editRule = null;
     this.groupBox1.Enabled = false;
 }
Пример #7
0
        public void dummy()
        {
            STRule obj = null;

            obj             = new STRule();
            obj.rCmdLine    = "ls -lah";
            obj.rType       = STRuleType.Block;
            obj.rFileOption = string.Empty;
            obj.rName       = "show ls result";
            allRules.Add(obj);
            obj             = new STRule();
            obj.rCmdLine    = "ps -ef";
            obj.rType       = STRuleType.Block;
            obj.rFileOption = string.Empty;
            obj.rName       = "show ps result";
            allRules.Add(obj);
        }
Пример #8
0
 public void update_ruleitem_show()
 {
     if (listBox_allrules.SelectedIndex >= 0)
     {
         STRule selectedruleitem = listBox_allrules.SelectedItem as STRule;
         this.label_show_ruleitem.Text = string.Format("{0}\n\tRuleName:{1}\n\tRuleCmd:{2} {3} {4}\n\tRuleType:{5}",
                                                       listBox_allrules.SelectedIndex.ToString(),
                                                       selectedruleitem.RuleName,
                                                       selectedruleitem.RuleCmdLine,
                                                       selectedruleitem.RuleFileOption,
                                                       selectedruleitem.RuleFileName,
                                                       selectedruleitem.RuleType.ToString());
     }
     else
     {
         this.label_show_ruleitem.Text = "No rule item selected";
     }
 }
Пример #9
0
 public STTask()
 {
     hName  = string.Empty;
     hPort  = 22;
     myRule = null;
 }
Пример #10
0
 public void ctrl_2_param(STRule inrule)
 {
     inrule.RuleName     = this.tb_rulename.Text;
     inrule.RuleCmdLine  = this.tb_rulecmd.Text;
     inrule.RuleFileName = this.tb_filename.Text;
 }
Пример #11
0
 public void param_2_ctrl(STRule inrule)
 {
     this.tb_rulename.Text = inrule.RuleName;
     this.tb_rulecmd.Text  = inrule.RuleCmdLine;
     this.tb_filename.Text = inrule.RuleFileName;
 }