-
Notifications
You must be signed in to change notification settings - Fork 20
/
SSH - Linux - CPU Info.xml
48 lines (48 loc) · 10.9 KB
/
SSH - Linux - CPU Info.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<TotalExport sourceSystem="NG">
<Workflows>
<WorkflowInfo Pnumber="15541" Name="SSH - Linux - CPU Info" Description="Simple template using the top command to retrieve various forms of CPU usage in terms of percentage. The results are converted to a table with four columns ('User', 'System', 'Nice', and 'Idle')." Xoml="<SequentialWorkflowActivity xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="CustomWorkflow" x:Class="WorkflowDesignerControl.CustomWorkflow">
 <StartSSHSession x:Name="ssh_connect" activityLicenseType="1" id="274" name="StartSSHSession" visible="True" disabled="False" isFavorite="False" isJsonValid="True" IsValid="True" Timeout="00:01:00" TimeInSeconds="60" RecoveryMethodSelection="{x:Null}" TargetModuleID="" TargetModuleName="" Path="{x:Null}" DisplayName="Start SSH Session" Description="Starts an SSH session" Port="22" MaxSessionTime="00:10:00" HostId="4" HostName="local shell server" UserName="" Password="" StartSession="SSH" OSType="0" certtype="" certpath="" notes="Initialize SSH session." TypeName="StartSSHSession" label="Start SSH Session" description="Starts an SSH session" />
 <SendSSHCommand x:Name="cmd_cpu_info" activityLicenseType="1" id="271" name="SendSSHCommand" visible="True" disabled="False" isFavorite="False" isJsonValid="True" IsValid="True" Timeout="00:01:00" TimeInSeconds="60" RecoveryMethodSelection="{x:Null}" TargetModuleID="" TargetModuleName="" Path="{x:Null}" DisplayName="Send SSH Command" Description="Sends a single SSH protocol command to an open SSH session" SessionName="ssh_connect" Comm="top -n 1 | grep Cpu | awk '{ $1=&quot;&quot;; print $0 }' | awk '{ print &quot;User|&quot;$1&quot;%\nSystem|&quot;$3&quot;%\nNice|&quot;$5&quot;%\nIdle|&quot;$7&quot;%&quot; }'" Prompt="" HostId="-1" HostName="" OSType="0" notes="Execute the top command to retrieve CPU usage information, where the -n 1 flag for top allows the program to exit after one iteration, rather than be ran in its default interactive mode. The output is then piped to grep to filter the line containing the string Cpu. That output is finally piped to awk where the first column is ignored, piped to awk again where custom labels are used for the first column of each row (i.e. User, System, etc.) and a tab is added before the second column on each row that printed." TypeName="SendSSHCommand" label="Send SSH Command" description="Sends a single SSH protocol command to an open SSH session" />
 <ConvertTextToTable x:Name="table_cpu_info" activityLicenseType="1" id="317" name="ConvertTextToTable" visible="True" disabled="False" isFavorite="False" isJsonValid="True" IsValid="True" Timeout="00:01:00" TimeInSeconds="60" RecoveryMethodSelection="{x:Null}" TargetModuleID="" TargetModuleName="" Path="{x:Null}" DisplayName="Convert Text to Table" Description="Converts a text variable into a table according to predefined column/row delimiters" TheValue="Type Used&#xD;&#xA;%cmd_cpu_info%" ColumnsSelection="0" ColumnsDelimiterText="|" ColumnsDelimiter="|" ColumnsDelimiterSelection="|" ColumnsRowNumber="1" RowsSelection="1" RowsDelimiterText="" RowsDelimiterSelection="Carriage Return" RowsDelimiter="Carriage Return" notes="Convert command output to table." TypeName="ConvertTextToTable" label="Convert Text to Table" description="Converts a text variable into a table according to predefined column/row delimiters" />
 <TerminateSSHSession x:Name="ssh_disconnect" activityLicenseType="1" id="275" name="TerminateSSHSession" visible="True" disabled="False" isFavorite="False" isJsonValid="True" IsValid="True" notes="End SSH session." Timeout="00:01:00" TimeInSeconds="60" RecoveryMethodSelection="{x:Null}" TargetModuleID="" TargetModuleName="" Path="{x:Null}" DisplayName="" Description="Terminates an SSH session" SessionName="ssh_connect" HostId="-1" HostName="{x:Null}" OSType="0" TypeName="TerminateSSHSession" label="TerminateSSHSession" description="Terminates an SSH session" />
</SequentialWorkflowActivity>" XomlStatus="0" Details="<p>Simple template using the <strong>top </strong>command to retrieve various forms of CPU usage in terms of percentage.&nbsp;The results are converted to a table with four columns (<strong>User</strong>, <strong>System</strong>, <strong>Nice</strong>, and <strong>Idle</strong>).</p><p><br></p><p>This is achieved with the following command:</p><p><br></p><p><strong>top -n 1 | grep Cpu | awk '{ $1=""; print $0 }' | awk '{ print "User\t"$1"%\nSystem\t"$3"%\nNice\t"$5"%\nIdle\t"$7"%" }'</strong></p><p><br></p><p>...where the <strong>-n 1 </strong>flag for <strong>top </strong>allows the program to exit after one iteration, rather than be ran in its default interactive mode. The output is then piped to <strong>grep </strong>to filter the line containing the string <strong>Cpu</strong>. That output is finally piped to <strong>awk </strong>where the first column is ignored, piped to <strong>awk </strong>again where custom labels are used for the first column of each row (i.e. <strong>User</strong>, <strong>System</strong>, etc.) and a tab is added before the second column on each row that printed. These results are then converted into a table.</p>" DateLic="34385064303975645753487875595347585630595A78516E636E586F6D4F335A58337773526C426F343064564844367062626E5966624B2F76336F414D54563552356976304C496651597575354E536D71505A764F3732586E4832325257496E304977596670514264484E4E336336732B4635745A6F3759326B4645697774776A4A49585257684144573661464F502F5361654A457653377057644D534C564A334170626D386835776C79695A73483749664175546D3849535A7957697355623556525245646471314C722B74384B4468712B6D565249764D344E54444B6B4B4D6E3339464B4B47556A6D41714E504C6A50475A537546496D507A3734556345637A6F576265543869706637684D6D326A7233574B423730634A33676E7A55734C397953494345363032664F415A454644615950374857395647504875447045" WorkflowType="0" WorkflowFolderId="80" Permissions="<NewDataSet><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="resultSet"><xs:complexType><xs:sequence><xs:element name="Type" type="xs:int" minOccurs="0" /><xs:element name="Number" type="xs:int" minOccurs="0" /><xs:element name="Read" type="xs:boolean" minOccurs="0" /><xs:element name="Write" type="xs:boolean" minOccurs="0" /><xs:element name="Run" type="xs:boolean" minOccurs="0" /><xs:element name="Owner" type="xs:boolean" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><resultSet><Type>1</Type><Number>1</Number><Read>true</Read><Write>true</Write><Run>true</Run><Owner>true</Owner></resultSet></NewDataSet>" ErrorHandling="" CurrentRevisionNumber="1" WorkflowParentId="0" DateCreated="2021-07-22T14:05:20.017" DateCreatedUser="1" DateModified="2021-07-22T14:06:19.330" DateModifiedUser="1" />
</Workflows>
<Objects>
<Hosts>
<Host Hnumber="4" Hname="eyeShare Module" Hdescription="Automatically Created Object" Deleted="0" DeviceType="1" Site="0" IPAddress="" Platform="0" InstanceMode="0" SNMPMIB="" CredentialsInherit="0" ExecutorID="0" AutoCreated="1" IsMasterHost="0" MasterHostId="0" />
</Hosts>
<ErrorHandlers />
<ErrorMessages />
<MessageTemplates />
<Sites />
<Developments />
<Users>
<User Unumber="1" Uname="Admin" FName="Ayehu" LName="Administrator" Email="Admin@localhost.com" Pnumber1="0000000" Pnumber2="0000000" Role="1" Password1="GO4LNahlTb3F0vFFgGrSO1QZfU55fsedFGLbmAcAVmGs4yG3jvClwosEbnNSqR8pE+z/b445CY+uaGNXWXVwTx6azqDPFQ==" Deleted="0" Modulenumber="0" ActiveDirectoryID="" HomePhoneNumber="" WorkPhoneNumber="" MobilePhoneNumber="" ListenerClientIP="" EmployeeNumber="" />
</Users>
<Groups />
<UsersGroupsArray />
<Domains />
<Commands />
<Classifications />
<Incidents />
<TimeFrames />
<Variables />
<Modules />
<Conditions />
<ConditionArrays />
<ConditionObjects />
<SoapWebServices />
<Triggers />
<TriggerConditionArrays />
<LogCategory />
<LogTriggerCategory />
<Schedules />
<CustomActivities />
<ActivitiesSource />
<ScheduleCategoriesRelations />
</Objects>
<ObjectsRelations>
<ObjectRelation ObjectID="1" Type="User" ParentWorkFlowID="15541" />
<ObjectRelation ObjectID="4" Type="Host" ParentWorkFlowID="15541" />
</ObjectsRelations>
<ExportKeys>
<Key name="passPhrase" value="7832664761624D496B477433795A323249616A30626A5379663765474365546950565A626D6B306B4B4D553D" />
<Key name="saltValue" value="4D6776426E73594F4D723453686E636B79456E4D64673D3D" />
<Key name="initVector" value="45453367315568306A6D6A6B4A694E6B3965424A59325077446757696D2B5866736B66714B5653614E714D3D" />
</ExportKeys>
</TotalExport>